1 // SMESH SMESH : implementaion of SMESH idl descriptions
3 // Copyright (C) 2003 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
24 // File : SMESH_Mesh.cxx
25 // Author : Paul RASCLE, EDF
29 #include "SMESH_Mesh.hxx"
30 #include "SMESH_subMesh.hxx"
31 #include "SMESH_Gen.hxx"
32 #include "SMESH_Hypothesis.hxx"
33 #include "SMESH_Group.hxx"
34 #include "SMESH_HypoFilter.hxx"
35 #include "SMESHDS_Group.hxx"
36 #include "SMESHDS_Script.hxx"
37 #include "SMESHDS_GroupOnGeom.hxx"
38 #include "SMESHDS_Document.hxx"
39 #include "SMDS_MeshVolume.hxx"
40 #include "SMDS_SetIterator.hxx"
42 #include "utilities.h"
44 #include "DriverMED_W_SMESHDS_Mesh.h"
45 #include "DriverDAT_W_SMDS_Mesh.h"
46 #include "DriverUNV_W_SMDS_Mesh.h"
47 #include "DriverSTL_W_SMDS_Mesh.h"
49 #include "DriverMED_R_SMESHDS_Mesh.h"
50 #include "DriverUNV_R_SMDS_Mesh.h"
51 #include "DriverSTL_R_SMDS_Mesh.h"
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;
72 #define cSMESH_Hyp(h) static_cast<const SMESH_Hypothesis*>(h)
74 typedef SMESH_HypoFilter THypType;
76 //=============================================================================
80 //=============================================================================
82 SMESH_Mesh::SMESH_Mesh(int theLocalId,
85 bool theIsEmbeddedMode,
86 SMESHDS_Document* theDocument):
89 MESSAGE("SMESH_Mesh::SMESH_Mesh(int localId)");
91 _studyId = theStudyId;
93 _myDocument = theDocument;
94 _idDoc = theDocument->NewMesh(theIsEmbeddedMode);
95 _myMeshDS = theDocument->GetMesh(_idDoc);
96 _isShapeToMesh = false;
98 _myMeshDS->ShapeToMesh( PseudoShape() );
101 //=============================================================================
105 //=============================================================================
107 SMESH_Mesh::~SMESH_Mesh()
109 INFOS("SMESH_Mesh::~SMESH_Mesh");
112 std::map < int, SMESH_Group * >::iterator itg;
113 for (itg = _mapGroup.begin(); itg != _mapGroup.end(); itg++) {
114 SMESH_Group *aGroup = (*itg).second;
120 //=============================================================================
122 * \brief Set geometry to be meshed
124 //=============================================================================
126 void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape)
128 if(MYDEBUG) MESSAGE("SMESH_Mesh::ShapeToMesh");
130 if ( !aShape.IsNull() && _isShapeToMesh )
131 throw SALOME_Exception(LOCALIZED ("a shape to mesh has already been defined"));
133 // clear current data
134 if ( !_myMeshDS->ShapeToMesh().IsNull() )
136 // removal of a shape to mesh, delete objects referring to sub-shapes:
138 std::map <int, SMESH_subMesh *>::iterator i_sm = _mapSubMesh.begin();
139 for ( ; i_sm != _mapSubMesh.end(); ++i_sm )
142 // - groups on geometry
143 std::map <int, SMESH_Group *>::iterator i_gr = _mapGroup.begin();
144 while ( i_gr != _mapGroup.end() ) {
145 if ( dynamic_cast<SMESHDS_GroupOnGeom*>( i_gr->second->GetGroupDS() )) {
146 _myMeshDS->RemoveGroup( i_gr->second->GetGroupDS() );
148 _mapGroup.erase( i_gr++ );
153 _mapAncestors.Clear();
156 TopoDS_Shape aNullShape;
157 _myMeshDS->ShapeToMesh( aNullShape );
160 // set a new geometry
161 if ( !aShape.IsNull() )
163 _myMeshDS->ShapeToMesh(aShape);
164 _isShapeToMesh = true;
166 // fill _mapAncestors
167 int desType, ancType;
168 for ( desType = TopAbs_VERTEX; desType > TopAbs_COMPOUND; desType-- )
169 for ( ancType = desType - 1; ancType >= TopAbs_COMPOUND; ancType-- )
170 TopExp::MapShapesAndAncestors ( aShape,
171 (TopAbs_ShapeEnum) desType,
172 (TopAbs_ShapeEnum) ancType,
177 //=======================================================================
179 * \brief Return geometry to be meshed. (It may be a PseudoShape()!)
181 //=======================================================================
183 TopoDS_Shape SMESH_Mesh::GetShapeToMesh() const
185 return _myMeshDS->ShapeToMesh();
188 //=======================================================================
190 * \brief Return a solid which is returned by GetShapeToMesh() if
191 * a real geometry to be meshed was not set
193 //=======================================================================
195 const TopoDS_Solid& SMESH_Mesh::PseudoShape()
197 static TopoDS_Solid aSolid;
198 if ( aSolid.IsNull() )
200 aSolid = BRepPrimAPI_MakeBox(1,1,1);
205 //=======================================================================
207 * \brief Remove all nodes and elements
209 //=======================================================================
211 void SMESH_Mesh::Clear()
213 // clear sub-meshes; get ready to re-compute as a side-effect
215 if ( SMESH_subMesh *sm = GetSubMeshContaining( GetShapeToMesh() ) )
217 SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(/*includeSelf=*/true,
218 /*complexShapeFirst=*/false);
219 while ( smIt->more() )
222 TopAbs_ShapeEnum shapeType = sm->GetSubShape().ShapeType();
223 if ( shapeType == TopAbs_VERTEX || shapeType < TopAbs_SOLID )
224 // all other shapes depends on vertices so they are already cleaned
225 sm->ComputeStateEngine( SMESH_subMesh::CLEAN );
226 // to recompute even if failed
227 sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
231 // clear entities not on sub-meshes
233 SMDS_VolumeIteratorPtr vIt = _myMeshDS->volumesIterator();
234 while ( vIt->more() )
235 _myMeshDS->RemoveFreeElement( vIt->next(), 0 );
237 SMDS_FaceIteratorPtr fIt = _myMeshDS->facesIterator();
238 while ( fIt->more() )
239 _myMeshDS->RemoveFreeElement( fIt->next(), 0 );
241 SMDS_EdgeIteratorPtr eIt = _myMeshDS->edgesIterator();
242 while ( eIt->more() )
243 _myMeshDS->RemoveFreeElement( eIt->next(), 0 );
245 SMDS_NodeIteratorPtr nIt = _myMeshDS->nodesIterator();
246 while ( nIt->more() ) {
247 const SMDS_MeshNode * node = nIt->next();
248 if ( node->NbInverseElements() == 0 )
249 _myMeshDS->RemoveFreeNode( node, 0 );
251 _myMeshDS->RemoveNode(node);
255 //=======================================================================
256 //function : UNVToMesh
258 //=======================================================================
260 int SMESH_Mesh::UNVToMesh(const char* theFileName)
262 if(MYDEBUG) MESSAGE("UNVToMesh - theFileName = "<<theFileName);
264 throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
265 _isShapeToMesh = false;
266 DriverUNV_R_SMDS_Mesh myReader;
267 myReader.SetMesh(_myMeshDS);
268 myReader.SetFile(theFileName);
269 myReader.SetMeshId(-1);
272 MESSAGE("UNVToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
273 MESSAGE("UNVToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
274 MESSAGE("UNVToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
275 MESSAGE("UNVToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
277 SMDS_MeshGroup* aGroup = (SMDS_MeshGroup*) myReader.GetGroup();
279 TGroupNamesMap aGroupNames = myReader.GetGroupNamesMap();
280 //const TGroupIdMap& aGroupId = myReader.GetGroupIdMap();
281 aGroup->InitSubGroupsIterator();
282 while (aGroup->MoreSubGroups()) {
283 SMDS_MeshGroup* aSubGroup = (SMDS_MeshGroup*) aGroup->NextSubGroup();
284 std::string aName = aGroupNames[aSubGroup];
287 SMESH_Group* aSMESHGroup = AddGroup( aSubGroup->GetType(), aName.c_str(), aId );
289 if(MYDEBUG) MESSAGE("UNVToMesh - group added: "<<aName);
290 SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( aSMESHGroup->GetGroupDS() );
292 aGroupDS->SetStoreName(aName.c_str());
293 aSubGroup->InitIterator();
294 const SMDS_MeshElement* aElement = 0;
295 while (aSubGroup->More()) {
296 aElement = aSubGroup->Next();
298 aGroupDS->SMDSGroup().Add(aElement);
302 aGroupDS->SetType(aElement->GetType());
310 //=======================================================================
311 //function : MEDToMesh
313 //=======================================================================
315 int SMESH_Mesh::MEDToMesh(const char* theFileName, const char* theMeshName)
317 if(MYDEBUG) MESSAGE("MEDToMesh - theFileName = "<<theFileName<<", mesh name = "<<theMeshName);
319 throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
320 _isShapeToMesh = false;
321 DriverMED_R_SMESHDS_Mesh myReader;
322 myReader.SetMesh(_myMeshDS);
323 myReader.SetMeshId(-1);
324 myReader.SetFile(theFileName);
325 myReader.SetMeshName(theMeshName);
326 Driver_Mesh::Status status = myReader.Perform();
328 MESSAGE("MEDToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
329 MESSAGE("MEDToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
330 MESSAGE("MEDToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
331 MESSAGE("MEDToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
334 // Reading groups (sub-meshes are out of scope of MED import functionality)
335 std::list<TNameAndType> aGroupNames = myReader.GetGroupNamesAndTypes();
336 if(MYDEBUG) MESSAGE("MEDToMesh - Nb groups = "<<aGroupNames.size());
338 std::list<TNameAndType>::iterator name_type = aGroupNames.begin();
339 for ( ; name_type != aGroupNames.end(); name_type++ ) {
340 SMESH_Group* aGroup = AddGroup( name_type->second, name_type->first.c_str(), anId );
342 if(MYDEBUG) MESSAGE("MEDToMesh - group added: "<<name_type->first.c_str());
343 SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( aGroup->GetGroupDS() );
345 aGroupDS->SetStoreName( name_type->first.c_str() );
346 myReader.GetGroup( aGroupDS );
353 //=======================================================================
354 //function : STLToMesh
356 //=======================================================================
358 int SMESH_Mesh::STLToMesh(const char* theFileName)
360 if(MYDEBUG) MESSAGE("STLToMesh - theFileName = "<<theFileName);
362 throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
363 _isShapeToMesh = false;
364 DriverSTL_R_SMDS_Mesh myReader;
365 myReader.SetMesh(_myMeshDS);
366 myReader.SetFile(theFileName);
367 myReader.SetMeshId(-1);
370 MESSAGE("STLToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
371 MESSAGE("STLToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
372 MESSAGE("STLToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
373 MESSAGE("STLToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
378 //=============================================================================
382 //=============================================================================
384 SMESH_Hypothesis::Hypothesis_Status
385 SMESH_Mesh::AddHypothesis(const TopoDS_Shape & aSubShape,
386 int anHypId ) throw(SALOME_Exception)
388 Unexpect aCatch(SalomeException);
389 if(MYDEBUG) MESSAGE("SMESH_Mesh::AddHypothesis");
391 SMESH_subMesh *subMesh = GetSubMesh(aSubShape);
392 if ( !subMesh || !subMesh->GetId())
393 return SMESH_Hypothesis::HYP_BAD_SUBSHAPE;
395 SMESHDS_SubMesh *subMeshDS = subMesh->GetSubMeshDS();
396 if ( subMeshDS && subMeshDS->IsComplexSubmesh() ) // group of sub-shapes and maybe of not sub-
398 MESSAGE("AddHypothesis() to complex submesh");
399 // return the worst but not fatal state of all group memebers
400 SMESH_Hypothesis::Hypothesis_Status aBestRet, aWorstNotFatal, ret;
401 aBestRet = SMESH_Hypothesis::HYP_BAD_DIM;
402 aWorstNotFatal = SMESH_Hypothesis::HYP_OK;
403 for ( TopoDS_Iterator itS ( aSubShape ); itS.More(); itS.Next())
405 if ( !GetMeshDS()->ShapeToIndex( itS.Value() ))
406 continue; // not sub-shape
407 ret = AddHypothesis( itS.Value(), anHypId );
408 if ( !SMESH_Hypothesis::IsStatusFatal( ret ) && ret > aWorstNotFatal )
409 aWorstNotFatal = ret;
410 if ( ret < aBestRet )
413 // bind hypotheses to a group just to know
414 SMESH_Hypothesis *anHyp = _gen->GetStudyContext(_studyId)->mapHypothesis[anHypId];
415 GetMeshDS()->AddHypothesis( aSubShape, anHyp );
417 if ( SMESH_Hypothesis::IsStatusFatal( aBestRet ))
419 return aWorstNotFatal;
422 StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
423 if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
425 if(MYDEBUG) MESSAGE("Hypothesis ID does not give an hypothesis");
430 throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
433 SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
434 MESSAGE( "SMESH_Mesh::AddHypothesis " << anHyp->GetName() );
436 bool isGlobalHyp = IsMainShape( aSubShape );
438 // NotConformAllowed can be only global
441 string hypName = anHyp->GetName();
442 if ( hypName == "NotConformAllowed" )
444 if(MYDEBUG) MESSAGE( "Hypotesis <NotConformAllowed> can be only global" );
445 return SMESH_Hypothesis::HYP_INCOMPATIBLE;
451 bool isAlgo = ( !anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO );
452 int event = isAlgo ? SMESH_subMesh::ADD_ALGO : SMESH_subMesh::ADD_HYP;
454 SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp);
457 if (!SMESH_Hypothesis::IsStatusFatal(ret) &&
458 anHyp->GetDim() <= SMESH_Gen::GetShapeDim(aSubShape)) // is added on father
460 event = isAlgo ? SMESH_subMesh::ADD_FATHER_ALGO : SMESH_subMesh::ADD_FATHER_HYP;
462 SMESH_Hypothesis::Hypothesis_Status ret2 =
463 subMesh->SubMeshesAlgoStateEngine(event, anHyp);
467 // check concurent hypotheses on ansestors
468 if (ret < SMESH_Hypothesis::HYP_CONCURENT && !isGlobalHyp )
470 SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false);
471 while ( smIt->more() ) {
472 SMESH_subMesh* sm = smIt->next();
473 if ( sm->IsApplicableHypotesis( anHyp )) {
474 ret2 = sm->CheckConcurentHypothesis( anHyp->GetType() );
484 if(MYDEBUG) subMesh->DumpAlgoState(true);
489 //=============================================================================
493 //=============================================================================
495 SMESH_Hypothesis::Hypothesis_Status
496 SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape & aSubShape,
497 int anHypId)throw(SALOME_Exception)
499 Unexpect aCatch(SalomeException);
500 if(MYDEBUG) MESSAGE("SMESH_Mesh::RemoveHypothesis");
502 SMESH_subMesh *subMesh = GetSubMesh(aSubShape);
503 SMESHDS_SubMesh *subMeshDS = subMesh->GetSubMeshDS();
504 if ( subMeshDS && subMeshDS->IsComplexSubmesh() )
506 // return the worst but not fatal state of all group memebers
507 SMESH_Hypothesis::Hypothesis_Status aBestRet, aWorstNotFatal, ret;
508 aBestRet = SMESH_Hypothesis::HYP_BAD_DIM;
509 aWorstNotFatal = SMESH_Hypothesis::HYP_OK;
510 for ( TopoDS_Iterator itS ( aSubShape ); itS.More(); itS.Next())
512 if ( !GetMeshDS()->ShapeToIndex( itS.Value() ))
513 continue; // not sub-shape
514 ret = RemoveHypothesis( itS.Value(), anHypId );
515 if ( !SMESH_Hypothesis::IsStatusFatal( ret ) && ret > aWorstNotFatal )
516 aWorstNotFatal = ret;
517 if ( ret < aBestRet )
520 SMESH_Hypothesis *anHyp = _gen->GetStudyContext(_studyId)->mapHypothesis[anHypId];
521 GetMeshDS()->RemoveHypothesis( aSubShape, anHyp );
523 if ( SMESH_Hypothesis::IsStatusFatal( aBestRet ))
525 return aWorstNotFatal;
528 StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
529 if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
530 throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
532 SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
533 int hypType = anHyp->GetType();
534 if(MYDEBUG) SCRUTE(hypType);
538 bool isAlgo = ( !anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO );
539 int event = isAlgo ? SMESH_subMesh::REMOVE_ALGO : SMESH_subMesh::REMOVE_HYP;
541 SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp);
543 // there may appear concurrent hyps that were covered by the removed hyp
544 if (ret < SMESH_Hypothesis::HYP_CONCURENT &&
545 subMesh->IsApplicableHypotesis( anHyp ) &&
546 subMesh->CheckConcurentHypothesis( anHyp->GetType() ) != SMESH_Hypothesis::HYP_OK)
547 ret = SMESH_Hypothesis::HYP_CONCURENT;
550 if (!SMESH_Hypothesis::IsStatusFatal(ret) &&
551 anHyp->GetDim() <= SMESH_Gen::GetShapeDim(aSubShape)) // is removed from father
553 event = isAlgo ? SMESH_subMesh::REMOVE_FATHER_ALGO : SMESH_subMesh::REMOVE_FATHER_HYP;
555 SMESH_Hypothesis::Hypothesis_Status ret2 =
556 subMesh->SubMeshesAlgoStateEngine(event, anHyp);
557 if (ret2 > ret) // more severe
560 // check concurent hypotheses on ansestors
561 if (ret < SMESH_Hypothesis::HYP_CONCURENT && !IsMainShape( aSubShape ) )
563 SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false);
564 while ( smIt->more() ) {
565 SMESH_subMesh* sm = smIt->next();
566 if ( sm->IsApplicableHypotesis( anHyp )) {
567 ret2 = sm->CheckConcurentHypothesis( anHyp->GetType() );
577 if(MYDEBUG) subMesh->DumpAlgoState(true);
578 if(MYDEBUG) SCRUTE(ret);
582 //=============================================================================
586 //=============================================================================
588 const std::list<const SMESHDS_Hypothesis*>&
589 SMESH_Mesh::GetHypothesisList(const TopoDS_Shape & aSubShape) const
590 throw(SALOME_Exception)
592 Unexpect aCatch(SalomeException);
593 return _myMeshDS->GetHypothesis(aSubShape);
596 //=======================================================================
598 * \brief Return the hypothesis assigned to the shape
599 * \param aSubShape - the shape to check
600 * \param aFilter - the hypothesis filter
601 * \param andAncestors - flag to check hypos assigned to ancestors of the shape
602 * \retval SMESH_Hypothesis* - the first hypo passed through aFilter
604 //=======================================================================
606 const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubShape,
607 const SMESH_HypoFilter& aFilter,
608 const bool andAncestors) const
611 const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
612 std::list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
613 for ( ; hyp != hypList.end(); hyp++ ) {
614 const SMESH_Hypothesis * h = cSMESH_Hyp( *hyp );
615 if ( aFilter.IsOk( h, aSubShape))
621 TopTools_ListIteratorOfListOfShape it( GetAncestors( aSubShape ));
622 for (; it.More(); it.Next() )
624 const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value());
625 std::list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
626 for ( ; hyp != hypList.end(); hyp++ ) {
627 const SMESH_Hypothesis * h = cSMESH_Hyp( *hyp );
628 if (aFilter.IsOk( h, it.Value() ))
636 //================================================================================
638 * \brief Return hypothesis assigned to the shape
639 * \param aSubShape - the shape to check
640 * \param aFilter - the hypothesis filter
641 * \param aHypList - the list of the found hypotheses
642 * \param andAncestors - flag to check hypos assigned to ancestors of the shape
643 * \retval int - number of unique hypos in aHypList
645 //================================================================================
647 int SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape,
648 const SMESH_HypoFilter& aFilter,
649 list <const SMESHDS_Hypothesis * >& aHypList,
650 const bool andAncestors) const
652 set<string> hypTypes; // to exclude same type hypos from the result list
655 // only one main hypothesis is allowed
656 bool mainHypFound = false;
659 std::list<const SMESHDS_Hypothesis*>::const_iterator hyp;
660 for ( hyp = aHypList.begin(); hyp != aHypList.end(); hyp++ ) {
661 if ( hypTypes.insert( (*hyp)->GetName() ).second )
663 if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
667 // get hypos from aSubShape
669 const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
670 for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
671 if ( aFilter.IsOk (cSMESH_Hyp( *hyp ), aSubShape) &&
672 ( cSMESH_Hyp(*hyp)->IsAuxiliary() || !mainHypFound ) &&
673 hypTypes.insert( (*hyp)->GetName() ).second )
675 aHypList.push_back( *hyp );
677 if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
682 // get hypos from ancestors of aSubShape
685 TopTools_MapOfShape map;
686 TopTools_ListIteratorOfListOfShape it( GetAncestors( aSubShape ));
687 for (; it.More(); it.Next() )
689 if ( !map.Add( it.Value() ))
691 const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value());
692 for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
693 if (aFilter.IsOk( cSMESH_Hyp( *hyp ), it.Value() ) &&
694 ( cSMESH_Hyp(*hyp)->IsAuxiliary() || !mainHypFound ) &&
695 hypTypes.insert( (*hyp)->GetName() ).second )
697 aHypList.push_back( *hyp );
699 if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
707 //=============================================================================
711 //=============================================================================
713 const std::list<SMESHDS_Command*> & SMESH_Mesh::GetLog() throw(SALOME_Exception)
715 Unexpect aCatch(SalomeException);
716 if(MYDEBUG) MESSAGE("SMESH_Mesh::GetLog");
717 return _myMeshDS->GetScript()->GetCommands();
720 //=============================================================================
724 //=============================================================================
725 void SMESH_Mesh::ClearLog() throw(SALOME_Exception)
727 Unexpect aCatch(SalomeException);
728 if(MYDEBUG) MESSAGE("SMESH_Mesh::ClearLog");
729 _myMeshDS->GetScript()->Clear();
732 //=============================================================================
734 * Get or Create the SMESH_subMesh object implementation
736 //=============================================================================
738 SMESH_subMesh *SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape)
739 throw(SALOME_Exception)
741 Unexpect aCatch(SalomeException);
742 SMESH_subMesh *aSubMesh;
743 int index = _myMeshDS->ShapeToIndex(aSubShape);
745 // for submeshes on GEOM Group
746 if ( !index && aSubShape.ShapeType() == TopAbs_COMPOUND ) {
747 TopoDS_Iterator it( aSubShape );
749 index = _myMeshDS->AddCompoundSubmesh( aSubShape, it.Value().ShapeType() );
752 // return NULL; // neither sub-shape nor a group
754 map <int, SMESH_subMesh *>::iterator i_sm = _mapSubMesh.find(index);
755 if ( i_sm != _mapSubMesh.end())
757 aSubMesh = i_sm->second;
761 aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape);
762 _mapSubMesh[index] = aSubMesh;
767 //=============================================================================
769 * Get the SMESH_subMesh object implementation. Dont create it, return null
770 * if it does not exist.
772 //=============================================================================
774 SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape) const
775 throw(SALOME_Exception)
777 Unexpect aCatch(SalomeException);
778 SMESH_subMesh *aSubMesh = NULL;
780 int index = _myMeshDS->ShapeToIndex(aSubShape);
782 map <int, SMESH_subMesh *>::const_iterator i_sm = _mapSubMesh.find(index);
783 if ( i_sm != _mapSubMesh.end())
784 aSubMesh = i_sm->second;
788 //=============================================================================
790 * Get the SMESH_subMesh object implementation. Dont create it, return null
791 * if it does not exist.
793 //=============================================================================
795 SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const int aShapeID) const
796 throw(SALOME_Exception)
798 Unexpect aCatch(SalomeException);
800 map <int, SMESH_subMesh *>::const_iterator i_sm = _mapSubMesh.find(aShapeID);
801 if (i_sm == _mapSubMesh.end())
805 //================================================================================
807 * \brief Return submeshes of groups containing the given subshape
809 //================================================================================
811 std::list<SMESH_subMesh*>
812 SMESH_Mesh::GetGroupSubMeshesContaining(const TopoDS_Shape & aSubShape) const
813 throw(SALOME_Exception)
815 Unexpect aCatch(SalomeException);
816 std::list<SMESH_subMesh*> found;
818 SMESH_subMesh * subMesh = GetSubMeshContaining(aSubShape);
822 // submeshes of groups have max IDs, so search from the map end
823 std::map<int, SMESH_subMesh *>::const_reverse_iterator i_sm;
824 for ( i_sm = _mapSubMesh.rbegin(); i_sm != _mapSubMesh.rend(); ++i_sm) {
825 SMESHDS_SubMesh * ds = i_sm->second->GetSubMeshDS();
826 if ( ds && ds->IsComplexSubmesh() ) {
827 TopExp_Explorer exp( i_sm->second->GetSubShape(), aSubShape.ShapeType() );
828 for ( ; exp.More(); exp.Next() ) {
829 if ( aSubShape.IsSame( exp.Current() )) {
830 found.push_back( i_sm->second );
840 //=======================================================================
841 //function : IsUsedHypothesis
842 //purpose : Return True if anHyp is used to mesh aSubShape
843 //=======================================================================
845 bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
846 const SMESH_subMesh* aSubMesh)
848 SMESH_Hypothesis* hyp = static_cast<SMESH_Hypothesis*>(anHyp);
850 // check if anHyp can be used to mesh aSubMesh
851 if ( !aSubMesh || !aSubMesh->IsApplicableHypotesis( hyp ))
854 const TopoDS_Shape & aSubShape = const_cast<SMESH_subMesh*>( aSubMesh )->GetSubShape();
856 SMESH_Algo *algo = _gen->GetAlgo(*this, aSubShape );
859 if (anHyp->GetType() > SMESHDS_Hypothesis::PARAM_ALGO)
860 return ( anHyp == algo );
862 // algorithm parameter
865 // look trough hypotheses used by algo
866 SMESH_HypoFilter hypoKind;
867 if ( algo->InitCompatibleHypoFilter( hypoKind, !hyp->IsAuxiliary() )) {
868 list <const SMESHDS_Hypothesis * > usedHyps;
869 if ( GetHypotheses( aSubShape, hypoKind, usedHyps, true ))
870 return ( find( usedHyps.begin(), usedHyps.end(), anHyp ) != usedHyps.end() );
874 // look through all assigned hypotheses
875 //SMESH_HypoFilter filter( SMESH_HypoFilter::Is( hyp ));
876 return false; //GetHypothesis( aSubShape, filter, true );
879 //=============================================================================
883 //=============================================================================
885 const list < SMESH_subMesh * >&
886 SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
887 throw(SALOME_Exception)
889 Unexpect aCatch(SalomeException);
890 if(MYDEBUG) MESSAGE("SMESH_Mesh::GetSubMeshUsingHypothesis");
891 map < int, SMESH_subMesh * >::iterator itsm;
892 _subMeshesUsingHypothesisList.clear();
893 for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
895 SMESH_subMesh *aSubMesh = (*itsm).second;
896 if ( IsUsedHypothesis ( anHyp, aSubMesh ))
897 _subMeshesUsingHypothesisList.push_back(aSubMesh);
899 return _subMeshesUsingHypothesisList;
902 //=======================================================================
903 //function : NotifySubMeshesHypothesisModification
904 //purpose : Say all submeshes using theChangedHyp that it has been modified
905 //=======================================================================
907 void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* hyp)
909 Unexpect aCatch(SalomeException);
911 const SMESH_Algo *foundAlgo = 0;
912 SMESH_HypoFilter algoKind, compatibleHypoKind;
913 list <const SMESHDS_Hypothesis * > usedHyps;
916 map < int, SMESH_subMesh * >::iterator itsm;
917 for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
919 SMESH_subMesh *aSubMesh = (*itsm).second;
920 if ( aSubMesh->IsApplicableHypotesis( hyp ))
922 const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape();
924 if ( !foundAlgo ) // init filter for algo search
925 algoKind.Init( THypType::IsAlgo() ).And( THypType::IsApplicableTo( aSubShape ));
927 const SMESH_Algo *algo = static_cast<const SMESH_Algo*>
928 ( GetHypothesis( aSubShape, algoKind, true ));
932 bool sameAlgo = ( algo == foundAlgo );
933 if ( !sameAlgo && foundAlgo )
934 sameAlgo = ( strcmp( algo->GetName(), foundAlgo->GetName() ) == 0);
936 if ( !sameAlgo ) { // init filter for used hypos search
937 if ( !algo->InitCompatibleHypoFilter( compatibleHypoKind, !hyp->IsAuxiliary() ))
938 continue; // algo does not use any hypothesis
942 // check if hyp is used by algo
944 if ( GetHypotheses( aSubShape, compatibleHypoKind, usedHyps, true ) &&
945 find( usedHyps.begin(), usedHyps.end(), hyp ) != usedHyps.end() )
947 aSubMesh->AlgoStateEngine(SMESH_subMesh::MODIF_HYP,
948 const_cast< SMESH_Hypothesis*>( hyp ));
955 //=============================================================================
957 * Auto color functionality
959 //=============================================================================
960 void SMESH_Mesh::SetAutoColor(bool theAutoColor) throw(SALOME_Exception)
962 Unexpect aCatch(SalomeException);
963 _isAutoColor = theAutoColor;
966 bool SMESH_Mesh::GetAutoColor() throw(SALOME_Exception)
968 Unexpect aCatch(SalomeException);
972 //=============================================================================
974 * To store mesh contents on disk in different formats.
976 //=============================================================================
978 bool SMESH_Mesh::HasDuplicatedGroupNamesMED()
980 set<string> aGroupNames;
981 for ( std::map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
982 SMESH_Group* aGroup = it->second;
983 std::string aGroupName = aGroup->GetName();
984 aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
985 if (!aGroupNames.insert(aGroupName).second)
992 void SMESH_Mesh::ExportMED(const char *file,
993 const char* theMeshName,
996 throw(SALOME_Exception)
998 Unexpect aCatch(SalomeException);
1000 DriverMED_W_SMESHDS_Mesh myWriter;
1001 myWriter.SetFile ( file, MED::EVersion(theVersion) );
1002 myWriter.SetMesh ( _myMeshDS );
1004 myWriter.SetMeshId ( _idDoc );
1006 myWriter.SetMeshId ( -1 );
1007 myWriter.SetMeshName( theMeshName );
1010 if ( theAutoGroups ) {
1011 myWriter.AddGroupOfNodes();
1012 myWriter.AddGroupOfEdges();
1013 myWriter.AddGroupOfFaces();
1014 myWriter.AddGroupOfVolumes();
1017 // Pass groups to writer. Provide unique group names.
1018 set<string> aGroupNames;
1020 int maxNbIter = 10000; // to guarantee cycle finish
1021 for ( std::map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
1022 SMESH_Group* aGroup = it->second;
1023 SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
1025 string aGroupName0 = aGroup->GetName();
1026 aGroupName0.resize(MAX_MED_GROUP_NAME_LENGTH);
1027 string aGroupName = aGroupName0;
1028 for (int i = 1; !aGroupNames.insert(aGroupName).second && i < maxNbIter; i++) {
1029 sprintf(&aString[0], "GR_%d_%s", i, aGroupName0.c_str());
1030 aGroupName = aString;
1031 aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
1033 aGroupDS->SetStoreName( aGroupName.c_str() );
1034 myWriter.AddGroup( aGroupDS );
1042 void SMESH_Mesh::ExportDAT(const char *file) throw(SALOME_Exception)
1044 Unexpect aCatch(SalomeException);
1045 DriverDAT_W_SMDS_Mesh myWriter;
1046 myWriter.SetFile(string(file));
1047 myWriter.SetMesh(_myMeshDS);
1048 myWriter.SetMeshId(_idDoc);
1052 void SMESH_Mesh::ExportUNV(const char *file) throw(SALOME_Exception)
1054 Unexpect aCatch(SalomeException);
1055 DriverUNV_W_SMDS_Mesh myWriter;
1056 myWriter.SetFile(string(file));
1057 myWriter.SetMesh(_myMeshDS);
1058 myWriter.SetMeshId(_idDoc);
1059 // myWriter.SetGroups(_mapGroup);
1061 for ( std::map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
1062 SMESH_Group* aGroup = it->second;
1063 SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
1065 std::string aGroupName = aGroup->GetName();
1066 aGroupDS->SetStoreName( aGroupName.c_str() );
1067 myWriter.AddGroup( aGroupDS );
1073 void SMESH_Mesh::ExportSTL(const char *file, const bool isascii) throw(SALOME_Exception)
1075 Unexpect aCatch(SalomeException);
1076 DriverSTL_W_SMDS_Mesh myWriter;
1077 myWriter.SetFile(string(file));
1078 myWriter.SetIsAscii( isascii );
1079 myWriter.SetMesh(_myMeshDS);
1080 myWriter.SetMeshId(_idDoc);
1084 //================================================================================
1086 * \brief Return number of nodes in the mesh
1088 //================================================================================
1090 int SMESH_Mesh::NbNodes() throw(SALOME_Exception)
1092 Unexpect aCatch(SalomeException);
1093 return _myMeshDS->NbNodes();
1096 //================================================================================
1098 * \brief Return number of edges of given order in the mesh
1100 //================================================================================
1102 int SMESH_Mesh::NbEdges(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1104 Unexpect aCatch(SalomeException);
1105 return _myMeshDS->GetMeshInfo().NbEdges(order);
1108 //================================================================================
1110 * \brief Return number of faces of given order in the mesh
1112 //================================================================================
1114 int SMESH_Mesh::NbFaces(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1116 Unexpect aCatch(SalomeException);
1117 return _myMeshDS->GetMeshInfo().NbFaces(order);
1120 //================================================================================
1122 * \brief Return the number of faces in the mesh
1124 //================================================================================
1126 int SMESH_Mesh::NbTriangles(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1128 Unexpect aCatch(SalomeException);
1129 return _myMeshDS->GetMeshInfo().NbTriangles(order);
1132 //================================================================================
1134 * \brief Return the number nodes faces in the mesh
1136 //================================================================================
1138 int SMESH_Mesh::NbQuadrangles(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1140 Unexpect aCatch(SalomeException);
1141 return _myMeshDS->GetMeshInfo().NbQuadrangles(order);
1144 //================================================================================
1146 * \brief Return the number of polygonal faces in the mesh
1148 //================================================================================
1150 int SMESH_Mesh::NbPolygons() throw(SALOME_Exception)
1152 Unexpect aCatch(SalomeException);
1153 return _myMeshDS->GetMeshInfo().NbPolygons();
1156 //================================================================================
1158 * \brief Return number of volumes of given order in the mesh
1160 //================================================================================
1162 int SMESH_Mesh::NbVolumes(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1164 Unexpect aCatch(SalomeException);
1165 return _myMeshDS->GetMeshInfo().NbVolumes(order);
1168 //================================================================================
1170 * \brief Return number of tetrahedrons of given order in the mesh
1172 //================================================================================
1174 int SMESH_Mesh::NbTetras(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1176 Unexpect aCatch(SalomeException);
1177 return _myMeshDS->GetMeshInfo().NbTetras(order);
1180 //================================================================================
1182 * \brief Return number of hexahedrons of given order in the mesh
1184 //================================================================================
1186 int SMESH_Mesh::NbHexas(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1188 Unexpect aCatch(SalomeException);
1189 return _myMeshDS->GetMeshInfo().NbHexas(order);
1192 //================================================================================
1194 * \brief Return number of pyramids of given order in the mesh
1196 //================================================================================
1198 int SMESH_Mesh::NbPyramids(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1200 Unexpect aCatch(SalomeException);
1201 return _myMeshDS->GetMeshInfo().NbPyramids(order);
1204 //================================================================================
1206 * \brief Return number of prisms (penthahedrons) of given order in the mesh
1208 //================================================================================
1210 int SMESH_Mesh::NbPrisms(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1212 Unexpect aCatch(SalomeException);
1213 return _myMeshDS->GetMeshInfo().NbPrisms(order);
1216 //================================================================================
1218 * \brief Return number of polyhedrons in the mesh
1220 //================================================================================
1222 int SMESH_Mesh::NbPolyhedrons() throw(SALOME_Exception)
1224 Unexpect aCatch(SalomeException);
1225 return _myMeshDS->GetMeshInfo().NbPolyhedrons();
1228 //================================================================================
1230 * \brief Return number of submeshes in the mesh
1232 //================================================================================
1234 int SMESH_Mesh::NbSubMesh() throw(SALOME_Exception)
1236 Unexpect aCatch(SalomeException);
1237 return _myMeshDS->NbSubMesh();
1240 //=======================================================================
1241 //function : IsNotConformAllowed
1242 //purpose : check if a hypothesis alowing notconform mesh is present
1243 //=======================================================================
1245 bool SMESH_Mesh::IsNotConformAllowed() const
1247 if(MYDEBUG) MESSAGE("SMESH_Mesh::IsNotConformAllowed");
1249 static SMESH_HypoFilter filter( SMESH_HypoFilter::HasName( "NotConformAllowed" ));
1250 return GetHypothesis( _myMeshDS->ShapeToMesh(), filter, false );
1253 //=======================================================================
1254 //function : IsMainShape
1256 //=======================================================================
1258 bool SMESH_Mesh::IsMainShape(const TopoDS_Shape& theShape) const
1260 return theShape.IsSame(_myMeshDS->ShapeToMesh() );
1263 //=============================================================================
1267 //=============================================================================
1269 SMESH_Group* SMESH_Mesh::AddGroup (const SMDSAbs_ElementType theType,
1270 const char* theName,
1272 const TopoDS_Shape& theShape)
1274 if (_mapGroup.find(_groupId) != _mapGroup.end())
1277 SMESH_Group* aGroup = new SMESH_Group (theId, this, theType, theName, theShape);
1278 GetMeshDS()->AddGroup( aGroup->GetGroupDS() );
1279 _mapGroup[_groupId++] = aGroup;
1283 //================================================================================
1285 * \brief Return iterator on all existing groups
1287 //================================================================================
1289 SMESH_Mesh::GroupIteratorPtr SMESH_Mesh::GetGroups() const
1291 typedef map <int, SMESH_Group *> TMap;
1292 return GroupIteratorPtr( new SMDS_mapIterator<TMap>( _mapGroup ));
1295 //=============================================================================
1297 * \brief Return a group by ID
1299 //=============================================================================
1301 SMESH_Group* SMESH_Mesh::GetGroup (const int theGroupID)
1303 if (_mapGroup.find(theGroupID) == _mapGroup.end())
1305 return _mapGroup[theGroupID];
1309 //=============================================================================
1311 * \brief Return IDs of all groups
1313 //=============================================================================
1315 std::list<int> SMESH_Mesh::GetGroupIds() const
1317 std::list<int> anIds;
1318 for ( std::map<int, SMESH_Group*>::const_iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ )
1319 anIds.push_back( it->first );
1325 //=============================================================================
1329 //=============================================================================
1331 void SMESH_Mesh::RemoveGroup (const int theGroupID)
1333 if (_mapGroup.find(theGroupID) == _mapGroup.end())
1335 GetMeshDS()->RemoveGroup( _mapGroup[theGroupID]->GetGroupDS() );
1336 delete _mapGroup[theGroupID];
1337 _mapGroup.erase (theGroupID);
1340 //=======================================================================
1341 //function : GetAncestors
1342 //purpose : return list of ancestors of theSubShape in the order
1343 // that lower dimention shapes come first.
1344 //=======================================================================
1346 const TopTools_ListOfShape& SMESH_Mesh::GetAncestors(const TopoDS_Shape& theS) const
1348 if ( _mapAncestors.Contains( theS ) )
1349 return _mapAncestors.FindFromKey( theS );
1351 static TopTools_ListOfShape emptyList;
1355 //=======================================================================
1357 //purpose : dumps contents of mesh to stream [ debug purposes ]
1358 //=======================================================================
1360 ostream& SMESH_Mesh::Dump(ostream& save)
1363 save << "========================== Dump contents of mesh ==========================" << endl << endl;
1364 save << ++clause << ") Total number of nodes: \t" << NbNodes() << endl;
1365 save << ++clause << ") Total number of edges: \t" << NbEdges() << endl;
1366 save << ++clause << ") Total number of faces: \t" << NbFaces() << endl;
1367 save << ++clause << ") Total number of polygons:\t" << NbPolygons() << endl;
1368 save << ++clause << ") Total number of volumes:\t" << NbVolumes() << endl;
1369 save << ++clause << ") Total number of polyhedrons:\t" << NbPolyhedrons() << endl << endl;
1370 for ( int isQuadratic = 0; isQuadratic < 2; ++isQuadratic )
1372 string orderStr = isQuadratic ? "quadratic" : "linear";
1373 SMDSAbs_ElementOrder order = isQuadratic ? ORDER_QUADRATIC : ORDER_LINEAR;
1375 save << ++clause << ") Total number of " << orderStr << " edges:\t" << NbEdges(order) << endl;
1376 save << ++clause << ") Total number of " << orderStr << " faces:\t" << NbFaces(order) << endl;
1377 if ( NbFaces(order) > 0 ) {
1378 int nb3 = NbTriangles(order);
1379 int nb4 = NbQuadrangles(order);
1380 save << clause << ".1) Number of " << orderStr << " triangles: \t" << nb3 << endl;
1381 save << clause << ".2) Number of " << orderStr << " quadrangles:\t" << nb4 << endl;
1382 if ( nb3 + nb4 != NbFaces(order) ) {
1383 std::map<int,int> myFaceMap;
1384 SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
1385 while( itFaces->more( ) ) {
1386 int nbNodes = itFaces->next()->NbNodes();
1387 if ( myFaceMap.find( nbNodes ) == myFaceMap.end() )
1388 myFaceMap[ nbNodes ] = 0;
1389 myFaceMap[ nbNodes ] = myFaceMap[ nbNodes ] + 1;
1391 save << clause << ".3) Faces in detail: " << endl;
1392 map <int,int>::iterator itF;
1393 for (itF = myFaceMap.begin(); itF != myFaceMap.end(); itF++)
1394 save << "--> nb nodes: " << itF->first << " - nb elemens:\t" << itF->second << endl;
1397 save << ++clause << ") Total number of " << orderStr << " volumes:\t" << NbVolumes(order) << endl;
1398 if ( NbVolumes(order) > 0 ) {
1399 int nb8 = NbHexas(order);
1400 int nb4 = NbTetras(order);
1401 int nb5 = NbPyramids(order);
1402 int nb6 = NbPrisms(order);
1403 save << clause << ".1) Number of " << orderStr << " hexahedrons:\t" << nb8 << endl;
1404 save << clause << ".2) Number of " << orderStr << " tetrahedrons:\t" << nb4 << endl;
1405 save << clause << ".3) Number of " << orderStr << " prisms: \t" << nb6 << endl;
1406 save << clause << ".4) Number of " << orderStr << " pyramids:\t" << nb5 << endl;
1407 if ( nb8 + nb4 + nb5 + nb6 != NbVolumes(order) ) {
1408 std::map<int,int> myVolumesMap;
1409 SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
1410 while( itVolumes->more( ) ) {
1411 int nbNodes = itVolumes->next()->NbNodes();
1412 if ( myVolumesMap.find( nbNodes ) == myVolumesMap.end() )
1413 myVolumesMap[ nbNodes ] = 0;
1414 myVolumesMap[ nbNodes ] = myVolumesMap[ nbNodes ] + 1;
1416 save << clause << ".5) Volumes in detail: " << endl;
1417 map <int,int>::iterator itV;
1418 for (itV = myVolumesMap.begin(); itV != myVolumesMap.end(); itV++)
1419 save << "--> nb nodes: " << itV->first << " - nb elemens:\t" << itV->second << endl;
1424 save << "===========================================================================" << endl;
1428 //=======================================================================
1429 //function : GetElementType
1430 //purpose : Returns type of mesh element with certain id
1431 //=======================================================================
1433 SMDSAbs_ElementType SMESH_Mesh::GetElementType( const int id, const bool iselem )
1435 return _myMeshDS->GetElementType( id, iselem );