Salome HOME
PR: merged from V5_1_4rc1
[modules/smesh.git] / src / SMDS / SMDS_MeshElement.cxx
index 6f5b5eb54b8844b645a2924c0b17449587932c89..8d0a608c4419e6ee3d3658e389b69fdf5854e0d5 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -19,6 +19,7 @@
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  SMESH SMDS : implementaion of Salome mesh data structure
 //
 #ifdef _MSC_VER
@@ -45,13 +46,13 @@ SMDS_MeshElement::SMDS_MeshElement(int id, ShortType meshId, ShortType shapeId):
 
 void SMDS_MeshElement::Print(ostream & OS) const
 {
-       OS << "dump of mesh element" << endl;
+        OS << "dump of mesh element" << endl;
 }
 
 ostream & operator <<(ostream & OS, const SMDS_MeshElement * ME)
 {
-       ME->Print(OS);
-       return OS;
+        ME->Print(OS);
+        return OS;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -60,7 +61,7 @@ ostream & operator <<(ostream & OS, const SMDS_MeshElement * ME)
 ///////////////////////////////////////////////////////////////////////////////
 SMDS_ElemIteratorPtr SMDS_MeshElement::nodesIterator() const
 {
-       return elementsIterator(SMDSAbs_Node);
+        return elementsIterator(SMDSAbs_Node);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -69,7 +70,7 @@ SMDS_ElemIteratorPtr SMDS_MeshElement::nodesIterator() const
 ///////////////////////////////////////////////////////////////////////////////
 SMDS_ElemIteratorPtr SMDS_MeshElement::edgesIterator() const
 {
-       return elementsIterator(SMDSAbs_Edge);
+        return elementsIterator(SMDSAbs_Edge);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -78,7 +79,7 @@ SMDS_ElemIteratorPtr SMDS_MeshElement::edgesIterator() const
 ///////////////////////////////////////////////////////////////////////////////
 SMDS_ElemIteratorPtr SMDS_MeshElement::facesIterator() const
 {
-       return elementsIterator(SMDSAbs_Face);
+        return elementsIterator(SMDSAbs_Face);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -86,14 +87,14 @@ SMDS_ElemIteratorPtr SMDS_MeshElement::facesIterator() const
 ///////////////////////////////////////////////////////////////////////////////
 int SMDS_MeshElement::NbNodes() const
 {
-       int nbnodes=0;
-       SMDS_ElemIteratorPtr it=nodesIterator();
-       while(it->more())
-       {
-               it->next();
-               nbnodes++;
-       }
-       return nbnodes;
+        int nbnodes=0;
+        SMDS_ElemIteratorPtr it=nodesIterator();
+        while(it->more())
+        {
+                it->next();
+                nbnodes++;
+        }
+        return nbnodes;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -101,14 +102,14 @@ int SMDS_MeshElement::NbNodes() const
 ///////////////////////////////////////////////////////////////////////////////
 int SMDS_MeshElement::NbEdges() const
 {
-       int nbedges=0;
-       SMDS_ElemIteratorPtr it=edgesIterator();
-       while(it->more())
-       {
-               it->next();
-               nbedges++;
-       }
-       return nbedges;
+        int nbedges=0;
+        SMDS_ElemIteratorPtr it=edgesIterator();
+        while(it->more())
+        {
+                it->next();
+                nbedges++;
+        }
+        return nbedges;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -116,14 +117,14 @@ int SMDS_MeshElement::NbEdges() const
 ///////////////////////////////////////////////////////////////////////////////
 int SMDS_MeshElement::NbFaces() const
 {
-       int nbfaces=0;
-       SMDS_ElemIteratorPtr it=facesIterator();
-       while(it->more())
-       {
-               it->next();
-               nbfaces++;
-       }
-       return nbfaces;
+        int nbfaces=0;
+        SMDS_ElemIteratorPtr it=facesIterator();
+        while(it->more())
+        {
+                it->next();
+                nbfaces++;
+        }
+        return nbfaces;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -147,23 +148,23 @@ class SMDS_MeshElement_MyIterator:public SMDS_ElemIterator
   const SMDS_MeshElement* next()
   {
     myMore=false;
-    return myElement;  
-  }    
+    return myElement;   
+  }     
 };
 SMDS_ElemIteratorPtr SMDS_MeshElement::
-       elementsIterator(SMDSAbs_ElementType type) const
+        elementsIterator(SMDSAbs_ElementType type) const
 {
-       /** @todo Check that iterator in the child classes return elements
-       in the same order for each different implementation (i.e: SMDS_VolumeOfNodes
-       and SMDS_VolumeOfFaces */
-       
-       if(type==GetType())
+        /** @todo Check that iterator in the child classes return elements
+        in the same order for each different implementation (i.e: SMDS_VolumeOfNodes
+        and SMDS_VolumeOfFaces */
+        
+        if(type==GetType())
           return SMDS_ElemIteratorPtr(new SMDS_MeshElement_MyIterator(this));
-       else 
-       {
+        else 
+        {
           MESSAGE("Iterator not implemented");
           return SMDS_ElemIteratorPtr((SMDS_ElemIterator*)NULL);
-       }
+        }
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -171,32 +172,32 @@ SMDS_ElemIteratorPtr SMDS_MeshElement::
 ///////////////////////////////////////////////////////////////////////////////
 int SMDS_MeshElement::GetID() const
 {
-       return myID;
+        return myID;
 }
 
 bool operator<(const SMDS_MeshElement& e1, const SMDS_MeshElement& e2)
 {
-       if(e1.GetType()!=e2.GetType()) return false;
-       switch(e1.GetType())
-       {
-       case SMDSAbs_Node:
-               return static_cast<const SMDS_MeshNode &>(e1) <
-                       static_cast<const SMDS_MeshNode &>(e2);
+        if(e1.GetType()!=e2.GetType()) return false;
+        switch(e1.GetType())
+        {
+        case SMDSAbs_Node:
+                return static_cast<const SMDS_MeshNode &>(e1) <
+                        static_cast<const SMDS_MeshNode &>(e2);
 
-       case SMDSAbs_Edge:
-               return static_cast<const SMDS_MeshEdge &>(e1) <
-                       static_cast<const SMDS_MeshEdge &>(e2);
+        case SMDSAbs_Edge:
+                return static_cast<const SMDS_MeshEdge &>(e1) <
+                        static_cast<const SMDS_MeshEdge &>(e2);
 
-       case SMDSAbs_Face:
-               return static_cast<const SMDS_MeshFace &>(e1) <
-                       static_cast<const SMDS_MeshFace &>(e2);
+        case SMDSAbs_Face:
+                return static_cast<const SMDS_MeshFace &>(e1) <
+                        static_cast<const SMDS_MeshFace &>(e2);
 
-       case SMDSAbs_Volume:
-               return static_cast<const SMDS_MeshVolume &>(e1) <
-                       static_cast<const SMDS_MeshVolume &>(e2);
+        case SMDSAbs_Volume:
+                return static_cast<const SMDS_MeshVolume &>(e1) <
+                        static_cast<const SMDS_MeshVolume &>(e2);
 
-       default : MESSAGE("Internal Error");
-       }
+        default : MESSAGE("Internal Error");
+        }
         return false;
 }
 
@@ -227,6 +228,17 @@ bool SMDS_MeshElement::IsMediumNode(const SMDS_MeshNode* node) const
   return false;
 }
 
+//================================================================================
+/*!
+ * \brief Return number of nodes excluding medium ones
+ */
+//================================================================================
+
+int SMDS_MeshElement::NbCornerNodes() const
+{
+  return IsQuadratic() ? NbNodes() - NbEdges() : NbNodes();
+}
+
 //================================================================================
   /*!
    * \brief Check if a node belongs to the element