]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
LOT2: move mcIdType to INTERP_KERNEL. Care of MEDCouplingNormalizedUnstructuredMesh.hxx
authoreap <eap@opencascade.com>
Thu, 14 Nov 2019 15:54:58 +0000 (18:54 +0300)
committereap <eap@opencascade.com>
Thu, 14 Nov 2019 15:54:58 +0000 (18:54 +0300)
src/INTERP_KERNEL/MCIdType.hxx [new file with mode: 0644]
src/MEDCoupling/MCType.hxx
src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.hxx
src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx

diff --git a/src/INTERP_KERNEL/MCIdType.hxx b/src/INTERP_KERNEL/MCIdType.hxx
new file mode 100644 (file)
index 0000000..a74f075
--- /dev/null
@@ -0,0 +1,43 @@
+// Copyright (C) 2017-2019  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)
+
+#ifndef __IK_MCIDTYPE_HXX__
+#define __IK_MCIDTYPE_HXX__
+
+#include <cstdint>
+#include <stddef.h>
+#include <cstddef>
+
+#ifndef MEDCOUPLING_USE_64BIT_IDS
+
+typedef std::int32_t mcIdType;
+
+#else
+
+typedef std::int64_t mcIdType;
+
+#endif
+
+template <class T> inline mcIdType ToIdType(T val)
+{
+  return static_cast<mcIdType>(val);
+}
+
+#endif
index f7cbce4d278f28b704fba14bde5111c904ddc02c..82a66c9cb356a74321ffe0ee54315dd08651bc32 100644 (file)
 #ifndef __MEDCOUPLING_MCTYPE_HXX__
 #define __MEDCOUPLING_MCTYPE_HXX__
 
+#include "MCIdType.hxx"
+
 #include <cstdint>
 #include <stddef.h>
 #include <cstddef>
 
 namespace MEDCoupling
 {
+  using mcIdType = ::mcIdType;
   using Int64 = std::int64_t;
   using Int32 = std::int32_t;
 #ifndef MEDCOUPLING_USE_64BIT_IDS
-  using mcIdType = std::int32_t;
 
 #define DataArrayIdType DataArrayInt32
 
 #else
-  using mcIdType = std::int64_t;
 
 #define DataArrayIdType DataArrayInt64
 
 #endif
 
-  template <class T> inline mcIdType ToIdType(T val)
-  {
-    return static_cast<mcIdType>(val);
-  }
-
 #define DataArrayInt DataArrayInt32
 #define DataArrayIntIterator DataArrayInt32Iterator
 }
index 9a9bd6325bfd3970d21d13a8d9f5706235e5e1df..bdf3a7e3d9c8b8fe012162ce6eac313d18d5e8ed 100644 (file)
@@ -35,26 +35,26 @@ class MEDCouplingNormalizedUnstructuredMesh
 public:
   static const int MY_SPACEDIM=SPACEDIM;
   static const int MY_MESHDIM=MESHDIM;
-  typedef int MyConnType;
+  typedef mcIdType MyConnType;
   static const INTERP_KERNEL::NumberingPolicy My_numPol=INTERP_KERNEL::ALL_C_MODE;
 public:
   MEDCouplingNormalizedUnstructuredMesh(const MEDCoupling::MEDCouplingPointSet *mesh);
   void getBoundingBox(double *boundingBox) const;
-  INTERP_KERNEL::NormalizedCellType getTypeOfElement(int eltId) const;
-  int getNumberOfNodesOfElement(int eltId) const;
-  int getNumberOfElements() const;
-  int getNumberOfNodes() const;
-  const int *getConnectivityPtr() const;
+  INTERP_KERNEL::NormalizedCellType getTypeOfElement(mcIdType eltId) const;
+  int getNumberOfNodesOfElement(mcIdType eltId) const;
+  mcIdType getNumberOfElements() const;
+  mcIdType getNumberOfNodes() const;
+  const mcIdType *getConnectivityPtr() const;
   const double *getCoordinatesPtr() const;
