00001 #include <iostream>
00002 #include "oblast.h"
00003
00004 using namespace std;
00005
00006
00007 short * Oblast::poplpr;
00008
00009
00010 Plocha *** Oblast::seplpr;
00011
00012
00013 short * Oblast::znamePlochy;
00014
00015
00016 Oblast::Oblast(SpolecnaData & sd, short * poplpr, Plocha *** seplpr, short * znamePlochy):
00017 sd(sd)
00018 {
00019 Oblast::poplpr = poplpr;
00020 Oblast::seplpr = seplpr;
00021 Oblast::znamePlochy = znamePlochy;
00022 }
00023
00024
00025 Oblast::~Oblast()
00026 {
00027
00028
00029
00030
00031
00032
00033 }
00034
00035
00036
00037 void Oblast::PlochyPrvkuSerazene(const long prvek, vector<list<long> > & plochyPrvku)
00038 {
00039
00040 long pbp,rada,sloupec;
00041
00042 long pp, cb;
00043 const long *srfsys;
00044
00045 if (sd.nnod[prvek] == KR_BODU){
00046 pp = KR_POCET_PLOCH;
00047 pbp = KR_PLOCHA_BODU;
00048 srfsys = &systemKrychle[0][0];
00049 }
00050 else {
00051 pp = CT_POCET_PLOCH;
00052 pbp = CT_PLOCHA_BODU;
00053 srfsys = &systemCtyrsten[0][0];
00054 }
00055
00056 vector<list<long> >::iterator ili;
00057 ili = plochyPrvku.begin();
00058
00059 list<long>::iterator ino;
00060 rada = 0;
00061 while(ili != plochyPrvku.end()){
00062 sloupec = 0;
00063 cb = sd.nodes[prvek][*(srfsys + rada * pbp + sloupec)];
00064 ili->push_front(cb);
00065 ino = ili->begin();
00066 while(sloupec < pbp-1){
00067 sloupec++;
00068 cb = sd.nodes[prvek][*(srfsys + rada * pbp + sloupec)];
00069 while(ino != ili->end()){
00070 if (*ino > cb)
00071 {
00072 ili->insert(ino,cb);
00073 break;
00074 }
00075 ino++;
00076 }
00077 if (ino == ili->end())
00078 ili->push_back(cb);
00079 ino = ili->begin();
00080 }
00081 ili++;
00082 rada++;
00083 }
00084 }
00085
00086 void Oblast::vlozPrvek(const long prvek)
00087 {
00088 long * plocha;
00089 long * pint;
00090 Plocha * pinset;
00091 vector<list<long> > plochyPrvku(sd.nnod[prvek] == KR_BODU ? KR_POCET_PLOCH : CT_POCET_PLOCH);
00092 pair<set<Plocha *, Comparator >::iterator,bool> check;
00093 PlochyPrvkuSerazene(prvek,plochyPrvku);
00094 long cisloPlochy = 0;
00095 for (vector<list<long> >::iterator i= plochyPrvku.begin(); i!=plochyPrvku.end(); i++)
00096 {
00097 plocha = new long[i->size()];
00098 pint = &plocha[0];
00099 for (list<long>::iterator j= i->begin(); j!=i->end(); j++)
00100 {
00101 *pint = *j;
00102 pint++;
00103 }
00104 Plocha * p = new Plocha(sd.xyz, plocha, i->size(), prvek, cisloPlochy);
00105
00106 seplpr[p->prvek][p->plocha] = p;
00107
00108 check = this->mp.insert(p);
00109
00110
00111 if (!check.second)
00112 {
00113
00114 pinset = *(check.first);
00115 pinset->typ = VNITRNI;
00116 p->typ = VNITRNI;
00117 pinset->vlozSousedniPlochu(p);
00118 p->vlozSousedniPlochu(pinset);
00119
00120
00121
00122 if (pinset->pbp == p->pbp){
00123 this->mp.erase(check.first);
00124 znamePlochy[p->prvek]++;
00125 znamePlochy[pinset->prvek]++;
00126 }
00127
00128
00129
00130
00131 else if (pinset->pbp > p->pbp)
00132 {
00133 znamePlochy[p->prvek]++;
00134 if (pinset->vyhodit){
00135 znamePlochy[pinset->prvek]++;
00136 this->mp.erase(check.first);
00137 }
00138 else pinset->vyhodit = true;
00139 }
00140
00141
00142
00143
00144
00145
00146
00147 else
00148 {
00149
00150 p->vyhodit = true;
00151
00152 this->mp.erase(check.first);
00153 znamePlochy[pinset->prvek]++;
00154
00155 check = this->mp.insert(p);
00156 if (!check.second)
00157 {
00158
00159 pinset = *(check.first);
00160
00161 pinset->typ = VNITRNI;
00162
00163 pinset->vlozSousedniPlochu(p);
00164
00165 p->vlozSousedniPlochu(pinset);
00166
00167 this->mp.erase(check.first);
00168 znamePlochy[pinset->prvek]++;
00169 znamePlochy[p->prvek]++;
00170 }
00171 }
00172 }
00173 cisloPlochy++;
00174 }
00175
00176 }
00177
00178
00179