+ return myInfo.NbVolumes(); // -PR- a verfier
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Return the number of child mesh of this mesh.
+/// Note that the tree structure of SMDS_Mesh seems to be unused in this version
+/// (2003-09-08) of SMESH
+///////////////////////////////////////////////////////////////////////////////
+int SMDS_Mesh::NbSubMesh() const
+{
+ return myChildren.size();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Destroy the mesh and all its elements
+/// All pointer on elements owned by this mesh become illegals.
+///////////////////////////////////////////////////////////////////////////////
+SMDS_Mesh::~SMDS_Mesh()
+{
+ list<SMDS_Mesh*>::iterator itc=myChildren.begin();
+ while(itc!=myChildren.end())
+ {
+ delete *itc;
+ itc++;
+ }
+
+ if(myParent==NULL)
+ {
+ delete myNodeIDFactory;
+ delete myElementIDFactory;
+ }
+ else
+ {
+ SMDS_ElemIteratorPtr eIt = elementsIterator();
+ while ( eIt->more() )
+ {
+ const SMDS_MeshElement *elem = eIt->next();
+ myElementIDFactory->ReleaseID(elem->GetID(), elem->getVtkId());
+ }
+ SMDS_NodeIteratorPtr itn = nodesIterator();
+ while (itn->more())
+ {
+ const SMDS_MeshNode *node = itn->next();
+ ((SMDS_MeshNode*)node)->SetPosition(SMDS_SpacePosition::originSpacePosition());
+ myNodeIDFactory->ReleaseID(node->GetID(), node->getVtkId());
+ }
+ }
+
+// SetOfNodes::Iterator itn(myNodes);
+// for (; itn.More(); itn.Next())
+// delete itn.Value();
+
+// SetOf0DElements::Iterator it0d (my0DElements);
+// for (; it0d.More(); it0d.Next())
+// {
+// SMDS_MeshElement* elem = it0d.Value();
+// delete elem;
+// }
+
+// SetOfEdges::Iterator ite(myEdges);
+// for (; ite.More(); ite.Next())
+// {
+// SMDS_MeshElement* elem = ite.Value();
+// delete elem;
+// }
+
+// SetOfFaces::Iterator itf(myFaces);
+// for (; itf.More(); itf.Next())
+// {
+// SMDS_MeshElement* elem = itf.Value();
+// delete elem;
+// }
+
+// SetOfVolumes::Iterator itv(myVolumes);
+// for (; itv.More(); itv.Next())
+// {
+// SMDS_MeshElement* elem = itv.Value();
+// delete elem;
+// }
+}
+
+//================================================================================
+/*!
+ * \brief Clear all data
+ */
+//================================================================================
+
+void SMDS_Mesh::Clear()
+{
+ MESSAGE("SMDS_Mesh::Clear");
+ if (myParent!=NULL)
+ {
+ SMDS_ElemIteratorPtr eIt = elementsIterator();
+ while ( eIt->more() )
+ {
+ const SMDS_MeshElement *elem = eIt->next();
+ myElementIDFactory->ReleaseID(elem->GetID(), elem->getVtkId());
+ }
+ SMDS_NodeIteratorPtr itn = nodesIterator();
+ while (itn->more())
+ {
+ const SMDS_MeshNode *node = itn->next();
+ myNodeIDFactory->ReleaseID(node->GetID(), node->getVtkId());
+ }
+ }
+ else
+ {
+ myNodeIDFactory->Clear();
+ myElementIDFactory->Clear();
+ }
+
+ SMDS_ElemIteratorPtr itv = elementsIterator();
+ while (itv->more())
+ {
+ SMDS_MeshElement* elem = (SMDS_MeshElement*)(itv->next());
+ SMDSAbs_ElementType aType = elem->GetType();
+ switch (aType)
+ {
+ case SMDSAbs_0DElement:
+ delete elem;
+ break;
+ case SMDSAbs_Edge:
+ myEdgePool->destroy(static_cast<SMDS_VtkEdge*>(elem));
+ break;
+ case SMDSAbs_Face:
+ myFacePool->destroy(static_cast<SMDS_VtkFace*>(elem));
+ break;
+ case SMDSAbs_Volume:
+ myVolumePool->destroy(static_cast<SMDS_VtkVolume*>(elem));
+ break;
+ default:
+ break;
+ }
+ }
+ myCells.clear();
+ myCellIdVtkToSmds.clear();
+ //myCellIdSmdsToVtk.clear();
+
+ SMDS_NodeIteratorPtr itn = nodesIterator();
+ while (itn->more())
+ {
+ SMDS_MeshNode *node = (SMDS_MeshNode*)(itn->next());
+ node->SetPosition(SMDS_SpacePosition::originSpacePosition());
+ myNodePool->destroy(node);
+ }
+ myNodes.clear();
+
+ list<SMDS_Mesh*>::iterator itc=myChildren.begin();
+ while(itc!=myChildren.end())
+ (*itc)->Clear();
+
+ myModified = false;
+ xmin = 0; xmax = 0;
+ ymin = 0; ymax = 0;
+ zmin = 0; zmax = 0;
+
+ myInfo.Clear();
+
+ myGrid->Initialize();
+ myGrid->Allocate();
+ vtkPoints* points = vtkPoints::New();
+ // rnv: to fix bug "21125: EDF 1233 SMESH: Degrardation of precision in a test case for quadratic conversion"
+ // using double type for storing coordinates of nodes instead float.
+ points->SetDataType(VTK_DOUBLE);
+ points->SetNumberOfPoints(0 /*SMDS_Mesh::chunkSize*/);
+ myGrid->SetPoints( points );
+ points->Delete();
+ myGrid->BuildLinks();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Return true if this mesh create faces with edges.
+/// A false returned value mean that faces are created with nodes. A concequence
+/// is, iteration on edges (SMDS_Element::edgesIterator) will be unavailable.
+///////////////////////////////////////////////////////////////////////////////
+bool SMDS_Mesh::hasConstructionEdges()
+{
+ return myHasConstructionEdges;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Return true if this mesh create volumes with faces
+/// A false returned value mean that volumes are created with nodes or edges.
+/// (see hasConstructionEdges)
+/// A concequence is, iteration on faces (SMDS_Element::facesIterator) will be
+/// unavailable.
+///////////////////////////////////////////////////////////////////////////////
+bool SMDS_Mesh::hasConstructionFaces()
+{
+ return myHasConstructionFaces;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Return true if nodes are linked to the finit elements, they are belonging to.
+/// Currently, It always return true.
+///////////////////////////////////////////////////////////////////////////////
+bool SMDS_Mesh::hasInverseElements()
+{
+ return myHasInverseElements;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Make this mesh creating construction edges (see hasConstructionEdges)
+/// @param b true to have construction edges, else false.
+///////////////////////////////////////////////////////////////////////////////
+void SMDS_Mesh::setConstructionEdges(bool b)
+{
+ myHasConstructionEdges=b;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Make this mesh creating construction faces (see hasConstructionFaces)
+/// @param b true to have construction faces, else false.
+///////////////////////////////////////////////////////////////////////////////
+void SMDS_Mesh::setConstructionFaces(bool b)
+{
+ myHasConstructionFaces=b;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+/// Make this mesh creating link from nodes to elements (see hasInverseElements)
+/// @param b true to link nodes to elements, else false.
+///////////////////////////////////////////////////////////////////////////////
+void SMDS_Mesh::setInverseElements(bool b)
+{
+ if(!b) MESSAGE("Error : inverseElement=false not implemented");
+ myHasInverseElements=b;
+}
+
+namespace {
+
+///////////////////////////////////////////////////////////////////////////////
+///Iterator on NCollection_Map
+///////////////////////////////////////////////////////////////////////////////
+template <class MAP, typename ELEM=const SMDS_MeshElement*, class FATHER=SMDS_ElemIterator>
+struct MYNode_Map_Iterator: public FATHER
+{
+ int _ctr;
+ const MAP& _map;
+ MYNode_Map_Iterator(const MAP& map): _map(map) // map is a std::vector<ELEM>
+ {
+ _ctr = 0;
+ }
+
+ bool more()
+ {
+ while (_ctr < _map.size())
+ {
+ if (_map[_ctr])
+ return true;
+ _ctr++;
+ }
+ return false;
+ }
+
+ ELEM next()
+ {
+ ELEM current = _map[_ctr];
+ _ctr++;
+ return current;
+ }
+};
+
+template <class MAP, typename ELEM=const SMDS_MeshElement*, class FATHER=SMDS_ElemIterator>
+struct MYElem_Map_Iterator: public FATHER
+{
+ int _ctr;
+ int _type;
+ const MAP& _map;
+ MYElem_Map_Iterator(const MAP& map, int typ): _map(map) // map is a std::vector<ELEM>
+ {
+ _ctr = 0;
+ _type = typ;
+ while (_ctr < _map.size()) // go to the first valid element
+ {
+ if (_map[_ctr])
+ if ( (_type == SMDSAbs_All) || (_map[_ctr]->GetType() == _type))
+ break;
+ _ctr++;
+ }
+ }
+
+bool more()
+ {
+ while (_ctr < _map.size())
+ {
+ if (_map[_ctr])
+ if ( (_type == SMDSAbs_All) || (_map[_ctr]->GetType() == _type))
+ return true;
+ _ctr++;
+ }
+ return false;
+ }