-  const int *getConnectivityIndexPtr() const;
+  const mcIdType *getConnectivityIndexPtr() const;
   void releaseTempArrays();
   ~MEDCouplingNormalizedUnstructuredMesh();
 private:
   void prepare();
 private:
   const MEDCoupling::MEDCouplingPointSet *_mesh;
-  int *_conn_for_interp;
-  int *_conn_index_for_interp;
+  mcIdType *_conn_for_interp;
+  mcIdType *_conn_index_for_interp;
 };
 
 #endif
index 7ca18cb078d526a897a4651c01aa9c751ac5dda0..c8b059097574ae0fe3926e204b4db912d49a9937 100644 (file)
@@ -48,11 +48,11 @@ void MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getBoundingBox(dou
     }
   const MEDCoupling::DataArrayDouble *array=_mesh->getCoords();
   const double *ptr=array->getConstPointer();
-  MEDCoupling::mcIdType nbOfPts=MEDCoupling::ToIdType(array->getNbOfElems())/SPACEDIM;
+  mcIdType nbOfPts=ToIdType(array->getNbOfElems())/SPACEDIM;
   for(int j=0;j<SPACEDIM;j++)
     {
       const double *work=ptr+j;
-      for(int i=0;i<nbOfPts;i++,work+=SPACEDIM)
+      for(mcIdType i=0;i<nbOfPts;i++,work+=SPACEDIM)
         {
           if(boundingBox[j]>*work)
             boundingBox[j]=*work;
@@ -63,31 +63,31 @@ void MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getBoundingBox(dou
 }
 
 template<int SPACEDIM,int MESHDIM>
-INTERP_KERNEL::NormalizedCellType MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getTypeOfElement(int eltId) const
+INTERP_KERNEL::NormalizedCellType MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getTypeOfElement(mcIdType eltId) const
 {
   return _mesh->getTypeOfCell(eltId);
 }
 
 template<int SPACEDIM,int MESHDIM>
-int MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getNumberOfNodesOfElement(int eltId) const
+int MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getNumberOfNodesOfElement(mcIdType eltId) const
 {
   return _mesh->getNumberOfNodesInCell(eltId);
 }
 
 template<int SPACEDIM,int MESHDIM>
-int MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getNumberOfElements() const
+mcIdType MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getNumberOfElements() const
 {
-  return MEDCoupling::ToIdType(_mesh->getNumberOfCells());
+  return ToIdType(_mesh->getNumberOfCells());
 }
 
 template<int SPACEDIM,int MESHDIM>
-int MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getNumberOfNodes() const
+mcIdType MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getNumberOfNodes() const
 {
   return _mesh->getNumberOfNodes();
 }
 
 template<int SPACEDIM,int MESHDIM>
-const int *MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getConnectivityPtr() const
+const mcIdType *MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getConnectivityPtr() const
 {
   return _conn_for_interp;
 }
@@ -100,7 +100,7 @@ const double *MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getCoordi
 }
 
 template<int SPACEDIM,int MESHDIM>
-const int *MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getConnectivityIndexPtr() const
+const mcIdType *MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getConnectivityIndexPtr() const
 {
   return _conn_index_for_interp;
 }
@@ -129,18 +129,18 @@ void MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::prepare()
   const MEDCoupling::MEDCouplingUMesh *m1(dynamic_cast<const MEDCoupling::MEDCouplingUMesh *>(_mesh));
   if(m1)
     {
-      MEDCoupling::mcIdType nbOfCell=MEDCoupling::ToIdType(m1->getNumberOfCells());
-      MEDCoupling::mcIdType initialConnSize=MEDCoupling::ToIdType(m1->getNodalConnectivity()->getNbOfElems());
-      _conn_for_interp=new int[initialConnSize-nbOfCell];
-      _conn_index_for_interp=new int[nbOfCell+1];
+      mcIdType nbOfCell=ToIdType(m1->getNumberOfCells());
+      mcIdType initialConnSize=ToIdType(m1->getNodalConnectivity()->getNbOfElems());
+      _conn_for_interp=new mcIdType[initialConnSize-nbOfCell];
+      _conn_index_for_interp=new mcIdType[nbOfCell+1];
       _conn_index_for_interp[0]=0;
-      const int *work_conn=m1->getNodalConnectivity()->getConstPointer()+1;
-      const int *work_conn_index=m1->getNodalConnectivityIndex()->getConstPointer();
-      int *work_conn_for_interp=_conn_for_interp;
-      int *work_conn_index_for_interp=_conn_index_for_interp;
-      for(int i=0;i<nbOfCell;i++)
+      const mcIdType *work_conn=m1->getNodalConnectivity()->getConstPointer()+1;
+      const mcIdType *work_conn_index=m1->getNodalConnectivityIndex()->getConstPointer();
+      mcIdType *work_conn_for_interp=_conn_for_interp;
+      mcIdType *work_conn_index_for_interp=_conn_index_for_interp;
+      for(mcIdType i=0;i<nbOfCell;i++)
         {
-          int nbOfValsToCopy=work_conn_index[1]-work_conn_index[0]-1;
+          mcIdType nbOfValsToCopy=work_conn_index[1]-work_conn_index[0]-1;
           work_conn_for_interp=std::copy(work_conn,work_conn+nbOfValsToCopy,work_conn_for_interp);
           work_conn_index_for_interp[1]=work_conn_index_for_interp[0]+nbOfValsToCopy;
           work_conn_index++;
@@ -152,23 +152,23 @@ void MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::prepare()
   const MEDCoupling::MEDCoupling1DGTUMesh *m2(dynamic_cast<const MEDCoupling::MEDCoupling1DGTUMesh *>(_mesh));
   if(m2)
     {
-      MEDCoupling::mcIdType nbOfCell=MEDCoupling::ToIdType(m2->getNumberOfCells());
-      _conn_index_for_interp=new int[nbOfCell+1];
-      const int *conni(m2->getNodalConnectivityIndex()->begin());
+      mcIdType nbOfCell=ToIdType(m2->getNumberOfCells());
+      _conn_index_for_interp=new mcIdType[nbOfCell+1];
+      const mcIdType *conni(m2->getNodalConnectivityIndex()->begin());
       std::copy(conni,conni+nbOfCell+1,_conn_index_for_interp);
-      _conn_for_interp=new int[m2->getNodalConnectivity()->getNumberOfTuples()];
+      _conn_for_interp=new mcIdType[m2->getNodalConnectivity()->getNumberOfTuples()];
       std::copy(m2->getNodalConnectivity()->begin(),m2->getNodalConnectivity()->end(),_conn_for_interp);
       return ;
     }
   const MEDCoupling::MEDCoupling1SGTUMesh *m3(dynamic_cast<const MEDCoupling::MEDCoupling1SGTUMesh *>(_mesh));
   if(m3)
     {
-      MEDCoupling::mcIdType nbOfCell=MEDCoupling::ToIdType(m3->getNumberOfCells()),nbNodesPerCell(m3->getNumberOfNodesPerCell());
-      _conn_index_for_interp=new int[nbOfCell+1]; _conn_index_for_interp[0]=0;
-      int *work(_conn_index_for_interp);
-      for(int i=0;i<nbOfCell;i++,work++)
+      mcIdType nbOfCell=ToIdType(m3->getNumberOfCells()),nbNodesPerCell(m3->getNumberOfNodesPerCell());
+      _conn_index_for_interp=new mcIdType[nbOfCell+1]; _conn_index_for_interp[0]=0;
+      mcIdType *work(_conn_index_for_interp);
+      for(mcIdType i=0;i<nbOfCell;i++,work++)
         work[1]=work[0]+nbNodesPerCell;
-      _conn_for_interp=new int[m3->getNodalConnectivity()->getNumberOfTuples()];
+      _conn_for_interp=new mcIdType[m3->getNodalConnectivity()->getNumberOfTuples()];
       std::copy(m3->getNodalConnectivity()->begin(),m3->getNodalConnectivity()->end(),_conn_for_interp);
       return ;
     }