47template<
class ElementIds>
51 const ElementIds& elemIds
56 if (
mesh.hasCellPoints())
65 return treeBoundBox(mesh.points(), mesh.cellPoints(celli));
78 return treeBoundBox(mesh.cells()[celli].box(mesh));
119 if (
mesh.hasCellPoints())
121 for (
const label celli : cellIds)
128 for (
const label celli : cellIds)
140inline Foam::treeBoundBox
141Foam::treeDataCell::getBounds(
const label index)
const
147void Foam::treeDataCell::update()
191 cellLabels_(cellLabels),
209 cellLabels_(std::move(cellLabels)),
212 decompMode_(decompMode)
227 if (mesh_.hasCellPoints())
229 for (
const label index : indices)
231 const label celli = cellLabels_[index];
233 bb.
add(mesh_.points(), mesh_.cellPoints(celli));
238 for (
const label index : indices)
240 const label celli = cellLabels_[index];
242 bb.
add(mesh_.cells()[celli].box(mesh_));
260 return mesh_.cellCentres();
267 const treeBoundBox& searchBox
273 ? searchBox.overlaps(bbs_[index])
274 : searchBox.overlaps(getBounds(index))
314 scalar& nearestDistSqr,
319 for (
const label index : indices)
321 const point& pt = centre(index);
323 const scalar distSqr =
sample.distSqr(pt);
325 if (distSqr < nearestDistSqr)
327 nearestDistSqr = distSqr;
335void Foam::treeDataCell::findNearestOp::operator()
340 scalar& nearestDistSqr,
345 tree_.shapes().findNearest
356void Foam::treeDataCell::findNearestOp::operator()
371bool Foam::treeDataCell::findIntersectOp::operator()
376 point& intersectionPoint
394 const treeBoundBox cellBb = shape.getBounds(index);
396 if ((cellBb.posBits(start) & cellBb.posBits(end)) != 0)
410 const vector dir(end - start);
411 scalar minDistSqr =
magSqr(dir);
416 for (
const label facei : shape.
mesh().
cells()[celli])
428 if (inter.hit() &&
sqr(inter.distance()) <= minDistSqr)
433 minDistSqr =
sqr(inter.distance());
434 intersectionPoint = inter.point();
Minimal example by using system/controlDict.functions:
scalar distance() const noexcept
Return distance to hit.
bool hit() const noexcept
Is there a hit.
const point_type & point() const noexcept
Return the point, no checks.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
void add(const boundBox &bb)
Extend to include the second box.
A face is a list of labels corresponding to mesh vertices.
Non-pointer based hierarchical recursive searching.
static scalar setPlanarTol(const scalar t)
Set the planar tolerance, returning the previous value.
A range or interval of labels defined by a start and a size.
Mesh consisting of general polyhedral cells.
cellDecomposition
Enumeration defining the decomposition of the cell for.
virtual const faceList & faces() const
Return raw faces.
virtual const pointField & points() const
Return raw points.
Cell-face mesh analysis engine.
const cellList & cells() const
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Standard boundBox with extra functionality for use in octree.
bool overlaps(const boundBox &bb) const
Overlaps with other bounding box, sphere etc?
direction posBits(const point &pt) const
Position of point relative to bounding box.
findIntersectOp(const indexedOctree< treeDataCell > &tree)
findNearestOp(const indexedOctree< treeDataCell > &tree)
Encapsulation of data needed to search in/for cells. Used to find the cell containing a point (e....
tmp< pointField > centres() const
Representative point cloud for contained shapes. One point per shape, corresponding to the cell centr...
const labelList & cellLabels() const noexcept
The subset of cell ids to use.
void findNearest(const labelUList &indices, const point &sample, scalar &nearestDistSqr, label &nearestIndex, point &nearestPoint) const
Calculates nearest (to sample) point in shape.
bool contains(const label index, const point &sample) const
Does shape at index contain sample.
const point & centre(const label index) const
Representative point (cell centre) at shape index.
label objectIndex(const label index) const
Map from shape index to original (non-subset) cell label.
static treeBoundBox bounds(const primitiveMesh &mesh, const labelUList &cellIds)
Return bounding box of specified mesh cells.
static treeBoundBoxList boxes(const primitiveMesh &mesh)
Calculate and return bounding boxes for all mesh cells.
const polyMesh & mesh() const noexcept
Reference to the supporting mesh.
polyMesh::cellDecomposition decompMode() const noexcept
The cell decomposition mode used.
bool overlaps(const label index, const treeBoundBox &searchBox) const
Does (bb of) shape at index overlap searchBox.
treeDataCell(const bool cacheBb, const polyMesh &mesh, polyMesh::cellDecomposition decompMode)
Construct from mesh, using all cells in mesh.
#define defineTypeName(Type)
Define the typeName.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
PointHit< point > pointHit
A PointHit with a 3D point.
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
List< treeBoundBox > treeBoundBoxList
A List of treeBoundBox.
static treeBoundBoxList boxesImpl(const primitiveMesh &mesh, const ElementIds &elemIds)
line< point, const point & > linePointRef
A line using referred points.
vector point
Point is a vector.
UList< label > labelUList
A UList of labels.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Tree tree(triangles.begin(), triangles.end())