1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMESH : implementaion of SMESH idl descriptions
23 // File : SMESH_Mesh.cxx
24 // Author : Paul RASCLE, EDF
28 #include "SMESH_Mesh.hxx"
29 #include "SMESH_subMesh.hxx"
30 #include "SMESH_Gen.hxx"
31 #include "SMESH_Hypothesis.hxx"
32 #include "SMESH_Group.hxx"
33 #include "SMESH_HypoFilter.hxx"
34 #include "SMESHDS_Group.hxx"
35 #include "SMESHDS_Script.hxx"
36 #include "SMESHDS_GroupOnGeom.hxx"
37 #include "SMESHDS_Document.hxx"
38 #include "SMDS_MeshVolume.hxx"
39 #include "SMDS_SetIterator.hxx"
41 #include "utilities.h"
43 #include "DriverMED_W_SMESHDS_Mesh.h"
44 #include "DriverDAT_W_SMDS_Mesh.h"
45 #include "DriverUNV_W_SMDS_Mesh.h"
46 #include "DriverSTL_W_SMDS_Mesh.h"
48 #include "DriverMED_R_SMESHDS_Mesh.h"
49 #include "DriverUNV_R_SMDS_Mesh.h"
50 #include "DriverSTL_R_SMDS_Mesh.h"
52 #undef _Precision_HeaderFile
53 #include <BRepPrimAPI_MakeBox.hxx>
55 #include <TopExp_Explorer.hxx>
56 #include <TopTools_ListIteratorOfListOfShape.hxx>
57 #include <TopTools_ListOfShape.hxx>
58 #include <TopTools_MapOfShape.hxx>
59 #include <TopoDS_Iterator.hxx>
61 #include "Utils_ExceptHandlers.hxx"
63 // maximum stored group name length in MED file
64 #define MAX_MED_GROUP_NAME_LENGTH 80
67 static int MYDEBUG = 0;
69 static int MYDEBUG = 0;
74 #define cSMESH_Hyp(h) static_cast<const SMESH_Hypothesis*>(h)
76 typedef SMESH_HypoFilter THypType;
78 //=============================================================================
82 //=============================================================================
84 SMESH_Mesh::SMESH_Mesh(int theLocalId,
87 bool theIsEmbeddedMode,
88 SMESHDS_Document* theDocument):
89 _groupId( 0 ), _nbSubShapes( 0 )
91 MESSAGE("SMESH_Mesh::SMESH_Mesh(int localId)");
93 _studyId = theStudyId;
95 _myDocument = theDocument;
96 _idDoc = theDocument->NewMesh(theIsEmbeddedMode);
97 _myMeshDS = theDocument->GetMesh(_idDoc);
98 _isShapeToMesh = false;
100 _myMeshDS->ShapeToMesh( PseudoShape() );
103 //=============================================================================
107 //=============================================================================
109 SMESH_Mesh::~SMESH_Mesh()
111 INFOS("SMESH_Mesh::~SMESH_Mesh");
114 std::map < int, SMESH_Group * >::iterator itg;
115 for (itg = _mapGroup.begin(); itg != _mapGroup.end(); itg++) {
116 SMESH_Group *aGroup = (*itg).second;
122 //=============================================================================
124 * \brief Set geometry to be meshed
126 //=============================================================================
128 void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape)
130 if(MYDEBUG) MESSAGE("SMESH_Mesh::ShapeToMesh");
132 if ( !aShape.IsNull() && _isShapeToMesh )
133 throw SALOME_Exception(LOCALIZED ("a shape to mesh has already been defined"));
135 // clear current data
136 if ( !_myMeshDS->ShapeToMesh().IsNull() )
138 // removal of a shape to mesh, delete objects referring to sub-shapes:
140 std::map <int, SMESH_subMesh *>::iterator i_sm = _mapSubMesh.begin();
141 for ( ; i_sm != _mapSubMesh.end(); ++i_sm )
144 // - groups on geometry
145 std::map <int, SMESH_Group *>::iterator i_gr = _mapGroup.begin();
146 while ( i_gr != _mapGroup.end() ) {
147 if ( dynamic_cast<SMESHDS_GroupOnGeom*>( i_gr->second->GetGroupDS() )) {
148 _myMeshDS->RemoveGroup( i_gr->second->GetGroupDS() );
150 _mapGroup.erase( i_gr++ );
155 _mapAncestors.Clear();
158 TopoDS_Shape aNullShape;
159 _myMeshDS->ShapeToMesh( aNullShape );
162 // set a new geometry
163 if ( !aShape.IsNull() )
165 _myMeshDS->ShapeToMesh(aShape);
166 _isShapeToMesh = true;
167 _nbSubShapes = _myMeshDS->MaxShapeIndex();
169 // fill _mapAncestors
170 int desType, ancType;
171 for ( desType = TopAbs_VERTEX; desType > TopAbs_COMPOUND; desType-- )
172 for ( ancType = desType - 1; ancType >= TopAbs_COMPOUND; ancType-- )
173 TopExp::MapShapesAndAncestors ( aShape,
174 (TopAbs_ShapeEnum) desType,
175 (TopAbs_ShapeEnum) ancType,
180 //=======================================================================
182 * \brief Return geometry to be meshed. (It may be a PseudoShape()!)
184 //=======================================================================
186 TopoDS_Shape SMESH_Mesh::GetShapeToMesh() const
188 return _myMeshDS->ShapeToMesh();
191 //=======================================================================
193 * \brief Return a solid which is returned by GetShapeToMesh() if
194 * a real geometry to be meshed was not set
196 //=======================================================================
198 const TopoDS_Solid& SMESH_Mesh::PseudoShape()
200 static TopoDS_Solid aSolid;
201 if ( aSolid.IsNull() )
203 aSolid = BRepPrimAPI_MakeBox(1,1,1);
208 //=======================================================================
210 * \brief Remove all nodes and elements
212 //=======================================================================
214 void SMESH_Mesh::Clear()
217 _myMeshDS->ClearMesh();
219 // update compute state of submeshes
220 if ( SMESH_subMesh *sm = GetSubMeshContaining( GetShapeToMesh() ) ) {
221 SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(/*includeSelf=*/true,
222 /*complexShapeFirst=*/false);
223 while ( smIt->more() ) {
225 sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
229 // // clear sub-meshes; get ready to re-compute as a side-effect
231 // if ( SMESH_subMesh *sm = GetSubMeshContaining( GetShapeToMesh() ) )
233 // SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(/*includeSelf=*/true,
234 // /*complexShapeFirst=*/false);
235 // while ( smIt->more() )
237 // sm = smIt->next();
238 // TopAbs_ShapeEnum shapeType = sm->GetSubShape().ShapeType();
239 // if ( shapeType == TopAbs_VERTEX || shapeType < TopAbs_SOLID )
240 // // all other shapes depends on vertices so they are already cleaned
241 // sm->ComputeStateEngine( SMESH_subMesh::CLEAN );
242 // // to recompute even if failed
243 // sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
247 // // clear entities not on sub-meshes
249 // SMDS_VolumeIteratorPtr vIt = _myMeshDS->volumesIterator();
250 // while ( vIt->more() )
251 // _myMeshDS->RemoveFreeElement( vIt->next(), 0 );
253 // SMDS_FaceIteratorPtr fIt = _myMeshDS->facesIterator();
254 // while ( fIt->more() )
255 // _myMeshDS->RemoveFreeElement( fIt->next(), 0 );
257 // SMDS_EdgeIteratorPtr eIt = _myMeshDS->edgesIterator();
258 // while ( eIt->more() )
259 // _myMeshDS->RemoveFreeElement( eIt->next(), 0 );
261 // SMDS_NodeIteratorPtr nIt = _myMeshDS->nodesIterator();
262 // while ( nIt->more() ) {
263 // const SMDS_MeshNode * node = nIt->next();
264 // if ( node->NbInverseElements() == 0 )
265 // _myMeshDS->RemoveFreeNode( node, 0 );
267 // _myMeshDS->RemoveNode(node);
271 //=======================================================================
272 //function : UNVToMesh
274 //=======================================================================
276 int SMESH_Mesh::UNVToMesh(const char* theFileName)
278 if(MYDEBUG) MESSAGE("UNVToMesh - theFileName = "<<theFileName);
280 throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
281 _isShapeToMesh = false;
282 DriverUNV_R_SMDS_Mesh myReader;
283 myReader.SetMesh(_myMeshDS);
284 myReader.SetFile(theFileName);
285 myReader.SetMeshId(-1);
288 MESSAGE("UNVToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
289 MESSAGE("UNVToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
290 MESSAGE("UNVToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
291 MESSAGE("UNVToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
293 SMDS_MeshGroup* aGroup = (SMDS_MeshGroup*) myReader.GetGroup();
295 TGroupNamesMap aGroupNames = myReader.GetGroupNamesMap();
296 //const TGroupIdMap& aGroupId = myReader.GetGroupIdMap();
297 aGroup->InitSubGroupsIterator();
298 while (aGroup->MoreSubGroups()) {
299 SMDS_MeshGroup* aSubGroup = (SMDS_MeshGroup*) aGroup->NextSubGroup();
300 std::string aName = aGroupNames[aSubGroup];
303 SMESH_Group* aSMESHGroup = AddGroup( aSubGroup->GetType(), aName.c_str(), aId );
305 if(MYDEBUG) MESSAGE("UNVToMesh - group added: "<<aName);
306 SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( aSMESHGroup->GetGroupDS() );
308 aGroupDS->SetStoreName(aName.c_str());
309 aSubGroup->InitIterator();
310 const SMDS_MeshElement* aElement = 0;
311 while (aSubGroup->More()) {
312 aElement = aSubGroup->Next();
314 aGroupDS->SMDSGroup().Add(aElement);
318 aGroupDS->SetType(aElement->GetType());
326 //=======================================================================
327 //function : MEDToMesh
329 //=======================================================================
331 int SMESH_Mesh::MEDToMesh(const char* theFileName, const char* theMeshName)
333 if(MYDEBUG) MESSAGE("MEDToMesh - theFileName = "<<theFileName<<", mesh name = "<<theMeshName);
335 throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
336 _isShapeToMesh = false;
337 DriverMED_R_SMESHDS_Mesh myReader;
338 myReader.SetMesh(_myMeshDS);
339 myReader.SetMeshId(-1);
340 myReader.SetFile(theFileName);
341 myReader.SetMeshName(theMeshName);
342 Driver_Mesh::Status status = myReader.Perform();
344 MESSAGE("MEDToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
345 MESSAGE("MEDToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
346 MESSAGE("MEDToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
347 MESSAGE("MEDToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
350 // Reading groups (sub-meshes are out of scope of MED import functionality)
351 std::list<TNameAndType> aGroupNames = myReader.GetGroupNamesAndTypes();
352 if(MYDEBUG) MESSAGE("MEDToMesh - Nb groups = "<<aGroupNames.size());
354 std::list<TNameAndType>::iterator name_type = aGroupNames.begin();
355 for ( ; name_type != aGroupNames.end(); name_type++ ) {
356 SMESH_Group* aGroup = AddGroup( name_type->second, name_type->first.c_str(), anId );
358 if(MYDEBUG) MESSAGE("MEDToMesh - group added: "<<name_type->first.c_str());
359 SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( aGroup->GetGroupDS() );
361 aGroupDS->SetStoreName( name_type->first.c_str() );
362 myReader.GetGroup( aGroupDS );
369 //=======================================================================
370 //function : STLToMesh
372 //=======================================================================
374 int SMESH_Mesh::STLToMesh(const char* theFileName)
376 if(MYDEBUG) MESSAGE("STLToMesh - theFileName = "<<theFileName);
378 throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
379 _isShapeToMesh = false;
380 DriverSTL_R_SMDS_Mesh myReader;
381 myReader.SetMesh(_myMeshDS);
382 myReader.SetFile(theFileName);
383 myReader.SetMeshId(-1);
386 MESSAGE("STLToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
387 MESSAGE("STLToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
388 MESSAGE("STLToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
389 MESSAGE("STLToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
394 //=============================================================================
398 //=============================================================================
400 SMESH_Hypothesis::Hypothesis_Status
401 SMESH_Mesh::AddHypothesis(const TopoDS_Shape & aSubShape,
402 int anHypId ) throw(SALOME_Exception)
404 Unexpect aCatch(SalomeException);
405 if(MYDEBUG) MESSAGE("SMESH_Mesh::AddHypothesis");
407 SMESH_subMesh *subMesh = GetSubMesh(aSubShape);
408 if ( !subMesh || !subMesh->GetId())
409 return SMESH_Hypothesis::HYP_BAD_SUBSHAPE;
411 SMESHDS_SubMesh *subMeshDS = subMesh->GetSubMeshDS();
412 if ( subMeshDS && subMeshDS->IsComplexSubmesh() ) // group of sub-shapes and maybe of not sub-
414 MESSAGE("AddHypothesis() to complex submesh");
415 // return the worst but not fatal state of all group memebers
416 SMESH_Hypothesis::Hypothesis_Status aBestRet, aWorstNotFatal, ret;
417 aBestRet = SMESH_Hypothesis::HYP_BAD_DIM;
418 aWorstNotFatal = SMESH_Hypothesis::HYP_OK;
419 for ( TopoDS_Iterator itS ( aSubShape ); itS.More(); itS.Next())
421 if ( !GetMeshDS()->ShapeToIndex( itS.Value() ))
422 continue; // not sub-shape
423 ret = AddHypothesis( itS.Value(), anHypId );
424 if ( !SMESH_Hypothesis::IsStatusFatal( ret ) && ret > aWorstNotFatal )
425 aWorstNotFatal = ret;
426 if ( ret < aBestRet )
429 // bind hypotheses to a group just to know
430 SMESH_Hypothesis *anHyp = _gen->GetStudyContext(_studyId)->mapHypothesis[anHypId];
431 GetMeshDS()->AddHypothesis( aSubShape, anHyp );
433 if ( SMESH_Hypothesis::IsStatusFatal( aBestRet ))
435 return aWorstNotFatal;
438 StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
439 if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
441 if(MYDEBUG) MESSAGE("Hypothesis ID does not give an hypothesis");
446 throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
449 SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
450 MESSAGE( "SMESH_Mesh::AddHypothesis " << anHyp->GetName() );
452 bool isGlobalHyp = IsMainShape( aSubShape );
454 // NotConformAllowed can be only global
457 string hypName = anHyp->GetName();
458 if ( hypName == "NotConformAllowed" )
460 if(MYDEBUG) MESSAGE( "Hypotesis <NotConformAllowed> can be only global" );
461 return SMESH_Hypothesis::HYP_INCOMPATIBLE;
467 bool isAlgo = ( !anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO );
468 int event = isAlgo ? SMESH_subMesh::ADD_ALGO : SMESH_subMesh::ADD_HYP;
470 SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp);
473 if (!SMESH_Hypothesis::IsStatusFatal(ret) &&
474 anHyp->GetDim() <= SMESH_Gen::GetShapeDim(aSubShape)) // is added on father
476 event = isAlgo ? SMESH_subMesh::ADD_FATHER_ALGO : SMESH_subMesh::ADD_FATHER_HYP;
478 SMESH_Hypothesis::Hypothesis_Status ret2 =
479 subMesh->SubMeshesAlgoStateEngine(event, anHyp);
483 // check concurent hypotheses on ansestors
484 if (ret < SMESH_Hypothesis::HYP_CONCURENT && !isGlobalHyp )
486 SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false);
487 while ( smIt->more() ) {
488 SMESH_subMesh* sm = smIt->next();
489 if ( sm->IsApplicableHypotesis( anHyp )) {
490 ret2 = sm->CheckConcurentHypothesis( anHyp->GetType() );
500 if(MYDEBUG) subMesh->DumpAlgoState(true);
505 //=============================================================================
509 //=============================================================================
511 SMESH_Hypothesis::Hypothesis_Status
512 SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape & aSubShape,
513 int anHypId)throw(SALOME_Exception)
515 Unexpect aCatch(SalomeException);
516 if(MYDEBUG) MESSAGE("SMESH_Mesh::RemoveHypothesis");
518 SMESH_subMesh *subMesh = GetSubMesh(aSubShape);
519 SMESHDS_SubMesh *subMeshDS = subMesh->GetSubMeshDS();
520 if ( subMeshDS && subMeshDS->IsComplexSubmesh() )
522 // return the worst but not fatal state of all group memebers
523 SMESH_Hypothesis::Hypothesis_Status aBestRet, aWorstNotFatal, ret;
524 aBestRet = SMESH_Hypothesis::HYP_BAD_DIM;
525 aWorstNotFatal = SMESH_Hypothesis::HYP_OK;
526 for ( TopoDS_Iterator itS ( aSubShape ); itS.More(); itS.Next())
528 if ( !GetMeshDS()->ShapeToIndex( itS.Value() ))
529 continue; // not sub-shape
530 ret = RemoveHypothesis( itS.Value(), anHypId );
531 if ( !SMESH_Hypothesis::IsStatusFatal( ret ) && ret > aWorstNotFatal )
532 aWorstNotFatal = ret;
533 if ( ret < aBestRet )
536 SMESH_Hypothesis *anHyp = _gen->GetStudyContext(_studyId)->mapHypothesis[anHypId];
537 GetMeshDS()->RemoveHypothesis( aSubShape, anHyp );
539 if ( SMESH_Hypothesis::IsStatusFatal( aBestRet ))
541 return aWorstNotFatal;
544 StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
545 if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
546 throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
548 SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
549 int hypType = anHyp->GetType();
550 if(MYDEBUG) SCRUTE(hypType);
554 bool isAlgo = ( !anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO );
555 int event = isAlgo ? SMESH_subMesh::REMOVE_ALGO : SMESH_subMesh::REMOVE_HYP;
557 SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp);
559 // there may appear concurrent hyps that were covered by the removed hyp
560 if (ret < SMESH_Hypothesis::HYP_CONCURENT &&
561 subMesh->IsApplicableHypotesis( anHyp ) &&
562 subMesh->CheckConcurentHypothesis( anHyp->GetType() ) != SMESH_Hypothesis::HYP_OK)
563 ret = SMESH_Hypothesis::HYP_CONCURENT;
566 if (!SMESH_Hypothesis::IsStatusFatal(ret) &&
567 anHyp->GetDim() <= SMESH_Gen::GetShapeDim(aSubShape)) // is removed from father
569 event = isAlgo ? SMESH_subMesh::REMOVE_FATHER_ALGO : SMESH_subMesh::REMOVE_FATHER_HYP;
571 SMESH_Hypothesis::Hypothesis_Status ret2 =
572 subMesh->SubMeshesAlgoStateEngine(event, anHyp);
573 if (ret2 > ret) // more severe
576 // check concurent hypotheses on ansestors
577 if (ret < SMESH_Hypothesis::HYP_CONCURENT && !IsMainShape( aSubShape ) )
579 SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false);
580 while ( smIt->more() ) {
581 SMESH_subMesh* sm = smIt->next();
582 if ( sm->IsApplicableHypotesis( anHyp )) {
583 ret2 = sm->CheckConcurentHypothesis( anHyp->GetType() );
593 if(MYDEBUG) subMesh->DumpAlgoState(true);
594 if(MYDEBUG) SCRUTE(ret);
598 //=============================================================================
602 //=============================================================================
604 const std::list<const SMESHDS_Hypothesis*>&
605 SMESH_Mesh::GetHypothesisList(const TopoDS_Shape & aSubShape) const
606 throw(SALOME_Exception)
608 Unexpect aCatch(SalomeException);
609 return _myMeshDS->GetHypothesis(aSubShape);
612 //=======================================================================
614 * \brief Return the hypothesis assigned to the shape
615 * \param aSubShape - the shape to check
616 * \param aFilter - the hypothesis filter
617 * \param andAncestors - flag to check hypos assigned to ancestors of the shape
618 * \param assignedTo - to return the shape the found hypo is assigned to
619 * \retval SMESH_Hypothesis* - the first hypo passed through aFilter
621 //=======================================================================
623 const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubShape,
624 const SMESH_HypoFilter& aFilter,
625 const bool andAncestors,
626 TopoDS_Shape* assignedTo) const
629 const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
630 std::list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
631 for ( ; hyp != hypList.end(); hyp++ ) {
632 const SMESH_Hypothesis * h = cSMESH_Hyp( *hyp );
633 if ( aFilter.IsOk( h, aSubShape)) {
634 if ( assignedTo ) *assignedTo = aSubShape;
641 TopTools_ListIteratorOfListOfShape it( GetAncestors( aSubShape ));
642 for (; it.More(); it.Next() )
644 const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value());
645 std::list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
646 for ( ; hyp != hypList.end(); hyp++ ) {
647 const SMESH_Hypothesis * h = cSMESH_Hyp( *hyp );
648 if (aFilter.IsOk( h, it.Value() )) {
649 if ( assignedTo ) *assignedTo = it.Value();
658 //================================================================================
660 * \brief Return hypothesis assigned to the shape
661 * \param aSubShape - the shape to check
662 * \param aFilter - the hypothesis filter
663 * \param aHypList - the list of the found hypotheses
664 * \param andAncestors - flag to check hypos assigned to ancestors of the shape
665 * \retval int - number of unique hypos in aHypList
667 //================================================================================
669 int SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape,
670 const SMESH_HypoFilter& aFilter,
671 list <const SMESHDS_Hypothesis * >& aHypList,
672 const bool andAncestors) const
674 set<string> hypTypes; // to exclude same type hypos from the result list
677 // only one main hypothesis is allowed
678 bool mainHypFound = false;
681 std::list<const SMESHDS_Hypothesis*>::const_iterator hyp;
682 for ( hyp = aHypList.begin(); hyp != aHypList.end(); hyp++ ) {
683 if ( hypTypes.insert( (*hyp)->GetName() ).second )
685 if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
689 // get hypos from aSubShape
691 const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
692 for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
693 if ( aFilter.IsOk (cSMESH_Hyp( *hyp ), aSubShape) &&
694 ( cSMESH_Hyp(*hyp)->IsAuxiliary() || !mainHypFound ) &&
695 hypTypes.insert( (*hyp)->GetName() ).second )
697 aHypList.push_back( *hyp );
699 if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
704 // get hypos from ancestors of aSubShape
707 TopTools_MapOfShape map;
708 TopTools_ListIteratorOfListOfShape it( GetAncestors( aSubShape ));
709 for (; it.More(); it.Next() )
711 if ( !map.Add( it.Value() ))
713 const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value());
714 for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
715 if (aFilter.IsOk( cSMESH_Hyp( *hyp ), it.Value() ) &&
716 ( cSMESH_Hyp(*hyp)->IsAuxiliary() || !mainHypFound ) &&
717 hypTypes.insert( (*hyp)->GetName() ).second )
719 aHypList.push_back( *hyp );
721 if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
729 //=============================================================================
733 //=============================================================================
735 const std::list<SMESHDS_Command*> & SMESH_Mesh::GetLog() throw(SALOME_Exception)
737 Unexpect aCatch(SalomeException);
738 if(MYDEBUG) MESSAGE("SMESH_Mesh::GetLog");
739 return _myMeshDS->GetScript()->GetCommands();
742 //=============================================================================
746 //=============================================================================
747 void SMESH_Mesh::ClearLog() throw(SALOME_Exception)
749 Unexpect aCatch(SalomeException);
750 if(MYDEBUG) MESSAGE("SMESH_Mesh::ClearLog");
751 _myMeshDS->GetScript()->Clear();
754 //=============================================================================
756 * Get or Create the SMESH_subMesh object implementation
758 //=============================================================================
760 SMESH_subMesh *SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape)
761 throw(SALOME_Exception)
763 Unexpect aCatch(SalomeException);
764 SMESH_subMesh *aSubMesh;
765 int index = _myMeshDS->ShapeToIndex(aSubShape);
767 // for submeshes on GEOM Group
768 if (( !index || index > _nbSubShapes ) && aSubShape.ShapeType() == TopAbs_COMPOUND ) {
769 TopoDS_Iterator it( aSubShape );
771 index = _myMeshDS->AddCompoundSubmesh( aSubShape, it.Value().ShapeType() );
774 // return NULL; // neither sub-shape nor a group
776 map <int, SMESH_subMesh *>::iterator i_sm = _mapSubMesh.find(index);
777 if ( i_sm != _mapSubMesh.end())
779 aSubMesh = i_sm->second;
783 aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape);
784 _mapSubMesh[index] = aSubMesh;
789 //=============================================================================
791 * Get the SMESH_subMesh object implementation. Dont create it, return null
792 * if it does not exist.
794 //=============================================================================
796 SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape) const
797 throw(SALOME_Exception)
799 Unexpect aCatch(SalomeException);
800 SMESH_subMesh *aSubMesh = NULL;
802 int index = _myMeshDS->ShapeToIndex(aSubShape);
804 map <int, SMESH_subMesh *>::const_iterator i_sm = _mapSubMesh.find(index);
805 if ( i_sm != _mapSubMesh.end())
806 aSubMesh = i_sm->second;
810 //=============================================================================
812 * Get the SMESH_subMesh object implementation. Dont create it, return null
813 * if it does not exist.
815 //=============================================================================
817 SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const int aShapeID) const
818 throw(SALOME_Exception)
820 Unexpect aCatch(SalomeException);
822 map <int, SMESH_subMesh *>::const_iterator i_sm = _mapSubMesh.find(aShapeID);
823 if (i_sm == _mapSubMesh.end())
827 //================================================================================
829 * \brief Return submeshes of groups containing the given subshape
831 //================================================================================
833 std::list<SMESH_subMesh*>
834 SMESH_Mesh::GetGroupSubMeshesContaining(const TopoDS_Shape & aSubShape) const
835 throw(SALOME_Exception)
837 Unexpect aCatch(SalomeException);
838 std::list<SMESH_subMesh*> found;
840 SMESH_subMesh * subMesh = GetSubMeshContaining(aSubShape);
844 // submeshes of groups have max IDs, so search from the map end
845 std::map<int, SMESH_subMesh *>::const_reverse_iterator i_sm;
846 for ( i_sm = _mapSubMesh.rbegin(); i_sm != _mapSubMesh.rend(); ++i_sm) {
847 SMESHDS_SubMesh * ds = i_sm->second->GetSubMeshDS();
848 if ( ds && ds->IsComplexSubmesh() ) {
849 TopExp_Explorer exp( i_sm->second->GetSubShape(), aSubShape.ShapeType() );
850 for ( ; exp.More(); exp.Next() ) {
851 if ( aSubShape.IsSame( exp.Current() )) {
852 found.push_back( i_sm->second );
862 //=======================================================================
863 //function : IsUsedHypothesis
864 //purpose : Return True if anHyp is used to mesh aSubShape
865 //=======================================================================
867 bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
868 const SMESH_subMesh* aSubMesh)
870 SMESH_Hypothesis* hyp = static_cast<SMESH_Hypothesis*>(anHyp);
872 // check if anHyp can be used to mesh aSubMesh
873 if ( !aSubMesh || !aSubMesh->IsApplicableHypotesis( hyp ))
876 const TopoDS_Shape & aSubShape = const_cast<SMESH_subMesh*>( aSubMesh )->GetSubShape();
878 SMESH_Algo *algo = _gen->GetAlgo(*this, aSubShape );
881 if (anHyp->GetType() > SMESHDS_Hypothesis::PARAM_ALGO)
882 return ( anHyp == algo );
884 // algorithm parameter
887 // look trough hypotheses used by algo
888 SMESH_HypoFilter hypoKind;
889 if ( algo->InitCompatibleHypoFilter( hypoKind, !hyp->IsAuxiliary() )) {
890 list <const SMESHDS_Hypothesis * > usedHyps;
891 if ( GetHypotheses( aSubShape, hypoKind, usedHyps, true ))
892 return ( find( usedHyps.begin(), usedHyps.end(), anHyp ) != usedHyps.end() );
896 // look through all assigned hypotheses
897 //SMESH_HypoFilter filter( SMESH_HypoFilter::Is( hyp ));
898 return false; //GetHypothesis( aSubShape, filter, true );
901 //=============================================================================
905 //=============================================================================
907 const list < SMESH_subMesh * >&
908 SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
909 throw(SALOME_Exception)
911 Unexpect aCatch(SalomeException);
912 if(MYDEBUG) MESSAGE("SMESH_Mesh::GetSubMeshUsingHypothesis");
913 map < int, SMESH_subMesh * >::iterator itsm;
914 _subMeshesUsingHypothesisList.clear();
915 for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
917 SMESH_subMesh *aSubMesh = (*itsm).second;
918 if ( IsUsedHypothesis ( anHyp, aSubMesh ))
919 _subMeshesUsingHypothesisList.push_back(aSubMesh);
921 return _subMeshesUsingHypothesisList;
924 //=======================================================================
925 //function : NotifySubMeshesHypothesisModification
926 //purpose : Say all submeshes using theChangedHyp that it has been modified
927 //=======================================================================
929 void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* hyp)
931 Unexpect aCatch(SalomeException);
933 const SMESH_Algo *foundAlgo = 0;
934 SMESH_HypoFilter algoKind, compatibleHypoKind;
935 list <const SMESHDS_Hypothesis * > usedHyps;
938 map < int, SMESH_subMesh * >::iterator itsm;
939 for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
941 SMESH_subMesh *aSubMesh = (*itsm).second;
942 if ( aSubMesh->IsApplicableHypotesis( hyp ))
944 const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape();
946 if ( !foundAlgo ) // init filter for algo search
947 algoKind.Init( THypType::IsAlgo() ).And( THypType::IsApplicableTo( aSubShape ));
949 const SMESH_Algo *algo = static_cast<const SMESH_Algo*>
950 ( GetHypothesis( aSubShape, algoKind, true ));
954 bool sameAlgo = ( algo == foundAlgo );
955 if ( !sameAlgo && foundAlgo )
956 sameAlgo = ( strcmp( algo->GetName(), foundAlgo->GetName() ) == 0);
958 if ( !sameAlgo ) { // init filter for used hypos search
959 if ( !algo->InitCompatibleHypoFilter( compatibleHypoKind, !hyp->IsAuxiliary() ))
960 continue; // algo does not use any hypothesis
964 // check if hyp is used by algo
966 if ( GetHypotheses( aSubShape, compatibleHypoKind, usedHyps, true ) &&
967 find( usedHyps.begin(), usedHyps.end(), hyp ) != usedHyps.end() )
969 aSubMesh->AlgoStateEngine(SMESH_subMesh::MODIF_HYP,
970 const_cast< SMESH_Hypothesis*>( hyp ));
977 //=============================================================================
979 * Auto color functionality
981 //=============================================================================
982 void SMESH_Mesh::SetAutoColor(bool theAutoColor) throw(SALOME_Exception)
984 Unexpect aCatch(SalomeException);
985 _isAutoColor = theAutoColor;
988 bool SMESH_Mesh::GetAutoColor() throw(SALOME_Exception)
990 Unexpect aCatch(SalomeException);
994 //=============================================================================
996 * To store mesh contents on disk in different formats.
998 //=============================================================================
1000 bool SMESH_Mesh::HasDuplicatedGroupNamesMED()
1002 set<string> aGroupNames;
1003 for ( std::map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
1004 SMESH_Group* aGroup = it->second;
1005 std::string aGroupName = aGroup->GetName();
1006 aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
1007 if (!aGroupNames.insert(aGroupName).second)
1014 void SMESH_Mesh::ExportMED(const char *file,
1015 const char* theMeshName,
1018 throw(SALOME_Exception)
1020 Unexpect aCatch(SalomeException);
1022 DriverMED_W_SMESHDS_Mesh myWriter;
1023 myWriter.SetFile ( file, MED::EVersion(theVersion) );
1024 myWriter.SetMesh ( _myMeshDS );
1026 myWriter.SetMeshId ( _idDoc );
1028 myWriter.SetMeshId ( -1 );
1029 myWriter.SetMeshName( theMeshName );
1032 if ( theAutoGroups ) {
1033 myWriter.AddGroupOfNodes();
1034 myWriter.AddGroupOfEdges();
1035 myWriter.AddGroupOfFaces();
1036 myWriter.AddGroupOfVolumes();
1039 // Pass groups to writer. Provide unique group names.
1040 set<string> aGroupNames;
1042 int maxNbIter = 10000; // to guarantee cycle finish
1043 for ( std::map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
1044 SMESH_Group* aGroup = it->second;
1045 SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
1047 string aGroupName0 = aGroup->GetName();
1048 aGroupName0.resize(MAX_MED_GROUP_NAME_LENGTH);
1049 string aGroupName = aGroupName0;
1050 for (int i = 1; !aGroupNames.insert(aGroupName).second && i < maxNbIter; i++) {
1051 sprintf(&aString[0], "GR_%d_%s", i, aGroupName0.c_str());
1052 aGroupName = aString;
1053 aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
1055 aGroupDS->SetStoreName( aGroupName.c_str() );
1056 myWriter.AddGroup( aGroupDS );
1064 void SMESH_Mesh::ExportDAT(const char *file) throw(SALOME_Exception)
1066 Unexpect aCatch(SalomeException);
1067 DriverDAT_W_SMDS_Mesh myWriter;
1068 myWriter.SetFile(string(file));
1069 myWriter.SetMesh(_myMeshDS);
1070 myWriter.SetMeshId(_idDoc);
1074 void SMESH_Mesh::ExportUNV(const char *file) throw(SALOME_Exception)
1076 Unexpect aCatch(SalomeException);
1077 DriverUNV_W_SMDS_Mesh myWriter;
1078 myWriter.SetFile(string(file));
1079 myWriter.SetMesh(_myMeshDS);
1080 myWriter.SetMeshId(_idDoc);
1081 // myWriter.SetGroups(_mapGroup);
1083 for ( std::map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
1084 SMESH_Group* aGroup = it->second;
1085 SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
1087 std::string aGroupName = aGroup->GetName();
1088 aGroupDS->SetStoreName( aGroupName.c_str() );
1089 myWriter.AddGroup( aGroupDS );
1095 void SMESH_Mesh::ExportSTL(const char *file, const bool isascii) throw(SALOME_Exception)
1097 Unexpect aCatch(SalomeException);
1098 DriverSTL_W_SMDS_Mesh myWriter;
1099 myWriter.SetFile(string(file));
1100 myWriter.SetIsAscii( isascii );
1101 myWriter.SetMesh(_myMeshDS);
1102 myWriter.SetMeshId(_idDoc);
1106 //================================================================================
1108 * \brief Return number of nodes in the mesh
1110 //================================================================================
1112 int SMESH_Mesh::NbNodes() throw(SALOME_Exception)
1114 Unexpect aCatch(SalomeException);
1115 return _myMeshDS->NbNodes();
1118 //================================================================================
1120 * \brief Return number of edges of given order in the mesh
1122 //================================================================================
1124 int SMESH_Mesh::NbEdges(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1126 Unexpect aCatch(SalomeException);
1127 return _myMeshDS->GetMeshInfo().NbEdges(order);
1130 //================================================================================
1132 * \brief Return number of faces of given order in the mesh
1134 //================================================================================
1136 int SMESH_Mesh::NbFaces(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1138 Unexpect aCatch(SalomeException);
1139 return _myMeshDS->GetMeshInfo().NbFaces(order);
1142 //================================================================================
1144 * \brief Return the number of faces in the mesh
1146 //================================================================================
1148 int SMESH_Mesh::NbTriangles(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1150 Unexpect aCatch(SalomeException);
1151 return _myMeshDS->GetMeshInfo().NbTriangles(order);
1154 //================================================================================
1156 * \brief Return the number nodes faces in the mesh
1158 //================================================================================
1160 int SMESH_Mesh::NbQuadrangles(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1162 Unexpect aCatch(SalomeException);
1163 return _myMeshDS->GetMeshInfo().NbQuadrangles(order);
1166 //================================================================================
1168 * \brief Return the number of polygonal faces in the mesh
1170 //================================================================================
1172 int SMESH_Mesh::NbPolygons() throw(SALOME_Exception)
1174 Unexpect aCatch(SalomeException);
1175 return _myMeshDS->GetMeshInfo().NbPolygons();
1178 //================================================================================
1180 * \brief Return number of volumes of given order in the mesh
1182 //================================================================================
1184 int SMESH_Mesh::NbVolumes(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1186 Unexpect aCatch(SalomeException);
1187 return _myMeshDS->GetMeshInfo().NbVolumes(order);
1190 //================================================================================
1192 * \brief Return number of tetrahedrons of given order in the mesh
1194 //================================================================================
1196 int SMESH_Mesh::NbTetras(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1198 Unexpect aCatch(SalomeException);
1199 return _myMeshDS->GetMeshInfo().NbTetras(order);
1202 //================================================================================
1204 * \brief Return number of hexahedrons of given order in the mesh
1206 //================================================================================
1208 int SMESH_Mesh::NbHexas(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1210 Unexpect aCatch(SalomeException);
1211 return _myMeshDS->GetMeshInfo().NbHexas(order);
1214 //================================================================================
1216 * \brief Return number of pyramids of given order in the mesh
1218 //================================================================================
1220 int SMESH_Mesh::NbPyramids(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1222 Unexpect aCatch(SalomeException);
1223 return _myMeshDS->GetMeshInfo().NbPyramids(order);
1226 //================================================================================
1228 * \brief Return number of prisms (penthahedrons) of given order in the mesh
1230 //================================================================================
1232 int SMESH_Mesh::NbPrisms(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1234 Unexpect aCatch(SalomeException);
1235 return _myMeshDS->GetMeshInfo().NbPrisms(order);
1238 //================================================================================
1240 * \brief Return number of polyhedrons in the mesh
1242 //================================================================================
1244 int SMESH_Mesh::NbPolyhedrons() throw(SALOME_Exception)
1246 Unexpect aCatch(SalomeException);
1247 return _myMeshDS->GetMeshInfo().NbPolyhedrons();
1250 //================================================================================
1252 * \brief Return number of submeshes in the mesh
1254 //================================================================================
1256 int SMESH_Mesh::NbSubMesh() throw(SALOME_Exception)
1258 Unexpect aCatch(SalomeException);
1259 return _myMeshDS->NbSubMesh();
1262 //=======================================================================
1263 //function : IsNotConformAllowed
1264 //purpose : check if a hypothesis alowing notconform mesh is present
1265 //=======================================================================
1267 bool SMESH_Mesh::IsNotConformAllowed() const
1269 if(MYDEBUG) MESSAGE("SMESH_Mesh::IsNotConformAllowed");
1271 static SMESH_HypoFilter filter( SMESH_HypoFilter::HasName( "NotConformAllowed" ));
1272 return GetHypothesis( _myMeshDS->ShapeToMesh(), filter, false );
1275 //=======================================================================
1276 //function : IsMainShape
1278 //=======================================================================
1280 bool SMESH_Mesh::IsMainShape(const TopoDS_Shape& theShape) const
1282 return theShape.IsSame(_myMeshDS->ShapeToMesh() );
1285 //=============================================================================
1289 //=============================================================================
1291 SMESH_Group* SMESH_Mesh::AddGroup (const SMDSAbs_ElementType theType,
1292 const char* theName,
1294 const TopoDS_Shape& theShape)
1296 if (_mapGroup.find(_groupId) != _mapGroup.end())
1299 SMESH_Group* aGroup = new SMESH_Group (theId, this, theType, theName, theShape);
1300 GetMeshDS()->AddGroup( aGroup->GetGroupDS() );
1301 _mapGroup[_groupId++] = aGroup;
1305 //================================================================================
1307 * \brief Return iterator on all existing groups
1309 //================================================================================
1311 SMESH_Mesh::GroupIteratorPtr SMESH_Mesh::GetGroups() const
1313 typedef map <int, SMESH_Group *> TMap;
1314 return GroupIteratorPtr( new SMDS_mapIterator<TMap>( _mapGroup ));
1317 //=============================================================================
1319 * \brief Return a group by ID
1321 //=============================================================================
1323 SMESH_Group* SMESH_Mesh::GetGroup (const int theGroupID)
1325 if (_mapGroup.find(theGroupID) == _mapGroup.end())
1327 return _mapGroup[theGroupID];
1331 //=============================================================================
1333 * \brief Return IDs of all groups
1335 //=============================================================================
1337 std::list<int> SMESH_Mesh::GetGroupIds() const
1339 std::list<int> anIds;
1340 for ( std::map<int, SMESH_Group*>::const_iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ )
1341 anIds.push_back( it->first );
1347 //=============================================================================
1351 //=============================================================================
1353 void SMESH_Mesh::RemoveGroup (const int theGroupID)
1355 if (_mapGroup.find(theGroupID) == _mapGroup.end())
1357 GetMeshDS()->RemoveGroup( _mapGroup[theGroupID]->GetGroupDS() );
1358 delete _mapGroup[theGroupID];
1359 _mapGroup.erase (theGroupID);
1362 //=======================================================================
1363 //function : GetAncestors
1364 //purpose : return list of ancestors of theSubShape in the order
1365 // that lower dimention shapes come first.
1366 //=======================================================================
1368 const TopTools_ListOfShape& SMESH_Mesh::GetAncestors(const TopoDS_Shape& theS) const
1370 if ( _mapAncestors.Contains( theS ) )
1371 return _mapAncestors.FindFromKey( theS );
1373 static TopTools_ListOfShape emptyList;
1377 //=======================================================================
1379 //purpose : dumps contents of mesh to stream [ debug purposes ]
1380 //=======================================================================
1382 ostream& SMESH_Mesh::Dump(ostream& save)
1385 save << "========================== Dump contents of mesh ==========================" << endl << endl;
1386 save << ++clause << ") Total number of nodes: \t" << NbNodes() << endl;
1387 save << ++clause << ") Total number of edges: \t" << NbEdges() << endl;
1388 save << ++clause << ") Total number of faces: \t" << NbFaces() << endl;
1389 save << ++clause << ") Total number of polygons:\t" << NbPolygons() << endl;
1390 save << ++clause << ") Total number of volumes:\t" << NbVolumes() << endl;
1391 save << ++clause << ") Total number of polyhedrons:\t" << NbPolyhedrons() << endl << endl;
1392 for ( int isQuadratic = 0; isQuadratic < 2; ++isQuadratic )
1394 string orderStr = isQuadratic ? "quadratic" : "linear";
1395 SMDSAbs_ElementOrder order = isQuadratic ? ORDER_QUADRATIC : ORDER_LINEAR;
1397 save << ++clause << ") Total number of " << orderStr << " edges:\t" << NbEdges(order) << endl;
1398 save << ++clause << ") Total number of " << orderStr << " faces:\t" << NbFaces(order) << endl;
1399 if ( NbFaces(order) > 0 ) {
1400 int nb3 = NbTriangles(order);
1401 int nb4 = NbQuadrangles(order);
1402 save << clause << ".1) Number of " << orderStr << " triangles: \t" << nb3 << endl;
1403 save << clause << ".2) Number of " << orderStr << " quadrangles:\t" << nb4 << endl;
1404 if ( nb3 + nb4 != NbFaces(order) ) {
1405 std::map<int,int> myFaceMap;
1406 SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
1407 while( itFaces->more( ) ) {
1408 int nbNodes = itFaces->next()->NbNodes();
1409 if ( myFaceMap.find( nbNodes ) == myFaceMap.end() )
1410 myFaceMap[ nbNodes ] = 0;
1411 myFaceMap[ nbNodes ] = myFaceMap[ nbNodes ] + 1;
1413 save << clause << ".3) Faces in detail: " << endl;
1414 map <int,int>::iterator itF;
1415 for (itF = myFaceMap.begin(); itF != myFaceMap.end(); itF++)
1416 save << "--> nb nodes: " << itF->first << " - nb elemens:\t" << itF->second << endl;
1419 save << ++clause << ") Total number of " << orderStr << " volumes:\t" << NbVolumes(order) << endl;
1420 if ( NbVolumes(order) > 0 ) {
1421 int nb8 = NbHexas(order);
1422 int nb4 = NbTetras(order);
1423 int nb5 = NbPyramids(order);
1424 int nb6 = NbPrisms(order);
1425 save << clause << ".1) Number of " << orderStr << " hexahedrons:\t" << nb8 << endl;
1426 save << clause << ".2) Number of " << orderStr << " tetrahedrons:\t" << nb4 << endl;
1427 save << clause << ".3) Number of " << orderStr << " prisms: \t" << nb6 << endl;
1428 save << clause << ".4) Number of " << orderStr << " pyramids:\t" << nb5 << endl;
1429 if ( nb8 + nb4 + nb5 + nb6 != NbVolumes(order) ) {
1430 std::map<int,int> myVolumesMap;
1431 SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
1432 while( itVolumes->more( ) ) {
1433 int nbNodes = itVolumes->next()->NbNodes();
1434 if ( myVolumesMap.find( nbNodes ) == myVolumesMap.end() )
1435 myVolumesMap[ nbNodes ] = 0;
1436 myVolumesMap[ nbNodes ] = myVolumesMap[ nbNodes ] + 1;
1438 save << clause << ".5) Volumes in detail: " << endl;
1439 map <int,int>::iterator itV;
1440 for (itV = myVolumesMap.begin(); itV != myVolumesMap.end(); itV++)
1441 save << "--> nb nodes: " << itV->first << " - nb elemens:\t" << itV->second << endl;
1446 save << "===========================================================================" << endl;
1450 //=======================================================================
1451 //function : GetElementType
1452 //purpose : Returns type of mesh element with certain id
1453 //=======================================================================
1455 SMDSAbs_ElementType SMESH_Mesh::GetElementType( const int id, const bool iselem )
1457 return _myMeshDS->GetElementType( id, iselem );