00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "g-map-generic.hh"
00026 #include "dynamic-coverage-real-face.hh"
00027 using namespace GMap3d;
00028
00029 void CGMapGeneric::shiftOneFictiveEdge(CDart* ADart, CDart* ADart2)
00030 {
00031 assert( ADart!=NULL && ADart2!=NULL );
00032 assert( !isFree1(ADart) );
00033
00034 CDart * d1 = alpha1(ADart);
00035 CDart * d2 = alpha21(ADart);
00036 CDart * d3 = alpha1(ADart2);
00037
00038 unsew1(d1);
00039 if (!isFree1(d2))
00040 unsew1(d2);
00041
00042 if (!isFree1(ADart2))
00043 unsew1(ADart2);
00044
00045 sew1(d1,d2);
00046
00047 sew1(ADart,ADart2);
00048
00049 if ( isFree1(d3) )
00050 sew1(alpha2(ADart),d3);
00051 }
00052
00053 unsigned int CGMapGeneric::shiftAllEdgesIncidentToVertex(CDart* ADart)
00054 {
00055 CDart * toShift = alpha12(ADart);
00056 CDart * next = NULL;
00057 unsigned int nb = 0;
00058
00059 while( toShift!=ADart )
00060 {
00061 next = alpha12(toShift);
00062 shiftOneFictiveEdge( toShift, alpha0(ADart) );
00063 ++nb;
00064 toShift = next;
00065 }
00066
00067 return nb;
00068 }
00069
00070 void CGMapGeneric::shiftAllAdjacentFictiveEdges(CDart* ADart, int AMark)
00071 {
00072 CDart * d = alpha12(ADart);
00073 CDart * tmp;
00074
00075 while (isMarked(d,AMark) &&
00076 d!=ADart )
00077 {
00078 tmp = alpha12(d);
00079 shiftOneFictiveEdge(d,alpha0(ADart));
00080 d=tmp;
00081 }
00082 }
00083
00084 void CGMapGeneric::shiftAllFictiveEdges(CDart* ADart, int AMark)
00085 {
00086 shiftAllAdjacentFictiveEdges(ADart, AMark);
00087
00088 shiftAllAdjacentFictiveEdges(alpha2(ADart), AMark);
00089 }
00090
00091 void CGMapGeneric::shiftAllFictiveEdgesAroundEdge(CDart* ADart, int AMark)
00092 {
00093 assert( ADart!=NULL );
00094
00095
00096 CDart* actu = ADart;
00097 CDart* toShift = NULL;
00098 CDart* tmp = NULL;
00099
00100 do
00101 {
00102 toShift = alpha12(actu);
00103
00104 while( isMarked(toShift, AMark) && toShift!=actu )
00105 {
00106 tmp = alpha12(toShift);
00107 shiftOneFictiveEdge( toShift, alpha0(actu) );
00108 toShift = tmp;
00109 }
00110 actu = alpha23(actu);
00111 }
00112 while ( actu!=ADart );
00113 }
00114
00115 bool CGMapGeneric::existFictiveEdgeIncidentTo(CDart *ADart, int AMark)
00116 {
00117 CDynamicCoverage123 it(this,ADart);
00118 while(it.cont())
00119 {
00120 if (isMarked(*it,AMark)) return true;
00121 ++it;
00122 }
00123 return false;
00124 }
00125
00126 int CGMapGeneric::findVertexType( CDart* ADart, CDart** AFirstDart,
00127 int AMark )
00128 {
00129 assert( ADart!=NULL );
00130
00131 int markVertex = getNewMark();
00132 int markEdge = getNewMark();
00133 int res = 0;
00134 int nbReel = 0;
00135 bool reelLoop = false;
00136
00137 CDynamicCoverageVertex it(this, ADart);
00138 for ( ; it.cont(); ++it )
00139 setMark(*it, markVertex);
00140
00141
00142
00143 for ( it.reinit(); it.cont() && nbReel<=2 && (!reelLoop || nbReel==1); ++it )
00144 {
00145 if ( !isMarked(*it, markEdge) )
00146 {
00147 if ( !isMarked(*it, AMark) )
00148 {
00149 if ( isMarked(alpha0(*it), markVertex) )
00150 {
00151 reelLoop = true;
00152 }
00153 else
00154 {
00155 if ( nbReel==0 )
00156 *AFirstDart = *it;
00157 }
00158 ++nbReel;
00159 markOrbit(*it, ORBIT_EDGE, markEdge);
00160 }
00161 }
00162 }
00163
00164 if ( reelLoop )
00165 {
00166 if ( nbReel==1 ) res = 1;
00167 else res = 3;
00168 }
00169 else
00170 {
00171 if ( nbReel==2 )
00172 res = 2;
00173 else if ( nbReel!=0 ) res = 3;
00174 }
00175
00176
00177 for ( it.reinit(); it.cont(); ++it )
00178 {
00179 if ( isMarked(*it, markEdge) )
00180 unmarkOrbit(*it, ORBIT_EDGE, markEdge);
00181
00182 unsetMark(*it, markVertex);
00183 }
00184
00185 assert(isWholeMapUnmarked(markVertex));
00186 assert(isWholeMapUnmarked(markEdge));
00187
00188 freeMark(markVertex);
00189 freeMark(markEdge);
00190
00191 return res;
00192 }
00193
00194 CDart* CGMapGeneric::findIncidentEdgeNonLoop(CDart* ADart)
00195 {
00196 assert( ADart!=NULL );
00197 assert( !isFree2(ADart) );
00198
00199 CDart* res = NULL;
00200 int markVertex = getNewMark();
00201
00202 CDynamicCoverageVertex it(this, ADart);
00203
00204
00205 while( it.cont() ) { setMark(*it, markVertex); ++it; }
00206
00207 for ( it.reinit(); it.cont() && res==NULL; ++it )
00208 {
00209 if ( !isMarked(alpha0(*it), markVertex) )
00210 {
00211 res = *it;
00212 }
00213 }
00214
00215 for ( it.reinit(); it.cont(); ++it )
00216 unsetMark(*it, markVertex);
00217
00218 assert(isWholeMapUnmarked(markVertex));
00219
00220 freeMark(markVertex);
00221
00222 return res;
00223 }
00224
00225 int CGMapGeneric::markRealFace(CDart* ADart, int AMark, int AMark2)
00226 {
00227 assert( ADart!=NULL );
00228 assert( !isMarked(ADart,AMark) );
00229
00230 int res = 0;
00231 CDynamicCoverageRealFace it(this, ADart, AMark);
00232 while ( it.cont() )
00233 {
00234 setMark(it++, AMark2);
00235 ++res;
00236 }
00237
00238 return res;
00239 }
00240
00241 int CGMapGeneric::unmarkRealFace(CDart* ADart, int AMark, int AMark2)
00242 {
00243 assert( ADart!=NULL );
00244 assert( !isMarked(ADart,AMark) );
00245
00246 int res = 0;
00247 CDynamicCoverageRealFace it(this, ADart, AMark);
00248 while ( it.cont() )
00249 {
00250 unsetMark(it++, AMark2);
00251 ++res;
00252 }
00253
00254 return res;
00255 }
00256