30 using namespace GMap3d;
34 int AIndex,
CDart* ADart)
36 CDart* current = ADart;
39 unsigned long int v1 = (
unsigned long int)getDirectInfo(current, AIndex);
40 unsigned long int v2 = (
unsigned long int)getDirectInfo(alpha0(current), AIndex);
42 list<CDart*>& tmp1 = ATestVertices[v1];
43 list<CDart*>& tmp2 = ATestVertices[v2];
46 list<CDart*>::iterator it;
47 CDart* foundEdge = NULL;
48 for (it = tmp1.begin(); foundEdge == NULL && it != tmp1.end(); ++it)
50 if (((
unsigned long int)getDirectInfo(alpha0(*it), AIndex)) == v2)
56 if (foundEdge != NULL)
70 bool roundingError =
false;
71 CDart* first = foundEdge;
75 if (!isFree2(foundEdge))
99 if (!here && foundEdge == first)
101 roundingError =
true;
108 if (isFree2(foundEdge))
110 sew2(alpha3(current), foundEdge);
111 sew2(current, alpha3(foundEdge));
115 CDart* prev1 = alpha2(foundEdge);
118 sew2(alpha3(current), foundEdge);
119 sew2(current, prev1);
127 tmp1.push_back(current);
128 tmp2.push_back(
alpha03(current));
136 while (current != ADart);
142 vector< CVertex > initVertices;
143 vector< list<CDart*> > testVertices;
147 CDart *d1 = NULL, *d2 = NULL;
153 cout <<
"Problème d'entête : fichier non OFF" << endl;
157 unsigned int nbSommets = 0;
158 unsigned int nbAretes = 0;
160 AStream >> nbSommets >> nbAretes;
161 while (nbSommets > 0)
165 cout <<
"Problème de lecture : pas assez de sommets" << endl;
170 initVertices.push_back(
CVertex(x, y, 0));
171 testVertices.push_back(list<CDart*>());
179 cout <<
"Problème de lecture : pas assez d'arêtes" << endl;
184 AStream >> v1 >> v2; AStream.ignore(256,
'\n');
187 assert(v1 < initVertices.size());
188 assert(v2 < initVertices.size());
196 linkAlpha0(alpha2(d1), alpha2(d2));
198 testVertices[v1].push_back(d1);
199 testVertices[v2].push_back(alpha2(d2));
202 map<double, CDart*> tabDart;
203 list<CDart*>::iterator it;
204 map<double, CDart*>::iterator it2;
211 for (
unsigned int i = 0; i < initVertices.size(); ++i)
213 it = testVertices[i].begin();
214 if (it != testVertices[i].end())
224 while (it != testVertices[i].end())
228 (pair<double, CDart*>
235 it2 = tabDart.begin();
237 while (it2 != tabDart.end())
239 sew1(prec, alpha2(it2->second));
243 sew1(prec, alpha2(first));
252 unsigned long int AV1,
unsigned long int AV2,
253 int AIndex,
CDart* APrec)
258 setDirectInfo(dart1, AIndex, (
void*)AV1);
259 setDirectInfo(dart2, AIndex, (
void*)AV2);
262 linkAlpha0(dart1, dart2);
266 linkAlpha0(alpha3(dart1), alpha3(dart2));
268 setDirectInfo(alpha3(dart1), AIndex, (
void*)AV1);
269 setDirectInfo(alpha3(dart2), AIndex, (
void*)AV2);
273 linkAlpha1(APrec, dart1);
274 linkAlpha1(alpha3(APrec), alpha3(dart1));
283 vector< CVertex > initVertices;
284 vector< list<CDart*> > testVertices;
288 CDart *prec = NULL, *first = NULL;
290 unsigned long int v1, v2, vf;
293 if (txt !=
"OFF" && txt !=
"OFF3D")
295 cout <<
"Problème d'entête : fichier non OFF" << endl;
299 unsigned int nbSommets = 0;
300 unsigned int nbFaces = 0;
301 unsigned int doubleNbAretes = 0;
303 AStream >> nbSommets >> nbFaces >> doubleNbAretes;
304 while (nbSommets > 0)
308 cout <<
"Problème de lecture : pas assez de sommets" << endl;
312 AStream >> x >> y >> z;
313 initVertices.push_back(
CVertex(x, y, z));
314 testVertices.push_back(list<CDart*>());
318 int index = getNewDirectInfo();
324 cout <<
"Problème de lecture : pas assez de faces" << endl;
325 freeDirectInfo(index);
337 assert(v1 < initVertices.size());
340 for (i = 0;i < n;++i)
343 assert(v2 < initVertices.size());
345 prec =
addEdgeOFF(initVertices, v1, v2, index,
348 if (first == NULL) first = alpha0(prec);
352 AStream.ignore(256,
'\n');
354 prec =
addEdgeOFF(initVertices, v1, vf, index,
357 linkAlpha1(first, prec);
358 linkAlpha1(alpha3(first), alpha3(prec));
365 freeDirectInfo(index);
373 stream.open(AFilename);
378 if (txt ==
"OFF2D")
return 2;
379 else if (txt ==
"OFF" || txt ==
"OFF3D")
return 3;
387 stream.open(AFilename);
403 int directInfoIndex = getNewDirectInfo();
404 int markVertex = getNewMark();
405 int markEdge = getNewMark();
406 unsigned long int nbV = 0;
407 unsigned long int nbE = 0;
410 if (!isMarked(*it, markVertex))
414 setDirectInfo(*it2, directInfoIndex, (
void*)nbV);
417 if (!isMarked(*it, markEdge))
425 AStream <<
"OFF2D" << endl;
426 AStream << nbV <<
" " << nbE << endl;
430 negateMaskMark(markVertex);
433 if (!isMarked(*it, markVertex))
436 AStream << v->
getX() <<
" " << v->
getY() << endl;
444 negateMaskMark(markEdge);
447 if (!isMarked(*it, markEdge))
449 AStream << (
unsigned long int)getDirectInfo(*it, directInfoIndex)
450 <<
" " << (
unsigned long int)getDirectInfo(alpha0(*it),
451 directInfoIndex) << endl;
456 negateMaskMark(markVertex); freeMark(markVertex);
457 negateMaskMark(markEdge); freeMark(markEdge);
458 freeDirectInfo(directInfoIndex);
468 int directInfoIndex = getNewDirectInfo();
469 int markVertex = getNewMark();
470 int markFace = getNewMark();
471 unsigned long int nbV = 0;
472 unsigned int nbE = 0;
473 unsigned int nbF = 0;
477 if (!isMarked(*it, markVertex))
481 setDirectInfo(*it2, directInfoIndex, (
void*)nbV);
484 if (!isMarked(*it, markFace))
486 bool faceOuverte =
false;
489 if (isFree0(*it)||isFree1(*it)) faceOuverte=
true;
490 setMark(alpha3(*itFace), markFace);
491 setMark(*itFace, markFace);
493 if ( !faceOuverte ) ++nbF;
498 AStream <<
"OFF" << endl;
499 AStream << nbV <<
" " << nbF <<
" " << nbE << endl;
503 negateMaskMark(markVertex);
506 if (!isMarked(*it, markVertex))
509 AStream << v->
getX() <<
" " << v->
getY() <<
" " << v->
getZ() << endl;
517 negateMaskMark(markFace);
520 if (!isMarked(*it, markFace))
523 int n=0;
bool faceOuverte =
false;
524 for (; !faceOuverte && itFace.
cont(); ++itFace)
526 if (isFree0(*it)||isFree1(*it)) faceOuverte=
true;
533 AStream << (n/2) <<
" ";
535 while( itFace.
cont() )
537 AStream << (
unsigned long int)getDirectInfo(*itFace, directInfoIndex)
540 setMark(alpha3(*itFace), markFace);
541 setMark(itFace++, markFace); assert(itFace.
cont());
543 setMark(alpha3(*itFace), markFace);
544 setMark(itFace++, markFace);
553 negateMaskMark(markVertex); freeMark(markVertex);
554 negateMaskMark(markFace); freeMark(markFace);
555 freeDirectInfo(directInfoIndex);
563 stream.open(AFilename, ios::trunc);
578 stream.open(AFilename, ios::trunc);