From 4b397988c9781893f7458994e39c27f3a7f67a36 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 22 Aug 2022 09:35:31 +0200 Subject: [PATCH] Code factorization + reduce number of little objects creation on heap --- src/INTERP_KERNEL/BBTree.txx | 11 +--- src/INTERP_KERNEL/BBTreeStandAlone.txx | 37 ++++++++++++++ src/INTERP_KERNEL/BoundingBox.hxx | 5 +- src/INTERP_KERNEL/Interpolation2D3D.hxx | 4 +- src/INTERP_KERNEL/Interpolation2D3D.txx | 48 ++++-------------- src/INTERP_KERNEL/Interpolation3D.txx | 35 ++++--------- src/INTERP_KERNEL/Interpolation3D1D.cxx | 15 ++++-- src/INTERP_KERNEL/Interpolation3D1D.hxx | 49 +++++++++--------- src/INTERP_KERNEL/Interpolation3D1D.txx | 35 +++---------- src/INTERP_KERNEL/InterpolationHelper.txx | 62 +++++++++++++++++++++++ src/INTERP_KERNEL/MeshElement.hxx | 10 ++-- src/INTERP_KERNEL/MeshElement.txx | 11 ++-- src/INTERP_KERNEL/TargetIntersector.hxx | 1 + src/INTERP_KERNEL/TargetIntersector.txx | 10 +++- 14 files changed, 189 insertions(+), 144 deletions(-) create mode 100644 src/INTERP_KERNEL/BBTreeStandAlone.txx create mode 100755 src/INTERP_KERNEL/InterpolationHelper.txx diff --git a/src/INTERP_KERNEL/BBTree.txx b/src/INTERP_KERNEL/BBTree.txx index 2a78e6dbc..227eab087 100644 --- a/src/INTERP_KERNEL/BBTree.txx +++ b/src/INTERP_KERNEL/BBTree.txx @@ -32,7 +32,6 @@ constexpr double BBTREE_DFT_EPSILON = 1e-12; template class BBTree { - private: BBTree* _left; BBTree* _right; @@ -48,7 +47,7 @@ private: static const int MIN_NB_ELEMS=15; static const int MAX_LEVEL=20; public: - + BBTree() = default; /*! Constructor of the bounding box tree \param bbs pointer to the [xmin1 xmax1 ymin1 ymax1 xmin2 xmax2 ...] array containing the bounding boxes that are to be indexed. @@ -68,7 +67,6 @@ public: BBTree<2> tree = new BBTree<2>(elems,0,0,nbelems,1e-12); \endcode */ - BBTree(const double* bbs, ConnType* elems, int level, ConnType nbelems, double epsilon=BBTREE_DFT_EPSILON): _left(0), _right(0), _level(level), _bb(bbs), _terminal(false),_nbelems(nbelems),_epsilon(epsilon) { @@ -143,8 +141,6 @@ public: _right=new BBTree(bbs, tmp, level+1, (ConnType)new_elems_right.size(),_epsilon); } - - ~BBTree() { @@ -153,13 +149,11 @@ public: } - /*! returns in \a elems the list of elements potentially intersecting the bounding box pointed to by \a bb \param bb pointer to query bounding box \param elems list of elements (given in 0-indexing that is to say in \b C \b mode) intersecting the bounding box */ - void getIntersectingElems(const double* bb, std::vector& elems) const { // terminal node : return list of elements intersecting bb @@ -237,7 +231,6 @@ public: \param xx pointer to query point coords \param elems list of elements (given in 0-indexing) intersecting the bounding box */ - void getElementsAroundPoint(const double* xx, std::vector& elems) const { // terminal node : return list of elements intersecting bb @@ -275,8 +268,6 @@ public: _right->getElementsAroundPoint(xx,elems); } - - ConnType size() { if (_terminal) return _nbelems; diff --git a/src/INTERP_KERNEL/BBTreeStandAlone.txx b/src/INTERP_KERNEL/BBTreeStandAlone.txx new file mode 100644 index 000000000..73b28580c --- /dev/null +++ b/src/INTERP_KERNEL/BBTreeStandAlone.txx @@ -0,0 +1,37 @@ +// Copyright (C) 2022 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#pragma once + +#include "BBTree.txx" +#include + +/*! + * Wrapper over BBTree to deal with ownership of bbox double array. + */ +template +class BBTreeStandAlone +{ +private: + std::unique_ptr _bbox; + BBTree _effective; +public: + BBTreeStandAlone(std::unique_ptr&& bbs, ConnType nbelems, double epsilon=BBTREE_DFT_EPSILON):_bbox(std::move(bbs)),_effective(_bbox.get(),nullptr,0,nbelems,epsilon) { } + void getIntersectingElems(const double* bb, std::vector& elems) const { _effective.getIntersectingElems(bb,elems); } +}; diff --git a/src/INTERP_KERNEL/BoundingBox.hxx b/src/INTERP_KERNEL/BoundingBox.hxx index 4c7919538..34a47b17c 100644 --- a/src/INTERP_KERNEL/BoundingBox.hxx +++ b/src/INTERP_KERNEL/BoundingBox.hxx @@ -59,6 +59,8 @@ namespace INTERP_KERNEL inline void dumpCoords() const; void toCompactData(double data[6]) const; + + BoundingBox& operator=(const BoundingBox& box) = delete; private: @@ -67,9 +69,6 @@ namespace INTERP_KERNEL /// disallow copying BoundingBox(const BoundingBox& box); - /// disallow assignment - BoundingBox& operator=(const BoundingBox& box); - /// Vector containing the coordinates of the box /// interlaced in the order XMIN, YMIN, ZMIN, XMAX, YMAX, ZMAX double _coords[6]; diff --git a/src/INTERP_KERNEL/Interpolation2D3D.hxx b/src/INTERP_KERNEL/Interpolation2D3D.hxx index b2698b18e..21fcedd4e 100644 --- a/src/INTERP_KERNEL/Interpolation2D3D.hxx +++ b/src/INTERP_KERNEL/Interpolation2D3D.hxx @@ -58,9 +58,9 @@ namespace INTERP_KERNEL protected: template - void performAdjustmentOfBB(Intersector3D* intersector, std::vector& bbox) const + void performAdjustmentOfBB(Intersector3D* intersector, double *bbox, std::size_t sz) const { - intersector->adjustBoundingBoxes(bbox,InterpolationOptions::getBoundingBoxAdjustment(),InterpolationOptions::getBoundingBoxAdjustmentAbs()); + intersector->adjustBoundingBoxes(bbox,sz,InterpolationOptions::getBoundingBoxAdjustment(),InterpolationOptions::getBoundingBoxAdjustmentAbs()); } private: diff --git a/src/INTERP_KERNEL/Interpolation2D3D.txx b/src/INTERP_KERNEL/Interpolation2D3D.txx index e813a11db..1412a0001 100755 --- a/src/INTERP_KERNEL/Interpolation2D3D.txx +++ b/src/INTERP_KERNEL/Interpolation2D3D.txx @@ -32,7 +32,7 @@ #include "PointLocator3DIntersectorP1P0.txx" #include "PolyhedronIntersectorP1P1.txx" #include "PointLocator3DIntersectorP1P1.txx" -#include "Log.hxx" +#include "InterpolationHelper.txx" #include "BBTree.txx" @@ -67,24 +67,17 @@ namespace INTERP_KERNEL { typedef typename MyMeshType::MyConnType ConnType; // create MeshElement objects corresponding to each element of the two meshes - const ConnType numSrcElems = srcMesh.getNumberOfElements(); const ConnType numTargetElems = targetMesh.getNumberOfElements(); - LOG(2, "Source mesh has " << numSrcElems << " elements and target mesh has " << numTargetElems << " elements "); + LOG(2, "Target mesh has " << numTargetElems << " elements "); - std::vector*> srcElems(numSrcElems); - std::vector*> targetElems(numTargetElems); - - std::map*, ConnType> indices; - DuplicateFacesType intersectFaces; - - for(ConnType i = 0 ; i < numSrcElems ; ++i) - srcElems[i] = new MeshElement(i, srcMesh); + std::vector< MeshElement > targetElems(numTargetElems); + DuplicateFacesType intersectFaces; for(ConnType i = 0 ; i < numTargetElems ; ++i) - targetElems[i] = new MeshElement(i, targetMesh); + targetElems[i].assign(i, targetMesh); - Intersector3D* intersector=0; + std::unique_ptr< Intersector3D > intersector; std::string methC = InterpolationOptions::filterInterpolationMethod(method); const double dimCaracteristic = CalculateCharacteristicSizeOfMeshes(srcMesh, targetMesh, InterpolationOptions::getPrintLevel()); if(methC=="P0P0") @@ -92,12 +85,12 @@ namespace INTERP_KERNEL switch(InterpolationOptions::getIntersectionType()) { case Triangulation: - intersector=new Polyhedron3D2DIntersectorP0P0(targetMesh, + intersector.reset( new Polyhedron3D2DIntersectorP0P0(targetMesh, srcMesh, dimCaracteristic, getPrecision(), intersectFaces, - getSplittingPolicy()); + getSplittingPolicy()) ); break; default: throw INTERP_KERNEL::Exception("Invalid 2D to 3D intersection type for P0P0 interp specified : must be Triangulation."); @@ -109,25 +102,14 @@ namespace INTERP_KERNEL matrix.resize(intersector->getNumberOfRowsOfResMatrix()); // create BBTree structure - // - get bounding boxes - std::vector bboxes(6 * numSrcElems); - for(ConnType i = 0; i < numSrcElems ; ++i) - { - // get source bboxes in right order - const BoundingBox* box = srcElems[i]->getBoundingBox(); - box->fillInXMinXmaxYminYmaxZminZmaxFormat(bboxes.data()+6*i); - } - // [ABN] Adjust 2D bounding box (those might be flat in the cases where the 2D surf are perfectly aligned with the axis) - performAdjustmentOfBB(intersector, bboxes); - - BBTree<3,ConnType> tree(bboxes.data(), nullptr, 0, numSrcElems, 0.); + BBTreeStandAlone<3,ConnType> tree( BuildBBTreeWithAdjustment(srcMesh,[this,&intersector](double *bbox, typename MyMeshType::MyConnType sz){ this->performAdjustmentOfBB(intersector.get(),bbox,sz); }) ); // for each target element, get source elements with which to calculate intersection // - calculate intersection by calling intersectCells for(ConnType i = 0; i < numTargetElems; ++i) { - const BoundingBox* box = targetElems[i]->getBoundingBox(); + const BoundingBox* box = targetElems[i].getBoundingBox(); // get target bbox in right order double targetBox[6]; @@ -154,16 +136,6 @@ namespace INTERP_KERNEL // free allocated memory ConnType ret=intersector->getNumberOfColsOfResMatrix(); - delete intersector; - - for(ConnType i = 0 ; i < numSrcElems ; ++i) - { - delete srcElems[i]; - } - for(ConnType i = 0 ; i < numTargetElems ; ++i) - { - delete targetElems[i]; - } return ret; } diff --git a/src/INTERP_KERNEL/Interpolation3D.txx b/src/INTERP_KERNEL/Interpolation3D.txx index 76f3056de..1cebcd47f 100755 --- a/src/INTERP_KERNEL/Interpolation3D.txx +++ b/src/INTERP_KERNEL/Interpolation3D.txx @@ -47,7 +47,7 @@ #else // use BBTree class -#include "BBTree.txx" +#include "InterpolationHelper.txx" #endif @@ -79,23 +79,18 @@ namespace INTERP_KERNEL template typename MyMeshType::MyConnType Interpolation3D::interpolateMeshes(const MyMeshType& srcMesh, const MyMeshType& targetMesh, MatrixType& result, const std::string& method) { - typedef typename MyMeshType::MyConnType ConnType; + using ConnType = typename MyMeshType::MyConnType; // create MeshElement objects corresponding to each element of the two meshes - const ConnType numSrcElems = srcMesh.getNumberOfElements(); const ConnType numTargetElems = targetMesh.getNumberOfElements(); - LOG(2, "Source mesh has " << numSrcElems << " elements and target mesh has " << numTargetElems << " elements "); + LOG(2, "Target mesh has " << numTargetElems << " elements "); - std::vector>> srcElems(numSrcElems); - std::vector>> targetElems(numTargetElems); - - std::map*, ConnType> indices; - - for(ConnType i = 0 ; i < numSrcElems ; ++i) - srcElems[i].reset( new MeshElement(i, srcMesh) ); + std::vector< MeshElement > targetElems(numTargetElems); for(ConnType i = 0 ; i < numTargetElems ; ++i) - targetElems[i].reset( new MeshElement(i, targetMesh) ); + { + targetElems[i].assign(i, targetMesh); + } std::unique_ptr> intersector; std::string methC = InterpolationOptions::filterInterpolationMethod(method); @@ -305,24 +300,14 @@ namespace INTERP_KERNEL } #else // Use BBTree - - // create BBTree structure - // - get bounding boxes - std::unique_ptr bboxes( new double[6 * numSrcElems] ); - for(ConnType i = 0; i < numSrcElems ; ++i) - { - // get source bboxes in right order - const BoundingBox *box = srcElems[i]->getBoundingBox(); - box->fillInXMinXmaxYminYmaxZminZmaxFormat(bboxes.get()+6*i); - } - - BBTree<3,ConnType> tree(bboxes.get(), nullptr, 0, numSrcElems); + // create BBTree structure + BBTreeStandAlone<3,ConnType> tree( BuildBBTree(srcMesh) ); // for each target element, get source elements with which to calculate intersection // - calculate intersection by calling intersectCells for(ConnType i = 0; i < numTargetElems; ++i) { - const BoundingBox* box = targetElems[i]->getBoundingBox(); + const BoundingBox* box = targetElems[i].getBoundingBox(); // get target bbox in right order double targetBox[6]; diff --git a/src/INTERP_KERNEL/Interpolation3D1D.cxx b/src/INTERP_KERNEL/Interpolation3D1D.cxx index 28e9c438a..f64146c40 100644 --- a/src/INTERP_KERNEL/Interpolation3D1D.cxx +++ b/src/INTERP_KERNEL/Interpolation3D1D.cxx @@ -27,16 +27,13 @@ namespace INTERP_KERNEL Interpolation3D1D::Interpolation3D1D(const InterpolationOptions& io):Interpolation(io) { } - /** - * Inspired from PlanarIntersector::adjustBoundingBoxes - */ - void Interpolation3D1D::adjustBoundingBoxes(std::vector& bbox) + void Interpolation3D1D::adjustBoundingBoxes(double *bbox, std::size_t sz) { const int SPACE_DIM = 3; const double adj = getBoundingBoxAdjustmentAbs(); const double adjRel = getBoundingBoxAdjustment(); - std::size_t size = bbox.size()/(2*SPACE_DIM); + std::size_t size = sz/(2*SPACE_DIM); for (std::size_t i=0; i::max(); @@ -52,4 +49,12 @@ namespace INTERP_KERNEL } } } + + /** + * Inspired from PlanarIntersector::adjustBoundingBoxes + */ + void Interpolation3D1D::adjustBoundingBoxes(std::vector& bbox) + { + adjustBoundingBoxes(bbox.data(),bbox.size()); + } } diff --git a/src/INTERP_KERNEL/Interpolation3D1D.hxx b/src/INTERP_KERNEL/Interpolation3D1D.hxx index 2015bb210..187309316 100755 --- a/src/INTERP_KERNEL/Interpolation3D1D.hxx +++ b/src/INTERP_KERNEL/Interpolation3D1D.hxx @@ -16,18 +16,18 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// Author : A Bruneton (CEA/DEN) - -#pragma once - -#include "INTERPKERNELDefines.hxx" -#include "Interpolation.hxx" -#include "NormalizedUnstructuredMesh.hxx" -#include "InterpolationOptions.hxx" - -#include - -namespace INTERP_KERNEL +// Author : A Bruneton (CEA/DEN) + +#pragma once + +#include "INTERPKERNELDefines.hxx" +#include "Interpolation.hxx" +#include "NormalizedUnstructuredMesh.hxx" +#include "InterpolationOptions.hxx" + +#include + +namespace INTERP_KERNEL { /** * \class Interpolation3D1D @@ -35,15 +35,16 @@ namespace INTERP_KERNEL * Can be seen as a specialization of Interpolation3D, and allows notably the adjustment of bounding boxes. */ - class INTERPKERNEL_EXPORT Interpolation3D1D : public Interpolation - { - public: - Interpolation3D1D(); - Interpolation3D1D(const InterpolationOptions& io); - template - typename MyMeshType::MyConnType interpolateMeshes(const MyMeshType& srcMesh, const MyMeshType& targetMesh, MatrixType& result, const std::string& method); - private: - void adjustBoundingBoxes(std::vector& bbox); - }; -} - + class INTERPKERNEL_EXPORT Interpolation3D1D : public Interpolation + { + public: + Interpolation3D1D(); + Interpolation3D1D(const InterpolationOptions& io); + template + typename MyMeshType::MyConnType interpolateMeshes(const MyMeshType& srcMesh, const MyMeshType& targetMesh, MatrixType& result, const std::string& method); + private: + void adjustBoundingBoxes(double *bbox, std::size_t sz); + void adjustBoundingBoxes(std::vector& bbox); + }; +} + diff --git a/src/INTERP_KERNEL/Interpolation3D1D.txx b/src/INTERP_KERNEL/Interpolation3D1D.txx index 63b4cc147..47d6e4505 100755 --- a/src/INTERP_KERNEL/Interpolation3D1D.txx +++ b/src/INTERP_KERNEL/Interpolation3D1D.txx @@ -29,9 +29,7 @@ #include "PointLocator3DIntersectorP1P1.txx" #include "Log.hxx" -#include "BBTree.txx" - -#include +#include "InterpolationHelper.txx" namespace INTERP_KERNEL { @@ -47,21 +45,14 @@ namespace INTERP_KERNEL typedef typename MyMeshType::MyConnType ConnType; // create MeshElement objects corresponding to each element of the two meshes - const ConnType numSrcElems = srcMesh.getNumberOfElements(); const ConnType numTargetElems = targetMesh.getNumberOfElements(); - LOG(2, "Source mesh has " << numSrcElems << " elements and target mesh has " << numTargetElems << " elements "); - - std::vector< std::unique_ptr< MeshElement > > srcElems(numSrcElems); - std::vector< std::unique_ptr< MeshElement > > targetElems(numTargetElems); - - std::map*, ConnType> indices; + LOG(2, "Target mesh has " << numTargetElems << " elements "); - for(ConnType i = 0 ; i < numSrcElems ; ++i) - srcElems[i].reset( new MeshElement(i, srcMesh) ); + std::vector< MeshElement > targetElems(numTargetElems); for(ConnType i = 0 ; i < numTargetElems ; ++i) - targetElems[i].reset( new MeshElement(i, targetMesh) ); + targetElems[i].assign(i, targetMesh); std::unique_ptr< Intersector3D > intersector; std::string methC = InterpolationOptions::filterInterpolationMethod(method); @@ -82,27 +73,13 @@ namespace INTERP_KERNEL // create empty maps for all source elements result.resize(intersector->getNumberOfRowsOfResMatrix()); - // create BBTree structure - // - get bounding boxes - std::vector bboxes(6*numSrcElems); - for(ConnType i = 0; i < numSrcElems ; ++i) - { - // get source bboxes in right order - const BoundingBox* box = srcElems[i]->getBoundingBox(); - box->fillInXMinXmaxYminYmaxZminZmaxFormat(bboxes.data()+6*i); - } - - adjustBoundingBoxes(bboxes); - const double *bboxPtr = nullptr; - if(numSrcElems>0) - bboxPtr=bboxes.data(); - BBTree<3,ConnType> tree(bboxPtr, nullptr, 0, numSrcElems); + BBTreeStandAlone<3,ConnType> tree( BuildBBTreeWithAdjustment(srcMesh,[this](double *bbox, typename MyMeshType::MyConnType sz){ this->adjustBoundingBoxes(bbox,sz); }) ); // for each target element, get source elements with which to calculate intersection // - calculate intersection by calling intersectCells for(ConnType i = 0; i < numTargetElems; ++i) { - const BoundingBox* box = targetElems[i]->getBoundingBox(); + const BoundingBox* box = targetElems[i].getBoundingBox(); // get target bbox in right order double targetBox[6]; box->fillInXMinXmaxYminYmaxZminZmaxFormat(targetBox); diff --git a/src/INTERP_KERNEL/InterpolationHelper.txx b/src/INTERP_KERNEL/InterpolationHelper.txx new file mode 100755 index 000000000..b89ff8a0e --- /dev/null +++ b/src/INTERP_KERNEL/InterpolationHelper.txx @@ -0,0 +1,62 @@ +// Copyright (C) 2022 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// Author : Anthony Geay (EDF R&D) + +#pragma once + +#include "BBTreeStandAlone.txx" +#include "Log.hxx" + +#include +#include + +namespace INTERP_KERNEL +{ + template + BBTreeStandAlone<3,typename MyMeshType::MyConnType> BuildBBTree(const MyMeshType& srcMesh) + { + return BuildBBTreeWithAdjustment(srcMesh,[](double *,typename MyMeshType::MyConnType){}); + } + + template + BBTreeStandAlone<3,typename MyMeshType::MyConnType> BuildBBTreeWithAdjustment(const MyMeshType& srcMesh, std::function bboxAdjuster) + { + using ConnType = typename MyMeshType::MyConnType; + const ConnType numSrcElems = srcMesh.getNumberOfElements(); + LOG(2, "Source mesh has " << numSrcElems << " elements"); + std::vector< MeshElement > srcElems(numSrcElems); + + for(ConnType i = 0 ; i < numSrcElems ; ++i) + { + srcElems[i].assign(i,srcMesh); + } + // create BBTree structure + // - get bounding boxes + const ConnType nbElts = 6 * numSrcElems; + std::unique_ptr bboxes( new double[nbElts] ); + for(ConnType i = 0; i < numSrcElems ; ++i) + { + // get source bboxes in right order + const BoundingBox *box = srcElems[i].getBoundingBox(); + box->fillInXMinXmaxYminYmaxZminZmaxFormat(bboxes.get()+6*i); + } + bboxAdjuster(bboxes.get(),nbElts); + return BBTreeStandAlone<3,ConnType>(std::move(bboxes),numSrcElems); + } +} diff --git a/src/INTERP_KERNEL/MeshElement.hxx b/src/INTERP_KERNEL/MeshElement.hxx index 1ff56a61d..900e5d533 100644 --- a/src/INTERP_KERNEL/MeshElement.hxx +++ b/src/INTERP_KERNEL/MeshElement.hxx @@ -41,19 +41,23 @@ namespace INTERP_KERNEL template MeshElement(const ConnType index, const MyMeshType& mesh); + MeshElement() = default; + + template + void assign(const ConnType index, const MyMeshType& mesh); + ~MeshElement() { } nbnodesincelltype getNumberOfNodes() const { return _number; } const BoundingBox *getBoundingBox() const { return &_box; } + MeshElement& operator=(const MeshElement& elem) = delete; + private: /// disallow copying MeshElement(const MeshElement& elem); - /// disallow assignment - MeshElement& operator=(const MeshElement& elem); - nbnodesincelltype _number; /// bounding box of the element - does not change after having been initialised diff --git a/src/INTERP_KERNEL/MeshElement.txx b/src/INTERP_KERNEL/MeshElement.txx index 7aee10798..7a716cff7 100755 --- a/src/INTERP_KERNEL/MeshElement.txx +++ b/src/INTERP_KERNEL/MeshElement.txx @@ -41,8 +41,14 @@ namespace INTERP_KERNEL */ template template - MeshElement::MeshElement(const ConnType index, const MyMeshType& mesh) - : _number( 0 ) + MeshElement::MeshElement(const ConnType index, const MyMeshType& mesh): _number( 0 ) + { + this->assign(index,mesh); + } + + template + template + void MeshElement::assign(const ConnType index, const MyMeshType& mesh) { auto numberCore = mesh.getNumberOfNodesOfElement(OTT::indFC(index)); if(numberCore < std::numeric_limits::max()) @@ -51,7 +57,6 @@ namespace INTERP_KERNEL std::unique_ptr vertices( new const double*[_number] ); for( nbnodesincelltype i = 0 ; i < _number ; ++i) vertices[i] = getCoordsOfNode(i , OTT::indFC(index), mesh); - // create bounding box _box.initializeWith(vertices.get(),_number); } diff --git a/src/INTERP_KERNEL/TargetIntersector.hxx b/src/INTERP_KERNEL/TargetIntersector.hxx index 84f29e87f..c0613c7de 100644 --- a/src/INTERP_KERNEL/TargetIntersector.hxx +++ b/src/INTERP_KERNEL/TargetIntersector.hxx @@ -52,6 +52,7 @@ namespace INTERP_KERNEL virtual ~TargetIntersector() { } void adjustBoundingBoxes(std::vector& bbox, double adjustmentEps, double adjustmentEpsAbs); + void adjustBoundingBoxes(double *bbox, std::size_t sz, double adjustmentEps, double adjustmentEpsAbs); }; } diff --git a/src/INTERP_KERNEL/TargetIntersector.txx b/src/INTERP_KERNEL/TargetIntersector.txx index 752784632..0cd9149fa 100644 --- a/src/INTERP_KERNEL/TargetIntersector.txx +++ b/src/INTERP_KERNEL/TargetIntersector.txx @@ -26,6 +26,12 @@ namespace INTERP_KERNEL { + template + void TargetIntersector::adjustBoundingBoxes(std::vector& bbox, double adjustmentEps, double adjustmentEpsAbs) + { + this->adjustBoundingBoxes(bbox.data(),bbox.size(),adjustmentEps,adjustmentEpsAbs); + } + /*! Readjusts a set of bounding boxes so that they are extended in all dimensions for avoiding missing interesting intersections @@ -34,9 +40,9 @@ namespace INTERP_KERNEL @param adjustmentEpsAbs absolute adjustment value (added on each side of the BBox in each dimension) */ template - void TargetIntersector::adjustBoundingBoxes(std::vector& bbox, double adjustmentEps, double adjustmentEpsAbs) + void TargetIntersector::adjustBoundingBoxes(double *bbox, std::size_t sz, double adjustmentEps, double adjustmentEpsAbs) { - std::size_t size = bbox.size()/(2*SPACEDIM); + std::size_t size = sz/(2*SPACEDIM); for (std::size_t i=0; i::max(); -- 2.39.2