26 #include "g-map-vertex.hh"
29 using namespace GMap3d;
43 const CTransformationMatrix* AMeshMatrix,
45 bool AMeshWithAdjacentSews,
46 bool AMeshAssociatedCells,
47 int ADirectInfoAlpha0,
int ADirectInfoAssoc)
51 CDynamicCoverageAll it(FMap);
53 int treated = FMap->getNewMark();
59 if (ADirectInfoAlpha0>=0 || ADirectInfoAssoc>=0)
61 direct0 = ADirectInfoAlpha0;
62 assoc = ADirectInfoAssoc;
69 direct0 = FMap->getNewDirectInfo();
75 assoc = FMap->getNewDirectInfo();
78 toMesh = FMap->getNewMark();
81 for (it.reinit(); it.cont(); ++it)
82 if (!FMap->isMarked(*it, treated))
84 if (FMap->isMarked(*it, AMarkNumber))
88 for (CDynamicCoverageEdge cov(FMap, *it); cov.cont(); ++cov)
90 if (FMap->isMarked( *cov , AMarkNumber) ||
91 FMap->isMarked(FMap->alpha0(*cov), AMarkNumber))
92 FMap->markOrbit(*cov, ORBIT_0, toMesh);
94 FMap->markOrbit(*cov, ORBIT_0, treated);
101 FMap->setMark(*it, treated);
104 FMap->negateMaskMark(treated);
108 FMap->saveAlphaInDirectInfo(0, direct0);
111 if (AMeshWithAdjacentSews)
112 FMap->duplicateMarkedDarts(toMesh, FMap, assoc,
false);
116 for (it.reinit(); it.cont(); ++it)
117 if (!FMap->isMarked(*it, treated))
119 if (FMap->isMarked(*it, toMesh))
121 FMap->markOrbit(*it, ORBIT_EDGE, treated);
125 FMesh.
mesh1(*it, ASx, AMeshMatrix, AMeshWithMerges, AMeshWithAdjacentSews,
126 AMeshAssociatedCells, direct0, assoc);
128 CDart* current = FMap->alpha0(*it);
130 for (
int i=1; i<ASx; ++i)
132 FMap->markOrbit(current, ORBIT_23, treated);
133 current = FMap->alpha1(current);
134 FMap->markOrbit(current, ORBIT_23, treated);
135 current = FMap->alpha0(current);
140 if (AMeshWithAdjacentSews)
142 CDynamicCoverage23 cov(FMap, *it);
144 for (; cov.cont(); ++cov)
145 if (FMap->isMarked(*cov, toMesh))
146 FMap->unsetMark(FMap->getDirectInfoAsDart(*cov, assoc), treated);
148 for (cov.reinit(); cov.cont(); ++cov)
149 if (FMap->isMarked(*cov, toMesh))
152 FMap->getDirectInfoAsDart(*cov, assoc);
154 if (!FMap->isMarked(current, treated))
156 FMesh.
mesh1(*cov, ASx, AMeshMatrix,
158 AMeshWithAdjacentSews,
159 AMeshAssociatedCells,
162 for (
int i=0; i<ASx; ++i)
164 FMap->markOrbit(current, ORBIT_23, treated);
165 current = FMap->alpha0(current);
166 FMap->markOrbit(current, ORBIT_23, treated);
167 current = FMap->alpha1(current);
174 FMap->markOrbit(*it, ORBIT_EDGE, treated);
176 FMesh.
mesh1(*it, ASx, AMeshMatrix, AMeshWithMerges,
177 AMeshWithAdjacentSews, AMeshAssociatedCells,
180 CDart* current = FMap->getDirectInfoAsDart(*it, assoc);
182 for (
int i=0; i<ASx; ++i)
184 FMap->markOrbit(current, ORBIT_23, treated);
185 current = FMap->alpha0(current);
186 FMap->markOrbit(current, ORBIT_23, treated);
187 current = FMap->alpha1(current);
193 FMap->setMark(*it, treated);
196 FMap->negateMaskMark(treated);
197 FMap->freeMark(treated);
199 if (ADirectInfoAlpha0<0 && ADirectInfoAssoc<0)
202 FMap->freeDirectInfo(direct0);
205 FMap->freeDirectInfo(assoc);
207 FMap->unmarkAll(toMesh);
208 FMap->freeMark(toMesh);
215 const CTransformationMatrix* AMeshMatrix,
216 bool AMeshWithMerges,
217 bool AMeshWithAdjacentSews,
218 bool AMeshAssociatedCells,
219 int AInitialMeshDim,
int AFinalMeshDim,
220 int ADirectInfoAlpha0,
int ADirectInfoAssoc)
224 assert(0<=AInitialMeshDim && AInitialMeshDim<=1);
225 assert(1<=AFinalMeshDim && AFinalMeshDim <=2);
226 assert(AInitialMeshDim < AFinalMeshDim);
228 CDynamicCoverageAll it(FMap);
230 int treated = FMap->getNewMark();
232 int toMesh2 = AFinalMeshDim==2 ? FMap->getNewMark() : -1;
233 int toMeshX = FMap->getNewMark();
234 int toMeshY = ASx==ASy ? toMeshX : FMap->getNewMark();
238 if (ADirectInfoAlpha0>=0 || ADirectInfoAssoc>=0)
240 direct0 = ADirectInfoAlpha0;
241 assoc = ADirectInfoAssoc;
247 direct0 = AInitialMeshDim==0 ? FMap->getNewDirectInfo() : -1;
253 assoc = FMap->getNewDirectInfo();
257 for (it.reinit(); it.cont(); ++it)
258 if (!FMap->isMarked(*it, treated))
260 if (FMap->isMarked(*it, AMarkNumber))
262 CDart* current = *it;
264 if (FMesh.
canMesh2(current, ASx,ASy, AInitialMeshDim))
268 if (AInitialMeshDim==0)
274 for (CDynamicCoverage01 fac(FMap, current);
275 !canMesh && fac.cont(); ++fac)
276 if (FMap->isMarked(*fac, AMarkNumber) &&
296 if (AFinalMeshDim==2)
297 FMap->setMark(current, toMesh2);
301 FMap->markOrbit(current, ORBIT_FACE, treated);
304 FMap->setMark(*it, treated);
307 FMap->negateMaskMark(treated);
311 if (AInitialMeshDim==0)
312 FMap->saveAlphaInDirectInfo(0, direct0);
316 int toDuplicate = FMap->getNewMark();
318 if (AInitialMeshDim==0)
320 int markedEdges = FMap->getNewMark();
322 FMap->markCopy(toMeshX, markedEdges);
323 FMap->markAdd (toMeshY, markedEdges);
325 FMap->negateMaskMark(markedEdges);
326 FMap->markIncidentCells(ORBIT_FACE, markedEdges);
327 FMap->negateMaskMark(markedEdges);
329 FMap->markCopy(AMarkNumber, toDuplicate);
330 FMap->markAnd (markedEdges, toDuplicate);
331 FMap->markIncidentCells(ORBIT_FACE, toDuplicate);
333 FMap->markAnd(toDuplicate, toMeshX);
334 FMap->markAnd(toDuplicate, toMeshY);
336 FMap->unmarkAll(markedEdges);
337 FMap->freeMark(markedEdges);
340 FMap->markIncidentCells(AMeshWithAdjacentSews ? ORBIT_FACE : ORBIT_01,
341 toMesh2, toDuplicate);
343 if (AInitialMeshDim!=0 || AMeshWithAdjacentSews)
344 FMap->duplicateMarkedDarts(toDuplicate, FMap, assoc,
false,
345 true,
true, AMeshWithAdjacentSews,
true);
347 FMap->unmarkAll(toDuplicate);
348 FMap->freeMark(toDuplicate);
352 FMap->freeMark(treated);
355 if (AInitialMeshDim==0)
357 if (AMeshWithMerges || AMeshWithAdjacentSews)
360 AMeshWithAdjacentSews, AMeshAssociatedCells,
365 AMeshWithAdjacentSews, AMeshAssociatedCells,
370 AMeshAssociatedCells =
true;
372 int mark = AFinalMeshDim == 2 ? toMesh2 : toMeshX;
374 for (it.reinit(); it.cont(); ++it)
375 if (FMap->isMarked(*it, mark))
377 CDart* square = FMap->duplicateDarts(*it, ORBIT_01, NULL, assoc);
379 FMap->setDirectInfo(*it, assoc, square);
381 FMesh.
mesh2(*it, ASx, ASy, AMeshMatrix, AMeshWithMerges,
382 AMeshWithAdjacentSews, AMeshAssociatedCells,
false,
383 0,1, direct0, assoc);
385 FMap->unmarkOrbit(*it, ORBIT_FACE, toMeshX);
386 FMap->unmarkOrbit(*it, ORBIT_FACE, toMeshY);
389 AMeshAssociatedCells =
false;
392 FMap->unmarkAll(toMeshX);
393 FMap->freeMark(toMeshX);
395 if (toMeshY != toMeshX)
397 FMap->unmarkAll(toMeshY);
398 FMap->freeMark(toMeshY);
403 if (AFinalMeshDim==2)
405 AMeshAssociatedCells = ! AMeshWithMerges;
406 bool getAssociatedEmbeddings = AMeshAssociatedCells && AInitialMeshDim!=1;
408 for (it.reinit(); it.cont(); ++it)
409 if (FMap->isMarked(*it, toMesh2))
411 FMesh.
mesh2(*it, ASx,ASy, AMeshMatrix, AMeshWithMerges,
412 AMeshWithAdjacentSews, AMeshAssociatedCells,
413 getAssociatedEmbeddings,
414 1,2, direct0, assoc);
415 FMap->unsetMark(*it, toMesh2);
418 AMeshAssociatedCells =
false;
420 FMap->freeMark(toMesh2);
423 if (ADirectInfoAlpha0<0 && direct0>=0)
424 FMap->freeDirectInfo(direct0);
426 if (ADirectInfoAssoc<0 && assoc>=0)
427 FMap->freeDirectInfo(assoc);
433 const CTransformationMatrix* AMeshMatrix,
434 bool AMeshWithMerges,
435 bool AMeshWithAdjacentSews,
436 bool AMeshAssociatedCells,
437 int AInitialMeshDim,
int AFinalMeshDim,
438 int ADirectInfoAlpha0,
int ADirectInfoAssoc)
443 assert(0<=AInitialMeshDim && AInitialMeshDim<=2);
444 assert(1<=AFinalMeshDim && AFinalMeshDim <=3);
445 assert(AInitialMeshDim < AFinalMeshDim);
447 CDynamicCoverageAll it(FMap);
449 int treated = FMap->getNewMark();
450 int selected = FMap->getNewMark();
452 int toMesh3 = AFinalMeshDim==3 ? FMap->getNewMark() : -1;
453 int toMeshX = FMap->getNewMark();
454 int toMeshY = ASy==ASx ? toMeshX : FMap->getNewMark();
455 int toMeshZ = ASz==ASx ? toMeshX : ASz==ASy ? toMeshY : FMap->getNewMark();
457 int s[3] = { ASx, ASy, ASz };
458 int m[3] = { toMeshX, toMeshY, toMeshZ };
462 if (ADirectInfoAssoc >= 0)
464 direct0 = ADirectInfoAlpha0;
465 assoc = ADirectInfoAssoc;
471 direct0 = AInitialMeshDim==0 ? FMap->getNewDirectInfo() : -1;
477 assoc = FMap->getNewDirectInfo();
481 for (it.reinit(); it.cont(); ++it)
482 if (!FMap->isMarked(*it, treated))
484 if (FMap->isMarked(*it, AMarkNumber))
486 CDart* current = *it;
488 if (FMesh.
canMesh3(current, ASx,ASy,ASz, AInitialMeshDim))
492 if (AInitialMeshDim<=1)
494 if (ASx!=ASy || ASy!=ASz)
498 for (
int dim=0; dim<3; ++dim)
499 if (s[(dim+1)%3]==s[dim])
501 alt[dim][0] = m[(dim+2)%3];
506 alt[dim][0] = m[(dim+1)%3];
508 if (s[(dim+2)%3]==s[dim] ||
509 s[(dim+2)%3]==s[(dim+1)%3])
512 alt[dim][1] = m[(dim+2)%3];
519 alt[0][0], alt[0][1],
520 alt[1][0], alt[1][1],
521 alt[2][0], alt[2][1]);
528 toMeshX, toMeshY, toMeshZ);
529 FMap->markOrbit(current, ORBIT_VOLUME, selected);
537 if (AFinalMeshDim==3)
538 FMap->setMark(current, toMesh3);
540 FMap->markOrbit(current, ORBIT_VOLUME, treated);
545 FMap->setMark(*it, treated);
548 FMap->negateMaskMark(treated);
552 if (AInitialMeshDim==0)
553 FMap->saveAlphaInDirectInfo(0, direct0);
557 int toDuplicate = FMap->getNewMark();
559 if (AInitialMeshDim<=1)
561 int markedEdges = FMap->getNewMark();
563 FMap->markCopy(toMeshX, markedEdges);
564 FMap->markAdd (toMeshY, markedEdges);
565 FMap->markAdd (toMeshZ, markedEdges);
568 FMap->markCopy(markedEdges, 1);
572 FMap->negateMaskMark(markedEdges);
573 FMap->markIncidentCells(ORBIT_VOLUME, markedEdges);
574 FMap->negateMaskMark(markedEdges);
576 FMap->markCopy(AMarkNumber, toDuplicate);
577 FMap->markAnd (markedEdges, toDuplicate);
578 FMap->markIncidentCells(ORBIT_VOLUME, toDuplicate);
580 FMap->markAnd(toDuplicate, toMeshX);
581 FMap->markAnd(toDuplicate, toMeshY);
582 FMap->markAnd(toDuplicate, toMeshZ);
584 FMap->unmarkAll(markedEdges);
585 FMap->freeMark(markedEdges);
588 FMap->markIncidentCells(ORBIT_VOLUME, toMesh3, toDuplicate);
590 if (AInitialMeshDim!=0 || AMeshWithAdjacentSews)
591 FMap->duplicateMarkedDarts(toDuplicate, FMap, assoc,
false,
592 true,
true,
true, AMeshWithAdjacentSews);
594 FMap->unmarkAll(toDuplicate);
595 FMap->freeMark(toDuplicate);
600 if (AInitialMeshDim==0)
602 if (AMeshWithMerges || AMeshWithAdjacentSews)
605 AMeshWithAdjacentSews, AMeshAssociatedCells,
610 AMeshWithAdjacentSews, AMeshAssociatedCells,
613 if (ASz!=ASx && ASz!=ASy)
615 AMeshWithAdjacentSews, AMeshAssociatedCells,
620 AMeshAssociatedCells =
true;
622 int mark = AFinalMeshDim == 3 ? toMesh3 : toMeshX;
624 for (it.reinit(); it.cont(); ++it)
625 if (FMap->isMarked(*it, mark))
627 CDart* cube = FMap->duplicateDarts(*it, ORBIT_012, NULL, assoc);
629 FMap->setDirectInfo(*it, assoc, cube);
631 FMesh.
mesh3(*it, ASx,ASy,ASz, AMeshMatrix,
632 AMeshWithMerges, AMeshWithAdjacentSews,
633 AMeshAssociatedCells, 0,1, direct0, assoc);
635 FMap->unmarkOrbit(*it, ORBIT_VOLUME, toMeshX);
636 FMap->unmarkOrbit(*it, ORBIT_VOLUME, toMeshY);
637 FMap->unmarkOrbit(*it, ORBIT_VOLUME, toMeshZ);
640 AMeshAssociatedCells =
false;
645 if (AInitialMeshDim<=1 && AFinalMeshDim>=2)
647 AMeshAssociatedCells = !AMeshWithMerges;
649 for (it.reinit(); it.cont(); ++it)
650 if (!FMap->isMarked(*it, treated))
652 if (FMap->isMarked(*it, toMeshX))
654 if (FMap->isMarked(FMap->alpha1(*it), toMeshY))
656 FMap->markOrbit(*it, ORBIT_FACE, treated);
657 FMesh.
mesh2(*it, ASx,ASy, AMeshMatrix, AMeshWithMerges,
658 AMeshWithAdjacentSews, AMeshAssociatedCells,
659 false, 1,2, direct0, assoc);
661 else if (FMap->isMarked(FMap->alpha1(*it), toMeshZ))
663 FMap->markOrbit(*it, ORBIT_FACE, treated);
664 FMesh.
mesh2(*it, ASx,ASz, AMeshMatrix, AMeshWithMerges,
665 AMeshWithAdjacentSews, AMeshAssociatedCells,
666 1,2, direct0, assoc);
669 else if (FMap->isMarked(*it, toMeshY))
671 if (FMap->isMarked(FMap->alpha1(*it), toMeshZ))
673 FMap->markOrbit(*it, ORBIT_FACE, treated);
674 FMesh.
mesh2(*it, ASy,ASz, AMeshMatrix, AMeshWithMerges,
675 AMeshWithAdjacentSews, AMeshAssociatedCells,
676 false, 1,2, direct0, assoc);
681 AMeshAssociatedCells =
false;
684 FMap->unmarkAll(treated);
685 FMap->freeMark(treated);
689 if (AFinalMeshDim==3)
691 for (it.reinit(); it.cont(); ++it)
692 if (FMap->isMarked(*it, toMesh3))
694 FMesh.
mesh3(*it, ASx,ASy,ASz, AMeshMatrix,
695 AMeshWithMerges, AMeshWithAdjacentSews,
696 AMeshAssociatedCells, 2,3, direct0, assoc);
697 FMap->unsetMark(*it, toMesh3);
700 FMap->freeMark(toMesh3);
704 FMap->unmarkAll(toMeshX);
705 FMap->freeMark(toMeshX);
709 FMap->unmarkAll(toMeshY);
710 FMap->freeMark(toMeshY);
713 if (ASz!=ASx && ASz!=ASy)
715 FMap->unmarkAll(toMeshZ);
716 FMap->freeMark(toMeshZ);
719 FMap->unmarkAll(selected);
720 FMap->freeMark(selected);
722 if (ADirectInfoAlpha0<0 && direct0>=0)
723 FMap->freeDirectInfo(direct0);
725 if (ADirectInfoAssoc<0 && assoc>=0)
726 FMap->freeDirectInfo(assoc);