Salome HOME
MEDCouplingMesh::computeEffectiveNbOfNodesPerCell
authorageay <ageay>
Thu, 25 Jul 2013 12:08:29 +0000 (12:08 +0000)
committerageay <ageay>
Thu, 25 Jul 2013 12:08:29 +0000 (12:08 +0000)
12 files changed:
src/MEDCoupling/MEDCoupling1GTUMesh.cxx
src/MEDCoupling/MEDCoupling1GTUMesh.hxx
src/MEDCoupling/MEDCouplingExtrudedMesh.cxx
src/MEDCoupling/MEDCouplingExtrudedMesh.hxx
src/MEDCoupling/MEDCouplingMesh.hxx
src/MEDCoupling/MEDCouplingStructuredMesh.cxx
src/MEDCoupling/MEDCouplingStructuredMesh.hxx
src/MEDCoupling/MEDCouplingUMesh.cxx
src/MEDCoupling/MEDCouplingUMesh.hxx
src/MEDCoupling/MEDCouplingUMeshDesc.cxx
src/MEDCoupling/MEDCouplingUMeshDesc.hxx
src/MEDCoupling_Swig/MEDCouplingCommon.i

index 3125889a6ab115fe632164444bdeb04625929994..6b820629056a169c2ecd0e05216406cce5365c1d 100644 (file)
@@ -703,6 +703,23 @@ DataArrayInt *MEDCoupling1SGTUMesh::computeNbOfFacesPerCell() const throw(INTERP
   return ret.retn();
 }
 
+DataArrayInt *MEDCoupling1SGTUMesh::computeEffectiveNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
+{
+  checkNonDynamicGeoType();
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+  int nbCells(getNumberOfCells());
+  ret->alloc(nbCells,1);
+  int *retPtr(ret->getPointer());
+  int nbNodesPerCell(getNumberOfNodesPerCell());
+  const int *conn(_conn->begin());
+  for(int i=0;i<nbCells;i++,conn+=nbNodesPerCell,retPtr++)
+    {
+      std::set<int> s(conn,conn+nbNodesPerCell);
+      *retPtr=(int)s.size();
+    }
+  return ret.retn();
+}
+
 void MEDCoupling1SGTUMesh::getNodeIdsOfCell(int cellId, std::vector<int>& conn) const
 {
   int sz=getNumberOfNodesPerCell();
@@ -1803,6 +1820,41 @@ DataArrayInt *MEDCoupling1DGTUMesh::computeNbOfFacesPerCell() const throw(INTERP
   return ret.retn();
 }
 
+/*!
+ * This method computes effective number of nodes per cell. That is to say nodes appearing several times in nodal connectivity of a cell,
+ * will be counted only once here whereas it will be counted several times in MEDCoupling1DGTUMesh::computeNbOfNodesPerCell method.
+ *
+ * \return DataArrayInt * - new object to be deallocated by the caller.
+ * \sa MEDCoupling1DGTUMesh::computeNbOfNodesPerCell
+ */
+DataArrayInt *MEDCoupling1DGTUMesh::computeEffectiveNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
+{
+  checkCoherency();
+  _conn_indx->checkMonotonic(true);
+  int nbOfCells(_conn_indx->getNumberOfTuples()-1);
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+  ret->alloc(nbOfCells,1);
+  int *retPtr(ret->getPointer());
+  const int *ci(_conn_indx->begin()),*c(_conn->begin());
+  if(getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED)
+    {
+      for(int i=0;i<nbOfCells;i++,retPtr++,ci++)
+        {
+          std::set<int> s(c+ci[0],c+ci[1]);
+          *retPtr=(int)s.size();
+        }
+    }
+  else
+    {
+      for(int i=0;i<nbOfCells;i++,retPtr++,ci++)
+        {
+          std::set<int> s(c+ci[0],c+ci[1]); s.erase(-1);
+          *retPtr=(int)s.size();
+        }
+    }
+  return ret.retn();
+}
+
 void MEDCoupling1DGTUMesh::getNodeIdsOfCell(int cellId, std::vector<int>& conn) const
 {
   int nbOfCells=getNumberOfCells();//performs checks
index 723234f4919166b45baf7fa365651e22c00c80e1..6cfebda37fdccb6038a7ccffe9936aa4c41018f8 100644 (file)
@@ -101,6 +101,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT int getNumberOfCells() const;
     MEDCOUPLING_EXPORT DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT DataArrayInt *computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT DataArrayInt *computeEffectiveNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
     MEDCOUPLING_EXPORT std::string simpleRepr() const;
     MEDCOUPLING_EXPORT std::string advancedRepr() const;
@@ -169,6 +170,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT int getNumberOfCells() const;
     MEDCOUPLING_EXPORT DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT DataArrayInt *computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT DataArrayInt *computeEffectiveNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
     MEDCOUPLING_EXPORT std::string simpleRepr() const;
     MEDCOUPLING_EXPORT std::string advancedRepr() const;
index 8f22b05f4b4217da09b2f9939bd5bd9ad6f07fd0..27c8d6df5b7907d5300eaa9791aadec78d7950a2 100644 (file)
@@ -301,6 +301,11 @@ DataArrayInt *MEDCouplingExtrudedMesh::computeNbOfFacesPerCell() const throw(INT
   return ret3D->renumberR(_mesh3D_ids->begin());
 }
 
+DataArrayInt *MEDCouplingExtrudedMesh::computeEffectiveNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
+{
+  return computeNbOfNodesPerCell();
+}
+
 int MEDCouplingExtrudedMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const
 {
   int ret=0;
index 06a5a871e65478a76656d2e52e6953870e94d2e1..6c40f15deecd0d15509795022e43cba39e42a232 100644 (file)
@@ -58,6 +58,7 @@ namespace ParaMEDMEM
     DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
     DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
     DataArrayInt *computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception);
+    DataArrayInt *computeEffectiveNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
     int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
     void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
     void getCoordinatesOfNode(int nodeId, std::vector<double>& coo) const throw(INTERP_KERNEL::Exception);
index cd460600b386957456639336069af50696c581d9..053d60e07c4a95565d1ee7efd237a223b0d766ce 100644 (file)
@@ -89,6 +89,7 @@ namespace ParaMEDMEM
     virtual DataArrayDouble *computeIsoBarycenterOfNodesPerCell() const throw(INTERP_KERNEL::Exception) = 0;
     virtual DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception) = 0;
     virtual DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception) = 0;
