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)
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);
273 void Foam::surfaceIntersection::classifyHit
275 const triSurface& surf1,
277 const triSurface& surf2,
278 const bool isFirstSurf,
283 DynamicList<edge>& allCutEdges,
284 DynamicList<point>& allCutPoints,
285 List<DynamicList<label>>& surfEdgeCuts
288 const edge& e = surf1.edges()[edgeI];
290 const labelList& facesA = surf1.edgeFaces()[edgeI];
293 label surf2Facei = pHit.index();
298 const pointField& surf2Pts = surf2.localPoints();
300 label nearType, nearLabel;
302 f2.nearestPointClassify(pHit.hitPoint(), surf2Pts, nearType, nearLabel);
308 surf1PointTol[e.start()],
309 surf1PointTol[e.end()],
322 Pout<< pHit.hitPoint() <<
" is surf1:" 323 <<
" end point of edge " << e
324 <<
" surf2: vertex " << f2[nearLabel]
325 <<
" coord:" << surf2Pts[f2[nearLabel]] <<
endl;
333 Pout<< pHit.hitPoint() <<
" is surf1:" 334 <<
" somewhere on edge " << e
335 <<
" surf2: vertex " << f2[nearLabel]
336 <<
" coord:" << surf2Pts[f2[nearLabel]] <<
endl;
339 allCutPoints.append(pHit.hitPoint());
340 surfEdgeCuts[edgeI].append(allCutPoints.size()-1);
342 const labelList& facesB = surf2.pointFaces()[f2[nearLabel]];
363 label edge2I = getEdge(surf2, surf2Facei, nearLabel);
364 const edge& e2 = surf2.edges()[edge2I];
368 Pout<< pHit.hitPoint() <<
" is surf1:" 369 <<
" end point of edge " << e
370 <<
" surf2: edge " << e2
371 <<
" coords:" << surf2Pts[e2.start()]
372 << surf2Pts[e2.end()] <<
endl;
383 label edge2I = getEdge(surf2, surf2Facei, nearLabel);
384 const edge& e2 = surf2.edges()[edge2I];
388 Pout<< pHit.hitPoint() <<
" is surf1:" 389 <<
" somewhere on edge " << e
390 <<
" surf2: edge " << e2
391 <<
" coords:" << surf2Pts[e2.start()]
392 << surf2Pts[e2.end()] <<
endl;
395 allCutPoints.append(pHit.hitPoint());
396 surfEdgeCuts[edgeI].append(allCutPoints.size()-1);
407 const labelList& facesB = surf2.edgeFaces()[edge2I];
431 Pout<< pHit.hitPoint() <<
" is surf1:" 432 <<
" end point of edge " << e
433 <<
" surf2: face " << surf2Facei
447 nearVert = e.start();
454 const point& nearPt = surf1.localPoints()[nearVert];
457 label otherVert = e.otherVertex(nearVert);
459 const point& otherPt = surf1.localPoints()[otherVert];
465 << pHit.hitPoint() <<
" is surf1:" 466 <<
" end point of edge " << e <<
" coord:" 467 << surf1.localPoints()[nearVert]
468 <<
" surf2: face " << surf2Facei <<
endl;
471 vector eVec = otherPt - nearPt;
473 if ((surf2.faceNormals()[surf2Facei] & eVec) > 0)
479 point hitPt = nearPt;
483 Pout<<
"Shifted " << pHit.hitPoint()
485 <<
" along edge:" << e
486 <<
" coords:" << surf1.localPoints()[e.start()]
487 << surf1.localPoints()[e.end()] <<
endl;
492 allCutPoints.append(hitPt);
493 surfEdgeCuts[edgeI].append(allCutPoints.size()-1);
509 Pout<<
"Discarding " << pHit.hitPoint()
510 <<
" since edge " << e <<
" on inside of surf2." 511 <<
" surf2 normal:" << surf2.faceNormals()[surf2Facei]
521 Pout<< pHit.hitPoint() <<
" is surf1:" 522 <<
" somewhere on edge " << e
523 <<
" surf2: face " << surf2Facei
528 allCutPoints.append(pHit.hitPoint());
529 surfEdgeCuts[edgeI].append(allCutPoints.size()-1);
557 void Foam::surfaceIntersection::doCutEdges
559 const triSurface& surf1,
560 const triSurfaceSearch& querySurf2,
561 const bool isFirstSurf,
562 const bool isSelfIntersection,
564 DynamicList<edge>& allCutEdges,
565 DynamicList<point>& allCutPoints,
566 List<DynamicList<label>>& surfEdgeCuts
571 const pointField& surf1Pts = surf1.localPoints();
576 forAll(surf1PointTol, pointi)
578 surf1PointTol[pointi] =
580 * minEdgeLen(surf1, pointi);
583 const triSurface& surf2 = querySurf2.surface();
585 forAll(surf1.edges(), edgeI)
587 const edge& e = surf1.edges()[edgeI];
589 point pStart = surf1Pts[e.start()];
590 const point& pEnd = surf1Pts[e.end()];
593 const scalar tolDim =
mag(tolVec);
595 bool doTrack =
false;
598 pointIndexHit pHit = querySurf2.tree().findLine(pStart, pEnd);
602 if (isSelfIntersection)
614 label hitFacei = pHit.index();
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()]
644 <<
" hit:" << pHit.hitPoint()
645 <<
" tolDim:" << tolDim
650 allCutPoints.append(pHit.hitPoint());
651 surfEdgeCuts[edgeI].append(allCutPoints.size()-1);
673 if (
mag(pHit.hitPoint() - pEnd) < tolDim)
679 pStart = pHit.hitPoint() + tolVec;
703 facePairToVertex_(0),
732 Pout<<
"Cutting surf1 edges" <<
endl;
756 transfer(edgeCuts1, surf1EdgeCuts_);
764 Pout<<
"Cutting surf2 edges" <<
endl;
783 transfer(edgeCuts2, surf2EdgeCuts_);
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_);
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_);
1029 Pout<<
"Empty intersection" <<
endl;
1039 scalar minEdgeLen = great;
1066 Pout<<
"Merged:" << hasMerged
1068 <<
" cutPoints:" << cutPoints_.
size()
1069 <<
" newPoints:" << newPoints.
size()
1079 edge& e = cutEdges_[edgeI];
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_;
surfaceIntersection()
Construct null.
label nPoints() const
Return number of points supporting patch faces.
#define forAll(list, i)
Loop across all elements in list.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
PointIndexHit< point > pointIndexHit
Vector< scalar > vector
A scalar version of the templated Vector.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
bool insert(const Key &key)
Insert a new entry.
const labelListList & surf2EdgeCuts() const
const labelListList & edgeCuts(const bool) const
Access either surf1EdgeCuts (isFirstSurface = true) or.
static scalar setPlanarTol(const scalar t)
Set the planar tolerance, returning the previous value.
Helper class to search on triSurface.
const Point & hitPoint() const
Return hit point.
const edgeList & cutEdges() const
static scalar planarTol()
Return planar tolerance.
vectorField pointField
pointField is a vectorField.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
bool found(const Key &) const
Return true if hashedEntry is found in table.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
friend class const_iterator
Declare friendship with the const_iterator.
const labelPairLookup & facePairToEdge() const
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
const labelListList & edgeFaces() const
Return edge-face addressing.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
List< label > labelList
A List of labels.
scalar mag(const pointField &) const
Return scalar magnitude.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
const labelPairLookup & facePairToVertex() const
label nEdges() const
Return number of edges in patch.
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
const pointField & cutPoints() const
const triSurface & surface() const
Return reference to the surface.
std::remove_reference< ::Foam::List< labelledTri > >::type::value_type FaceType
vector point
Point is a vector.
const labelListList & surf1EdgeCuts() const
#define WarningInFunction
Report a warning using Foam::Warning.
label end() const
Return end vertex label.
prefixOSstream Pout(cout, "Pout")
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.
dimensioned< scalar > mag(const dimensioned< Type > &)
const doubleScalar e
Elementary charge.
Triangulated surface description with patch information.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
Holder of intersections of edges of a surface with another surface. Optionally shuffles around points...
label index() const
Return index.
label start() const
Return start vertex label.