+
+//=======================================================================
+//function : IsNotConformAllowed
+//purpose : check if a hypothesis alowing notconform mesh is present
+//=======================================================================
+
+bool SMESH_Mesh::IsNotConformAllowed() const
+{
+ if(MYDEBUG) MESSAGE("SMESH_Mesh::IsNotConformAllowed");
+
+ const list<const SMESHDS_Hypothesis*>& listHyp =
+ _myMeshDS->GetHypothesis( _myMeshDS->ShapeToMesh() );
+ list<const SMESHDS_Hypothesis*>::const_iterator it=listHyp.begin();
+ while (it!=listHyp.end())
+ {
+ const SMESHDS_Hypothesis *aHyp = *it;
+ string hypName = aHyp->GetName();
+ if ( hypName == "NotConformAllowed" )
+ return true;
+ it++;
+ }
+ return false;
+}
+
+//=======================================================================
+//function : IsMainShape
+//purpose :
+//=======================================================================
+
+bool SMESH_Mesh::IsMainShape(const TopoDS_Shape& theShape) const
+{
+ return theShape.IsSame(_myMeshDS->ShapeToMesh() );
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Group* SMESH_Mesh::AddGroup (const SMDSAbs_ElementType theType,
+ const char* theName,
+ int& theId,
+ const TopoDS_Shape& theShape)
+{
+ if (_mapGroup.find(_groupId) != _mapGroup.end())
+ return NULL;
+ theId = _groupId;
+ SMESH_Group* aGroup = new SMESH_Group (theId, this, theType, theName, theShape);
+ GetMeshDS()->AddGroup( aGroup->GetGroupDS() );
+ _mapGroup[_groupId++] = aGroup;
+ return aGroup;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+SMESH_Group* SMESH_Mesh::GetGroup (const int theGroupID)
+{
+ if (_mapGroup.find(theGroupID) == _mapGroup.end())
+ return NULL;
+ return _mapGroup[theGroupID];
+}
+
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+list<int> SMESH_Mesh::GetGroupIds()
+{
+ list<int> anIds;
+ for ( map<int, SMESH_Group*>::const_iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ )
+ anIds.push_back( it->first );
+
+ return anIds;
+}
+
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+
+void SMESH_Mesh::RemoveGroup (const int theGroupID)
+{
+ if (_mapGroup.find(theGroupID) == _mapGroup.end())
+ return;
+ GetMeshDS()->RemoveGroup( _mapGroup[theGroupID]->GetGroupDS() );
+ _mapGroup.erase (theGroupID);
+ delete _mapGroup[theGroupID];
+}
+
+//=======================================================================
+//function : GetAncestors
+//purpose : return list of ancestors of theSubShape in the order
+// that lower dimention shapes come first.
+//=======================================================================
+
+const TopTools_ListOfShape& SMESH_Mesh::GetAncestors(const TopoDS_Shape& theS)
+{
+ if ( _mapAncestors.IsEmpty() )
+ {
+ // fill _mapAncestors
+ int desType, ancType;
+ for ( desType = TopAbs_EDGE; desType > TopAbs_COMPOUND; desType-- )
+ for ( ancType = desType - 1; ancType >= TopAbs_COMPOUND; ancType-- )
+ TopExp::MapShapesAndAncestors (_myMeshDS->ShapeToMesh(),
+ (TopAbs_ShapeEnum) desType,
+ (TopAbs_ShapeEnum) ancType,
+ _mapAncestors );
+ }
+
+ if ( _mapAncestors.Contains( theS ) )
+ return _mapAncestors.FindFromKey( theS );
+
+ static TopTools_ListOfShape emptyList;
+ return emptyList;
+}
+
+//=======================================================================
+//function : Dump
+//purpose : dumps contents of mesh to stream [ debug purposes ]
+//=======================================================================
+ostream& SMESH_Mesh::Dump(ostream& save)
+{
+ save << "========================== Dump contents of mesh ==========================" << endl;
+ save << "1) Total number of nodes: " << NbNodes() << endl;
+ save << "2) Total number of edges: " << NbEdges() << endl;
+ save << "3) Total number of faces: " << NbFaces() << endl;
+ if ( NbFaces() > 0 ) {
+ int nb3 = NbTriangles();
+ int nb4 = NbQuadrangles();
+ save << "3.1.) Number of triangles: " << nb3 << endl;
+ save << "3.2.) Number of quadrangles: " << nb4 << endl;
+ if ( nb3 + nb4 != NbFaces() ) {
+ map<int,int> myFaceMap;
+ SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
+ while( itFaces->more( ) ) {
+ int nbNodes = itFaces->next()->NbNodes();
+ if ( myFaceMap.find( nbNodes ) == myFaceMap.end() )
+ myFaceMap[ nbNodes ] = 0;
+ myFaceMap[ nbNodes ] = myFaceMap[ nbNodes ] + 1;
+ }
+ save << "3.3.) Faces in detail: " << endl;
+ map <int,int>::iterator itF;
+ for (itF = myFaceMap.begin(); itF != myFaceMap.end(); itF++)
+ save << "--> nb nodes: " << itF->first << " - nb elemens: " << itF->second << endl;
+ }
+ }
+ save << "4) Total number of volumes: " << NbVolumes() << endl;
+ if ( NbVolumes() > 0 ) {
+ int nb8 = NbHexas();
+ int nb4 = NbTetras();
+ int nb5 = NbPyramids();
+ int nb6 = NbPrisms();
+ save << "4.1.) Number of hexahedrons: " << nb8 << endl;
+ save << "4.2.) Number of tetrahedrons: " << nb4 << endl;
+ save << "4.3.) Number of prisms: " << nb6 << endl;
+ save << "4.4.) Number of pyramides: " << nb5 << endl;
+ if ( nb8 + nb4 + nb5 + nb6 != NbVolumes() ) {
+ map<int,int> myVolumesMap;
+ SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
+ while( itVolumes->more( ) ) {
+ int nbNodes = itVolumes->next()->NbNodes();
+ if ( myVolumesMap.find( nbNodes ) == myVolumesMap.end() )
+ myVolumesMap[ nbNodes ] = 0;
+ myVolumesMap[ nbNodes ] = myVolumesMap[ nbNodes ] + 1;
+ }
+ save << "4.5.) Volumes in detail: " << endl;
+ map <int,int>::iterator itV;
+ for (itV = myVolumesMap.begin(); itV != myVolumesMap.end(); itV++)
+ save << "--> nb nodes: " << itV->first << " - nb elemens: " << itV->second << endl;
+ }
+ }
+ save << "===========================================================================" << endl;
+ return save;
+}