From: Anthony Geay Date: Tue, 19 Apr 2022 09:30:28 +0000 (+0200) Subject: [EDF25207] : More robust implementation keeping the same amount size of object for... X-Git-Tag: V9_9_0b1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f2686d284dca28201ef46050af8e37fa2e381e63;p=tools%2Fmedcoupling.git [EDF25207] : More robust implementation keeping the same amount size of object for MeshElement objects --- diff --git a/src/INTERP_KERNEL/MeshElement.hxx b/src/INTERP_KERNEL/MeshElement.hxx index 2953cf960..fa452b785 100644 --- a/src/INTERP_KERNEL/MeshElement.hxx +++ b/src/INTERP_KERNEL/MeshElement.hxx @@ -37,6 +37,7 @@ namespace INTERP_KERNEL { public: + using nbnodesincelltype = std::uint32_t; template MeshElement(const ConnType index, const MyMeshType& mesh); @@ -44,7 +45,7 @@ namespace INTERP_KERNEL ConnType getIndex() const { return _index; } - std::uint16_t getNumberOfNodes() const { return _number; } + nbnodesincelltype getNumberOfNodes() const { return _number; } const BoundingBox* getBoundingBox() const { return _box; } @@ -58,7 +59,7 @@ namespace INTERP_KERNEL /// global number of the element const ConnType _index; - const std::uint16_t _number; + nbnodesincelltype _number; /// bounding box of the element - does not change after having been initialised BoundingBox* _box; diff --git a/src/INTERP_KERNEL/MeshElement.txx b/src/INTERP_KERNEL/MeshElement.txx index e73d8074c..3c4d745b2 100755 --- a/src/INTERP_KERNEL/MeshElement.txx +++ b/src/INTERP_KERNEL/MeshElement.txx @@ -26,6 +26,8 @@ #include "MeshUtils.hxx" #include "BoundingBox.hxx" #include +#include +#include namespace INTERP_KERNEL { @@ -39,16 +41,24 @@ namespace INTERP_KERNEL template template MeshElement::MeshElement(const ConnType index, const MyMeshType& mesh) - : _index(index), _number( static_cast(mesh.getNumberOfNodesOfElement(OTT::indFC(index))) ), _box(nullptr) + : _index(index), _number( 0 ), _box(nullptr) { - const double**vertices = new const double*[_number]; + auto numberCore = mesh.getNumberOfNodesOfElement(OTT::indFC(index)); + if(numberCore < std::numeric_limits::max()) + { + _number = static_cast< nbnodesincelltype >(numberCore); + const double**vertices = new const double*[_number]; + for( nbnodesincelltype i = 0 ; i < _number ; ++i) + vertices[i] = getCoordsOfNode(i , OTT::indFC(index), mesh); - for(std::uint16_t i = 0 ; i < _number ; ++i) - vertices[i] = getCoordsOfNode(i , OTT::indFC(index), mesh); - - // create bounding box - _box = new BoundingBox(vertices,_number); - delete [] vertices; + // create bounding box + _box = new BoundingBox(vertices,_number); + delete [] vertices; + } + else + { + std::cerr << "ERROR at index " << index << " : exceeding capacity !" << std::endl; + } } /**