+    virtual DataArrayInt *computeEffectiveNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception) = 0;
     virtual DataArrayInt *computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception) = 0;
     virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const = 0;
     virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const = 0;
index 91ba40dd9fa6a4d1e1f3a26fbed948591a8e1ae9..9398553ba325b54fe947c93eee0ed717ea5104ce 100644 (file)
@@ -125,6 +125,18 @@ DataArrayInt *MEDCouplingStructuredMesh::computeNbOfFacesPerCell() const throw(I
   return ret.retn();
 }
 
+/*!
+ * This method computes effective number of nodes per cell. That is to say nodes appearing several times in nodal connectivity of a cell,
+ * will be counted only once here whereas it will be counted several times in MEDCouplingMesh::computeNbOfNodesPerCell method.
+ * Here for structured mesh it returns exactly as MEDCouplingStructuredMesh::computeNbOfNodesPerCell does.
+ *
+ * \return DataArrayInt * - new object to be deallocated by the caller.
+ */
+DataArrayInt *MEDCouplingStructuredMesh::computeEffectiveNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
+{
+  return computeNbOfNodesPerCell();
+}
+
 void MEDCouplingStructuredMesh::getNodeIdsOfCell(int cellId, std::vector<int>& conn) const
 {
   int meshDim=getMeshDimension();
index b4f9052c6a71d53b2659917d84e4dedfb4026216..a8cb2ef7c80d6ef2002ad6e45967e1e846edf1e3 100644 (file)
@@ -37,6 +37,7 @@ namespace ParaMEDMEM
     DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
     DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
     DataArrayInt *computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception);
+    DataArrayInt *computeEffectiveNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
     static void GetPosFromId(int nodeId, int meshDim, const int *split, int *res);
     static INTERP_KERNEL::NormalizedCellType GetGeoTypeGivenMeshDimension(int meshDim) throw(INTERP_KERNEL::Exception);
     void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
index ea3d4f8fac4809fe38582ce1456cbd260fc42e31..fca3d1aa2a65063a3c2487722807e5616d3fde70 100644 (file)
@@ -1391,6 +1391,7 @@ DataArrayInt *MEDCouplingUMesh::getNodeIdsInUse(int& nbrOfNodesInUse) const thro
  * So for pohyhedrons some nodes can be counted several times in the returned result.
  * 
  * \return a newly allocated array
