51 bool Foam::surfaceIntersection::excludeEdgeHit
53 const triSurface& surf,
60 const edge& e = surf.
edges()[edgeI];
64 if (f[0] == e.start() || f[0] == e.end())
196 void Foam::surfaceIntersection::storeIntersection
198 const bool isFirstSurf,
201 DynamicList<edge>& allCutEdges,
202 DynamicList<point>& allCutPoints
207 label faceA = facesA[facesAI];
211 FixedList<label, 2> 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)
244 "Foam::surfaceIntersection::storeIntersection" 245 "(const bool isFirstSurf, const labelList& facesA," 246 "const label faceB, DynamicList<edge>& allCutEdges," 247 "DynamicList<point>& allCutPoints)" 248 ) <<
"Encountered degenerate edge between face " 249 << twoFaces[0] <<
" on first surface" 250 <<
" and face " << twoFaces[1] <<
" on second surface" 252 <<
"Point on first surface:" << prevHit <<
endl 253 <<
"Point on second surface:" << thisHit <<
endl 258 allCutEdges.append(edge(*iter, allCutPoints.size()-1));
261 facePairToEdge_.insert(twoFaces, allCutEdges.size()-1);
278 void Foam::surfaceIntersection::classifyHit
280 const triSurface& surf1,
282 const triSurface& surf2,
283 const bool isFirstSurf,
288 DynamicList<edge>& allCutEdges,
289 DynamicList<point>& allCutPoints,
290 List<DynamicList<label> >& surfEdgeCuts
293 const edge& e = surf1.edges()[edgeI];
295 const labelList& facesA = surf1.edgeFaces()[edgeI];
298 label surf2FaceI = pHit.index();
303 const pointField& surf2Pts = surf2.localPoints();
305 label nearType, nearLabel;
307 f2.nearestPointClassify(pHit.hitPoint(), surf2Pts, nearType, nearLabel);
313 surf1PointTol[e.start()],
314 surf1PointTol[e.end()],
327 Pout<< pHit.hitPoint() <<
" is surf1:" 328 <<
" end point of edge " << e
329 <<
" surf2: vertex " << f2[nearLabel]
330 <<
" coord:" << surf2Pts[f2[nearLabel]] <<
endl;
338 Pout<< pHit.hitPoint() <<
" is surf1:" 339 <<
" somewhere on edge " << e
340 <<
" surf2: vertex " << f2[nearLabel]
341 <<
" coord:" << surf2Pts[f2[nearLabel]] <<
endl;
344 allCutPoints.append(pHit.hitPoint());
345 surfEdgeCuts[edgeI].append(allCutPoints.size()-1);
347 const labelList& facesB = surf2.pointFaces()[f2[nearLabel]];
368 label edge2I = getEdge(surf2, surf2FaceI, nearLabel);
369 const edge& e2 = surf2.edges()[edge2I];
373 Pout<< pHit.hitPoint() <<
" is surf1:" 374 <<
" end point of edge " << e
375 <<
" surf2: edge " << e2
376 <<
" coords:" << surf2Pts[e2.start()]
377 << surf2Pts[e2.end()] <<
endl;
388 label edge2I = getEdge(surf2, surf2FaceI, nearLabel);
389 const edge& e2 = surf2.edges()[edge2I];
393 Pout<< pHit.hitPoint() <<
" is surf1:" 394 <<
" somewhere on edge " << e
395 <<
" surf2: edge " << e2
396 <<
" coords:" << surf2Pts[e2.start()]
397 << surf2Pts[e2.end()] <<
endl;
400 allCutPoints.append(pHit.hitPoint());
401 surfEdgeCuts[edgeI].append(allCutPoints.size()-1);
412 const labelList& facesB = surf2.edgeFaces()[edge2I];
436 Pout<< pHit.hitPoint() <<
" is surf1:" 437 <<
" end point of edge " << e
438 <<
" surf2: face " << surf2FaceI
452 nearVert = e.start();
459 const point& nearPt = surf1.localPoints()[nearVert];
462 label otherVert = e.otherVertex(nearVert);
464 const point& otherPt = surf1.localPoints()[otherVert];
470 << pHit.hitPoint() <<
" is surf1:" 471 <<
" end point of edge " << e <<
" coord:" 472 << surf1.localPoints()[nearVert]
473 <<
" surf2: face " << surf2FaceI <<
endl;
476 vector eVec = otherPt - nearPt;
478 if ((surf2.faceNormals()[surf2FaceI] & eVec) > 0)
484 point hitPt = nearPt;
488 Pout<<
"Shifted " << pHit.hitPoint()
490 <<
" along edge:" << e
491 <<
" coords:" << surf1.localPoints()[e.start()]
492 << surf1.localPoints()[e.end()] <<
endl;
497 allCutPoints.append(hitPt);
498 surfEdgeCuts[edgeI].append(allCutPoints.size()-1);
514 Pout<<
"Discarding " << pHit.hitPoint()
515 <<
" since edge " << e <<
" on inside of surf2." 516 <<
" surf2 normal:" << surf2.faceNormals()[surf2FaceI]
526 Pout<< pHit.hitPoint() <<
" is surf1:" 527 <<
" somewhere on edge " << e
528 <<
" surf2: face " << surf2FaceI
533 allCutPoints.append(pHit.hitPoint());
534 surfEdgeCuts[edgeI].append(allCutPoints.size()-1);
562 void Foam::surfaceIntersection::doCutEdges
564 const triSurface& surf1,
565 const triSurfaceSearch& querySurf2,
566 const bool isFirstSurf,
567 const bool isSelfIntersection,
569 DynamicList<edge>& allCutEdges,
570 DynamicList<point>& allCutPoints,
571 List<DynamicList<label> >& surfEdgeCuts
576 const pointField& surf1Pts = surf1.localPoints();
581 forAll(surf1PointTol, pointI)
583 surf1PointTol[pointI] =
585 * minEdgeLen(surf1, pointI);
588 const triSurface& surf2 = querySurf2.surface();
590 forAll(surf1.edges(), edgeI)
592 const edge& e = surf1.edges()[edgeI];
594 point pStart = surf1Pts[e.start()];
595 const point& pEnd = surf1Pts[e.end()];
598 const scalar tolDim =
mag(tolVec);
600 bool doTrack =
false;
603 pointIndexHit pHit = querySurf2.tree().findLine(pStart, pEnd);
607 if (isSelfIntersection)
619 label hitFaceI = pHit.index();
633 label edgeEnd = classify
635 surf1PointTol[e.start()],
636 surf1PointTol[e.end()],
646 Pout<<
"edge:" << edgeI <<
" vertices:" << e
647 <<
" start:" << surf1Pts[e.start()]
648 <<
" end:" << surf1Pts[e.end()]
649 <<
" hit:" << pHit.hitPoint()
650 <<
" tolDim:" << tolDim
655 allCutPoints.append(pHit.hitPoint());
656 surfEdgeCuts[edgeI].append(allCutPoints.size()-1);
678 if (
mag(pHit.hitPoint() - pEnd) < tolDim)
684 pStart = pHit.hitPoint() + tolVec;
708 facePairToVertex_(0),
737 Pout<<
"Cutting surf1 edges" <<
endl;
761 transfer(edgeCuts1, surf1EdgeCuts_);
769 Pout<<
"Cutting surf2 edges" <<
endl;
788 transfer(edgeCuts2, surf2EdgeCuts_);
795 Pout<<
"surfaceIntersection : Intersection generated:" 797 <<
" points:" << cutPoints_.
size() <<
endl 798 <<
" edges :" << cutEdges_.
size() <<
endl;
800 Pout<<
"surfaceIntersection : Writing intersection to intEdges.obj" 804 writeOBJ(cutPoints_, cutEdges_, intStream);
807 Pout<<
"Dumping cut edges of surface1 to surf1EdgeCuts.obj" <<
endl;
808 OFstream edge1Stream(
"surf1EdgeCuts.obj");
809 writeIntersectedEdges(surf1, surf1EdgeCuts_, edge1Stream);
811 Pout<<
"Dumping cut edges of surface2 to surf2EdgeCuts.obj" <<
endl;
812 OFstream edge2Stream(
"surf2EdgeCuts.obj");
813 writeIntersectedEdges(surf2, surf2EdgeCuts_, edge2Stream);
829 facePairToVertex_(2*
max(surf1.
size(), surf2.
size())),
830 facePairToEdge_(2*
max(surf1.
size(), surf2.
size())),
845 Pout<<
"Storing surf1 intersections" <<
endl;
852 forAll(intersections1, edgeI)
862 edgeCuts1[edgeI].append(allCutPoints.
size()-1);
876 transfer(edgeCuts1, surf1EdgeCuts_);
886 Pout<<
"Storing surf2 intersections" <<
endl;
893 forAll(intersections2, edgeI)
903 edgeCuts2[edgeI].append(allCutPoints.
size()-1);
917 transfer(edgeCuts2, surf2EdgeCuts_);
928 Pout<<
"surfaceIntersection : Intersection generated:" 930 <<
" points:" << cutPoints_.
size() <<
endl 931 <<
" edges :" << cutEdges_.
size() <<
endl;
933 Pout<<
"surfaceIntersection : Writing intersection to intEdges.obj" 937 writeOBJ(cutPoints_, cutEdges_, intStream);
940 Pout<<
"Dumping cut edges of surface1 to surf1EdgeCuts.obj" <<
endl;
941 OFstream edge1Stream(
"surf1EdgeCuts.obj");
942 writeIntersectedEdges(surf1, surf1EdgeCuts_, edge1Stream);
944 Pout<<
"Dumping cut edges of surface2 to surf2EdgeCuts.obj" <<
endl;
945 OFstream edge2Stream(
"surf2EdgeCuts.obj");
946 writeIntersectedEdges(surf2, surf2EdgeCuts_, edge2Stream);
957 label edgeI = iter();
959 const edge& e = cutEdges_[edgeI];
967 label pointI = iter();
969 if (!usedPoints.
found(pointI))
971 WarningIn(
"surfaceIntersection::surfaceIntersection")
972 <<
"Problem: cut point:" << pointI
973 <<
" coord:" << cutPoints_[pointI]
974 <<
" not used by any edge" <<
endl;
1001 Pout<<
"Cutting surf1 edges" <<
endl;
1025 transfer(edgeCuts1, surf1EdgeCuts_);
1034 Pout<<
"Empty intersection" <<
endl;
1044 scalar minEdgeLen = GREAT;
1071 Pout<<
"Merged:" << hasMerged
1073 <<
" cutPoints:" << cutPoints_.
size()
1074 <<
" newPoints:" << newPoints.
size()
1084 edge& e = cutEdges_[edgeI];
1087 e.
end() = pointMap[e.
end()];
1093 Pout<<
"Degenerate cut:" << edgeI <<
" vertices:" << e
1094 <<
" coords:" << cutPoints_[e.
start()] <<
' ' 1095 << cutPoints_[e.
end()] <<
endl;
1101 forAll(surf1EdgeCuts_, edgeI)
1104 labelList& cutVerts = surf1EdgeCuts_[edgeI];
1106 removeDuplicates(pointMap, cutVerts);
1112 Pout<<
"surfaceIntersection : Intersection generated and compressed:" 1114 <<
" points:" << cutPoints_.
size() <<
endl 1115 <<
" edges :" << cutEdges_.
size() <<
endl;
1118 Pout<<
"surfaceIntersection : Writing intersection to intEdges.obj" 1121 OFstream intStream(
"intEdges.obj");
1122 writeOBJ(cutPoints_, cutEdges_, intStream);
1128 Pout<<
"Dumping cut edges of surface1 to surf1EdgeCuts.obj" <<
endl;
1129 OFstream edge1Stream(
"surf1EdgeCuts.obj");
1130 writeIntersectedEdges(surf1, surf1EdgeCuts_, edge1Stream);
1151 return facePairToVertex_;
1157 return facePairToEdge_;
1163 const bool isFirstSurf
1168 return surf1EdgeCuts_;
1172 return surf2EdgeCuts_;
1179 return surf1EdgeCuts_;
1185 return surf2EdgeCuts_;
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
vector point
Point is a vector.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
dimensioned< scalar > mag(const dimensioned< Type > &)
edgeList edges() const
Return edges in face point ordering,.
const labelListList & edgeFaces() const
Return edge-face addressing.
bool empty() const
Return true if the UList is empty (ie, size() is zero).
Triangulated surface description with patch information.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void size(const label)
Override size to be inconsistent with allocated storage.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
PointIndexHit< point > pointIndexHit
friend class const_iterator
Declare friendship with the const_iterator.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
label index() const
Return index.
label nPoints() const
Return number of points supporting patch faces.
vectorField pointField
pointField is a vectorField.
static scalar setPlanarTol(const scalar t)
Set the planar tolerance, returning the previous value.
const Point & hitPoint() const
Return hit point.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
scalar mag(const pointField &) const
Return scalar magnitude.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Holder of intersections of edges of a surface with another surface. Optionally shuffles around points...
const Field< PointType > & localPoints() const
Return pointField of points in patch.
const double e
Elementary charge.
Ostream & endl(Ostream &os)
Add newline and flush stream.
#define WarningIn(functionName)
Report a warning using Foam::Warning.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const labelPairLookup & facePairToVertex() const
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const pointField & cutPoints() const
const labelListList & edgeCuts(const bool) const
Access either surf1EdgeCuts (isFirstSurface = true) or.
const labelListList & surf2EdgeCuts() const
static scalar planarTol()
Return planar tolerance.
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.
surfaceIntersection()
Construct null.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
const labelListList & surf1EdgeCuts() const
label end() const
Return end vertex label.
List< label > labelList
A List of labels.
Vector< scalar > vector
A scalar version of the templated Vector.
const labelPairLookup & facePairToEdge() const
label start() const
Return start vertex label.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
label nEdges() const
Return number of edges in patch.
const triSurface & surface() const
Return reference to the surface.
bool found(const Key &) const
Return true if hashedEntry is found in table.
defineTypeNameAndDebug(combustionModel, 0)
const edgeList & cutEdges() const
prefixOSstream Pout(cout,"Pout")
Helper class to search on triSurface.
bool insert(const Key &key)
Insert a new entry.