Salome HOME
Fix compilation of gcc 4.3.2
[modules/smesh.git] / src / SMDS / SMDS_MeshInfo.hxx
index b92c857dbabee8b2370944b39995f1a0c7d50666..2227824883d2e7c722cf53b4774cf14b7a6ea02a 100644 (file)
@@ -40,7 +40,9 @@ public:
   inline void Clear();
 
   int NbNodes() const { return myNbNodes; }
+  inline int NbElements(SMDSAbs_ElementType type=SMDSAbs_All) const;
 
+  int Nb0DElements() const { return myNb0DElements; }
   inline int NbEdges      (SMDSAbs_ElementOrder order = ORDER_ANY) const;
   inline int NbFaces      (SMDSAbs_ElementOrder order = ORDER_ANY) const;
   inline int NbTriangles  (SMDSAbs_ElementOrder order = ORDER_ANY) const;
@@ -60,7 +62,7 @@ private:
   // methods to count NOT POLY elements
   inline void remove(const SMDS_MeshElement* el);
   inline void add   (const SMDS_MeshElement* el);
-  inline int  index(SMDSAbs_ElementType type, int nbNodes);
+  inline int  index(SMDSAbs_ElementType type, int nbNodes) const;
   // methods to remove elements of ANY kind
   inline void RemoveEdge(const SMDS_MeshElement* el);
   inline void RemoveFace(const SMDS_MeshElement* el);
@@ -68,6 +70,7 @@ private:
 
   int myNbNodes;
 
+  int myNb0DElements;
   int myNbEdges      , myNbQuadEdges      ;
   int myNbTriangles  , myNbQuadTriangles  ;
   int myNbQuadrangles, myNbQuadQuadrangles;
@@ -85,6 +88,7 @@ private:
 
 inline SMDS_MeshInfo::SMDS_MeshInfo():
   myNbNodes(0),
+  myNb0DElements(0),
   myNbEdges      (0), myNbQuadEdges      (0),
   myNbTriangles  (0), myNbQuadTriangles  (0),
   myNbQuadrangles(0), myNbQuadQuadrangles(0),
@@ -96,30 +100,30 @@ inline SMDS_MeshInfo::SMDS_MeshInfo():
   myNbPolyhedrons(0)
 {
   // Number of nodes in standard element types
-  // n   v  f  e
-  // o   o  a  d
+  // n   v  f  e  0
+  // o   o  a  d  d
   // d   l  c  g
   // e      e  e
-  // -----------
-  // 1      
+  // --------------
+  // 1            *
   // 2         *
   // 3      *
   // 4   *  *  *
-  // 5   *  
+  // 5   *
   // 6   *  *
-  // 7      
+  // 7
   // 8   *  *
-  // 9      
-  // 10  *  
-  // 11     
-  // 12     
-  // 13  *  
-  // 14     
-  // 15  *  
-  // 16     
-  // 17     
-  // 18     
-  // 19     
+  // 9
+  // 10  *
+  // 11
+  // 12
+  // 13  *
+  // 14
+  // 15  *
+  // 16
+  // 17
+  // 18
+  // 19
   // 20  *
   //
   // So to have a unique index for each type basing on nb of nodes, we use a shift:
@@ -130,6 +134,8 @@ inline SMDS_MeshInfo::SMDS_MeshInfo():
   myNb.resize( index( SMDSAbs_Volume,20 ) + 1, NULL);
   myNb[ index( SMDSAbs_Node,1 )] = & myNbNodes;
 
+  myNb[ index( SMDSAbs_0DElement,1 )] = & myNb0DElements;
+
   myNb[ index( SMDSAbs_Edge,2 )] = & myNbEdges;
   myNb[ index( SMDSAbs_Edge,4 )] = & myNbQuadEdges;
 
@@ -153,7 +159,7 @@ SMDS_MeshInfo::Clear()
   myNbPolygons=myNbPolyhedrons=0;
 }
 inline int // index
-SMDS_MeshInfo::index(SMDSAbs_ElementType type, int nbNodes)
+SMDS_MeshInfo::index(SMDSAbs_ElementType type, int nbNodes) const
 { return nbNodes + myShift[ type ]; }
 
 inline void // remove
@@ -212,4 +218,29 @@ inline int // NbPrisms
 SMDS_MeshInfo::NbPrisms  (SMDSAbs_ElementOrder order) const
 { return order == ORDER_ANY ? myNbPrisms+myNbQuadPrisms : order == ORDER_LINEAR ? myNbPrisms : myNbQuadPrisms; }
 
+inline int // NbElements
+SMDS_MeshInfo::NbElements(SMDSAbs_ElementType type) const
+{ 
+  int nb = 0;
+  switch (type) {
+  case SMDSAbs_All:
+    for ( int i=1+index( SMDSAbs_Node,1 ); i<myNb.size(); ++i ) if ( myNb[i] ) nb += *myNb[i];
+    nb += myNbPolygons + myNbPolyhedrons;
+    break;
+  case SMDSAbs_Volume:
+    nb = myNbTetras+ myNbPyramids+ myNbPrisms+ myNbHexas+
+      myNbQuadTetras+ myNbQuadPyramids+ myNbQuadPrisms+ myNbQuadHexas+myNbPolyhedrons;
+    break;
+  case SMDSAbs_Face:
+    nb = myNbTriangles+ myNbQuadrangles+ myNbQuadTriangles+ myNbQuadQuadrangles + myNbPolygons;
+    break;
+  case SMDSAbs_Edge:
+    nb = myNbEdges + myNbQuadEdges;
+    break;
+  case SMDSAbs_Node:
+    nb = myNbNodes;
+  default:;
+  }
+  return nb;
+}
 #endif