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])
74 <<
"None of the faces reachable from face " << includedFace
75 <<
" connects to the intersection."
91 if (elems[elemI] == elem)
107 forAll(edgeLabels, edgeLabelI)
109 if (edges[edgeLabels[edgeLabelI]] ==
e)
111 return edgeLabels[edgeLabelI];
115 <<
"Cannot find edge " <<
e <<
" in edges " << edgeLabels
126 const triSurface& surf1,
127 const triSurface& surf2,
134 surf1.patches().size()
135 + surf2.patches().size()
139 label combinedPatchi = 0;
142 combinedPatches[combinedPatchi++] = surf1.patches()[
patchi];
146 patchMap2.setSize(surf2.patches().size());
148 forAll(surf2.patches(), patch2I)
152 forAll(surf1.patches(), patch1I)
154 if (surf1.patches()[patch1I] == surf2.patches()[patch2I])
164 combinedPatches[combinedPatchi] = surf2.patches()[patch2I];
165 patchMap2[patch2I] = combinedPatchi;
170 patchMap2[patch2I] = index;
174 combinedPatches.setSize(combinedPatchi);
176 return combinedPatches;
180 void Foam::booleanSurface::propagateEdgeSide
182 const triSurface& surf,
183 const label prevVert0,
184 const label prevFacei,
185 const label prevState,
190 const labelList& eFaces = surf.sortedEdgeFaces()[edgeI];
193 if (eFaces.size() == 2)
208 if (((eFaces.size() % 2) == 1) && (eFaces.size() != 1))
211 <<
"Don't know how to handle edges with odd number of faces"
213 <<
"edge:" << edgeI <<
" vertices:" << surf.edges()[edgeI]
214 <<
" coming from face:" << prevFacei
220 label ind = index(eFaces, prevFacei);
224 const edge&
e = surf.edges()[edgeI];
230 if (
e.start() == prevVert0)
234 nextInd = eFaces.fcIndex(ind);
235 prevInd = eFaces.rcIndex(ind);
240 nextInd = eFaces.rcIndex(ind);
241 prevInd = eFaces.fcIndex(ind);
245 if (prevState == OUTSIDE)
255 if (eFacei == nextInd)
284 if (eFacei == prevInd)
307 void Foam::booleanSurface::propagateSide
309 const triSurface& surf,
310 const label prevState,
315 if (side[facei] == UNVISITED)
317 side[facei] = prevState;
319 const labelledTri& tri = surf.localFaces()[facei];
328 const labelList& myEdges = surf.faceEdges()[facei];
384 const label includeFace1,
385 const label includeFace2
393 Pout<<
"booleanSurface : Generating intersected surface for surf1"
403 Pout<<
"booleanSurface : Generated cutSurf1: " <<
endl;
406 Pout<<
"Writing to file cutSurf1.obj" <<
endl;
407 cutSurf1.
write(
"cutSurf1.obj");
412 Pout<<
"booleanSurface : Generating intersected surface for surf2"
421 Pout<<
"booleanSurface : Generated cutSurf2: " <<
endl;
424 Pout<<
"Writing to file cutSurf2.obj" <<
endl;
425 cutSurf2.
write(
"cutSurf2.obj");
430 label cutSurf1Facei = index(cutSurf1.
faceMap(), includeFace1);
434 Pout<<
"cutSurf1 : starting to fill from face:" << cutSurf1Facei
438 if (cutSurf1Facei == -1)
441 <<
"Did not find face with label " << includeFace1
442 <<
" in intersectedSurface."
447 label cutSurf2Facei = index(cutSurf2.
faceMap(), includeFace2);
451 Pout<<
"cutSurf2 : starting to fill from face:" << cutSurf2Facei
454 if (cutSurf2Facei == -1)
457 <<
"Did not find face with label " << includeFace2
458 <<
" in intersectedSurface."
472 forAll(int1Edges, intEdgeI)
474 label edgeI = int1Edges[intEdgeI];
475 isIntersectionEdge1[edgeI] =
true;
479 cutSurf1.
markZones(isIntersectionEdge1, faceZone1);
483 checkIncluded(cutSurf1, faceZone1, cutSurf1Facei);
490 if (faceZone1[facei] == faceZone1[cutSurf1Facei])
492 includedFaces1[facei] =
true;
520 forAll(int2Edges, intEdgeI)
522 label edgeI = int2Edges[intEdgeI];
523 isIntersectionEdge2[edgeI] =
true;
527 cutSurf2.
markZones(isIntersectionEdge2, faceZone2);
531 checkIncluded(cutSurf2, faceZone2, cutSurf2Facei);
538 if (faceZone2[facei] == faceZone2[cutSurf2Facei])
540 includedFaces2[facei] =
true;
585 label combinedPointi = 0;
590 label cutSurfPointi = pointMap1[pointi];
597 intersectionLabels[cutSurfPointi] = combinedPointi;
601 combinedPoints[combinedPointi++] = subSurf1.
points()[pointi];
611 label cutSurfPointi = pointMap2[pointi];
616 pointMap[pointi] = intersectionLabels[cutSurfPointi];
620 pointMap[pointi] = combinedPointi;
622 combinedPoints[combinedPointi++] = subSurf2.
points()[pointi];
653 label combinedFacei = 0;
656 faceMap_[combinedFacei] = faceMap1[facei];
657 combinedFaces[combinedFacei++] = subSurf1[facei];
665 faceMap_[combinedFacei] = -faceMap2[facei]-1;
667 combinedFaces[combinedFacei++] =
673 patchMap2[
f.region()]
695 const label booleanOp
703 Pout<<
"booleanSurface : Testing surf1 and surf2" <<
endl;
712 if (eFaces.
size() == 1)
715 <<
"surf1 is open surface at edge " << edgeI
716 <<
" verts:" << surf1.
edges()[edgeI]
717 <<
" connected to faces " << eFaces <<
endl;
728 if (eFaces.
size() == 1)
731 <<
"surf2 is open surface at edge " << edgeI
732 <<
" verts:" << surf2.
edges()[edgeI]
733 <<
" connected to faces " << eFaces <<
endl;
746 Pout<<
"booleanSurface : Generating intersected surface for surf1"
755 Pout<<
"booleanSurface : Generated cutSurf1: " <<
endl;
758 Pout<<
"Writing to file cutSurf1.obj" <<
endl;
759 cutSurf1.
write(
"cutSurf1.obj");
769 Pout<<
"booleanSurface : Generating intersected surface for surf2"
778 Pout<<
"booleanSurface : Generated cutSurf2: " <<
endl;
781 Pout<<
"Writing to file cutSurf2.obj" <<
endl;
782 cutSurf2.
write(
"cutSurf2.obj");
816 label combinedPointi = 0;
820 combinedPoints[combinedPointi++] = cutSurf1.
points()[pointi];
830 combinedPoints[combinedPointi++] = cutSurf2.
points()[pointi];
840 Pout<<
"booleanSurface : generated points:" <<
nl
842 <<
" : original surface1"
845 <<
" .. " << cutSurf1.
nPoints()-1
846 <<
" : intersection points"
848 <<
" " << cutSurf1.
nPoints() <<
" .. "
850 <<
" : surface2 points"
859 label combinedFacei = 0;
863 combinedFaces[combinedFacei++] = cutSurf1[facei];
868 labelledTri& combinedTri = combinedFaces[combinedFacei++];
877 combinedTri[fp] = tri[fp] + cutSurf1.
nPoints();
905 Pout<<
"booleanSurface : Generated combinedSurf: " <<
endl;
908 Pout<<
"Writing to file combinedSurf.obj" <<
endl;
909 combinedSurf.write(
"combinedSurf.obj");
919 label combinedFacei = 0;
923 faceMap_[combinedFacei++] = cutSurf1.
faceMap()[facei];
927 faceMap_[combinedFacei++] = -cutSurf2.
faceMap()[facei] - 1;
948 forAll(combinedSurf, facei)
950 pointHit curHit = combinedSurf[facei].nearestPoint(outsidePoint, pts);
961 Pout<<
"booleanSurface : found for point:" << outsidePoint
962 <<
" nearest face:" << minFacei
963 <<
" nearest point:" << minHit.
rawPoint()
974 propagateSide(combinedSurf, OUTSIDE, minFacei, side);
986 if (side[facei] == UNVISITED)
989 <<
"Face " << facei <<
" has not been reached by walking from"
990 <<
" nearest point " << minHit.
rawPoint()
993 else if (side[facei] == OUTSIDE)
997 include[facei] =
true;
1001 include[facei] =
false;
1005 include[facei] = (facei < cutSurf1.
size());
1012 include[facei] =
false;
1016 include[facei] =
true;
1020 include[facei] = (facei >= cutSurf1.
size());
1041 forAll(subToCombinedFace, facei)
1044 label combinedFacei = subToCombinedFace[facei];
1048 if (combinedFacei < cutSurf1.
size())
1050 label cutSurf1Face = combinedFacei;
1052 faceMap_[facei] = cutSurf1.
faceMap()[cutSurf1Face];
1056 label cutSurf2Face = combinedFacei - cutSurf1.
size();
1058 faceMap_[facei] = - cutSurf2.
faceMap()[cutSurf2Face] - 1;
#define forAll(list, i)
Loop across all elements in list.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
scalar distance() const
Return distance to hit.
const Point & rawPoint() const
Return point with no checking.
label nEdges() const
Return number of edges in patch.
label nPoints() const
Return number of points supporting patch faces.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const Field< PointType > & points() const
Return reference to global points.
const labelListList & edgeFaces() const
Return edge-face addressing.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
friend Ostream & operator(Ostream &, const UList< T > &)
Surface-surface intersection. Given two surfaces construct combined surface.
booleanSurface()
Construct null.
vector span() const
The bounding box span (from minimum to maximum)
Given triSurface and intersection creates the intersected (properly triangulated) surface....
bool isSurfacePoint(const label pointi) const
Is point coming from original surface?
const labelList & intersectionEdges() const
Labels of edges in *this which originate from 'cuts'.
label nSurfacePoints() const
Number of points from original surface.
const labelList & faceMap() const
New to old.
Triangle with additional region number.
label region() const
Return region label.
Given point flip all faces such that normals point in same direction.
Basic surface-surface intersection description. Constructed from two surfaces it creates a descriptio...
Standard boundBox + extra functionality for use in octree.
Triangulated surface description with patch information.
triSurface()
Construct null.
void write(Ostream &) const
Write to Ostream in simple FOAM format.
triSurface subsetMesh(const boolList &include, labelList &pointMap, labelList &faceMap) const
Return new surface. Returns pointMap, faceMap from.
label markZones(const boolList &borderEdge, labelList &faceZone) const
(size and) fills faceZone with zone of face. Zone is area
void operator=(const triSurface &)
void writeStats(Ostream &) const
Write some statistics.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define WarningInFunction
Report a warning using Foam::Warning.
const dimensionedScalar c
Speed of light in a vacuum.
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
List< geometricSurfacePatch > geometricSurfacePatchList
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Pout(cout, "Pout")