Go to the documentation of this file.
31 #include "triSurface.H"
33 #include "treeDataTriSurface.H"
60 scalar minSize = SMALL * bb.
minDim();
64 const edge&
e = edges[edgeI];
66 scalar eMag =
e.mag(localPoints);
71 <<
"Edge " << edgeI <<
" vertices " <<
e
72 <<
" coords:" << localPoints[
e[0]] <<
' '
73 << localPoints[
e[1]] <<
" is very small compared to bounding"
74 <<
" box dimensions " << bb <<
endl
75 <<
"This might lead to problems in intersection"
99 Pout<<
"Calculating intersection of " << edgeLabels.
size() <<
" edges"
100 <<
" out of " << surf1.
nEdges() <<
" with " << surf2.
size()
101 <<
" triangles ..." <<
endl;
111 label edgeI = edgeLabels[i];
115 Pout<<
"Intersecting edge " << edgeI <<
" with surface" <<
endl;
120 const point& pStart = points1[meshPoints[
e.start()]];
121 const point& pEnd = points1[meshPoints[
e.end()]];
123 const vector eVec(pEnd - pStart);
131 start[i] = pStart - 0.5*surf1PointTol[
e[0]]*
n;
132 end[i] = pEnd + 0.5*surf1PointTol[
e[1]]*
n;
150 const label edgeI = edgeLabels[i];
152 labelList& intersectionTypes = classification_[edgeI];
157 forAll(intersectionTypes, hitI)
160 label& hitType = intersectionTypes[hitI];
170 if (
mag(pHit.
hitPoint() - start[i]) < surf1PointTol[
e[0]])
175 else if (
mag(pHit.
hitPoint() - end[i]) < surf1PointTol[
e[1]])
180 else if (
mag(edgeDirs[i] & normals2[pHit.
index()]) < alignedCos_)
184 Pout<<
"Flat angle edge:" << edgeI
185 <<
" face:" << pHit.
index()
186 <<
" cos:" <<
mag(edgeDirs[i] & normals2[pHit.
index()])
194 Info<<
" hit " << pHit <<
" classify = " << hitType <<
endl;
203 Pout<<
"Found " << nHits <<
" intersections of edges with surface ..."
225 bool hasPerturbed =
false;
231 const labelList& edgeEnds = classification_[edgeI];
235 bool perturbStart =
false;
236 bool perturbEnd =
false;
239 if (edgeEnds.first() == 0)
244 if (edgeEnds.last() == 1)
250 if (perturbStart || perturbEnd)
257 vector eVec(points1[v1] - points1[v0]);
264 points1[v0] += t*surf1PointTol[
e[0]]*
n;
270 affectedEdges[pEdges[i]] =
true;
277 points1[v1] += t*surf1PointTol[
e[1]]*
n;
283 affectedEdges[pEdges[i]] =
true;
308 const labelList& edgeEnds = classification_[edgeI];
310 bool hasPerturbed =
false;
314 if (edgeEnds[i] == 2)
326 vector n(points1[meshPoints[
e[1]]] - points1[meshPoints[
e[0]]]);
327 scalar magN =
mag(
n) + VSMALL;
330 rndVec -=
n*(
n & rndVec);
333 rndVec /=
mag(rndVec) + VSMALL;
338 Pout<<
"rotating: shifting endpoint " << meshPoints[pointI]
339 <<
" of edge:" << edgeI <<
" verts:"
340 << points1[meshPoints[
e[0]]] <<
' '
341 << points1[meshPoints[
e[1]]]
343 <<
" tol:" << surf1PointTol[pointI] <<
endl;
345 points1[meshPoints[pointI]] += rndVec;
352 affectedEdges[pEdges[i]] =
true;
386 bool hasPerturbed =
false;
401 label nearType, nearLabel;
411 points1[meshPoints[
e[0]]] += offset;
418 affectedEdges[pEdges0[i]] =
true;
422 points1[meshPoints[
e[1]]] += offset;
429 affectedEdges[pEdges1[i]] =
true;
461 classification_(surf1.
nEdges())
488 classification_(classification)
504 const labelList& pEdges = pointEdges[pointI];
506 scalar minDist = GREAT;
510 minDist =
min(minDist, edges[pEdges[i]].
mag(localPoints));
513 minLen[pointI] = minDist;
546 for (; iter < nIters; iter++)
558 label edgeI = edgesToTest[i];
561 if (!affectedEdges[edgeI])
565 bool shiftedEdgeEndPoints =
576 nShifted += (shiftedEdgeEndPoints ? 1 : 0);
578 if (!shiftedEdgeEndPoints)
591 nRotated += (rotatedEdge ? 1 : 0);
599 bool offsetEdgePoints =
610 nOffset += (offsetEdgePoints ? 1 : 0);
618 Pout<<
"Edges to test : " <<
nl
619 <<
" total:" << edgesToTest.
size() <<
nl
620 <<
" resolved by:" <<
nl
621 <<
" shifting : " << nShifted <<
nl
622 <<
" rotating : " << nRotated <<
nl
623 <<
" offsetting : " << nOffset <<
nl
628 if (nShifted == 0 && nRotated == 0 && nOffset == 0)
639 forAll(affectedEdges, edgeI)
641 if (affectedEdges[edgeI])
643 newEdgesToTest[newEdgeI++] = edgeI;
646 newEdgesToTest.
setSize(newEdgeI);
650 Pout<<
"Edges to test:" <<
nl
651 <<
" was : " << edgesToTest.
size() <<
nl
652 <<
" is : " << newEdgesToTest.
size() <<
nl
657 edgesToTest.
transfer(newEdgesToTest);
659 if (edgesToTest.empty())
692 label edgeI = edgeMap[subI];
694 labelList& intersectionTypes = classification_[edgeI];
700 sz = intersections.
size();
708 bool foundFace =
false;
709 for (
label interI = 0; interI < sz; interI++)
711 if (intersections[interI].index() ==
faceMap[subHit.
index()])
724 intersections.
setSize(sz+nNew);
725 intersectionTypes.
setSize(sz+nNew);
732 bool foundFace =
false;
733 for (
label interI = 0; interI < sz; interI++)
735 if (intersections[interI].index() ==
faceMap[subHit.
index()])
750 intersectionTypes[nNew] = subClass[i];
const labelListList & classification() const
For every intersection the classification status.
Simple random number generator.
label index() const
Return index.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
const Field< PointType > & points() const
Return reference to global points.
static scalar alignedCos_
Cosine between edge and face normal when considered parallel.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
#define forAll(list, i)
Loop across all elements in list.
point centre(const pointField &) const
Return centre (centroid)
const Field< PointType > & localPoints() const
Return pointField of points in patch.
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...
bool hit() const
Is there a hit.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
Unit conversion functions.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &info) const
Calculate all intersections from start to end.
dimensioned< scalar > mag(const dimensioned< Type > &)
Helper class to search on triSurface.
bool inlinePerturb(const triSurface &surf1, const scalarField &surf1PointTol, const label edgeI, Random &rndGen, pointField &points1, boolList &affectedEdges) const
Perturb endpoints of edge if they are close to the intersection.
label removeDegenerates(const label nIters, const triSurface &surf1, const triSurfaceSearch &query2, const scalarField &surf1PointTol, pointField &points1)
Resolve ties. Shuffles points so all edge - face intersections.
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
const Point & rawPoint() const
Return point with no checking.
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.
const Point & hitPoint() const
Return hit point.
const labelListList & pointEdges() const
Return point-edge addressing.
static scalarField minEdgeLength(const triSurface &surf)
Calculate min edge length for every surface point.
scalar minDim() const
Smallest length/height/width dimension.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
scalar scalar01()
Returns the current sample.
errorManip< error > abort(error &err)
const double e
Elementary charge.
Vector< scalar > vector
A scalar version of the templated Vector.
void intersectEdges(const triSurface &surf1, const pointField &points1, const triSurfaceSearch &querySurf2, const scalarField &surf1PointTol, const labelList &edgeLabels)
Intersect selected surface edges (edgeLabels) with surface2.
edgeIntersections()
Construct null.
void setSize(const label)
Reset size of List.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
PointIndexHit< point > pointIndexHit
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.
Triangle with additional region number.
static void checkEdges(const triSurface &surf)
Check for too small edges.
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
bool offsetPerturb(const triSurface &surf1, const triSurface &surf2, const label edgeI, Random &rndGen, pointField &points1, boolList &affectedEdges) const
Perturb edge by shifting in direction trianglecentre - intersection.
void merge(const edgeIntersections &, const labelList &edgeMap, const labelList &faceMap, const bool merge=true)
Merge (or override) edge intersection for a subset.
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:
const labelList & meshPoints() const
Return labelList of mesh points in patch.
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
#define WarningInFunction
Report a warning using Foam::Warning.
cachedRandom rndGen(label(0), -1)
bool merge(dictionary &, const dictionary &, const bool, const HashTable< wordList, word > &)
bool rotatePerturb(const triSurface &surf1, const scalarField &surf1PointTol, const label edgeI, Random &rndGen, pointField &points1, boolList &affectedEdges) const
Perturb single endpoint of edge if edge is algigned with face.
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
dimensionedScalar cos(const dimensionedScalar &ds)