Go to the documentation of this file.
31 #include "triSurface.H"
64 if (
f[0] ==
e.start() ||
f[0] ==
e.end())
198 const bool isFirstSurf,
207 label faceA = facesA[facesAI];
223 labelPairLookup::const_iterator iter = facePairToVertex_.find(twoFaces);
225 if (iter == facePairToVertex_.end())
228 facePairToVertex_.insert(twoFaces, allCutPoints.size()-1);
237 const point& prevHit = allCutPoints[*iter];
238 const point& thisHit = allCutPoints.last();
240 if (
mag(prevHit - thisHit) < SMALL)
243 <<
"Encountered degenerate edge between face "
244 << twoFaces[0] <<
" on first surface"
245 <<
" and face " << twoFaces[1] <<
" on second surface"
247 <<
"Point on first surface:" << prevHit <<
endl
248 <<
"Point on second surface:" << thisHit <<
endl
253 allCutEdges.
append(
edge(*iter, allCutPoints.size()-1));
256 facePairToEdge_.insert(twoFaces, allCutEdges.size()-1);
278 const bool isFirstSurf,
300 label nearType, nearLabel;
308 surf1PointTol[
e.start()],
309 surf1PointTol[
e.end()],
315 if (nearType == triPointRef::POINT)
323 <<
" end point of edge " <<
e
324 <<
" surf2: vertex " << f2[nearLabel]
325 <<
" coord:" << surf2Pts[f2[nearLabel]] <<
endl;
334 <<
" somewhere on edge " <<
e
335 <<
" surf2: vertex " << f2[nearLabel]
336 <<
" coord:" << surf2Pts[f2[nearLabel]] <<
endl;
340 surfEdgeCuts[edgeI].append(allCutPoints.size()-1);
357 else if (nearType == triPointRef::EDGE)
363 label edge2I = getEdge(surf2, surf2FaceI, nearLabel);
369 <<
" end point of edge " <<
e
370 <<
" surf2: edge " << e2
371 <<
" coords:" << surf2Pts[e2.
start()]
383 label edge2I = getEdge(surf2, surf2FaceI, nearLabel);
389 <<
" somewhere on edge " <<
e
390 <<
" surf2: edge " << e2
391 <<
" coords:" << surf2Pts[e2.
start()]
396 surfEdgeCuts[edgeI].append(allCutPoints.size()-1);
432 <<
" end point of edge " <<
e
433 <<
" surf2: face " << surf2FaceI
447 nearVert =
e.start();
457 label otherVert =
e.otherVertex(nearVert);
466 <<
" end point of edge " <<
e <<
" coord:"
468 <<
" surf2: face " << surf2FaceI <<
endl;
471 vector eVec = otherPt - nearPt;
479 point hitPt = nearPt;
485 <<
" along edge:" <<
e
492 allCutPoints.
append(hitPt);
493 surfEdgeCuts[edgeI].append(allCutPoints.size()-1);
510 <<
" since edge " <<
e <<
" on inside of surf2."
511 <<
" surf2 normal:" << surf2.
faceNormals()[surf2FaceI]
522 <<
" somewhere on edge " <<
e
523 <<
" surf2: face " << surf2FaceI
529 surfEdgeCuts[edgeI].append(allCutPoints.size()-1);
561 const bool isFirstSurf,
562 const bool isSelfIntersection,
569 scalar oldTol = intersection::setPlanarTol(1
e-3);
576 forAll(surf1PointTol, pointI)
578 surf1PointTol[pointI] =
579 intersection::planarTol()
580 * minEdgeLen(surf1, pointI);
589 point pStart = surf1Pts[
e.start()];
590 const point& pEnd = surf1Pts[
e.end()];
592 const point tolVec = intersection::planarTol()*(pEnd-pStart);
593 const scalar tolDim =
mag(tolVec);
595 bool doTrack =
false;
602 if (isSelfIntersection)
628 label edgeEnd = classify
630 surf1PointTol[
e.start()],
631 surf1PointTol[
e.end()],
641 Pout<<
"edge:" << edgeI <<
" vertices:" <<
e
642 <<
" start:" << surf1Pts[
e.start()]
643 <<
" end:" << surf1Pts[
e.end()]
645 <<
" tolDim:" << tolDim
647 << intersection::planarTol()
651 surfEdgeCuts[edgeI].append(allCutPoints.size()-1);
692 intersection::setPlanarTol(oldTol);
703 facePairToVertex_(0),
732 Pout<<
"Cutting surf1 edges" <<
endl;
756 transfer(edgeCuts1, surf1EdgeCuts_);
764 Pout<<
"Cutting surf2 edges" <<
endl;
783 transfer(edgeCuts2, surf2EdgeCuts_);
784 cutEdges_.transfer(allCutEdges);
785 cutPoints_.transfer(allCutPoints);
790 Pout<<
"surfaceIntersection : Intersection generated:"
792 <<
" points:" << cutPoints_.size() <<
endl
793 <<
" edges :" << cutEdges_.size() <<
endl;
795 Pout<<
"surfaceIntersection : Writing intersection to intEdges.obj"
799 writeOBJ(cutPoints_, cutEdges_, intStream);
802 Pout<<
"Dumping cut edges of surface1 to surf1EdgeCuts.obj" <<
endl;
803 OFstream edge1Stream(
"surf1EdgeCuts.obj");
804 writeIntersectedEdges(surf1, surf1EdgeCuts_, edge1Stream);
806 Pout<<
"Dumping cut edges of surface2 to surf2EdgeCuts.obj" <<
endl;
807 OFstream edge2Stream(
"surf2EdgeCuts.obj");
808 writeIntersectedEdges(surf2, surf2EdgeCuts_, edge2Stream);
824 facePairToVertex_(2*
max(surf1.
size(), surf2.
size())),
825 facePairToEdge_(2*
max(surf1.
size(), surf2.
size())),
840 Pout<<
"Storing surf1 intersections" <<
endl;
847 forAll(intersections1, edgeI)
857 edgeCuts1[edgeI].
append(allCutPoints.size()-1);
871 transfer(edgeCuts1, surf1EdgeCuts_);
881 Pout<<
"Storing surf2 intersections" <<
endl;
888 forAll(intersections2, edgeI)
898 edgeCuts2[edgeI].
append(allCutPoints.size()-1);
912 transfer(edgeCuts2, surf2EdgeCuts_);
917 cutEdges_.transfer(allCutEdges);
918 cutPoints_.transfer(allCutPoints);
923 Pout<<
"surfaceIntersection : Intersection generated:"
925 <<
" points:" << cutPoints_.size() <<
endl
926 <<
" edges :" << cutEdges_.size() <<
endl;
928 Pout<<
"surfaceIntersection : Writing intersection to intEdges.obj"
932 writeOBJ(cutPoints_, cutEdges_, intStream);
935 Pout<<
"Dumping cut edges of surface1 to surf1EdgeCuts.obj" <<
endl;
936 OFstream edge1Stream(
"surf1EdgeCuts.obj");
937 writeIntersectedEdges(surf1, surf1EdgeCuts_, edge1Stream);
939 Pout<<
"Dumping cut edges of surface2 to surf2EdgeCuts.obj" <<
endl;
940 OFstream edge2Stream(
"surf2EdgeCuts.obj");
941 writeIntersectedEdges(surf2, surf2EdgeCuts_, edge2Stream);
952 label edgeI = iter();
954 const edge&
e = cutEdges_[edgeI];
962 label pointI = iter();
964 if (!usedPoints.
found(pointI))
967 <<
"Problem: cut point:" << pointI
968 <<
" coord:" << cutPoints_[pointI]
969 <<
" not used by any edge" <<
endl;
996 Pout<<
"Cutting surf1 edges" <<
endl;
1020 transfer(edgeCuts1, surf1EdgeCuts_);
1021 cutEdges_.transfer(allCutEdges);
1022 cutPoints_.transfer(allCutPoints);
1025 if (cutPoints_.empty() && cutEdges_.empty())
1029 Pout<<
"Empty intersection" <<
endl;
1039 scalar minEdgeLen = GREAT;
1066 Pout<<
"Merged:" << hasMerged
1068 <<
" cutPoints:" << cutPoints_.size()
1069 <<
" newPoints:" << newPoints.size()
1074 cutPoints_.transfer(newPoints);
1079 edge&
e = cutEdges_[edgeI];
1081 e.start() = pointMap[
e.start()];
1082 e.end() = pointMap[
e.end()];
1088 Pout<<
"Degenerate cut:" << edgeI <<
" vertices:" <<
e
1089 <<
" coords:" << cutPoints_[
e.start()] <<
' '
1090 << cutPoints_[
e.end()] <<
endl;
1096 forAll(surf1EdgeCuts_, edgeI)
1099 labelList& cutVerts = surf1EdgeCuts_[edgeI];
1101 removeDuplicates(pointMap, cutVerts);
1107 Pout<<
"surfaceIntersection : Intersection generated and compressed:"
1109 <<
" points:" << cutPoints_.size() <<
endl
1110 <<
" edges :" << cutEdges_.size() <<
endl;
1113 Pout<<
"surfaceIntersection : Writing intersection to intEdges.obj"
1116 OFstream intStream(
"intEdges.obj");
1117 writeOBJ(cutPoints_, cutEdges_, intStream);
1123 Pout<<
"Dumping cut edges of surface1 to surf1EdgeCuts.obj" <<
endl;
1124 OFstream edge1Stream(
"surf1EdgeCuts.obj");
1125 writeIntersectedEdges(surf1, surf1EdgeCuts_, edge1Stream);
1146 return facePairToVertex_;
1152 return facePairToEdge_;
1158 const bool isFirstSurf
1163 return surf1EdgeCuts_;
1167 return surf2EdgeCuts_;
1174 return surf1EdgeCuts_;
1180 return surf2EdgeCuts_;
const labelListList & surf2EdgeCuts() const
const labelPairLookup & facePairToVertex() const
const labelListList & pointFaces() const
Return point-face addressing.
label index() const
Return index.
const labelPairLookup & facePairToEdge() const
const labelListList & edgeFaces() const
Return edge-face addressing.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
#define forAll(list, i)
Loop across all elements in list.
void writeOBJ(Ostream &os, label &vertI, const tetPoints &tet)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
const labelListList & edgeCuts(const bool) const
Access either surf1EdgeCuts (isFirstSurface = true) or.
label nEdges() const
Return number of edges in patch.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
bool hit() const
Is there a hit.
void doCutEdges(const triSurface &surf1, const triSurfaceSearch &querySurf2, const bool isFirstSurf, const bool isSelfIntersection, DynamicList< edge > &allCutEdges, DynamicList< point > &allCutPoints, List< DynamicList< label > > &surfEdgeCuts)
Cut edges of surf1 with surface 2.
static scalar planarTol()
Return planar tolerance.
surfaceIntersection()
Construct null.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< scalar > mag(const dimensioned< Type > &)
Helper class to search on triSurface.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
label end() const
Return end vertex label.
const labelListList & surf1EdgeCuts() const
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
Triangulated surface description with patch information.
void append(const T &)
Append an element at the end of the list.
const Point & hitPoint() const
Return hit point.
const indexedOctree< treeDataTriSurface > & tree() const
Demand driven construction of the octree.
void classifyHit(const triSurface &surf1, const scalarField &surf1PointTol, const triSurface &surf2, const bool isFirstSurf, const label edgeI, const scalar tolDim, const pointIndexHit &pHit, DynamicList< edge > &allCutEdges, DynamicList< point > &allCutPoints, List< DynamicList< label > > &surfEdgeCuts)
Investigate pHit to whether is case of point hits point,.
const pointField & cutPoints() const
label nPoints() const
Return number of points supporting patch faces.
bool found(const Key &) const
Return true if hashedEntry is found in table.
const double e
Elementary charge.
const edgeList & cutEdges() const
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
void storeIntersection(const bool isFirstSurf, const labelList &facesA, const label faceB, DynamicList< edge > &, DynamicList< point > &)
Update reference between faceA and faceB. Updates facePairToVertex_.
label start() const
Return start vertex label.
prefixOSstream Pout(cout, "Pout")
const Field< PointType > & faceNormals() const
Return face normals for patch.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const triSurface & surface() const
Return reference to the surface.
const dimensionedScalar e
Elementary charge.
bool insert(const Key &key)
Insert a new entry.
Triangle with additional region number.
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
void size(const label)
Override size to be inconsistent with allocated storage.
Holder of intersections of edges of a surface with another surface. Optionally shuffles around points...
pointHit nearestPointClassify(const point &p, const pointField &points, label &nearType, label &nearLabel) const
Return nearest point to face and classify it:
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
#define WarningInFunction
Report a warning using Foam::Warning.
label mergePoints(const UList< Type > &points, const scalar mergeTol, const bool verbose, labelList &pointMap, const Type &origin=Type::zero)
Sorts and merges points. All points closer than/equal mergeTol get merged.
static bool excludeEdgeHit(const triSurface &surf, const label edgeI, const label faceI, const scalar tol)
Do some checks if edge and face (resulting from hit)