36bool Foam::triSurfaceSearch::checkUniqueHit
38 const pointIndexHit& currHit,
39 const UList<pointIndexHit>& hits,
47 const labelledTri&
f =
surface()[currHit.index()];
49 f.nearestPointClassify
61 const label nearPointi =
f[nearLabel];
68 const label pointFacei = pointFaces[pI];
70 if (pointFacei != currHit.index())
76 if (hit.index() == pointFacei)
91 const label edgeI = fEdges[nearLabel];
97 const label edgeFacei = edgeFaces[fI];
99 if (edgeFacei != currHit.index())
105 if (hit.index() == edgeFacei)
108 const vector currHitNormal =
111 const vector existingHitNormal =
114 const label signCurrHit =
115 pos0(currHitNormal & lineVec);
117 const label signExistingHit =
118 pos0(existingHitNormal & lineVec);
120 if (signCurrHit == signExistingHit)
136Foam::triSurfaceSearch::triSurfaceSearch(
const triSurface& surface)
145Foam::triSurfaceSearch::triSurfaceSearch
157 if (
dict.readIfPresent(
"tolerance", tolerance_) && tolerance_ > 0)
159 Info<<
" using intersection tolerance " << tolerance_ << endl;
163 if (
dict.readIfPresent(
"maxTreeDepth", maxTreeDepth_) && maxTreeDepth_ > 0)
165 Info<<
" using maximum tree depth " << maxTreeDepth_ << endl;
170Foam::triSurfaceSearch::triSurfaceSearch
173 const scalar tolerance,
174 const label maxTreeDepth
178 tolerance_(tolerance),
179 maxTreeDepth_(maxTreeDepth),
213 if (surface().size())
221 <<
"Surface does not have compact point numbering."
222 <<
" Of " << surface().points().
size()
224 <<
" are used. This might give problems in some routines."
236 const scalar oldTol =
262 PackedList<2>& nodeTypes = treePtr_->nodeTypes();
290 if (!
tree().bb().contains(sample))
292 inside[sampleI] =
false;
296 inside[sampleI] =
true;
300 inside[sampleI] =
false;
314 const scalar oldTol =
319 const treeDataTriSurface::findNearestOp fOp(octree);
325 info[i] = octree.findNearest
344 const scalar nearestDistSqr = 0.25*
magSqr(span);
346 return tree().findNearest(pt, nearestDistSqr);
361 const scalar oldTol =
366 info[i] = octree.findLine(start[i], end[i]);
377 List<pointIndexHit>& info
380 const indexedOctree<treeDataTriSurface>& octree =
tree();
382 info.setSize(start.size());
384 const scalar oldTol =
389 info[i] = octree.findLineAny(start[i], end[i]);
400 List<List<pointIndexHit>>& info
403 const indexedOctree<treeDataTriSurface>& octree =
tree();
405 info.setSize(start.size());
407 const scalar oldTol =
411 DynamicList<pointIndexHit> hits;
413 DynamicList<label> shapeMask;
415 treeDataTriSurface::findAllIntersectOp allIntersectOp(octree, shapeMask);
449 shapeMask.append(inter.index());
457 info[pointi].transfer(hits);
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void append(const T &val)
Copy append an element to the end of this list.
Minimal example by using system/controlDict.functions:
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(label n)
Alias for resize().
A dynamic list of packed unsigned integers, with the number of bits per item specified by the <Width>...
label index() const noexcept
Return the hit index.
bool hit() const noexcept
Is there a hit?
const Map< label > & meshPointMap() const
Mesh point map.
const Field< point_type > & faceNormals() const
Return face unit normals for patch.
const labelListList & pointFaces() const
Return point-face addressing.
const labelListList & edgeFaces() const
Return edge-face addressing.
const labelListList & faceEdges() const
Return face-edge addressing.
void size(const label n)
Older name for setAddressableSize.
void inflate(const scalar factor)
Expand box by factor*mag(span) in all dimensions.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
static scalar & perturbTol() noexcept
Get the perturbation tolerance.
Non-pointer based hierarchical recursive searching.
pointIndexHit findLineAny(const point &start, const point &end) const
Find any intersection of line between start and end.
Standard boundBox with extra functionality for use in octree.
void flip()
Flip orientation (if cached on octree).
void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &info) const
Calculate all intersections from start to end.
boolList calcInside(const pointField &searchPoints) const
Calculate for each searchPoint inside/outside status.
scalar tolerance() const
Return tolerance to use in searches.
const triSurface & surface() const
Return reference to the surface.
const indexedOctree< treeDataTriSurface > & tree() const
Demand driven construction of the octree.
~triSurfaceSearch()
Destructor.
void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
label maxTreeDepth() const
Return max tree depth of octree.
void clearOut()
Clear storage.
pointIndexHit nearest(const point &pt, const vector &span) const
Calculate nearest point on surface for single searchPoint. Returns.
void findNearest(const pointField &samples, const scalarField &nearestDistSqr, List< pointIndexHit > &info) const
Triangulated surface description with patch information.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
@ OUTSIDE
A location outside the volume.
@ INSIDE
A location inside the volume.
#define WarningInFunction
Report a warning using Foam::Warning.
treeDataPrimitivePatch< triSurface > treeDataTriSurface
dimensionedScalar pos0(const dimensionedScalar &ds)
List< label > labelList
A List of labels.
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
vector point
Point is a vector.
List< bool > boolList
A List of bools.
vectorField pointField
pointField is a vectorField.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Tree tree(triangles.begin(), triangles.end())
#define forAll(list, i)
Loop across all elements in list.
scalarField samples(nIntervals, Zero)