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()
214 _myMeshDS->ClearMesh();
216 // update compute state of submeshes
217 if ( SMESH_subMesh *sm = GetSubMeshContaining( GetShapeToMesh() ) ) {
218 SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(/*includeSelf=*/true,
219 /*complexShapeFirst=*/false);
220 while ( smIt->more() ) {
222 sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
226 // // clear sub-meshes; get ready to re-compute as a side-effect
228 // if ( SMESH_subMesh *sm = GetSubMeshContaining( GetShapeToMesh() ) )
230 // SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(/*includeSelf=*/true,
231 // /*complexShapeFirst=*/false);
232 // while ( smIt->more() )
234 // sm = smIt->next();
235 // TopAbs_ShapeEnum shapeType = sm->GetSubShape().ShapeType();
236 // if ( shapeType == TopAbs_VERTEX || shapeType < TopAbs_SOLID )
237 // // all other shapes depends on vertices so they are already cleaned
238 // sm->ComputeStateEngine( SMESH_subMesh::CLEAN );
239 // // to recompute even if failed
240 // sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
244 // // clear entities not on sub-meshes
246 // SMDS_VolumeIteratorPtr vIt = _myMeshDS->volumesIterator();
247 // while ( vIt->more() )
248 // _myMeshDS->RemoveFreeElement( vIt->next(), 0 );
250 // SMDS_FaceIteratorPtr fIt = _myMeshDS->facesIterator();
251 // while ( fIt->more() )
252 // _myMeshDS->RemoveFreeElement( fIt->next(), 0 );
254 // SMDS_EdgeIteratorPtr eIt = _myMeshDS->edgesIterator();
255 // while ( eIt->more() )
256 // _myMeshDS->RemoveFreeElement( eIt->next(), 0 );
258 // SMDS_NodeIteratorPtr nIt = _myMeshDS->nodesIterator();
259 // while ( nIt->more() ) {
260 // const SMDS_MeshNode * node = nIt->next();
261 // if ( node->NbInverseElements() == 0 )
262 // _myMeshDS->RemoveFreeNode( node, 0 );
264 // _myMeshDS->RemoveNode(node);
268 //=======================================================================
269 //function : UNVToMesh
271 //=======================================================================
273 int SMESH_Mesh::UNVToMesh(const char* theFileName)
275 if(MYDEBUG) MESSAGE("UNVToMesh - theFileName = "<<theFileName);
277 throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
278 _isShapeToMesh = false;
279 DriverUNV_R_SMDS_Mesh myReader;
280 myReader.SetMesh(_myMeshDS);
281 myReader.SetFile(theFileName);
282 myReader.SetMeshId(-1);
285 MESSAGE("UNVToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
286 MESSAGE("UNVToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
287 MESSAGE("UNVToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
288 MESSAGE("UNVToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
290 SMDS_MeshGroup* aGroup = (SMDS_MeshGroup*) myReader.GetGroup();
292 TGroupNamesMap aGroupNames = myReader.GetGroupNamesMap();
293 //const TGroupIdMap& aGroupId = myReader.GetGroupIdMap();
294 aGroup->InitSubGroupsIterator();
295 while (aGroup->MoreSubGroups()) {
296 SMDS_MeshGroup* aSubGroup = (SMDS_MeshGroup*) aGroup->NextSubGroup();
297 std::string aName = aGroupNames[aSubGroup];
300 SMESH_Group* aSMESHGroup = AddGroup( aSubGroup->GetType(), aName.c_str(), aId );
302 if(MYDEBUG) MESSAGE("UNVToMesh - group added: "<<aName);
303 SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( aSMESHGroup->GetGroupDS() );
305 aGroupDS->SetStoreName(aName.c_str());
306 aSubGroup->InitIterator();
307 const SMDS_MeshElement* aElement = 0;
308 while (aSubGroup->More()) {
309 aElement = aSubGroup->Next();
311 aGroupDS->SMDSGroup().Add(aElement);
315 aGroupDS->SetType(aElement->GetType());
323 //=======================================================================
324 //function : MEDToMesh
326 //=======================================================================
328 int SMESH_Mesh::MEDToMesh(const char* theFileName, const char* theMeshName)
330 if(MYDEBUG) MESSAGE("MEDToMesh - theFileName = "<<theFileName<<", mesh name = "<<theMeshName);
332 throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
333 _isShapeToMesh = false;
334 DriverMED_R_SMESHDS_Mesh myReader;
335 myReader.SetMesh(_myMeshDS);
336 myReader.SetMeshId(-1);
337 myReader.SetFile(theFileName);
338 myReader.SetMeshName(theMeshName);
339 Driver_Mesh::Status status = myReader.Perform();
341 MESSAGE("MEDToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
342 MESSAGE("MEDToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
343 MESSAGE("MEDToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
344 MESSAGE("MEDToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
347 // Reading groups (sub-meshes are out of scope of MED import functionality)
348 std::list<TNameAndType> aGroupNames = myReader.GetGroupNamesAndTypes();
349 if(MYDEBUG) MESSAGE("MEDToMesh - Nb groups = "<<aGroupNames.size());
351 std::list<TNameAndType>::iterator name_type = aGroupNames.begin();
352 for ( ; name_type != aGroupNames.end(); name_type++ ) {
353 SMESH_Group* aGroup = AddGroup( name_type->second, name_type->first.c_str(), anId );
355 if(MYDEBUG) MESSAGE("MEDToMesh - group added: "<<name_type->first.c_str());
356 SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( aGroup->GetGroupDS() );
358 aGroupDS->SetStoreName( name_type->first.c_str() );
359 myReader.GetGroup( aGroupDS );
366 //=======================================================================
367 //function : STLToMesh
369 //=======================================================================
371 int SMESH_Mesh::STLToMesh(const char* theFileName)
373 if(MYDEBUG) MESSAGE("STLToMesh - theFileName = "<<theFileName);
375 throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
376 _isShapeToMesh = false;
377 DriverSTL_R_SMDS_Mesh myReader;
378 myReader.SetMesh(_myMeshDS);
379 myReader.SetFile(theFileName);
380 myReader.SetMeshId(-1);
383 MESSAGE("STLToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
384 MESSAGE("STLToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
385 MESSAGE("STLToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
386 MESSAGE("STLToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
391 //=============================================================================
395 //=============================================================================
397 SMESH_Hypothesis::Hypothesis_Status
398 SMESH_Mesh::AddHypothesis(const TopoDS_Shape & aSubShape,
399 int anHypId ) throw(SALOME_Exception)
401 Unexpect aCatch(SalomeException);
402 if(MYDEBUG) MESSAGE("SMESH_Mesh::AddHypothesis");
404 SMESH_subMesh *subMesh = GetSubMesh(aSubShape);
405 if ( !subMesh || !subMesh->GetId())
406 return SMESH_Hypothesis::HYP_BAD_SUBSHAPE;
408 SMESHDS_SubMesh *subMeshDS = subMesh->GetSubMeshDS();
409 if ( subMeshDS && subMeshDS->IsComplexSubmesh() ) // group of sub-shapes and maybe of not sub-
411 MESSAGE("AddHypothesis() to complex submesh");
412 // return the worst but not fatal state of all group memebers
413 SMESH_Hypothesis::Hypothesis_Status aBestRet, aWorstNotFatal, ret;
414 aBestRet = SMESH_Hypothesis::HYP_BAD_DIM;
415 aWorstNotFatal = SMESH_Hypothesis::HYP_OK;
416 for ( TopoDS_Iterator itS ( aSubShape ); itS.More(); itS.Next())
418 if ( !GetMeshDS()->ShapeToIndex( itS.Value() ))
419 continue; // not sub-shape
420 ret = AddHypothesis( itS.Value(), anHypId );
421 if ( !SMESH_Hypothesis::IsStatusFatal( ret ) && ret > aWorstNotFatal )
422 aWorstNotFatal = ret;
423 if ( ret < aBestRet )
426 // bind hypotheses to a group just to know
427 SMESH_Hypothesis *anHyp = _gen->GetStudyContext(_studyId)->mapHypothesis[anHypId];
428 GetMeshDS()->AddHypothesis( aSubShape, anHyp );
430 if ( SMESH_Hypothesis::IsStatusFatal( aBestRet ))
432 return aWorstNotFatal;
435 StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
436 if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
438 if(MYDEBUG) MESSAGE("Hypothesis ID does not give an hypothesis");
443 throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
446 SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
447 MESSAGE( "SMESH_Mesh::AddHypothesis " << anHyp->GetName() );
449 bool isGlobalHyp = IsMainShape( aSubShape );
451 // NotConformAllowed can be only global
454 string hypName = anHyp->GetName();
455 if ( hypName == "NotConformAllowed" )
457 if(MYDEBUG) MESSAGE( "Hypotesis <NotConformAllowed> can be only global" );
458 return SMESH_Hypothesis::HYP_INCOMPATIBLE;
464 bool isAlgo = ( !anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO );
465 int event = isAlgo ? SMESH_subMesh::ADD_ALGO : SMESH_subMesh::ADD_HYP;
467 SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp);
470 if (!SMESH_Hypothesis::IsStatusFatal(ret) &&
471 anHyp->GetDim() <= SMESH_Gen::GetShapeDim(aSubShape)) // is added on father
473 event = isAlgo ? SMESH_subMesh::ADD_FATHER_ALGO : SMESH_subMesh::ADD_FATHER_HYP;
475 SMESH_Hypothesis::Hypothesis_Status ret2 =
476 subMesh->SubMeshesAlgoStateEngine(event, anHyp);
480 // check concurent hypotheses on ansestors
481 if (ret < SMESH_Hypothesis::HYP_CONCURENT && !isGlobalHyp )
483 SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false);
484 while ( smIt->more() ) {
485 SMESH_subMesh* sm = smIt->next();
486 if ( sm->IsApplicableHypotesis( anHyp )) {
487 ret2 = sm->CheckConcurentHypothesis( anHyp->GetType() );
497 if(MYDEBUG) subMesh->DumpAlgoState(true);
502 //=============================================================================
506 //=============================================================================
508 SMESH_Hypothesis::Hypothesis_Status
509 SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape & aSubShape,
510 int anHypId)throw(SALOME_Exception)
512 Unexpect aCatch(SalomeException);
513 if(MYDEBUG) MESSAGE("SMESH_Mesh::RemoveHypothesis");
515 SMESH_subMesh *subMesh = GetSubMesh(aSubShape);
516 SMESHDS_SubMesh *subMeshDS = subMesh->GetSubMeshDS();
517 if ( subMeshDS && subMeshDS->IsComplexSubmesh() )
519 // return the worst but not fatal state of all group memebers
520 SMESH_Hypothesis::Hypothesis_Status aBestRet, aWorstNotFatal, ret;
521 aBestRet = SMESH_Hypothesis::HYP_BAD_DIM;
522 aWorstNotFatal = SMESH_Hypothesis::HYP_OK;
523 for ( TopoDS_Iterator itS ( aSubShape ); itS.More(); itS.Next())
525 if ( !GetMeshDS()->ShapeToIndex( itS.Value() ))
526 continue; // not sub-shape
527 ret = RemoveHypothesis( itS.Value(), anHypId );
528 if ( !SMESH_Hypothesis::IsStatusFatal( ret ) && ret > aWorstNotFatal )
529 aWorstNotFatal = ret;
530 if ( ret < aBestRet )
533 SMESH_Hypothesis *anHyp = _gen->GetStudyContext(_studyId)->mapHypothesis[anHypId];
534 GetMeshDS()->RemoveHypothesis( aSubShape, anHyp );
536 if ( SMESH_Hypothesis::IsStatusFatal( aBestRet ))
538 return aWorstNotFatal;
541 StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
542 if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
543 throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
545 SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
546 int hypType = anHyp->GetType();
547 if(MYDEBUG) SCRUTE(hypType);
551 bool isAlgo = ( !anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO );
552 int event = isAlgo ? SMESH_subMesh::REMOVE_ALGO : SMESH_subMesh::REMOVE_HYP;
554 SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp);
556 // there may appear concurrent hyps that were covered by the removed hyp
557 if (ret < SMESH_Hypothesis::HYP_CONCURENT &&
558 subMesh->IsApplicableHypotesis( anHyp ) &&
559 subMesh->CheckConcurentHypothesis( anHyp->GetType() ) != SMESH_Hypothesis::HYP_OK)
560 ret = SMESH_Hypothesis::HYP_CONCURENT;
563 if (!SMESH_Hypothesis::IsStatusFatal(ret) &&
564 anHyp->GetDim() <= SMESH_Gen::GetShapeDim(aSubShape)) // is removed from father
566 event = isAlgo ? SMESH_subMesh::REMOVE_FATHER_ALGO : SMESH_subMesh::REMOVE_FATHER_HYP;
568 SMESH_Hypothesis::Hypothesis_Status ret2 =
569 subMesh->SubMeshesAlgoStateEngine(event, anHyp);
570 if (ret2 > ret) // more severe
573 // check concurent hypotheses on ansestors
574 if (ret < SMESH_Hypothesis::HYP_CONCURENT && !IsMainShape( aSubShape ) )
576 SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false);
577 while ( smIt->more() ) {
578 SMESH_subMesh* sm = smIt->next();
579 if ( sm->IsApplicableHypotesis( anHyp )) {
580 ret2 = sm->CheckConcurentHypothesis( anHyp->GetType() );
590 if(MYDEBUG) subMesh->DumpAlgoState(true);
591 if(MYDEBUG) SCRUTE(ret);
595 //=============================================================================
599 //=============================================================================
601 const std::list<const SMESHDS_Hypothesis*>&
602 SMESH_Mesh::GetHypothesisList(const TopoDS_Shape & aSubShape) const
603 throw(SALOME_Exception)
605 Unexpect aCatch(SalomeException);
606 return _myMeshDS->GetHypothesis(aSubShape);
609 //=======================================================================
611 * \brief Return the hypothesis assigned to the shape
612 * \param aSubShape - the shape to check
613 * \param aFilter - the hypothesis filter
614 * \param andAncestors - flag to check hypos assigned to ancestors of the shape
615 * \param assignedTo - to return the shape the found hypo is assigned to
616 * \retval SMESH_Hypothesis* - the first hypo passed through aFilter
618 //=======================================================================
620 const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubShape,
621 const SMESH_HypoFilter& aFilter,
622 const bool andAncestors,
623 TopoDS_Shape* assignedTo) const
626 const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
627 std::list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
628 for ( ; hyp != hypList.end(); hyp++ ) {
629 const SMESH_Hypothesis * h = cSMESH_Hyp( *hyp );
630 if ( aFilter.IsOk( h, aSubShape)) {
631 if ( assignedTo ) *assignedTo = aSubShape;
638 TopTools_ListIteratorOfListOfShape it( GetAncestors( aSubShape ));
639 for (; it.More(); it.Next() )
641 const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value());
642 std::list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
643 for ( ; hyp != hypList.end(); hyp++ ) {
644 const SMESH_Hypothesis * h = cSMESH_Hyp( *hyp );
645 if (aFilter.IsOk( h, it.Value() )) {
646 if ( assignedTo ) *assignedTo = it.Value();
655 //================================================================================
657 * \brief Return hypothesis assigned to the shape
658 * \param aSubShape - the shape to check
659 * \param aFilter - the hypothesis filter
660 * \param aHypList - the list of the found hypotheses
661 * \param andAncestors - flag to check hypos assigned to ancestors of the shape
662 * \retval int - number of unique hypos in aHypList
664 //================================================================================
666 int SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape,
667 const SMESH_HypoFilter& aFilter,
668 list <const SMESHDS_Hypothesis * >& aHypList,
669 const bool andAncestors) const
671 set<string> hypTypes; // to exclude same type hypos from the result list
674 // only one main hypothesis is allowed
675 bool mainHypFound = false;
678 std::list<const SMESHDS_Hypothesis*>::const_iterator hyp;
679 for ( hyp = aHypList.begin(); hyp != aHypList.end(); hyp++ ) {
680 if ( hypTypes.insert( (*hyp)->GetName() ).second )
682 if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
686 // get hypos from aSubShape
688 const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
689 for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
690 if ( aFilter.IsOk (cSMESH_Hyp( *hyp ), aSubShape) &&
691 ( cSMESH_Hyp(*hyp)->IsAuxiliary() || !mainHypFound ) &&
692 hypTypes.insert( (*hyp)->GetName() ).second )
694 aHypList.push_back( *hyp );
696 if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
701 // get hypos from ancestors of aSubShape
704 TopTools_MapOfShape map;
705 TopTools_ListIteratorOfListOfShape it( GetAncestors( aSubShape ));
706 for (; it.More(); it.Next() )
708 if ( !map.Add( it.Value() ))
710 const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value());
711 for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
712 if (aFilter.IsOk( cSMESH_Hyp( *hyp ), it.Value() ) &&
713 ( cSMESH_Hyp(*hyp)->IsAuxiliary() || !mainHypFound ) &&
714 hypTypes.insert( (*hyp)->GetName() ).second )
716 aHypList.push_back( *hyp );
718 if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
726 //=============================================================================
730 //=============================================================================
732 const std::list<SMESHDS_Command*> & SMESH_Mesh::GetLog() throw(SALOME_Exception)
734 Unexpect aCatch(SalomeException);
735 if(MYDEBUG) MESSAGE("SMESH_Mesh::GetLog");
736 return _myMeshDS->GetScript()->GetCommands();
739 //=============================================================================
743 //=============================================================================
744 void SMESH_Mesh::ClearLog() throw(SALOME_Exception)
746 Unexpect aCatch(SalomeException);
747 if(MYDEBUG) MESSAGE("SMESH_Mesh::ClearLog");
748 _myMeshDS->GetScript()->Clear();
751 //=============================================================================
753 * Get or Create the SMESH_subMesh object implementation
755 //=============================================================================
757 SMESH_subMesh *SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape)
758 throw(SALOME_Exception)
760 Unexpect aCatch(SalomeException);
761 SMESH_subMesh *aSubMesh;
762 int index = _myMeshDS->ShapeToIndex(aSubShape);
764 // for submeshes on GEOM Group
765 if ( !index && aSubShape.ShapeType() == TopAbs_COMPOUND ) {
766 TopoDS_Iterator it( aSubShape );
768 index = _myMeshDS->AddCompoundSubmesh( aSubShape, it.Value().ShapeType() );
771 // return NULL; // neither sub-shape nor a group
773 map <int, SMESH_subMesh *>::iterator i_sm = _mapSubMesh.find(index);
774 if ( i_sm != _mapSubMesh.end())
776 aSubMesh = i_sm->second;
780 aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape);
781 _mapSubMesh[index] = aSubMesh;
786 //=============================================================================
788 * Get the SMESH_subMesh object implementation. Dont create it, return null
789 * if it does not exist.
791 //=============================================================================
793 SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape) const
794 throw(SALOME_Exception)
796 Unexpect aCatch(SalomeException);
797 SMESH_subMesh *aSubMesh = NULL;
799 int index = _myMeshDS->ShapeToIndex(aSubShape);
801 map <int, SMESH_subMesh *>::const_iterator i_sm = _mapSubMesh.find(index);
802 if ( i_sm != _mapSubMesh.end())
803 aSubMesh = i_sm->second;
807 //=============================================================================
809 * Get the SMESH_subMesh object implementation. Dont create it, return null
810 * if it does not exist.
812 //=============================================================================
814 SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const int aShapeID) const
815 throw(SALOME_Exception)
817 Unexpect aCatch(SalomeException);
819 map <int, SMESH_subMesh *>::const_iterator i_sm = _mapSubMesh.find(aShapeID);
820 if (i_sm == _mapSubMesh.end())
824 //================================================================================
826 * \brief Return submeshes of groups containing the given subshape
828 //================================================================================
830 std::list<SMESH_subMesh*>
831 SMESH_Mesh::GetGroupSubMeshesContaining(const TopoDS_Shape & aSubShape) const
832 throw(SALOME_Exception)
834 Unexpect aCatch(SalomeException);
835 std::list<SMESH_subMesh*> found;
837 SMESH_subMesh * subMesh = GetSubMeshContaining(aSubShape);
841 // submeshes of groups have max IDs, so search from the map end
842 std::map<int, SMESH_subMesh *>::const_reverse_iterator i_sm;
843 for ( i_sm = _mapSubMesh.rbegin(); i_sm != _mapSubMesh.rend(); ++i_sm) {
844 SMESHDS_SubMesh * ds = i_sm->second->GetSubMeshDS();
845 if ( ds && ds->IsComplexSubmesh() ) {
846 TopExp_Explorer exp( i_sm->second->GetSubShape(), aSubShape.ShapeType() );
847 for ( ; exp.More(); exp.Next() ) {
848 if ( aSubShape.IsSame( exp.Current() )) {
849 found.push_back( i_sm->second );
859 //=======================================================================
860 //function : IsUsedHypothesis
861 //purpose : Return True if anHyp is used to mesh aSubShape
862 //=======================================================================
864 bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
865 const SMESH_subMesh* aSubMesh)
867 SMESH_Hypothesis* hyp = static_cast<SMESH_Hypothesis*>(anHyp);
869 // check if anHyp can be used to mesh aSubMesh
870 if ( !aSubMesh || !aSubMesh->IsApplicableHypotesis( hyp ))
873 const TopoDS_Shape & aSubShape = const_cast<SMESH_subMesh*>( aSubMesh )->GetSubShape();
875 SMESH_Algo *algo = _gen->GetAlgo(*this, aSubShape );
878 if (anHyp->GetType() > SMESHDS_Hypothesis::PARAM_ALGO)
879 return ( anHyp == algo );
881 // algorithm parameter
884 // look trough hypotheses used by algo
885 SMESH_HypoFilter hypoKind;
886 if ( algo->InitCompatibleHypoFilter( hypoKind, !hyp->IsAuxiliary() )) {
887 list <const SMESHDS_Hypothesis * > usedHyps;
888 if ( GetHypotheses( aSubShape, hypoKind, usedHyps, true ))
889 return ( find( usedHyps.begin(), usedHyps.end(), anHyp ) != usedHyps.end() );
893 // look through all assigned hypotheses
894 //SMESH_HypoFilter filter( SMESH_HypoFilter::Is( hyp ));
895 return false; //GetHypothesis( aSubShape, filter, true );
898 //=============================================================================
902 //=============================================================================
904 const list < SMESH_subMesh * >&
905 SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
906 throw(SALOME_Exception)
908 Unexpect aCatch(SalomeException);
909 if(MYDEBUG) MESSAGE("SMESH_Mesh::GetSubMeshUsingHypothesis");
910 map < int, SMESH_subMesh * >::iterator itsm;
911 _subMeshesUsingHypothesisList.clear();
912 for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
914 SMESH_subMesh *aSubMesh = (*itsm).second;
915 if ( IsUsedHypothesis ( anHyp, aSubMesh ))
916 _subMeshesUsingHypothesisList.push_back(aSubMesh);
918 return _subMeshesUsingHypothesisList;
921 //=======================================================================
922 //function : NotifySubMeshesHypothesisModification
923 //purpose : Say all submeshes using theChangedHyp that it has been modified
924 //=======================================================================
926 void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* hyp)
928 Unexpect aCatch(SalomeException);
930 const SMESH_Algo *foundAlgo = 0;
931 SMESH_HypoFilter algoKind, compatibleHypoKind;
932 list <const SMESHDS_Hypothesis * > usedHyps;
935 map < int, SMESH_subMesh * >::iterator itsm;
936 for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
938 SMESH_subMesh *aSubMesh = (*itsm).second;
939 if ( aSubMesh->IsApplicableHypotesis( hyp ))
941 const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape();
943 if ( !foundAlgo ) // init filter for algo search
944 algoKind.Init( THypType::IsAlgo() ).And( THypType::IsApplicableTo( aSubShape ));
946 const SMESH_Algo *algo = static_cast<const SMESH_Algo*>
947 ( GetHypothesis( aSubShape, algoKind, true ));
951 bool sameAlgo = ( algo == foundAlgo );
952 if ( !sameAlgo && foundAlgo )
953 sameAlgo = ( strcmp( algo->GetName(), foundAlgo->GetName() ) == 0);
955 if ( !sameAlgo ) { // init filter for used hypos search
956 if ( !algo->InitCompatibleHypoFilter( compatibleHypoKind, !hyp->IsAuxiliary() ))
957 continue; // algo does not use any hypothesis
961 // check if hyp is used by algo
963 if ( GetHypotheses( aSubShape, compatibleHypoKind, usedHyps, true ) &&
964 find( usedHyps.begin(), usedHyps.end(), hyp ) != usedHyps.end() )
966 aSubMesh->AlgoStateEngine(SMESH_subMesh::MODIF_HYP,
967 const_cast< SMESH_Hypothesis*>( hyp ));
974 //=============================================================================
976 * Auto color functionality
978 //=============================================================================
979 void SMESH_Mesh::SetAutoColor(bool theAutoColor) throw(SALOME_Exception)
981 Unexpect aCatch(SalomeException);
982 _isAutoColor = theAutoColor;
985 bool SMESH_Mesh::GetAutoColor() throw(SALOME_Exception)
987 Unexpect aCatch(SalomeException);
991 //=============================================================================
993 * To store mesh contents on disk in different formats.
995 //=============================================================================
997 bool SMESH_Mesh::HasDuplicatedGroupNamesMED()
999 set<string> aGroupNames;
1000 for ( std::map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
1001 SMESH_Group* aGroup = it->second;
1002 std::string aGroupName = aGroup->GetName();
1003 aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
1004 if (!aGroupNames.insert(aGroupName).second)
1011 void SMESH_Mesh::ExportMED(const char *file,
1012 const char* theMeshName,
1015 throw(SALOME_Exception)
1017 Unexpect aCatch(SalomeException);
1019 DriverMED_W_SMESHDS_Mesh myWriter;
1020 myWriter.SetFile ( file, MED::EVersion(theVersion) );
1021 myWriter.SetMesh ( _myMeshDS );
1023 myWriter.SetMeshId ( _idDoc );
1025 myWriter.SetMeshId ( -1 );
1026 myWriter.SetMeshName( theMeshName );
1029 if ( theAutoGroups ) {
1030 myWriter.AddGroupOfNodes();
1031 myWriter.AddGroupOfEdges();
1032 myWriter.AddGroupOfFaces();
1033 myWriter.AddGroupOfVolumes();
1036 // Pass groups to writer. Provide unique group names.
1037 set<string> aGroupNames;
1039 int maxNbIter = 10000; // to guarantee cycle finish
1040 for ( std::map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
1041 SMESH_Group* aGroup = it->second;
1042 SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
1044 string aGroupName0 = aGroup->GetName();
1045 aGroupName0.resize(MAX_MED_GROUP_NAME_LENGTH);
1046 string aGroupName = aGroupName0;
1047 for (int i = 1; !aGroupNames.insert(aGroupName).second && i < maxNbIter; i++) {
1048 sprintf(&aString[0], "GR_%d_%s", i, aGroupName0.c_str());
1049 aGroupName = aString;
1050 aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
1052 aGroupDS->SetStoreName( aGroupName.c_str() );
1053 myWriter.AddGroup( aGroupDS );
1061 void SMESH_Mesh::ExportDAT(const char *file) throw(SALOME_Exception)
1063 Unexpect aCatch(SalomeException);
1064 DriverDAT_W_SMDS_Mesh myWriter;
1065 myWriter.SetFile(string(file));
1066 myWriter.SetMesh(_myMeshDS);
1067 myWriter.SetMeshId(_idDoc);
1071 void SMESH_Mesh::ExportUNV(const char *file) throw(SALOME_Exception)
1073 Unexpect aCatch(SalomeException);
1074 DriverUNV_W_SMDS_Mesh myWriter;
1075 myWriter.SetFile(string(file));
1076 myWriter.SetMesh(_myMeshDS);
1077 myWriter.SetMeshId(_idDoc);
1078 // myWriter.SetGroups(_mapGroup);
1080 for ( std::map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
1081 SMESH_Group* aGroup = it->second;
1082 SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
1084 std::string aGroupName = aGroup->GetName();
1085 aGroupDS->SetStoreName( aGroupName.c_str() );
1086 myWriter.AddGroup( aGroupDS );
1092 void SMESH_Mesh::ExportSTL(const char *file, const bool isascii) throw(SALOME_Exception)
1094 Unexpect aCatch(SalomeException);
1095 DriverSTL_W_SMDS_Mesh myWriter;
1096 myWriter.SetFile(string(file));
1097 myWriter.SetIsAscii( isascii );
1098 myWriter.SetMesh(_myMeshDS);
1099 myWriter.SetMeshId(_idDoc);
1103 //================================================================================
1105 * \brief Return number of nodes in the mesh
1107 //================================================================================
1109 int SMESH_Mesh::NbNodes() throw(SALOME_Exception)
1111 Unexpect aCatch(SalomeException);
1112 return _myMeshDS->NbNodes();
1115 //================================================================================
1117 * \brief Return number of edges of given order in the mesh
1119 //================================================================================
1121 int SMESH_Mesh::NbEdges(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1123 Unexpect aCatch(SalomeException);
1124 return _myMeshDS->GetMeshInfo().NbEdges(order);
1127 //================================================================================
1129 * \brief Return number of faces of given order in the mesh
1131 //================================================================================
1133 int SMESH_Mesh::NbFaces(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1135 Unexpect aCatch(SalomeException);
1136 return _myMeshDS->GetMeshInfo().NbFaces(order);
1139 //================================================================================
1141 * \brief Return the number of faces in the mesh
1143 //================================================================================
1145 int SMESH_Mesh::NbTriangles(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1147 Unexpect aCatch(SalomeException);
1148 return _myMeshDS->GetMeshInfo().NbTriangles(order);
1151 //================================================================================
1153 * \brief Return the number nodes faces in the mesh
1155 //================================================================================
1157 int SMESH_Mesh::NbQuadrangles(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1159 Unexpect aCatch(SalomeException);
1160 return _myMeshDS->GetMeshInfo().NbQuadrangles(order);
1163 //================================================================================
1165 * \brief Return the number of polygonal faces in the mesh
1167 //================================================================================
1169 int SMESH_Mesh::NbPolygons() throw(SALOME_Exception)
1171 Unexpect aCatch(SalomeException);
1172 return _myMeshDS->GetMeshInfo().NbPolygons();
1175 //================================================================================
1177 * \brief Return number of volumes of given order in the mesh
1179 //================================================================================
1181 int SMESH_Mesh::NbVolumes(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1183 Unexpect aCatch(SalomeException);
1184 return _myMeshDS->GetMeshInfo().NbVolumes(order);
1187 //================================================================================
1189 * \brief Return number of tetrahedrons of given order in the mesh
1191 //================================================================================
1193 int SMESH_Mesh::NbTetras(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1195 Unexpect aCatch(SalomeException);
1196 return _myMeshDS->GetMeshInfo().NbTetras(order);
1199 //================================================================================
1201 * \brief Return number of hexahedrons of given order in the mesh
1203 //================================================================================
1205 int SMESH_Mesh::NbHexas(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1207 Unexpect aCatch(SalomeException);
1208 return _myMeshDS->GetMeshInfo().NbHexas(order);
1211 //================================================================================
1213 * \brief Return number of pyramids of given order in the mesh
1215 //================================================================================
1217 int SMESH_Mesh::NbPyramids(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1219 Unexpect aCatch(SalomeException);
1220 return _myMeshDS->GetMeshInfo().NbPyramids(order);
1223 //================================================================================
1225 * \brief Return number of prisms (penthahedrons) of given order in the mesh
1227 //================================================================================
1229 int SMESH_Mesh::NbPrisms(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1231 Unexpect aCatch(SalomeException);
1232 return _myMeshDS->GetMeshInfo().NbPrisms(order);
1235 //================================================================================
1237 * \brief Return number of polyhedrons in the mesh
1239 //================================================================================
1241 int SMESH_Mesh::NbPolyhedrons() throw(SALOME_Exception)
1243 Unexpect aCatch(SalomeException);
1244 return _myMeshDS->GetMeshInfo().NbPolyhedrons();
1247 //================================================================================
1249 * \brief Return number of submeshes in the mesh
1251 //================================================================================
1253 int SMESH_Mesh::NbSubMesh() throw(SALOME_Exception)
1255 Unexpect aCatch(SalomeException);
1256 return _myMeshDS->NbSubMesh();
1259 //=======================================================================
1260 //function : IsNotConformAllowed
1261 //purpose : check if a hypothesis alowing notconform mesh is present
1262 //=======================================================================
1264 bool SMESH_Mesh::IsNotConformAllowed() const
1266 if(MYDEBUG) MESSAGE("SMESH_Mesh::IsNotConformAllowed");
1268 static SMESH_HypoFilter filter( SMESH_HypoFilter::HasName( "NotConformAllowed" ));
1269 return GetHypothesis( _myMeshDS->ShapeToMesh(), filter, false );
1272 //=======================================================================
1273 //function : IsMainShape
1275 //=======================================================================
1277 bool SMESH_Mesh::IsMainShape(const TopoDS_Shape& theShape) const
1279 return theShape.IsSame(_myMeshDS->ShapeToMesh() );
1282 //=============================================================================
1286 //=============================================================================
1288 SMESH_Group* SMESH_Mesh::AddGroup (const SMDSAbs_ElementType theType,
1289 const char* theName,
1291 const TopoDS_Shape& theShape)
1293 if (_mapGroup.find(_groupId) != _mapGroup.end())
1296 SMESH_Group* aGroup = new SMESH_Group (theId, this, theType, theName, theShape);
1297 GetMeshDS()->AddGroup( aGroup->GetGroupDS() );
1298 _mapGroup[_groupId++] = aGroup;
1302 //================================================================================
1304 * \brief Return iterator on all existing groups
1306 //================================================================================
1308 SMESH_Mesh::GroupIteratorPtr SMESH_Mesh::GetGroups() const
1310 typedef map <int, SMESH_Group *> TMap;
1311 return GroupIteratorPtr( new SMDS_mapIterator<TMap>( _mapGroup ));
1314 //=============================================================================
1316 * \brief Return a group by ID
1318 //=============================================================================
1320 SMESH_Group* SMESH_Mesh::GetGroup (const int theGroupID)
1322 if (_mapGroup.find(theGroupID) == _mapGroup.end())
1324 return _mapGroup[theGroupID];
1328 //=============================================================================
1330 * \brief Return IDs of all groups
1332 //=============================================================================
1334 std::list<int> SMESH_Mesh::GetGroupIds() const
1336 std::list<int> anIds;
1337 for ( std::map<int, SMESH_Group*>::const_iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ )
1338 anIds.push_back( it->first );
1344 //=============================================================================
1348 //=============================================================================
1350 void SMESH_Mesh::RemoveGroup (const int theGroupID)
1352 if (_mapGroup.find(theGroupID) == _mapGroup.end())
1354 GetMeshDS()->RemoveGroup( _mapGroup[theGroupID]->GetGroupDS() );
1355 delete _mapGroup[theGroupID];
1356 _mapGroup.erase (theGroupID);
1359 //=======================================================================
1360 //function : GetAncestors
1361 //purpose : return list of ancestors of theSubShape in the order
1362 // that lower dimention shapes come first.
1363 //=======================================================================
1365 const TopTools_ListOfShape& SMESH_Mesh::GetAncestors(const TopoDS_Shape& theS) const
1367 if ( _mapAncestors.Contains( theS ) )
1368 return _mapAncestors.FindFromKey( theS );
1370 static TopTools_ListOfShape emptyList;
1374 //=======================================================================
1376 //purpose : dumps contents of mesh to stream [ debug purposes ]
1377 //=======================================================================
1379 ostream& SMESH_Mesh::Dump(ostream& save)
1382 save << "========================== Dump contents of mesh ==========================" << endl << endl;
1383 save << ++clause << ") Total number of nodes: \t" << NbNodes() << endl;
1384 save << ++clause << ") Total number of edges: \t" << NbEdges() << endl;
1385 save << ++clause << ") Total number of faces: \t" << NbFaces() << endl;
1386 save << ++clause << ") Total number of polygons:\t" << NbPolygons() << endl;
1387 save << ++clause << ") Total number of volumes:\t" << NbVolumes() << endl;
1388 save << ++clause << ") Total number of polyhedrons:\t" << NbPolyhedrons() << endl << endl;
1389 for ( int isQuadratic = 0; isQuadratic < 2; ++isQuadratic )
1391 string orderStr = isQuadratic ? "quadratic" : "linear";
1392 SMDSAbs_ElementOrder order = isQuadratic ? ORDER_QUADRATIC : ORDER_LINEAR;
1394 save << ++clause << ") Total number of " << orderStr << " edges:\t" << NbEdges(order) << endl;
1395 save << ++clause << ") Total number of " << orderStr << " faces:\t" << NbFaces(order) << endl;
1396 if ( NbFaces(order) > 0 ) {
1397 int nb3 = NbTriangles(order);
1398 int nb4 = NbQuadrangles(order);
1399 save << clause << ".1) Number of " << orderStr << " triangles: \t" << nb3 << endl;
1400 save << clause << ".2) Number of " << orderStr << " quadrangles:\t" << nb4 << endl;
1401 if ( nb3 + nb4 != NbFaces(order) ) {
1402 std::map<int,int> myFaceMap;
1403 SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
1404 while( itFaces->more( ) ) {
1405 int nbNodes = itFaces->next()->NbNodes();
1406 if ( myFaceMap.find( nbNodes ) == myFaceMap.end() )
1407 myFaceMap[ nbNodes ] = 0;
1408 myFaceMap[ nbNodes ] = myFaceMap[ nbNodes ] + 1;
1410 save << clause << ".3) Faces in detail: " << endl;
1411 map <int,int>::iterator itF;
1412 for (itF = myFaceMap.begin(); itF != myFaceMap.end(); itF++)
1413 save << "--> nb nodes: " << itF->first << " - nb elemens:\t" << itF->second << endl;
1416 save << ++clause << ") Total number of " << orderStr << " volumes:\t" << NbVolumes(order) << endl;
1417 if ( NbVolumes(order) > 0 ) {
1418 int nb8 = NbHexas(order);
1419 int nb4 = NbTetras(order);
1420 int nb5 = NbPyramids(order);
1421 int nb6 = NbPrisms(order);
1422 save << clause << ".1) Number of " << orderStr << " hexahedrons:\t" << nb8 << endl;
1423 save << clause << ".2) Number of " << orderStr << " tetrahedrons:\t" << nb4 << endl;
1424 save << clause << ".3) Number of " << orderStr << " prisms: \t" << nb6 << endl;
1425 save << clause << ".4) Number of " << orderStr << " pyramids:\t" << nb5 << endl;
1426 if ( nb8 + nb4 + nb5 + nb6 != NbVolumes(order) ) {
1427 std::map<int,int> myVolumesMap;
1428 SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
1429 while( itVolumes->more( ) ) {
1430 int nbNodes = itVolumes->next()->NbNodes();
1431 if ( myVolumesMap.find( nbNodes ) == myVolumesMap.end() )
1432 myVolumesMap[ nbNodes ] = 0;
1433 myVolumesMap[ nbNodes ] = myVolumesMap[ nbNodes ] + 1;
1435 save << clause << ".5) Volumes in detail: " << endl;
1436 map <int,int>::iterator itV;
1437 for (itV = myVolumesMap.begin(); itV != myVolumesMap.end(); itV++)
1438 save << "--> nb nodes: " << itV->first << " - nb elemens:\t" << itV->second << endl;
1443 save << "===========================================================================" << endl;
1447 //=======================================================================
1448 //function : GetElementType
1449 //purpose : Returns type of mesh element with certain id
1450 //=======================================================================
1452 SMDSAbs_ElementType SMESH_Mesh::GetElementType( const int id, const bool iselem )
1454 return _myMeshDS->GetElementType( id, iselem );