]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
[EDF25207] : More robust implementation keeping the same amount size of object for... V9_9_0b1
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 19 Apr 2022 09:30:28 +0000 (11:30 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 19 Apr 2022 09:30:28 +0000 (11:30 +0200)
src/INTERP_KERNEL/MeshElement.hxx
src/INTERP_KERNEL/MeshElement.txx

index 2953cf96010f73351eb9c962b1b2a4f0830c7eaf..fa452b7853b97065c937f0c13b030a99a0558439 100644 (file)
@@ -37,6 +37,7 @@ namespace INTERP_KERNEL
   {
 
   public:
   {
 
   public:
+    using nbnodesincelltype = std::uint32_t;
     template<class MyMeshType>
     MeshElement(const ConnType index, const MyMeshType& mesh);
     
     template<class MyMeshType>
     MeshElement(const ConnType index, const MyMeshType& mesh);
     
@@ -44,7 +45,7 @@ namespace INTERP_KERNEL
     
     ConnType getIndex() const { return _index; }
     
     
     ConnType getIndex() const { return _index; }
     
-    std::uint16_t getNumberOfNodes() const { return _number; }
+    nbnodesincelltype getNumberOfNodes() const { return _number; }
     
     const BoundingBox* getBoundingBox() const { return _box; }
 
     
     const BoundingBox* getBoundingBox() const { return _box; }
 
@@ -58,7 +59,7 @@ namespace INTERP_KERNEL
     /// global number of the element
     const ConnType _index;
 
     /// 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;
     
     /// bounding box of the element - does not change after having been initialised
     BoundingBox* _box;
index e73d8074cf7eb3d2a370758ecb315b7c63269f59..3c4d745b29e3ecd8bb678c845036afdef8446239 100755 (executable)
@@ -26,6 +26,8 @@
 #include "MeshUtils.hxx"
 #include "BoundingBox.hxx"
 #include <assert.h>
 #include "MeshUtils.hxx"
 #include "BoundingBox.hxx"
 #include <assert.h>
+#include <type_traits>
+#include <limits>
 
 namespace INTERP_KERNEL
 {
 
 namespace INTERP_KERNEL
 {
@@ -39,16 +41,24 @@ namespace INTERP_KERNEL
   template<class ConnType>
   template<class MyMeshType>
   MeshElement<ConnType>::MeshElement(const ConnType index, const MyMeshType& mesh)
   template<class ConnType>
   template<class MyMeshType>
   MeshElement<ConnType>::MeshElement(const ConnType index, const MyMeshType& mesh)
-    : _index(index), _number( static_cast<std::uint16_t>(mesh.getNumberOfNodesOfElement(OTT<typename MyMeshType::MyConnType,MyMeshType::My_numPol>::indFC(index))) ), _box(nullptr)
+    : _index(index), _number( 0 ), _box(nullptr)
   {
   {
-    const double**vertices = new const double*[_number];
+    auto numberCore = mesh.getNumberOfNodesOfElement(OTT<typename MyMeshType::MyConnType,MyMeshType::My_numPol>::indFC(index));
+    if(numberCore < std::numeric_limits<nbnodesincelltype>::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<typename MyMeshType::MyConnType,MyMeshType::My_numPol>::indFC(index), mesh);
 
 
-    for(std::uint16_t i = 0 ; i < _number ; ++i)
-      vertices[i] = getCoordsOfNode(i , OTT<typename MyMeshType::MyConnType,MyMeshType::My_numPol>::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;
+    }
   }
     
   /**
   }
     
   /**