Go to the documentation of this file.
66 const label includedFace
75 bool usesIncluded =
false;
90 <<
"None of the faces reachable from face " << includedFace
91 <<
" connects to the intersection."
107 if (elems[elemI] == elem)
123 forAll(edgeLabels, edgeLabelI)
125 if (edges[edgeLabels[edgeLabelI]] ==
e)
127 return edgeLabels[edgeLabelI];
131 <<
"Cannot find edge " <<
e <<
" in edges " << edgeLabels
155 label combinedPatchI = 0;
158 combinedPatches[combinedPatchI++] = surf1.
patches()[patchI];
180 combinedPatches[combinedPatchI] = surf2.
patches()[patch2I];
181 patchMap2[patch2I] = combinedPatchI;
186 patchMap2[patch2I] = index;
190 combinedPatches.
setSize(combinedPatchI);
192 return combinedPatches;
199 const label prevVert0,
200 const label prevFaceI,
201 const label prevState,
209 if (eFaces.
size() == 2)
224 if (((eFaces.
size() % 2) == 1) && (eFaces.
size() != 1))
227 <<
"Don't know how to handle edges with odd number of faces"
229 <<
"edge:" << edgeI <<
" vertices:" << surf.
edges()[edgeI]
230 <<
" coming from face:" << prevFaceI
236 label ind = index(eFaces, prevFaceI);
246 if (
e.start() == prevVert0)
250 nextInd = eFaces.fcIndex(ind);
251 prevInd = eFaces.rcIndex(ind);
256 nextInd = eFaces.rcIndex(ind);
257 prevInd = eFaces.fcIndex(ind);
261 if (prevState == OUTSIDE)
271 if (eFaceI == nextInd)
300 if (eFaceI == prevInd)
326 const label prevState,
331 if (side[faceI] == UNVISITED)
333 side[faceI] = prevState;
400 const label includeFace1,
401 const label includeFace2
409 Pout<<
"booleanSurface : Generating intersected surface for surf1"
419 Pout<<
"booleanSurface : Generated cutSurf1: " <<
endl;
422 Pout<<
"Writing to file cutSurf1.obj" <<
endl;
423 cutSurf1.
write(
"cutSurf1.obj");
428 Pout<<
"booleanSurface : Generating intersected surface for surf2"
437 Pout<<
"booleanSurface : Generated cutSurf2: " <<
endl;
440 Pout<<
"Writing to file cutSurf2.obj" <<
endl;
441 cutSurf2.
write(
"cutSurf2.obj");
446 label cutSurf1FaceI = index(cutSurf1.
faceMap(), includeFace1);
450 Pout<<
"cutSurf1 : starting to fill from face:" << cutSurf1FaceI
454 if (cutSurf1FaceI == -1)
457 <<
"Did not find face with label " << includeFace1
458 <<
" in intersectedSurface."
463 label cutSurf2FaceI = index(cutSurf2.
faceMap(), includeFace2);
467 Pout<<
"cutSurf2 : starting to fill from face:" << cutSurf2FaceI
470 if (cutSurf2FaceI == -1)
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;
606 label cutSurfPointI = pointMap1[pointI];
613 intersectionLabels[cutSurfPointI] = combinedPointI;
617 combinedPoints[combinedPointI++] = subSurf1.
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()]
693 triSurface::operator=
711 const label booleanOp
719 Pout<<
"booleanSurface : Testing surf1 and surf2" <<
endl;
726 const labelList& eFaces = edgeFaces[edgeI];
728 if (eFaces.
size() == 1)
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)
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");
933 faceMap_.setSize(combinedSurf.
size());
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)
1005 <<
"Face " << faceI <<
" has not been reached by walking from"
1006 <<
" nearest point " << minHit.
rawPoint()
1009 else if (side[faceI] == OUTSIDE)
1013 include[faceI] =
true;
1017 include[faceI] =
false;
1021 include[faceI] = (faceI < cutSurf1.
size());
1028 include[faceI] =
false;
1032 include[faceI] =
true;
1036 include[faceI] = (faceI >= cutSurf1.
size());
1055 faceMap_.setSize(subSurf.
size());
1057 forAll(subToCombinedFace, faceI)
1060 label combinedFaceI = subToCombinedFace[faceI];
1064 if (combinedFaceI < cutSurf1.
size())
1066 label cutSurf1Face = combinedFaceI;
1068 faceMap_[faceI] = cutSurf1.
faceMap()[cutSurf1Face];
1072 label cutSurf2Face = combinedFaceI - cutSurf1.
size();
1074 faceMap_[faceI] = - cutSurf2.
faceMap()[cutSurf2Face] - 1;
static void propagateEdgeSide(const triSurface &surf, const label prevVert0, const label prevFaceI, const label prevState, const label edgeI, labelList &side)
On edgeI, coming from face prevFace, determines visibility/side of.
const Field< PointType > & points() const
Return reference to global points.
const labelListList & edgeFaces() const
Return edge-face addressing.
void writeStats(Ostream &) const
Write some statistics.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
#define forAll(list, i)
Loop across all elements in list.
This class describes the interaction of a face and a point. It carries the info of a successful hit a...
Given point flip all faces such that normals point in same direction.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
const Point & rawPoint() const
Return point with no checking.
label nEdges() const
Return number of edges in patch.
Standard boundBox + extra functionality for use in octree.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
label nSurfacePoints() const
Number of points from original surface.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const labelListList & faceEdges() const
Return face-edge addressing.
const geometricSurfacePatchList & patches() const
static geometricSurfacePatchList mergePatches(const triSurface &surf1, const triSurface &surf2, labelList &patchMap2)
Generate combined patchList (returned). Sets patchMap to map from.
booleanOpType
Enumeration listing the possible volume operator types.
vector span() const
The bounding box span (from minimum to maximum)
triSurface subsetMesh(const boolList &include, labelList &pointMap, labelList &faceMap) const
Return new surface. Returns pointMap, faceMap from.
scalar distance() const
Return distance to hit.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Given triSurface and intersection creates the intersected (properly triangulated) surface....
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Pre-declare SubField and related Field type.
Basic surface-surface intersection description. Constructed from two surfaces it creates a descriptio...
Triangulated surface description with patch information.
A subset of mesh faces organised as a primitive patch.
static label index(const labelList &elems, const label elem)
Get label in elems of elem.
void operator=(const triSurface &)
const labelList & faceMap() const
New to old.
label nPoints() const
Return number of points supporting patch faces.
const labelList & intersectionEdges() const
Labels of edges in *this which originate from 'cuts'.
errorManip< error > abort(error &err)
errorManipArg< error, int > exit(error &err, const int errNo=1)
void setSize(const label)
Reset size of List.
label markZones(const boolList &borderEdge, labelList &faceZone) const
(size and) fills faceZone with zone of face. Zone is area
static void propagateSide(const triSurface &surf, const label prevState, const label faceI, labelList &side)
Given in/outside status of face determines status for all.
static const NamedEnum< booleanOpType, 4 > booleanOpTypeNames
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label region() const
Return region label.
prefixOSstream Pout(cout, "Pout")
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
static void checkIncluded(const intersectedSurface &surf, const labelList &faceZone, const label includedFace)
Check whether subset of faces (from markZones) reaches up to.
const dimensionedScalar e
Elementary charge.
booleanSurface()
Construct null.
Triangle with additional region number.
const dimensionedScalar c
Speed of light in a vacuum.
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
const labelListList & sortedEdgeFaces() const
Return edge-face addressing sorted (for edges with more than.
void size(const label)
Override size to be inconsistent with allocated storage.
bool isSurfacePoint(const label pointI) const
Is point coming from original surface?
void write(const fileName &, const word &ext, const bool sort) const
Generic write routine. Chooses writer based on extension.
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.
Initialise the NamedEnum HashTable from the static list of names.
static label findEdge(const edgeList &edges, const labelList &edgeLabels, const edge &e)
Find index of edge e in subset edgeLabels.