26CDomainPrism::CDomainPrism(
const vector<XY> &Points,
XYZ &start,
XYZ &end)
49 TiXmlElement* pYarn = Element.FirstChildElement(
"Yarn");
62 TiXmlElement Yarn(
"Yarn");
64 Element.InsertEndChild(Yarn);
85 list<int>::iterator itInt;
86 list<int>::iterator itStart;
91 for (itInt = QuadIndices.begin(); itInt != QuadIndices.end(); )
101 if (
GetPlane( points, ElementPlane))
106 for (itInt = TriIndices.begin(); itInt != TriIndices.end(); )
120 list<int>::iterator itIndices;
122 list<int>::iterator itStartIndex;
124 for (itIndices = Indices.begin(); itIndices != Indices.end(); )
126 StartIndex = (*(itIndices));
127 itStartIndex = itIndices;
128 vector<int> PolygonIndex;
131 int i = 0, iPoints = 0;
146 }
while ((*itIndices) != StartIndex);
167 vector<PLANE>::iterator itPlanes1, itPlanes2;
187 if (Plane1.
d != Plane2.
d)
196 const double TOL = 1e-9;
200 vector<XYZ> NewTriangles;
201 vector<bool> NewTrianglesFlipped;
202 vector<XYZ>::iterator itXYZ;
203 vector<XYZ> NewQuads;
205 vector<PLANE>::const_iterator itPlane;
206 list<int>::iterator itStart;
207 list<int>::iterator itInt;
208 const XYZ *p1, *p2, *p3, *p4;
209 double d1, d2, d3, d4;
221 for (itInt = QuadIndices.begin(); itInt != QuadIndices.end(); )
225 p1 = &Mesh.
GetNode(*(itInt++));
226 p2 = &Mesh.
GetNode(*(itInt++));
227 p3 = &Mesh.
GetNode(*(itInt++));
228 p4 = &Mesh.
GetNode(*(itInt++));
230 d1 =
DotProduct(itPlane->Normal, *p1) - itPlane->d;
231 d2 =
DotProduct(itPlane->Normal, *p2) - itPlane->d;
232 d3 =
DotProduct(itPlane->Normal, *p3) - itPlane->d;
233 d4 =
DotProduct(itPlane->Normal, *p4) - itPlane->d;
237 if ( fabs(d1) <
TOL || fabs(d2) <
TOL || fabs(d3) <
TOL || fabs(d4) <
TOL)
238 itInt = QuadIndices.erase(itStart, itInt);
240 else if (d1 >= -
TOL && d2 >= -
TOL && d3 >= -
TOL && d4 >= -
TOL)
244 else if (d1 <
TOL && d2 < TOL && d3 >
TOL && d4 >
TOL)
246 itInt = QuadIndices.erase(itStart, itInt);
248 NewQuads.push_back(*p4 + (*p1 - *p4) * u);
250 NewQuads.push_back(*p3 + (*p2 - *p3) * u);
251 NewQuads.push_back(*p3);
252 NewQuads.push_back(*p4);
254 else if (d2 <
TOL && d3 < TOL && d4 >
TOL && d1 >
TOL)
256 itInt = QuadIndices.erase(itStart, itInt);
257 NewQuads.push_back(*p1);
259 NewQuads.push_back(*p1 + (*p2 - *p1) * u);
261 NewQuads.push_back(*p4 + (*p3 - *p4) * u);
262 NewQuads.push_back(*p4);
264 else if (d3 <
TOL && d4 < TOL && d1 >
TOL && d2 >
TOL)
266 itInt = QuadIndices.erase(itStart, itInt);
267 NewQuads.push_back(*p1);
268 NewQuads.push_back(*p2);
270 NewQuads.push_back(*p2 + (*p3 - *p2) * u);
272 NewQuads.push_back(*p1 + (*p4 - *p1) * u);
274 else if (d4 <
TOL && d1 < TOL && d2 >
TOL && d3 >
TOL)
276 itInt = QuadIndices.erase(itStart, itInt);
278 NewQuads.push_back(*p2 + (*p1 - *p2) * u);
279 NewQuads.push_back(*p2);
280 NewQuads.push_back(*p3);
282 NewQuads.push_back(*p3 + (*p4 - *p3) * u);
293 for (i = 0; i < int(NewQuads.size() / 4); ++i)
296 QuadIndices.push_back(4 * i + iLastNodeIndex);
297 QuadIndices.push_back(4 * i + 1 + iLastNodeIndex);
298 QuadIndices.push_back(4 * i + 2 + iLastNodeIndex);
299 QuadIndices.push_back(4 * i + 3 + iLastNodeIndex);
301 for (itXYZ = NewQuads.begin(); itXYZ != NewQuads.end(); ++itXYZ)
308 for (itInt = TriIndices.begin(); itInt != TriIndices.end(); )
312 p1 = &Mesh.
GetNode(*(itInt++));
313 p2 = &Mesh.
GetNode(*(itInt++));
314 p3 = &Mesh.
GetNode(*(itInt++));
316 d1 =
DotProduct(itPlane->Normal, *p1) - itPlane->d;
317 d2 =
DotProduct(itPlane->Normal, *p2) - itPlane->d;
318 d3 =
DotProduct(itPlane->Normal, *p3) - itPlane->d;
322 itInt = TriIndices.erase(itStart, itInt);
324 else if (d1 >= -
TOL && d2 >= -
TOL && d3 >= -
TOL)
330 itInt = TriIndices.erase(itStart, itInt);
335 dTemp = d2; d2 = d1; d1 = dTemp;
336 pTemp = p2; p2 = p1; p1 = pTemp;
337 bFlipped = !bFlipped;
341 dTemp = d3; d3 = d2; d2 = dTemp;
342 pTemp = p3; p3 = p2; p2 = pTemp;
343 bFlipped = !bFlipped;
346 dTemp = d2; d2 = d1; d1 = dTemp;
347 pTemp = p2; p2 = p1; p1 = pTemp;
348 bFlipped = !bFlipped;
354 NewTriangles.push_back(*p1);
356 NewTriangles.push_back(*p1 + (*p2 - *p1) * u);
358 NewTriangles.push_back(*p1 + (*p3 - *p1) * u);
359 NewTrianglesFlipped.push_back(bFlipped);
363 NewTriangles.push_back(*p1);
364 NewTriangles.push_back(*p2);
366 NewTriangles.push_back(*p2 + (*p3 - *p2) * u);
367 NewTrianglesFlipped.push_back(bFlipped);
369 NewTriangles.push_back(*p2 + (*p3 - *p2) * u);
371 NewTriangles.push_back(*p1 + (*p3 - *p1) * u);
372 NewTriangles.push_back(*p1);
373 NewTrianglesFlipped.push_back(bFlipped);
380 for (i = 0; i < int(NewTriangles.size() / 3); ++i)
386 if (!NewTrianglesFlipped[i])
388 TriIndices.push_back(3 * i + iLastNodeIndex);
389 TriIndices.push_back(3 * i + 1 + iLastNodeIndex);
390 TriIndices.push_back(3 * i + 2 + iLastNodeIndex);
394 TriIndices.push_back(3 * i + iLastNodeIndex);
395 TriIndices.push_back(3 * i + 2 + iLastNodeIndex);
396 TriIndices.push_back(3 * i + 1 + iLastNodeIndex);
399 for (itXYZ = NewTriangles.begin(); itXYZ != NewTriangles.end(); ++itXYZ)
403 NewTriangles.clear();
404 NewTrianglesFlipped.clear();
406 vector<int> ClosedLoop;
408 FillGaps(Mesh, *itPlane, ClosedLoop);
423 const double TOL = 1e-9;
427 vector<XYZ> NewTriangles;
428 vector<bool> NewTrianglesFlipped;
429 vector<XYZ>::iterator itXYZ;
430 vector<XYZ> NewQuads;
432 vector<PLANE>::const_iterator itPlane;
433 list<int>::iterator itStart;
434 list<int>::iterator itInt;
435 const XYZ *p1, *p2, *p3, *p4;
436 double d1, d2, d3, d4;
444 vector<CMesh>::iterator itDomainMeshes;
445 bool bSaveDomainMeshes =
false;
446 if (DomainMeshes.size() != 0)
447 bSaveDomainMeshes =
true;
453 for (itInt = QuadIndices.begin(); itInt != QuadIndices.end(); )
457 p1 = &Mesh.
GetNode(*(itInt++));
458 p2 = &Mesh.
GetNode(*(itInt++));
459 p3 = &Mesh.
GetNode(*(itInt++));
460 p4 = &Mesh.
GetNode(*(itInt++));
462 d1 =
DotProduct(itPlane->Normal, *p1) - itPlane->d;
463 d2 =
DotProduct(itPlane->Normal, *p2) - itPlane->d;
464 d3 =
DotProduct(itPlane->Normal, *p3) - itPlane->d;
465 d4 =
DotProduct(itPlane->Normal, *p4) - itPlane->d;
469 if (fabs(d1) <
TOL || fabs(d2) <
TOL || fabs(d3) <
TOL || fabs(d4) <
TOL)
470 itInt = QuadIndices.erase(itStart, itInt);
472 else if (d1 >= -
TOL && d2 >= -
TOL && d3 >= -
TOL && d4 >= -
TOL)
476 else if (d1 <
TOL && d2 < TOL && d3 >
TOL && d4 >
TOL)
478 itInt = QuadIndices.erase(itStart, itInt);
480 NewQuads.push_back(*p4 + (*p1 - *p4) * u);
482 NewQuads.push_back(*p3 + (*p2 - *p3) * u);
483 NewQuads.push_back(*p3);
484 NewQuads.push_back(*p4);
486 else if (d2 <
TOL && d3 < TOL && d4 >
TOL && d1 >
TOL)
488 itInt = QuadIndices.erase(itStart, itInt);
489 NewQuads.push_back(*p1);
491 NewQuads.push_back(*p1 + (*p2 - *p1) * u);
493 NewQuads.push_back(*p4 + (*p3 - *p4) * u);
494 NewQuads.push_back(*p4);
496 else if (d3 <
TOL && d4 < TOL && d1 >
TOL && d2 >
TOL)
498 itInt = QuadIndices.erase(itStart, itInt);
499 NewQuads.push_back(*p1);
500 NewQuads.push_back(*p2);
502 NewQuads.push_back(*p2 + (*p3 - *p2) * u);
504 NewQuads.push_back(*p1 + (*p4 - *p1) * u);
506 else if (d4 <
TOL && d1 < TOL && d2 >
TOL && d3 >
TOL)
508 itInt = QuadIndices.erase(itStart, itInt);
510 NewQuads.push_back(*p2 + (*p1 - *p2) * u);
511 NewQuads.push_back(*p2);
512 NewQuads.push_back(*p3);
514 NewQuads.push_back(*p3 + (*p4 - *p3) * u);
525 for (i = 0; i < int(NewQuads.size() / 4); ++i)
528 QuadIndices.push_back(4 * i + iLastNodeIndex);
529 QuadIndices.push_back(4 * i + 1 + iLastNodeIndex);
530 QuadIndices.push_back(4 * i + 2 + iLastNodeIndex);
531 QuadIndices.push_back(4 * i + 3 + iLastNodeIndex);
533 for (itXYZ = NewQuads.begin(); itXYZ != NewQuads.end(); ++itXYZ)
540 for (itInt = TriIndices.begin(); itInt != TriIndices.end(); )
544 p1 = &Mesh.
GetNode(*(itInt++));
545 p2 = &Mesh.
GetNode(*(itInt++));
546 p3 = &Mesh.
GetNode(*(itInt++));
548 d1 =
DotProduct(itPlane->Normal, *p1) - itPlane->d;
549 d2 =
DotProduct(itPlane->Normal, *p2) - itPlane->d;
550 d3 =
DotProduct(itPlane->Normal, *p3) - itPlane->d;
554 itInt = TriIndices.erase(itStart, itInt);
556 else if (d1 >= -
TOL && d2 >= -
TOL && d3 >= -
TOL)
562 itInt = TriIndices.erase(itStart, itInt);
567 dTemp = d2; d2 = d1; d1 = dTemp;
568 pTemp = p2; p2 = p1; p1 = pTemp;
569 bFlipped = !bFlipped;
573 dTemp = d3; d3 = d2; d2 = dTemp;
574 pTemp = p3; p3 = p2; p2 = pTemp;
575 bFlipped = !bFlipped;
578 dTemp = d2; d2 = d1; d1 = dTemp;
579 pTemp = p2; p2 = p1; p1 = pTemp;
580 bFlipped = !bFlipped;
586 NewTriangles.push_back(*p1);
588 NewTriangles.push_back(*p1 + (*p2 - *p1) * u);
590 NewTriangles.push_back(*p1 + (*p3 - *p1) * u);
591 NewTrianglesFlipped.push_back(bFlipped);
595 NewTriangles.push_back(*p1);
596 NewTriangles.push_back(*p2);
598 NewTriangles.push_back(*p2 + (*p3 - *p2) * u);
599 NewTrianglesFlipped.push_back(bFlipped);
601 NewTriangles.push_back(*p2 + (*p3 - *p2) * u);
603 NewTriangles.push_back(*p1 + (*p3 - *p1) * u);
604 NewTriangles.push_back(*p1);
605 NewTrianglesFlipped.push_back(bFlipped);
612 for (i = 0; i < int(NewTriangles.size() / 3); ++i)
618 if (!NewTrianglesFlipped[i])
620 TriIndices.push_back(3 * i + iLastNodeIndex);
621 TriIndices.push_back(3 * i + 1 + iLastNodeIndex);
622 TriIndices.push_back(3 * i + 2 + iLastNodeIndex);
626 TriIndices.push_back(3 * i + iLastNodeIndex);
627 TriIndices.push_back(3 * i + 2 + iLastNodeIndex);
628 TriIndices.push_back(3 * i + 1 + iLastNodeIndex);
631 for (itXYZ = NewTriangles.begin(); itXYZ != NewTriangles.end(); ++itXYZ)
635 NewTriangles.clear();
636 NewTrianglesFlipped.clear();
638 vector<int> ClosedLoop;
641 if (!
FillGaps(Mesh, *itPlane, ClosedLoop,
false))
644 if (bSaveDomainMeshes)
646 if (ClosedLoop.size() > 0)
648 for (itDomainMeshes = DomainMeshes.begin(); itDomainMeshes != DomainMeshes.end(); itDomainMeshes++)
653 for (
int i = 0; i < 3; i++)
655 Points[i] = (*itDomainMeshes).GetNode(i);
657 Normal =
CrossProduct((Points[0] - Points[1]), Points[2] - Points[1]);
661 int iIndex = (*itDomainMeshes).GetNumNodes();
662 int iPolyStart = iIndex;
663 vector<int>::iterator itClosedLoop;
665 int iStartInd = ClosedLoop[0];
666 for (itClosedLoop = ClosedLoop.begin(); itClosedLoop != ClosedLoop.end(); itClosedLoop++)
668 if (*itClosedLoop == iStartInd && iIndex > iPolyStart)
670 Indices.push_back(iPolyStart);
674 Indices.push_back(iIndex++);
675 (*itDomainMeshes).AddNode(Mesh.
GetNode(*itClosedLoop));
678 if (ClosedLoop[ClosedLoop.size() - 1] != iStartInd)
679 Indices.push_back(iPolyStart);
699 const double TOL = 1e-9;
703 vector<XYZ> NewTriangles;
705 vector<XYZ>::iterator itXYZ;
706 vector<XYZ> NewQuads;
708 vector<PLANE>::const_iterator itPlane;
709 list<int>::iterator itStart;
710 list<int>::iterator itInt;
711 const XYZ *p1, *p2, *p3, *p4;
718 vector<XYZ> IntersectQuads;
724 for (itInt = QuadIndices.begin(); itInt != QuadIndices.end(); )
728 double d1= 0, d2=0, d3=0, d4 = 0;
729 p1 = &Mesh.
GetNode(*(itInt++));
730 p2 = &Mesh.
GetNode(*(itInt++));
731 p3 = &Mesh.
GetNode(*(itInt++));
732 p4 = &Mesh.
GetNode(*(itInt++));
740 if (!b1 && !b2 && !b3 && !b4)
742 itInt = QuadIndices.erase(itStart, itInt);
744 else if (b1 && b2 && b3 && b4)
752 itInt = QuadIndices.erase(itStart, itInt);
753 IntersectQuads.push_back(*p1);
754 IntersectQuads.push_back(*p2);
755 IntersectQuads.push_back(*p3);
756 IntersectQuads.push_back(*p4);
762 for (i = 0; i < int(IntersectQuads.size() / 4); ++i)
764 IntersectQuadIndices.push_back(4 * i);
765 IntersectQuadIndices.push_back(4 * i + 1);
766 IntersectQuadIndices.push_back(4 * i + 2);
767 IntersectQuadIndices.push_back(4 * i + 3);
769 for (itXYZ = IntersectQuads.begin(); itXYZ != IntersectQuads.end(); ++itXYZ)
773 IntersectQuads.clear();
777 vector<XYZ> IntersectTriangles;
780 for (itInt = TriIndices.begin(); itInt != TriIndices.end(); )
784 double d1 = 0, d2 = 0, d3 = 0, d4 = 0;
785 p1 = &Mesh.
GetNode(*(itInt++));
786 p2 = &Mesh.
GetNode(*(itInt++));
787 p3 = &Mesh.
GetNode(*(itInt++));
793 if (!b1 && !b2 && !b3)
795 itInt = TriIndices.erase(itStart, itInt);
797 else if (b1 && b2 && b3)
803 itInt = TriIndices.erase(itStart, itInt);
804 IntersectTriangles.push_back(*p1);
805 IntersectTriangles.push_back(*p2);
806 IntersectTriangles.push_back(*p3);
813 for (i = 0; i < int(IntersectQuads.size() / 4); ++i)
815 IntersectTriangleIndices.push_back(4 * i + iLastNodeIndex);
816 IntersectTriangleIndices.push_back(4 * i + 1 + iLastNodeIndex);
817 IntersectTriangleIndices.push_back(4 * i + 2 + iLastNodeIndex);
818 IntersectTriangleIndices.push_back(4 * i + 3 + iLastNodeIndex);
820 for (itXYZ = IntersectTriangles.begin(); itXYZ != IntersectTriangles.end(); ++itXYZ)
824 IntersectTriangles.clear();
829 vector<CMesh::ELEMENT_TYPE> VolumeElements;
830 vector<CMesh::ELEMENT_TYPE>::iterator itElementType;
838 for (itElementType = VolumeElements.begin(); itElementType != VolumeElements.end(); ++itElementType)
840 list<int> &Indices = Mesh.
GetIndices(*itElementType);
841 for (itInt = Indices.begin(); itInt != Indices.end(); )
847 for (i = 0; i < iNumNodes; ++i)
849 Center += Mesh.
GetNode(*(itInt++));
857 itInt = Indices.erase(itStart, itInt);
865 IntersectMesh.
SaveToVTK(
"IntersectionMesh");
875 const double TOL = 1e-9;
879 vector<XYZ> NewTriangles;
881 vector<XYZ>::iterator itXYZ;
882 vector<XYZ> NewQuads;
884 vector<PLANE>::const_iterator itPlane;
885 list<int>::iterator itStart;
886 list<int>::iterator itInt;
887 const XYZ *p1, *p2, *p3, *p4;
895 vector<XYZ> IntersectQuads;
901 for (itInt = QuadIndices.begin(); itInt != QuadIndices.end(); )
905 double d1 = 0, d2 = 0, d3 = 0, d4 = 0;
906 p1 = &Mesh.
GetNode(*(itInt++));
907 p2 = &Mesh.
GetNode(*(itInt++));
908 p3 = &Mesh.
GetNode(*(itInt++));
909 p4 = &Mesh.
GetNode(*(itInt++));
917 if (!b1 && !b2 && !b3 && !b4)
919 itInt = QuadIndices.erase(itStart, itInt);
921 else if (b1 && b2 && b3 && b4)
929 itInt = QuadIndices.erase(itStart, itInt);
930 IntersectQuads.push_back(*p1);
931 IntersectQuads.push_back(*p2);
932 IntersectQuads.push_back(*p3);
933 IntersectQuads.push_back(*p4);
939 for (i = 0; i < int(IntersectQuads.size() / 4); ++i)
941 IntersectQuadIndices.push_back(4 * i);
942 IntersectQuadIndices.push_back(4 * i + 1);
943 IntersectQuadIndices.push_back(4 * i + 2);
944 IntersectQuadIndices.push_back(4 * i + 3);
946 for (itXYZ = IntersectQuads.begin(); itXYZ != IntersectQuads.end(); ++itXYZ)
950 IntersectQuads.clear();
954 vector<XYZ> IntersectTriangles;
957 for (itInt = TriIndices.begin(); itInt != TriIndices.end(); )
961 double d1 = 0, d2 = 0, d3 = 0, d4 = 0;
962 p1 = &Mesh.
GetNode(*(itInt++));
963 p2 = &Mesh.
GetNode(*(itInt++));
964 p3 = &Mesh.
GetNode(*(itInt++));
970 if (!b1 && !b2 && !b3)
972 itInt = TriIndices.erase(itStart, itInt);
974 else if (b1 && b2 && b3)
980 itInt = TriIndices.erase(itStart, itInt);
981 IntersectTriangles.push_back(*p1);
982 IntersectTriangles.push_back(*p2);
983 IntersectTriangles.push_back(*p3);
990 for (i = 0; i < int(IntersectQuads.size() / 4); ++i)
992 IntersectTriangleIndices.push_back(4 * i + iLastNodeIndex);
993 IntersectTriangleIndices.push_back(4 * i + 1 + iLastNodeIndex);
994 IntersectTriangleIndices.push_back(4 * i + 2 + iLastNodeIndex);
995 IntersectTriangleIndices.push_back(4 * i + 3 + iLastNodeIndex);
997 for (itXYZ = IntersectTriangles.begin(); itXYZ != IntersectTriangles.end(); ++itXYZ)
1001 IntersectTriangles.clear();
1006 vector<CMesh::ELEMENT_TYPE> VolumeElements;
1007 vector<CMesh::ELEMENT_TYPE>::iterator itElementType;
1015 for (itElementType = VolumeElements.begin(); itElementType != VolumeElements.end(); ++itElementType)
1017 list<int> &Indices = Mesh.
GetIndices(*itElementType);
1018 for (itInt = Indices.begin(); itInt != Indices.end(); )
1024 for (i = 0; i < iNumNodes; ++i)
1026 Center += Mesh.
GetNode(*(itInt++));
1028 Center /= iNumNodes;
1034 itInt = Indices.erase(itStart, itInt);
1042 IntersectMesh.
SaveToVTK(
"IntersectionMesh");
1053 const double TOL = 1e-9;
1056 const XYZ *p1, *p2, *p3, *p4;
1057 double d1, d2, d3, d4;
1059 vector<pair<int, int> > Segments;
1066 list<int>::iterator itInt;
1069 for (itInt = QuadIndices.begin(); itInt != QuadIndices.end(); )
1095 if (d1 <=
TOL && d2 <=
TOL)
1097 Segments.push_back(pair<int, int>(i1, i2));
1099 if (d2 <=
TOL && d3 <=
TOL)
1101 Segments.push_back(pair<int, int>(i2, i3));
1103 if (d3 <=
TOL && d4 <=
TOL)
1105 Segments.push_back(pair<int, int>(i3, i4));
1107 if (d4 <=
TOL && d1 <=
TOL)
1109 Segments.push_back(pair<int, int>(i4, i1));
1114 for (itInt = TriIndices.begin(); itInt != TriIndices.end(); )
1136 if (d1 <=
TOL && d2 <=
TOL)
1138 Segments.push_back(pair<int, int>(i1, i2));
1140 if (d2 <=
TOL && d3 <=
TOL)
1142 Segments.push_back(pair<int, int>(i2, i3));
1144 if (d3 <=
TOL && d1 <=
TOL)
1146 Segments.push_back(pair<int, int>(i3, i1));
1150 vector<pair<int, int> >::iterator itSegment;
1153 int iIndex, iFirstIndex;
1161 map<int, int> Indices;
1162 map<int, int>::iterator itIndex;
1164 for (itSegment = Segments.begin(); itSegment != Segments.end(); ++itSegment)
1166 Indices[itSegment->first]++;
1167 Indices[itSegment->second]++;
1171 while (Segments.size())
1173 vector<int> ClosedLoop;
1177 iFirstIndex = iIndex = Segments.begin()->first;
1181 for (itSegment = Segments.begin(); itSegment != Segments.end(); ++itSegment)
1184 if (itSegment->second == iIndex)
1187 iIndex = itSegment->first;
1189 itSegment = Segments.erase(itSegment);
1206 ClosedLoop.push_back(iIndex);
1209 if (iFirstIndex == iIndex)
1221 TGERROR(
"Unable to fill gaps satisfactorily");
1225 TGLOG(
"Number of nodes: " << Indices.size());
1234 for (itIndex = Indices.begin(); itIndex != Indices.end(); ++itIndex)
1236 if (itIndex->second != 2)
1237 TGLOG(
"Node " << itIndex->first <<
" referenced " << itIndex->second <<
" times. (" << Mesh.
GetNode(itIndex->first) <<
")");
1247 vector<int>::iterator itCurrent = ClosedLoop.begin();
1248 vector<int>::iterator itNext = itCurrent + 1;
1249 while (itNext != ClosedLoop.end())
1251 if (*itCurrent == *itNext)
1253 itNext = ClosedLoop.erase(itNext);
1265 vector<int>::iterator itPrev = ClosedLoop.begin();
1266 itCurrent = itPrev + 1;
1267 itNext = itCurrent + 1;
1269 while (itNext != ClosedLoop.end())
1271 if (*itPrev == *itNext)
1273 ClosedLoop.erase(itCurrent, itNext + 1);
1274 if (itPrev != ClosedLoop.begin())
1278 itNext = itCurrent + 1;
1287 if (itPrev == ClosedLoop.end())
1288 itPrev = ClosedLoop.begin();
1292 Polygon.insert(Polygon.begin(), ClosedLoop.begin(), ClosedLoop.end());
1304 pair<XY, XY> XYCorners;
1311 XY CornerXDir(XYCorners.second.x, XYCorners.first.y);
1312 XY CornerZDir(XYCorners.first.x, XYCorners.second.y);
1318 XYZ Up = SlaveNodes[0].GetUp();
1319 XYZ Side = SlaveNodes[0].GetSide();
1322 StartPoint = Side * XYCorners.first.
x;
1323 StartPoint += Up * XYCorners.first.
y;
1324 SizeVecs[0] = Side * CornerXDir.
x;
1325 SizeVecs[0] += Up * CornerXDir.
y;
1326 SizeVecs[2] = Side * CornerZDir.
x;
1327 SizeVecs[2] += Up * CornerZDir.
y;
1330 StartPoint += Node0;
1331 SizeVecs[0] += Node0;
1332 SizeVecs[0] -= StartPoint;
1333 SizeVecs[2] += Node0;
1334 SizeVecs[2] -= StartPoint;
1336 SizeVecs[1] = Node1 - Node0;
1341 vector<int> StartIndices, EndIndices;
1342 int NumSectionPoints =
m_Points.size();
1344 for (
int i = 0; i < NumSectionPoints; ++i)
1346 StartIndices.push_back(i);
1347 EndIndices.push_back(i + NumSectionPoints);
1349 StartIndices.push_back(0);
1350 EndIndices.push_back(NumSectionPoints);
#define TGLOGINDENT(MESSAGE)
Combines the TGLOG macro and TGLOGAUTOINDENT macro in one.
#define TGERROR(MESSAGE)
Macros used to report the file name and line number to the TexGenError and TexGenLog functions.
Abstract base class representing the domain in which a textile cell may lie.
virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType=OUTPUT_STANDARD) const
Used for saving data to XML.
CMesh m_Mesh
A mesh representing the domain as a surface mesh.
vector< PLANE > m_ElementPlanes
Planes corresponding to mesh elements.
void RemoveDuplicatePlanes()
Iterate through m_ElementPlanes to remove duplicates.
bool GetPlane(XYZ *points, PLANE &plane)
Generate a plane from a vector of co-planar points.
void GetMeshWithPolygonEnd(CMesh &Mesh)
void BuildMesh()
Get the limits for a single given repeat vector and surface mesh.
void ClipIntersectMeshToDomain(CMesh &Mesh, bool bFillGaps=true) const
void GetPolygonLimits(XYZ &StartPoint, XYZ *SizeVecs)
void GeneratePlanes()
Generate a set of planes corresponding to the mesh elements.
bool PlaneEqual(PLANE Plane1, PLANE Plane2)
Test if both normal and d of two PLANE structures are equal.
CYarn m_Yarn
Create the domain as yarn with constant polygon section and two nodes.
static bool FillGaps(CMesh &Mesh, const PLANE &Plane, vector< int > &Polygon, bool bMeshGaps=true)
CDomainPrism(const vector< XY > &Points, XYZ &start, XYZ &end)
Constructor.
void ClipMeshToDomain(CMesh &Mesh, bool bFillGaps=true) const
void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType=OUTPUT_STANDARD) const
Used for saving data to XML.
vector< XY > m_Points
Prism section points.
Defines the nodes and elements of a surface or volume mesh.
bool AddElement(ELEMENT_TYPE Type, const vector< int > &Indices)
Add an element to the mesh of given type with node number checking.
int GetNumNodes() const
Return the number of nodes.
int MergeNodes(const double Tolerance=1e-8)
If any nodes share the same coordinates merge the nodes together and adjust indices accordingly.
void InsertMesh(const CMesh &Mesh, XYZ Offset=XYZ(0, 0, 0))
Add the contents of Mesh to this mesh.
void RemoveDegenerateTriangles()
Remove triangles which have two equal corner indices.
const int AddNode(XYZ Node)
Append a node to the list of nodes, the integer returns the index of the node
const XYZ & GetNode(int iIndex) const
Get the node with given ID.
int RemoveUnreferencedNodes()
Remove nodes that are not referenced by any elements.
list< int >::iterator ConvertQuadtoTriangles(list< int >::iterator itQuad)
Convert a specific quad element to two triangles.
bool SaveToVTK(string Filename, const vector< CMeshDataBase * > *pMeshData=NULL) const
Save the mesh to VTK unstructured grid file format (.vtu)
static int GetNumNodes(ELEMENT_TYPE Type)
Get the number of nodes a particular element type contains.
void RemoveElementType(ELEMENT_TYPE Type)
Remove elements of given type.
const list< int > & GetIndices(ELEMENT_TYPE ElemType) const
Get the element indices of a given element type.
void MeshClosedLoop(const XYZ &Normal, const vector< int > &ClosedLoopVector, bool bQuality=false)
void Clear()
Empty mesh nodes and indices.
Represents a point on the centreline of a yarn.
Creates a polygonal section, where a list of points are given to form the closed polygon.
Represents a yarn consisting of master nodes, section and interpolation function.
bool AddSurfaceToMesh(CMesh &Mesh, bool bAddEndCaps=true) const
Create surface mesh for this yarn and add it to the surface mesh object.
void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType)
Used for saving data to XML.
const CNode * GetNode(int iIndex) const
Get a master node by index.
void AssignSection(const CYarnSection &YarnSection)
Assign a section to the yarn.
const vector< CSlaveNode > & GetSlaveNodes(BUILD_TYPE Usage) const
Get the slave nodes and build them if necessary.
void AddNode(const CNode &Node)
Add a node to the end of the list of nodes (note the nodes must be ordered)
void SetResolution(int iNumSlaveNodes, int iNumSectionPoints)
Set the resolution of the mesh created.
bool PointInsideYarn(const XYZ &Point, XYZ *pTangent=NULL, XY *pLoc=NULL, double *pVolumeFraction=NULL, double *pDistanceToSurface=NULL, double dTolerance=1e-9, XYZ *pOrientation=NULL, XYZ *pUp=NULL, bool bSurface=false) const
Determine if the given point lies within the yarn (this function doesn't take the repeats into accoun...
Creates a section which is constant all along the yarn.
Namespace containing a series of customised math operations not found in the standard c++ library.
void GetMinMaxXY(const std::vector< XY > &Points, XY &Min, XY &Max)
double GetLength(const XYZ &Point1, const XYZ &Point2)
Get the length between two points.
WXYZ & Normalise(WXYZ &Quaternion)
Normalise the quaternion and return it.
double DotProduct(const XYZ &left, const XYZ &right)
Get the dot product of two vectors.
XYZ CrossProduct(const XYZ &left, const XYZ &right)
Get the cross product of two vectors.
Struct for representing a Plane.
Struct for representing points in 2D space.
Struct for representing points in 3D space.