diff --git a/src/meshTools/indexedOctree/indexedOctree.H b/src/meshTools/indexedOctree/indexedOctree.H index 6d7f425176..d82603ab4f 100644 --- a/src/meshTools/indexedOctree/indexedOctree.H +++ b/src/meshTools/indexedOctree/indexedOctree.H @@ -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, diff --git a/src/meshTools/indexedOctree/treeDataCell.C b/src/meshTools/indexedOctree/treeDataCell.C index 87b5dde123..8492f59c4f 100644 --- a/src/meshTools/indexedOctree/treeDataCell.C +++ b/src/meshTools/indexedOctree/treeDataCell.C @@ -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& 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, diff --git a/src/meshTools/indexedOctree/treeDataCell.H b/src/meshTools/indexedOctree/treeDataCell.H index 7e42a6d906..4bf5ddb5c2 100644 --- a/src/meshTools/indexedOctree/treeDataCell.H +++ b/src/meshTools/indexedOctree/treeDataCell.H @@ -48,7 +48,7 @@ class primitiveMesh; template 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& ); //- 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&, ..)" ); } diff --git a/src/meshTools/indexedOctree/treeDataEdge.C b/src/meshTools/indexedOctree/treeDataEdge.C index 0adc3b781c..0a65f8ece8 100644 --- a/src/meshTools/indexedOctree/treeDataEdge.C +++ b/src/meshTools/indexedOctree/treeDataEdge.C @@ -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& 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]]; diff --git a/src/meshTools/indexedOctree/treeDataEdge.H b/src/meshTools/indexedOctree/treeDataEdge.H index 68f3a5924a..8b7e54879f 100644 --- a/src/meshTools/indexedOctree/treeDataEdge.H +++ b/src/meshTools/indexedOctree/treeDataEdge.H @@ -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& 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, diff --git a/src/meshTools/indexedOctree/treeDataFace.C b/src/meshTools/indexedOctree/treeDataFace.C index bf2bd722e5..f8273bec03 100644 --- a/src/meshTools/indexedOctree/treeDataFace.C +++ b/src/meshTools/indexedOctree/treeDataFace.C @@ -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& 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); diff --git a/src/meshTools/indexedOctree/treeDataFace.H b/src/meshTools/indexedOctree/treeDataFace.H index 4337f1b78d..6dbb881dbb 100644 --- a/src/meshTools/indexedOctree/treeDataFace.H +++ b/src/meshTools/indexedOctree/treeDataFace.H @@ -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& ); //- 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&, ..)" ); } diff --git a/src/meshTools/indexedOctree/treeDataPoint.C b/src/meshTools/indexedOctree/treeDataPoint.C index db5f61e001..ffdbfdd4e0 100644 --- a/src/meshTools/indexedOctree/treeDataPoint.C +++ b/src/meshTools/indexedOctree/treeDataPoint.C @@ -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]; diff --git a/src/meshTools/indexedOctree/treeDataPoint.H b/src/meshTools/indexedOctree/treeDataPoint.H index c2522120f7..236f8139b8 100644 --- a/src/meshTools/indexedOctree/treeDataPoint.H +++ b/src/meshTools/indexedOctree/treeDataPoint.H @@ -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, diff --git a/src/meshTools/indexedOctree/treeDataPrimitivePatch.C b/src/meshTools/indexedOctree/treeDataPrimitivePatch.C index ec4bcb5437..8fc75b77c5 100644 --- a/src/meshTools/indexedOctree/treeDataPrimitivePatch.C +++ b/src/meshTools/indexedOctree/treeDataPrimitivePatch.C @@ -477,7 +477,7 @@ void Foam::treeDataPrimitivePatch:: 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]; diff --git a/src/meshTools/indexedOctree/treeDataPrimitivePatch.H b/src/meshTools/indexedOctree/treeDataPrimitivePatch.H index cf7b0cb1eb..7c3757504b 100644 --- a/src/meshTools/indexedOctree/treeDataPrimitivePatch.H +++ b/src/meshTools/indexedOctree/treeDataPrimitivePatch.H @@ -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&, ..)" ); } diff --git a/src/meshTools/indexedOctree/treeDataTriSurface.C b/src/meshTools/indexedOctree/treeDataTriSurface.C index e0afe06906..e0f6d1a9df 100644 --- a/src/meshTools/indexedOctree/treeDataTriSurface.C +++ b/src/meshTools/indexedOctree/treeDataTriSurface.C @@ -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" ); } diff --git a/src/meshTools/indexedOctree/treeDataTriSurface.H b/src/meshTools/indexedOctree/treeDataTriSurface.H index 88f92c0ba4..f602783afe 100644 --- a/src/meshTools/indexedOctree/treeDataTriSurface.H +++ b/src/meshTools/indexedOctree/treeDataTriSurface.H @@ -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,