mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add Xfer<> construction for indexedOctree components
- in preparation for using PackedBoolList
This commit is contained in:
@ -164,8 +164,8 @@ private:
|
||||
|
||||
// Construction
|
||||
|
||||
//- Split list of indices into 8 bins according to where they are in
|
||||
// relation to mid.
|
||||
//- Split list of indices into 8 bins
|
||||
// according to where they are in relation to mid.
|
||||
void divide
|
||||
(
|
||||
const labelList& indices,
|
||||
@ -173,8 +173,8 @@ private:
|
||||
labelListList& result
|
||||
) const;
|
||||
|
||||
//- Subdivide the contents node at position contentI. Appends to
|
||||
// contents.
|
||||
//- Subdivide the contents node at position contentI.
|
||||
// Appends to contents.
|
||||
node divide
|
||||
(
|
||||
const treeBoundBox& bb,
|
||||
|
||||
@ -64,19 +64,7 @@ Foam::treeBoundBox Foam::treeDataCell::calcCellBb(const label cellI) const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::treeDataCell::treeDataCell
|
||||
(
|
||||
const bool cacheBb,
|
||||
const primitiveMesh& mesh,
|
||||
const labelList& cellLabels
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
cellLabels_(cellLabels),
|
||||
cacheBb_(cacheBb)
|
||||
void Foam::treeDataCell::update()
|
||||
{
|
||||
if (cacheBb_)
|
||||
{
|
||||
@ -90,6 +78,38 @@ Foam::treeDataCell::treeDataCell
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::treeDataCell::treeDataCell
|
||||
(
|
||||
const bool cacheBb,
|
||||
const primitiveMesh& mesh,
|
||||
const unallocLabelList& cellLabels
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
cellLabels_(cellLabels),
|
||||
cacheBb_(cacheBb)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
Foam::treeDataCell::treeDataCell
|
||||
(
|
||||
const bool cacheBb,
|
||||
const primitiveMesh& mesh,
|
||||
const Xfer<labelList>& cellLabels
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
cellLabels_(cellLabels),
|
||||
cacheBb_(cacheBb)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
Foam::treeDataCell::treeDataCell
|
||||
(
|
||||
const bool cacheBb,
|
||||
@ -100,15 +120,7 @@ Foam::treeDataCell::treeDataCell
|
||||
cellLabels_(identity(mesh_.nCells())),
|
||||
cacheBb_(cacheBb)
|
||||
{
|
||||
if (cacheBb_)
|
||||
{
|
||||
bbs_.setSize(cellLabels_.size());
|
||||
|
||||
forAll(cellLabels_, i)
|
||||
{
|
||||
bbs_[i] = calcCellBb(cellLabels_[i]);
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@ -159,7 +171,7 @@ bool Foam::treeDataCell::contains
|
||||
// nearestPoint.
|
||||
void Foam::treeDataCell::findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
|
||||
@ -48,7 +48,7 @@ class primitiveMesh;
|
||||
template<class Type> class indexedOctree;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class treeDataCell Declaration
|
||||
Class treeDataCell Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class treeDataCell
|
||||
@ -72,6 +72,9 @@ class treeDataCell
|
||||
//- Calculate cell bounding box
|
||||
treeBoundBox calcCellBb(const label cellI) const;
|
||||
|
||||
//- Initialise all member data
|
||||
void update();
|
||||
|
||||
public:
|
||||
|
||||
// Declare name of the class and its debug switch
|
||||
@ -85,7 +88,15 @@ public:
|
||||
(
|
||||
const bool cacheBb,
|
||||
const primitiveMesh&,
|
||||
const labelList&
|
||||
const unallocLabelList&
|
||||
);
|
||||
|
||||
//- Construct from mesh and subset of cells, transferring contents
|
||||
treeDataCell
|
||||
(
|
||||
const bool cacheBb,
|
||||
const primitiveMesh&,
|
||||
const Xfer<labelList>&
|
||||
);
|
||||
|
||||
//- Construct from mesh. Uses all cells in mesh.
|
||||
@ -96,18 +107,18 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
const labelList& cellLabels() const
|
||||
inline const labelList& cellLabels() const
|
||||
{
|
||||
return cellLabels_;
|
||||
}
|
||||
|
||||
const primitiveMesh& mesh() const
|
||||
inline const primitiveMesh& mesh() const
|
||||
{
|
||||
return mesh_;
|
||||
}
|
||||
|
||||
|
||||
label size() const
|
||||
inline label size() const
|
||||
{
|
||||
return cellLabels_.size();
|
||||
}
|
||||
@ -153,7 +164,7 @@ public:
|
||||
// Returns actual point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -165,7 +176,7 @@ public:
|
||||
// Returns point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
@ -177,7 +188,7 @@ public:
|
||||
notImplemented
|
||||
(
|
||||
"treeDataCell::findNearest"
|
||||
"(const labelList&, const linePointRef&, ..)"
|
||||
"(const unallocLabelList&, const linePointRef&, ..)"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -43,21 +43,7 @@ Foam::treeBoundBox Foam::treeDataEdge::calcBb(const label edgeI) const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::treeDataEdge::treeDataEdge
|
||||
(
|
||||
const bool cacheBb,
|
||||
const edgeList& edges,
|
||||
const pointField& points,
|
||||
const labelList& edgeLabels
|
||||
)
|
||||
:
|
||||
edges_(edges),
|
||||
points_(points),
|
||||
edgeLabels_(edgeLabels),
|
||||
cacheBb_(cacheBb)
|
||||
void Foam::treeDataEdge::update()
|
||||
{
|
||||
if (cacheBb_)
|
||||
{
|
||||
@ -71,6 +57,42 @@ Foam::treeDataEdge::treeDataEdge
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::treeDataEdge::treeDataEdge
|
||||
(
|
||||
const bool cacheBb,
|
||||
const edgeList& edges,
|
||||
const pointField& points,
|
||||
const unallocLabelList& edgeLabels
|
||||
)
|
||||
:
|
||||
edges_(edges),
|
||||
points_(points),
|
||||
edgeLabels_(edgeLabels),
|
||||
cacheBb_(cacheBb)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
Foam::treeDataEdge::treeDataEdge
|
||||
(
|
||||
const bool cacheBb,
|
||||
const edgeList& edges,
|
||||
const pointField& points,
|
||||
const Xfer<labelList>& edgeLabels
|
||||
)
|
||||
:
|
||||
edges_(edges),
|
||||
points_(points),
|
||||
edgeLabels_(edgeLabels),
|
||||
cacheBb_(cacheBb)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::pointField Foam::treeDataEdge::points() const
|
||||
@ -121,7 +143,7 @@ bool Foam::treeDataEdge::overlaps
|
||||
// nearestPoint.
|
||||
void Foam::treeDataEdge::findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -131,7 +153,7 @@ void Foam::treeDataEdge::findNearest
|
||||
{
|
||||
forAll(indices, i)
|
||||
{
|
||||
label index = indices[i];
|
||||
const label index = indices[i];
|
||||
|
||||
const edge& e = edges_[edgeLabels_[index]];
|
||||
|
||||
@ -153,7 +175,7 @@ void Foam::treeDataEdge::findNearest
|
||||
// Returns point and distance (squared)
|
||||
void Foam::treeDataEdge::findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
@ -167,7 +189,7 @@ void Foam::treeDataEdge::findNearest
|
||||
|
||||
forAll(indices, i)
|
||||
{
|
||||
label index = indices[i];
|
||||
const label index = indices[i];
|
||||
|
||||
const edge& e = edges_[edgeLabels_[index]];
|
||||
|
||||
|
||||
@ -81,6 +81,9 @@ class treeDataEdge
|
||||
//- Calculate edge bounding box
|
||||
treeBoundBox calcBb(const label edgeI) const;
|
||||
|
||||
//- Initialise all member data
|
||||
void update();
|
||||
|
||||
public:
|
||||
|
||||
// Declare name of the class and its debug switch
|
||||
@ -95,7 +98,17 @@ public:
|
||||
const bool cacheBb,
|
||||
const edgeList& edges,
|
||||
const pointField& points,
|
||||
const labelList& edgeLabels
|
||||
const unallocLabelList& edgeLabels
|
||||
);
|
||||
|
||||
//- Construct from selected edges, transferring contents.
|
||||
// !Holds references to edges and points
|
||||
treeDataEdge
|
||||
(
|
||||
const bool cacheBb,
|
||||
const edgeList& edges,
|
||||
const pointField& points,
|
||||
const Xfer<labelList>& edgeLabels
|
||||
);
|
||||
|
||||
|
||||
@ -139,7 +152,7 @@ public:
|
||||
// Returns actual point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -151,7 +164,7 @@ public:
|
||||
// Returns point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
|
||||
@ -76,12 +76,27 @@ void Foam::treeDataFace::update()
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::treeDataFace::treeDataFace
|
||||
(
|
||||
const bool cacheBb,
|
||||
const primitiveMesh& mesh,
|
||||
const labelList& faceLabels
|
||||
const unallocLabelList& faceLabels
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
faceLabels_(faceLabels),
|
||||
isTreeFace_(mesh.nFaces(), 0),
|
||||
cacheBb_(cacheBb)
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
Foam::treeDataFace::treeDataFace
|
||||
(
|
||||
const bool cacheBb,
|
||||
const primitiveMesh& mesh,
|
||||
const Xfer<labelList>& faceLabels
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
@ -467,7 +482,7 @@ bool Foam::treeDataFace::overlaps
|
||||
// nearestPoint.
|
||||
void Foam::treeDataFace::findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -477,7 +492,7 @@ void Foam::treeDataFace::findNearest
|
||||
{
|
||||
forAll(indices, i)
|
||||
{
|
||||
label index = indices[i];
|
||||
const label index = indices[i];
|
||||
|
||||
const face& f = mesh_.faces()[faceLabels_[index]];
|
||||
|
||||
@ -514,7 +529,7 @@ bool Foam::treeDataFace::intersects
|
||||
}
|
||||
}
|
||||
|
||||
label faceI = faceLabels_[index];
|
||||
const label faceI = faceLabels_[index];
|
||||
|
||||
const vector dir(end - start);
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ class primitiveMesh;
|
||||
class polyPatch;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class treeDataFace Declaration
|
||||
Class treeDataFace Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class treeDataFace
|
||||
@ -101,7 +101,15 @@ public:
|
||||
(
|
||||
const bool cacheBb,
|
||||
const primitiveMesh&,
|
||||
const labelList&
|
||||
const unallocLabelList&
|
||||
);
|
||||
|
||||
//- Construct from mesh and subset of faces, transferring contents
|
||||
treeDataFace
|
||||
(
|
||||
const bool cacheBb,
|
||||
const primitiveMesh&,
|
||||
const Xfer<labelList>&
|
||||
);
|
||||
|
||||
//- Construct from mesh. Uses all faces in mesh.
|
||||
@ -115,17 +123,17 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
const labelList& faceLabels() const
|
||||
inline const labelList& faceLabels() const
|
||||
{
|
||||
return faceLabels_;
|
||||
}
|
||||
|
||||
const primitiveMesh& mesh() const
|
||||
inline const primitiveMesh& mesh() const
|
||||
{
|
||||
return mesh_;
|
||||
}
|
||||
|
||||
label size() const
|
||||
inline label size() const
|
||||
{
|
||||
return faceLabels_.size();
|
||||
}
|
||||
@ -156,7 +164,7 @@ public:
|
||||
// Returns actual point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -168,7 +176,7 @@ public:
|
||||
// Returns point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
@ -180,7 +188,7 @@ public:
|
||||
notImplemented
|
||||
(
|
||||
"treeDataFace::findNearest"
|
||||
"(const labelList&, const linePointRef&, ..)"
|
||||
"(const unallocLabelList&, const linePointRef&, ..)"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,6 @@ defineTypeNameAndDebug(Foam::treeDataPoint, 0);
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::treeDataPoint::treeDataPoint(const pointField& points)
|
||||
:
|
||||
points_(points)
|
||||
@ -78,7 +77,7 @@ bool Foam::treeDataPoint::overlaps
|
||||
// nearestPoint.
|
||||
void Foam::treeDataPoint::findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -88,7 +87,7 @@ void Foam::treeDataPoint::findNearest
|
||||
{
|
||||
forAll(indices, i)
|
||||
{
|
||||
label index = indices[i];
|
||||
const label index = indices[i];
|
||||
|
||||
const point& pt = points_[index];
|
||||
|
||||
@ -108,7 +107,7 @@ void Foam::treeDataPoint::findNearest
|
||||
// Returns point and distance (squared)
|
||||
void Foam::treeDataPoint::findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
@ -122,7 +121,7 @@ void Foam::treeDataPoint::findNearest
|
||||
|
||||
forAll(indices, i)
|
||||
{
|
||||
label index = indices[i];
|
||||
const label index = indices[i];
|
||||
|
||||
const point& shapePt = points_[index];
|
||||
|
||||
|
||||
@ -69,14 +69,14 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components. Holds reference to points!
|
||||
treeDataPoint(const pointField& points);
|
||||
treeDataPoint(const pointField&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
label size() const
|
||||
inline label size() const
|
||||
{
|
||||
return points_.size();
|
||||
}
|
||||
@ -107,7 +107,7 @@ public:
|
||||
// Returns actual point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -119,7 +119,7 @@ public:
|
||||
// Returns point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
|
||||
@ -477,7 +477,7 @@ void
|
||||
Foam::treeDataPrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -489,7 +489,7 @@ findNearest
|
||||
|
||||
forAll(indices, i)
|
||||
{
|
||||
label index = indices[i];
|
||||
const label index = indices[i];
|
||||
|
||||
const face& f = patch_[index];
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ TemplateName(treeDataPrimitivePatch);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class treeDataPrimitivePatch Declaration
|
||||
Class treeDataPrimitivePatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template
|
||||
@ -151,7 +151,7 @@ public:
|
||||
// Returns actual point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -163,7 +163,7 @@ public:
|
||||
// Returns point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
@ -175,7 +175,7 @@ public:
|
||||
notImplemented
|
||||
(
|
||||
"treeDataPrimitivePatch::findNearest"
|
||||
"(const labelList&, const linePointRef&, ..)"
|
||||
"(const unallocLabelList&, const linePointRef&, ..)"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -313,7 +313,7 @@ bool Foam::treeDataTriSurface::overlaps
|
||||
// nearestPoint.
|
||||
void Foam::treeDataTriSurface::findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -396,7 +396,7 @@ void Foam::treeDataTriSurface::findNearest
|
||||
// nearestPoint.
|
||||
void Foam::treeDataTriSurface::findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
@ -407,7 +407,7 @@ void Foam::treeDataTriSurface::findNearest
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"treeDataTriSurface::findNearest(const labelList&"
|
||||
"treeDataTriSurface::findNearest(const unallocLabelList&"
|
||||
", const linePointRef&, treeBoundBox&, label&, point&, point&) const"
|
||||
);
|
||||
}
|
||||
|
||||
@ -91,12 +91,12 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
const triSurface& surface() const
|
||||
inline const triSurface& surface() const
|
||||
{
|
||||
return surface_;
|
||||
}
|
||||
|
||||
label size() const
|
||||
inline label size() const
|
||||
{
|
||||
return surface_.size();
|
||||
}
|
||||
@ -127,7 +127,7 @@ public:
|
||||
// Returns actual point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const point& sample,
|
||||
|
||||
scalar& nearestDistSqr,
|
||||
@ -139,7 +139,7 @@ public:
|
||||
// Returns point and distance (squared)
|
||||
void findNearest
|
||||
(
|
||||
const labelList& indices,
|
||||
const unallocLabelList& indices,
|
||||
const linePointRef& ln,
|
||||
|
||||
treeBoundBox& tightest,
|
||||
|
||||
Reference in New Issue
Block a user