46 void Foam::booleanSurface::checkIncluded
48 const intersectedSurface& surf,
50 const label includedFace
53 forAll(surf.intersectionEdges(), intEdgeI)
55 label edgeI = surf.intersectionEdges()[intEdgeI];
57 const labelList& myFaces = surf.edgeFaces()[edgeI];
59 bool usesIncluded =
false;
63 if (faceZone[myFaces[myFaceI]] == faceZone[includedFace])
75 "booleanSurface::checkIncluded(const intersectedSurface&" 76 ", const labelList&, const label)" 77 ) <<
"None of the faces reachable from face " << includedFace
78 <<
" connects to the intersection." 94 if (elems[elemI] == elem)
110 forAll(edgeLabels, edgeLabelI)
112 if (edges[edgeLabels[edgeLabelI]] == e)
114 return edgeLabels[edgeLabelI];
119 "booleanSurface::findEdge(const edgeList&, const labelList&" 121 ) <<
"Cannot find edge " << e <<
" in edges " << edgeLabels
132 const triSurface& surf1,
133 const triSurface& surf2,
140 surf1.patches().size()
141 + surf2.patches().size()
145 label combinedPatchI = 0;
146 forAll(surf1.patches(), patchI)
148 combinedPatches[combinedPatchI++] = surf1.patches()[patchI];
152 patchMap2.setSize(surf2.patches().size());
154 forAll(surf2.patches(), patch2I)
158 forAll(surf1.patches(), patch1I)
160 if (surf1.patches()[patch1I] == surf2.patches()[patch2I])
170 combinedPatches[combinedPatchI] = surf2.patches()[patch2I];
171 patchMap2[patch2I] = combinedPatchI;
176 patchMap2[patch2I] = index;
180 combinedPatches.setSize(combinedPatchI);
182 return combinedPatches;
186 void Foam::booleanSurface::propagateEdgeSide
188 const triSurface& surf,
189 const label prevVert0,
190 const label prevFaceI,
191 const label prevState,
196 const labelList& eFaces = surf.sortedEdgeFaces()[edgeI];
199 if (eFaces.size() == 2)
214 if (((eFaces.size() % 2) == 1) && (eFaces.size() != 1))
218 "booleanSurface::propagateEdgeSide(const triSurface&," 219 "const label, const label, const label, const label," 221 ) <<
"Don't know how to handle edges with odd number of faces" 223 <<
"edge:" << edgeI <<
" vertices:" << surf.edges()[edgeI]
224 <<
" coming from face:" << prevFaceI
230 label ind = index(eFaces, prevFaceI);
234 const edge& e = surf.edges()[edgeI];
240 if (e.start() == prevVert0)
244 nextInd = eFaces.fcIndex(ind);
245 prevInd = eFaces.rcIndex(ind);
250 nextInd = eFaces.rcIndex(ind);
251 prevInd = eFaces.fcIndex(ind);
255 if (prevState == OUTSIDE)
265 if (eFaceI == nextInd)
294 if (eFaceI == prevInd)
317 void Foam::booleanSurface::propagateSide
319 const triSurface& surf,
320 const label prevState,
325 if (side[faceI] == UNVISITED)
327 side[faceI] = prevState;
329 const labelledTri& tri = surf.localFaces()[faceI];
338 const labelList& myEdges = surf.faceEdges()[faceI];
394 const label includeFace1,
395 const label includeFace2
403 Pout<<
"booleanSurface : Generating intersected surface for surf1" 413 Pout<<
"booleanSurface : Generated cutSurf1: " <<
endl;
416 Pout<<
"Writing to file cutSurf1.obj" <<
endl;
417 cutSurf1.
write(
"cutSurf1.obj");
422 Pout<<
"booleanSurface : Generating intersected surface for surf2" 431 Pout<<
"booleanSurface : Generated cutSurf2: " <<
endl;
434 Pout<<
"Writing to file cutSurf2.obj" <<
endl;
435 cutSurf2.
write(
"cutSurf2.obj");
440 label cutSurf1FaceI = index(cutSurf1.
faceMap(), includeFace1);
444 Pout<<
"cutSurf1 : starting to fill from face:" << cutSurf1FaceI
448 if (cutSurf1FaceI == -1)
452 "booleanSurface(const triSurfaceSearch&" 453 ", const label, const triSurfaceSearch&, const label)" 454 ) <<
"Did not find face with label " << includeFace1
455 <<
" in intersectedSurface." 460 label cutSurf2FaceI = index(cutSurf2.
faceMap(), includeFace2);
464 Pout<<
"cutSurf2 : starting to fill from face:" << cutSurf2FaceI
467 if (cutSurf2FaceI == -1)
471 "booleanSurface(const triSurfaceSearch&" 472 ", const label, const triSurfaceSearch&, const label)" 473 ) <<
"Did not find face with label " << includeFace2
474 <<
" in intersectedSurface." 488 forAll(int1Edges, intEdgeI)
490 label edgeI = int1Edges[intEdgeI];
491 isIntersectionEdge1[edgeI] =
true;
495 cutSurf1.
markZones(isIntersectionEdge1, faceZone1);
499 checkIncluded(cutSurf1, faceZone1, cutSurf1FaceI);
506 if (faceZone1[faceI] == faceZone1[cutSurf1FaceI])
508 includedFaces1[faceI] =
true;
536 forAll(int2Edges, intEdgeI)
538 label edgeI = int2Edges[intEdgeI];
539 isIntersectionEdge2[edgeI] =
true;
543 cutSurf2.
markZones(isIntersectionEdge2, faceZone2);
547 checkIncluded(cutSurf2, faceZone2, cutSurf2FaceI);
554 if (faceZone2[faceI] == faceZone2[cutSurf2FaceI])
556 includedFaces2[faceI] =
true;
601 label combinedPointI = 0;
603 forAll(subSurf1.points(), pointI)
606 label cutSurfPointI = pointMap1[pointI];
613 intersectionLabels[cutSurfPointI] = combinedPointI;
617 combinedPoints[combinedPointI++] = subSurf1.points()[pointI];
624 forAll(subSurf2.points(), pointI)
627 label cutSurfPointI = pointMap2[pointI];
632 pointMap[pointI] = intersectionLabels[cutSurfPointI];
636 pointMap[pointI] = combinedPointI;
638 combinedPoints[combinedPointI++] = subSurf2.points()[pointI];
666 faceMap_.
setSize(combinedFaces.size());
669 label combinedFaceI = 0;
672 faceMap_[combinedFaceI] = faceMap1[faceI];
673 combinedFaces[combinedFaceI++] = subSurf1[faceI];
681 faceMap_[combinedFaceI] = -faceMap2[faceI]-1;
683 combinedFaces[combinedFaceI++] =
689 patchMap2[f.region()]
711 const label booleanOp
719 Pout<<
"booleanSurface : Testing surf1 and surf2" <<
endl;
726 const labelList& eFaces = edgeFaces[edgeI];
728 if (eFaces.
size() == 1)
730 WarningIn(
"booleanSurface::booleanSurface")
731 <<
"surf1 is open surface at edge " << edgeI
732 <<
" verts:" << surf1.
edges()[edgeI]
733 <<
" connected to faces " << eFaces <<
endl;
742 const labelList& eFaces = edgeFaces[edgeI];
744 if (eFaces.
size() == 1)
746 WarningIn(
"booleanSurface::booleanSurface")
747 <<
"surf2 is open surface at edge " << edgeI
748 <<
" verts:" << surf2.
edges()[edgeI]
749 <<
" connected to faces " << eFaces <<
endl;
762 Pout<<
"booleanSurface : Generating intersected surface for surf1" 771 Pout<<
"booleanSurface : Generated cutSurf1: " <<
endl;
774 Pout<<
"Writing to file cutSurf1.obj" <<
endl;
775 cutSurf1.
write(
"cutSurf1.obj");
785 Pout<<
"booleanSurface : Generating intersected surface for surf2" 794 Pout<<
"booleanSurface : Generated cutSurf2: " <<
endl;
797 Pout<<
"Writing to file cutSurf2.obj" <<
endl;
798 cutSurf2.
write(
"cutSurf2.obj");
832 label combinedPointI = 0;
836 combinedPoints[combinedPointI++] = cutSurf1.
points()[pointI];
846 combinedPoints[combinedPointI++] = cutSurf2.
points()[pointI];
856 Pout<<
"booleanSurface : generated points:" <<
nl 858 <<
" : original surface1" 861 <<
" .. " << cutSurf1.
nPoints()-1
862 <<
" : intersection points" 864 <<
" " << cutSurf1.
nPoints() <<
" .. " 866 <<
" : surface2 points" 875 label combinedFaceI = 0;
879 combinedFaces[combinedFaceI++] = cutSurf1[faceI];
884 labelledTri& combinedTri = combinedFaces[combinedFaceI++];
893 combinedTri[fp] = tri[fp] + cutSurf1.
nPoints();
921 Pout<<
"booleanSurface : Generated combinedSurf: " <<
endl;
924 Pout<<
"Writing to file combinedSurf.obj" <<
endl;
925 combinedSurf.write(
"combinedSurf.obj");
935 label combinedFaceI = 0;
939 faceMap_[combinedFaceI++] = cutSurf1.
faceMap()[faceI];
943 faceMap_[combinedFaceI++] = -cutSurf2.
faceMap()[faceI] - 1;
964 forAll(combinedSurf, faceI)
966 pointHit curHit = combinedSurf[faceI].nearestPoint(outsidePoint, pts);
977 Pout<<
"booleanSurface : found for point:" << outsidePoint
978 <<
" nearest face:" << minFaceI
979 <<
" nearest point:" << minHit.
rawPoint()
990 propagateSide(combinedSurf, OUTSIDE, minFaceI, side);
1002 if (side[faceI] == UNVISITED)
1006 "booleanSurface::booleanSurface" 1007 "(const triSurfaceSearch&, const triSurfaceSearch&" 1008 ", const label booleanOp)" 1009 ) <<
"Face " << faceI <<
" has not been reached by walking from" 1010 <<
" nearest point " << minHit.
rawPoint()
1013 else if (side[faceI] == OUTSIDE)
1017 include[faceI] =
true;
1021 include[faceI] =
false;
1025 include[faceI] = (faceI < cutSurf1.
size());
1032 include[faceI] =
false;
1036 include[faceI] =
true;
1040 include[faceI] = (faceI >= cutSurf1.
size());
1059 faceMap_.
setSize(subSurf.size());
1061 forAll(subToCombinedFace, faceI)
1064 label combinedFaceI = subToCombinedFace[faceI];
1068 if (combinedFaceI < cutSurf1.
size())
1070 label cutSurf1Face = combinedFaceI;
1072 faceMap_[faceI] = cutSurf1.
faceMap()[cutSurf1Face];
1076 label cutSurf2Face = combinedFaceI - cutSurf1.
size();
1078 faceMap_[faceI] = - cutSurf2.
faceMap()[cutSurf2Face] - 1;
const Point & rawPoint() const
Return point with no checking.
bool isSurfacePoint(const label pointI) const
Is point coming from original surface?
Basic surface-surface intersection description. Constructed from two surfaces it creates a descriptio...
const labelListList & edgeFaces() const
Return edge-face addressing.
Given point flip all faces such that normals point in same direction.
const labelList & faceMap() const
New to old.
Given triSurface and intersection creates the intersected (properly triangulated) surface...
Triangulated surface description with patch information.
label markZones(const boolList &borderEdge, labelList &faceZone) const
(size and) fills faceZone with zone of face. Zone is area
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Standard boundBox + extra functionality for use in octree.
void size(const label)
Override size to be inconsistent with allocated storage.
errorManipArg< error, int > exit(error &err, const int errNo=1)
triSurface()
Construct null.
friend Ostream & operator(Ostream &, const UList< T > &)
List< geometricSurfacePatch > geometricSurfacePatchList
label nPoints() const
Return number of points supporting patch faces.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
Triangle with additional region number.
label region() const
Return region label.
void setSize(const label)
Reset size of List.
Ostream & endl(Ostream &os)
Add newline and flush stream.
#define WarningIn(functionName)
Report a warning using Foam::Warning.
label nSurfacePoints() const
Number of points from original surface.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
triSurface subsetMesh(const boolList &include, labelList &pointMap, labelList &faceMap) const
Return new surface. Returns pointMap, faceMap from.
const labelList & intersectionEdges() const
Labels of edges in *this which originate from 'cuts'.
booleanSurface()
Construct null.
void operator=(const triSurface &)
errorManip< error > abort(error &err)
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
scalar distance() const
Return distance to hit.
void write(Ostream &) const
Write to Ostream in simple FOAM format.
List< label > labelList
A List of labels.
label nEdges() const
Return number of edges in patch.
label findEdge(const edgeList &edges, const labelList &candidates, const label v0, const label v1)
Return edge among candidates that uses the two vertices.
void writeStats(Ostream &) const
Write some statistics.
const Field< PointType > & points() const
Return reference to global points.
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Pout(cout,"Pout")