+ * \sa MEDCouplingUMesh::computeEffectiveNbOfNodesPerCell
  */
 DataArrayInt *MEDCouplingUMesh::computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
 {
@@ -1411,6 +1412,36 @@ DataArrayInt *MEDCouplingUMesh::computeNbOfNodesPerCell() const throw(INTERP_KER
   return ret.retn();
 }
 
+/*!
+ * This method computes effective number of nodes per cell. That is to say nodes appearing several times in nodal connectivity of a cell,
+ * will be counted only once here whereas it will be counted several times in MEDCouplingUMesh::computeNbOfNodesPerCell method.
+ *
+ * \return DataArrayInt * - new object to be deallocated by the caller.
+ * \sa MEDCouplingUMesh::computeNbOfNodesPerCell
+ */
+DataArrayInt *MEDCouplingUMesh::computeEffectiveNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
+{
+  checkConnectivityFullyDefined();
+  int nbOfCells=getNumberOfCells();
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+  ret->alloc(nbOfCells,1);
+  int *retPtr=ret->getPointer();
+  const int *conn=getNodalConnectivity()->getConstPointer();
+  const int *connI=getNodalConnectivityIndex()->getConstPointer();
+  for(int i=0;i<nbOfCells;i++,retPtr++)
+    {
+      std::set<int> s(conn+connI[i]+1,conn+connI[i+1]);
+      if(conn[connI[i]]!=(int)INTERP_KERNEL::NORM_POLYHED)
+        *retPtr=(int)s.size();
+      else
+        {
+          s.erase(-1);
+          *retPtr=(int)s.size();
+        }
+    }
+  return ret.retn();
+}
+
 /*!
  * This method returns a newly allocated array containing this->getNumberOfCells() tuples and 1 component.
  * For each cell in \b this the number of faces constituting (entity of dimension this->getMeshDimension()-1) cell is computed.
index 0eec1a163f190310b8d665ac1ea44b940e85df5d..0567d1eb0290bb64eafb5351373e5af10e3f42cd 100644 (file)
@@ -109,6 +109,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT void computeNodeIdsAlg(std::vector<bool>& nodeIdsInUse) const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT DataArrayInt *computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT DataArrayInt *computeEffectiveNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT DataArrayInt *zipCoordsTraducer() throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT void findCommonCells(int compType, int startCellId, DataArrayInt *& commonCellsArr, DataArrayInt *& commonCellsIArr) const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT bool areCellsIncludedIn(const MEDCouplingUMesh *other, int compType, DataArrayInt *& arr) const throw(INTERP_KERNEL::Exception);
index 883889f4b496475f8b87f9698da184b5f71e3f89..cce7da8d81252c626c6b588aced6018fae50b345 100644 (file)
@@ -177,6 +177,11 @@ DataArrayInt *MEDCouplingUMeshDesc::computeNbOfFacesPerCell() const throw(INTERP
   throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::computeNbOfFacesPerCell : not implemented yet !");
 }
 
+DataArrayInt *MEDCouplingUMeshDesc::computeEffectiveNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
+{
+  throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::computeEffectiveNbOfNodesPerCell : not implemented yet !");
+}
+
 int MEDCouplingUMeshDesc::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const
 {
   const int *desc_connec=_desc_connec->getConstPointer();
index 086e55234a175fd64aa05815ef5886d315677f3c..bed0e3ae16799bbb73694bd2d5c2e276f8b823c0 100644 (file)
@@ -54,6 +54,7 @@ namespace ParaMEDMEM
     MEDCOUPLING_EXPORT DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT DataArrayInt *computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception);
+    MEDCOUPLING_EXPORT DataArrayInt *computeEffectiveNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
     MEDCOUPLING_EXPORT int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const;
     MEDCOUPLING_EXPORT void getNodeIdsOfCell(int cellId, std::vector<int>& conn) const;
     MEDCOUPLING_EXPORT std::string simpleRepr() const;
index 99d800efead31822e2f3271de023e2dfdc3a71e6..144defc4a9dcee1d4d11f2ae024a4195eb34e6ff 100644 (file)
@@ -364,6 +364,7 @@ using namespace INTERP_KERNEL;
 %newobject ParaMEDMEM::MEDCouplingMesh::checkTypeConsistencyAndContig;
 %newobject ParaMEDMEM::MEDCouplingMesh::computeNbOfNodesPerCell;
 %newobject ParaMEDMEM::MEDCouplingMesh::computeNbOfFacesPerCell;
+%newobject ParaMEDMEM::MEDCouplingMesh::computeEffectiveNbOfNodesPerCell;
 %newobject ParaMEDMEM::MEDCouplingMesh::buildPartRange;
 %newobject ParaMEDMEM::MEDCouplingMesh::giveCellsWithType;
 %newobject ParaMEDMEM::MEDCouplingMesh::getCoordinatesAndOwner;
@@ -682,6 +683,7 @@ namespace ParaMEDMEM
     virtual DataArrayInt *giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
     virtual DataArrayInt *computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
     virtual DataArrayInt *computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception);
+    virtual DataArrayInt *computeEffectiveNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
     virtual MEDCouplingMesh *buildPartRange(int beginCellIds, int endCellIds, int stepCellIds) const throw(INTERP_KERNEL::Exception);
     virtual int getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception);
     virtual INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const throw(INTERP_KERNEL::Exception);