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 map < int, SMESH_Group * >::iterator itg;
113 for (itg = _mapGroup.begin(); itg != _mapGroup.end(); itg++) {
114 SMESH_Group *aGroup = (*itg).second;
119 //=============================================================================
121 * \brief Set geometry to be meshed
123 //=============================================================================
125 void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape)
127 if(MYDEBUG) MESSAGE("SMESH_Mesh::ShapeToMesh");
129 if ( !aShape.IsNull() && _isShapeToMesh )
130 throw SALOME_Exception(LOCALIZED ("a shape to mesh has already been defined"));
132 // clear current data
133 if ( !_myMeshDS->ShapeToMesh().IsNull() )
135 // removal of a shape to mesh, delete objects referring to sub-shapes:
137 map <int, SMESH_subMesh *>::iterator i_sm = _mapSubMesh.begin();
138 for ( ; i_sm != _mapSubMesh.end(); ++i_sm )
141 // - groups on geometry
142 map <int, SMESH_Group *>::iterator i_gr = _mapGroup.begin();
143 while ( i_gr != _mapGroup.end() ) {
144 if ( dynamic_cast<SMESHDS_GroupOnGeom*>( i_gr->second->GetGroupDS() )) {
145 _myMeshDS->RemoveGroup( i_gr->second->GetGroupDS() );
147 _mapGroup.erase( i_gr++ );
152 _mapAncestors.Clear();
155 TopoDS_Shape aNullShape;
156 _myMeshDS->ShapeToMesh( aNullShape );
159 // set a new geometry
160 if ( !aShape.IsNull() )
162 _myMeshDS->ShapeToMesh(aShape);
163 _isShapeToMesh = true;
165 // fill _mapAncestors
166 int desType, ancType;
167 for ( desType = TopAbs_VERTEX; desType > TopAbs_COMPOUND; desType-- )
168 for ( ancType = desType - 1; ancType >= TopAbs_COMPOUND; ancType-- )
169 TopExp::MapShapesAndAncestors ( aShape,
170 (TopAbs_ShapeEnum) desType,
171 (TopAbs_ShapeEnum) ancType,
176 //=======================================================================
178 * \brief Return geometry to be meshed. (It may be a PseudoShape()!)
180 //=======================================================================
182 TopoDS_Shape SMESH_Mesh::GetShapeToMesh() const
184 return _myMeshDS->ShapeToMesh();
187 //=======================================================================
189 * \brief Return a solid which is returned by GetShapeToMesh() if
190 * a real geometry to be meshed was not set
192 //=======================================================================
194 const TopoDS_Solid& SMESH_Mesh::PseudoShape()
196 static TopoDS_Solid aSolid;
197 if ( aSolid.IsNull() )
199 aSolid = BRepPrimAPI_MakeBox(1,1,1);
204 //=======================================================================
206 * \brief Remove all nodes and elements
208 //=======================================================================
210 void SMESH_Mesh::Clear()
212 // clear sub-meshes; get ready to re-compute as a side-effect
214 if ( SMESH_subMesh *sm = GetSubMeshContaining( GetShapeToMesh() ) )
216 SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(/*includeSelf=*/true,
217 /*complexShapeFirst=*/false);
218 while ( smIt->more() )
221 TopAbs_ShapeEnum shapeType = sm->GetSubShape().ShapeType();
222 if ( shapeType == TopAbs_VERTEX || shapeType < TopAbs_SOLID )
223 // all other shapes depends on vertices so they are already cleaned
224 sm->ComputeStateEngine( SMESH_subMesh::CLEAN );
228 // clear entities not on sub-meshes
230 SMDS_VolumeIteratorPtr vIt = _myMeshDS->volumesIterator();
231 while ( vIt->more() )
232 _myMeshDS->RemoveFreeElement( vIt->next(), 0 );
234 SMDS_FaceIteratorPtr fIt = _myMeshDS->facesIterator();
235 while ( fIt->more() )
236 _myMeshDS->RemoveFreeElement( fIt->next(), 0 );
238 SMDS_EdgeIteratorPtr eIt = _myMeshDS->edgesIterator();
239 while ( eIt->more() )
240 _myMeshDS->RemoveFreeElement( eIt->next(), 0 );
242 SMDS_NodeIteratorPtr nIt = _myMeshDS->nodesIterator();
243 while ( nIt->more() ) {
244 const SMDS_MeshNode * node = nIt->next();
245 if ( node->NbInverseElements() == 0 )
246 _myMeshDS->RemoveFreeNode( node, 0 );
248 _myMeshDS->RemoveNode(node);
252 //=======================================================================
253 //function : UNVToMesh
255 //=======================================================================
257 int SMESH_Mesh::UNVToMesh(const char* theFileName)
259 if(MYDEBUG) MESSAGE("UNVToMesh - theFileName = "<<theFileName);
261 throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
262 _isShapeToMesh = false;
263 DriverUNV_R_SMDS_Mesh myReader;
264 myReader.SetMesh(_myMeshDS);
265 myReader.SetFile(theFileName);
266 myReader.SetMeshId(-1);
269 MESSAGE("UNVToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
270 MESSAGE("UNVToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
271 MESSAGE("UNVToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
272 MESSAGE("UNVToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
274 SMDS_MeshGroup* aGroup = (SMDS_MeshGroup*) myReader.GetGroup();
276 TGroupNamesMap aGroupNames = myReader.GetGroupNamesMap();
277 //const TGroupIdMap& aGroupId = myReader.GetGroupIdMap();
278 aGroup->InitSubGroupsIterator();
279 while (aGroup->MoreSubGroups()) {
280 SMDS_MeshGroup* aSubGroup = (SMDS_MeshGroup*) aGroup->NextSubGroup();
281 std::string aName = aGroupNames[aSubGroup];
284 SMESH_Group* aSMESHGroup = AddGroup( aSubGroup->GetType(), aName.c_str(), aId );
286 if(MYDEBUG) MESSAGE("UNVToMesh - group added: "<<aName);
287 SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( aSMESHGroup->GetGroupDS() );
289 aGroupDS->SetStoreName(aName.c_str());
290 aSubGroup->InitIterator();
291 const SMDS_MeshElement* aElement = 0;
292 while (aSubGroup->More()) {
293 aElement = aSubGroup->Next();
295 aGroupDS->SMDSGroup().Add(aElement);
299 aGroupDS->SetType(aElement->GetType());
307 //=======================================================================
308 //function : MEDToMesh
310 //=======================================================================
312 int SMESH_Mesh::MEDToMesh(const char* theFileName, const char* theMeshName)
314 if(MYDEBUG) MESSAGE("MEDToMesh - theFileName = "<<theFileName<<", mesh name = "<<theMeshName);
316 throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
317 _isShapeToMesh = false;
318 DriverMED_R_SMESHDS_Mesh myReader;
319 myReader.SetMesh(_myMeshDS);
320 myReader.SetMeshId(-1);
321 myReader.SetFile(theFileName);
322 myReader.SetMeshName(theMeshName);
323 Driver_Mesh::Status status = myReader.Perform();
325 MESSAGE("MEDToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
326 MESSAGE("MEDToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
327 MESSAGE("MEDToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
328 MESSAGE("MEDToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
331 // Reading groups (sub-meshes are out of scope of MED import functionality)
332 list<TNameAndType> aGroupNames = myReader.GetGroupNamesAndTypes();
333 if(MYDEBUG) MESSAGE("MEDToMesh - Nb groups = "<<aGroupNames.size());
335 list<TNameAndType>::iterator name_type = aGroupNames.begin();
336 for ( ; name_type != aGroupNames.end(); name_type++ ) {
337 SMESH_Group* aGroup = AddGroup( name_type->second, name_type->first.c_str(), anId );
339 if(MYDEBUG) MESSAGE("MEDToMesh - group added: "<<name_type->first.c_str());
340 SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( aGroup->GetGroupDS() );
342 aGroupDS->SetStoreName( name_type->first.c_str() );
343 myReader.GetGroup( aGroupDS );
350 //=======================================================================
351 //function : STLToMesh
353 //=======================================================================
355 int SMESH_Mesh::STLToMesh(const char* theFileName)
357 if(MYDEBUG) MESSAGE("STLToMesh - theFileName = "<<theFileName);
359 throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
360 _isShapeToMesh = false;
361 DriverSTL_R_SMDS_Mesh myReader;
362 myReader.SetMesh(_myMeshDS);
363 myReader.SetFile(theFileName);
364 myReader.SetMeshId(-1);
367 MESSAGE("STLToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
368 MESSAGE("STLToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
369 MESSAGE("STLToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
370 MESSAGE("STLToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
375 //=============================================================================
379 //=============================================================================
381 SMESH_Hypothesis::Hypothesis_Status
382 SMESH_Mesh::AddHypothesis(const TopoDS_Shape & aSubShape,
383 int anHypId ) throw(SALOME_Exception)
385 Unexpect aCatch(SalomeException);
386 if(MYDEBUG) MESSAGE("SMESH_Mesh::AddHypothesis");
388 SMESH_subMesh *subMesh = GetSubMesh(aSubShape);
389 if ( !subMesh || !subMesh->GetId())
390 return SMESH_Hypothesis::HYP_BAD_SUBSHAPE;
392 SMESHDS_SubMesh *subMeshDS = subMesh->GetSubMeshDS();
393 if ( subMeshDS && subMeshDS->IsComplexSubmesh() ) // group of sub-shapes and maybe of not sub-
395 MESSAGE("AddHypothesis() to complex submesh");
396 // return the worst but not fatal state of all group memebers
397 SMESH_Hypothesis::Hypothesis_Status aBestRet, aWorstNotFatal, ret;
398 aBestRet = SMESH_Hypothesis::HYP_BAD_DIM;
399 aWorstNotFatal = SMESH_Hypothesis::HYP_OK;
400 for ( TopoDS_Iterator itS ( aSubShape ); itS.More(); itS.Next())
402 if ( !GetMeshDS()->ShapeToIndex( itS.Value() ))
403 continue; // not sub-shape
404 ret = AddHypothesis( itS.Value(), anHypId );
405 if ( !SMESH_Hypothesis::IsStatusFatal( ret ) && ret > aWorstNotFatal )
406 aWorstNotFatal = ret;
407 if ( ret < aBestRet )
410 // bind hypotheses to a group just to know
411 SMESH_Hypothesis *anHyp = _gen->GetStudyContext(_studyId)->mapHypothesis[anHypId];
412 GetMeshDS()->AddHypothesis( aSubShape, anHyp );
414 if ( SMESH_Hypothesis::IsStatusFatal( aBestRet ))
416 return aWorstNotFatal;
419 StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
420 if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
422 if(MYDEBUG) MESSAGE("Hypothesis ID does not give an hypothesis");
427 throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
430 SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
431 MESSAGE( "SMESH_Mesh::AddHypothesis " << anHyp->GetName() );
433 bool isGlobalHyp = IsMainShape( aSubShape );
435 // NotConformAllowed can be only global
438 string hypName = anHyp->GetName();
439 if ( hypName == "NotConformAllowed" )
441 if(MYDEBUG) MESSAGE( "Hypotesis <NotConformAllowed> can be only global" );
442 return SMESH_Hypothesis::HYP_INCOMPATIBLE;
448 bool isAlgo = ( !anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO );
449 int event = isAlgo ? SMESH_subMesh::ADD_ALGO : SMESH_subMesh::ADD_HYP;
451 SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp);
454 if (!SMESH_Hypothesis::IsStatusFatal(ret) &&
455 anHyp->GetDim() <= SMESH_Gen::GetShapeDim(aSubShape)) // is added on father
457 event = isAlgo ? SMESH_subMesh::ADD_FATHER_ALGO : SMESH_subMesh::ADD_FATHER_HYP;
459 SMESH_Hypothesis::Hypothesis_Status ret2 =
460 subMesh->SubMeshesAlgoStateEngine(event, anHyp);
464 // check concurent hypotheses on ansestors
465 if (ret < SMESH_Hypothesis::HYP_CONCURENT && !isGlobalHyp )
467 SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false);
468 while ( smIt->more() ) {
469 SMESH_subMesh* sm = smIt->next();
470 if ( sm->IsApplicableHypotesis( anHyp )) {
471 ret2 = sm->CheckConcurentHypothesis( anHyp->GetType() );
481 if(MYDEBUG) subMesh->DumpAlgoState(true);
486 //=============================================================================
490 //=============================================================================
492 SMESH_Hypothesis::Hypothesis_Status
493 SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape & aSubShape,
494 int anHypId)throw(SALOME_Exception)
496 Unexpect aCatch(SalomeException);
497 if(MYDEBUG) MESSAGE("SMESH_Mesh::RemoveHypothesis");
499 SMESH_subMesh *subMesh = GetSubMesh(aSubShape);
500 SMESHDS_SubMesh *subMeshDS = subMesh->GetSubMeshDS();
501 if ( subMeshDS && subMeshDS->IsComplexSubmesh() )
503 // return the worst but not fatal state of all group memebers
504 SMESH_Hypothesis::Hypothesis_Status aBestRet, aWorstNotFatal, ret;
505 aBestRet = SMESH_Hypothesis::HYP_BAD_DIM;
506 aWorstNotFatal = SMESH_Hypothesis::HYP_OK;
507 for ( TopoDS_Iterator itS ( aSubShape ); itS.More(); itS.Next())
509 if ( !GetMeshDS()->ShapeToIndex( itS.Value() ))
510 continue; // not sub-shape
511 ret = RemoveHypothesis( itS.Value(), anHypId );
512 if ( !SMESH_Hypothesis::IsStatusFatal( ret ) && ret > aWorstNotFatal )
513 aWorstNotFatal = ret;
514 if ( ret < aBestRet )
517 SMESH_Hypothesis *anHyp = _gen->GetStudyContext(_studyId)->mapHypothesis[anHypId];
518 GetMeshDS()->RemoveHypothesis( aSubShape, anHyp );
520 if ( SMESH_Hypothesis::IsStatusFatal( aBestRet ))
522 return aWorstNotFatal;
525 StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
526 if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
527 throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
529 SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
530 int hypType = anHyp->GetType();
531 if(MYDEBUG) SCRUTE(hypType);
535 bool isAlgo = ( !anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO );
536 int event = isAlgo ? SMESH_subMesh::REMOVE_ALGO : SMESH_subMesh::REMOVE_HYP;
538 SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp);
540 // there may appear concurrent hyps that were covered by the removed hyp
541 if (ret < SMESH_Hypothesis::HYP_CONCURENT &&
542 subMesh->IsApplicableHypotesis( anHyp ) &&
543 subMesh->CheckConcurentHypothesis( anHyp->GetType() ) != SMESH_Hypothesis::HYP_OK)
544 ret = SMESH_Hypothesis::HYP_CONCURENT;
547 if (!SMESH_Hypothesis::IsStatusFatal(ret) &&
548 anHyp->GetDim() <= SMESH_Gen::GetShapeDim(aSubShape)) // is removed from father
550 event = isAlgo ? SMESH_subMesh::REMOVE_FATHER_ALGO : SMESH_subMesh::REMOVE_FATHER_HYP;
552 SMESH_Hypothesis::Hypothesis_Status ret2 =
553 subMesh->SubMeshesAlgoStateEngine(event, anHyp);
554 if (ret2 > ret) // more severe
557 // check concurent hypotheses on ansestors
558 if (ret < SMESH_Hypothesis::HYP_CONCURENT && !IsMainShape( aSubShape ) )
560 SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false);
561 while ( smIt->more() ) {
562 SMESH_subMesh* sm = smIt->next();
563 if ( sm->IsApplicableHypotesis( anHyp )) {
564 ret2 = sm->CheckConcurentHypothesis( anHyp->GetType() );
574 if(MYDEBUG) subMesh->DumpAlgoState(true);
575 if(MYDEBUG) SCRUTE(ret);
579 //=============================================================================
583 //=============================================================================
585 const list<const SMESHDS_Hypothesis*>&
586 SMESH_Mesh::GetHypothesisList(const TopoDS_Shape & aSubShape) const
587 throw(SALOME_Exception)
589 Unexpect aCatch(SalomeException);
590 return _myMeshDS->GetHypothesis(aSubShape);
593 //=======================================================================
595 * \brief Return the hypothesis assigned to the shape
596 * \param aSubShape - the shape to check
597 * \param aFilter - the hypothesis filter
598 * \param andAncestors - flag to check hypos assigned to ancestors of the shape
599 * \retval SMESH_Hypothesis* - the first hypo passed through aFilter
601 //=======================================================================
603 const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubShape,
604 const SMESH_HypoFilter& aFilter,
605 const bool andAncestors) const
608 const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
609 list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
610 for ( ; hyp != hypList.end(); hyp++ ) {
611 const SMESH_Hypothesis * h = cSMESH_Hyp( *hyp );
612 if ( aFilter.IsOk( h, aSubShape))
618 TopTools_ListIteratorOfListOfShape it( GetAncestors( aSubShape ));
619 for (; it.More(); it.Next() )
621 const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value());
622 list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
623 for ( ; hyp != hypList.end(); hyp++ ) {
624 const SMESH_Hypothesis * h = cSMESH_Hyp( *hyp );
625 if (aFilter.IsOk( h, it.Value() ))
633 //================================================================================
635 * \brief Return hypothesis assigned to the shape
636 * \param aSubShape - the shape to check
637 * \param aFilter - the hypothesis filter
638 * \param aHypList - the list of the found hypotheses
639 * \param andAncestors - flag to check hypos assigned to ancestors of the shape
640 * \retval int - number of unique hypos in aHypList
642 //================================================================================
644 int SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape,
645 const SMESH_HypoFilter& aFilter,
646 list <const SMESHDS_Hypothesis * >& aHypList,
647 const bool andAncestors) const
649 set<string> hypTypes; // to exclude same type hypos from the result list
652 // only one main hypothesis is allowed
653 bool mainHypFound = false;
656 list<const SMESHDS_Hypothesis*>::const_iterator hyp;
657 for ( hyp = aHypList.begin(); hyp != aHypList.end(); hyp++ ) {
658 if ( hypTypes.insert( (*hyp)->GetName() ).second )
660 if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
664 // get hypos from aSubShape
666 const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
667 for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
668 if ( aFilter.IsOk (cSMESH_Hyp( *hyp ), aSubShape) &&
669 ( cSMESH_Hyp(*hyp)->IsAuxiliary() || !mainHypFound ) &&
670 hypTypes.insert( (*hyp)->GetName() ).second )
672 aHypList.push_back( *hyp );
674 if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
679 // get hypos from ancestors of aSubShape
682 TopTools_MapOfShape map;
683 TopTools_ListIteratorOfListOfShape it( GetAncestors( aSubShape ));
684 for (; it.More(); it.Next() )
686 if ( !map.Add( it.Value() ))
688 const list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value());
689 for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
690 if (aFilter.IsOk( cSMESH_Hyp( *hyp ), it.Value() ) &&
691 ( cSMESH_Hyp(*hyp)->IsAuxiliary() || !mainHypFound ) &&
692 hypTypes.insert( (*hyp)->GetName() ).second )
694 aHypList.push_back( *hyp );
696 if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
704 //=============================================================================
708 //=============================================================================
710 const list<SMESHDS_Command*> & SMESH_Mesh::GetLog() throw(SALOME_Exception)
712 Unexpect aCatch(SalomeException);
713 if(MYDEBUG) MESSAGE("SMESH_Mesh::GetLog");
714 return _myMeshDS->GetScript()->GetCommands();
717 //=============================================================================
721 //=============================================================================
722 void SMESH_Mesh::ClearLog() throw(SALOME_Exception)
724 Unexpect aCatch(SalomeException);
725 if(MYDEBUG) MESSAGE("SMESH_Mesh::ClearLog");
726 _myMeshDS->GetScript()->Clear();
729 //=============================================================================
731 * Get or Create the SMESH_subMesh object implementation
733 //=============================================================================
735 SMESH_subMesh *SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape)
736 throw(SALOME_Exception)
738 Unexpect aCatch(SalomeException);
739 SMESH_subMesh *aSubMesh;
740 int index = _myMeshDS->ShapeToIndex(aSubShape);
742 // for submeshes on GEOM Group
743 if ( !index && aSubShape.ShapeType() == TopAbs_COMPOUND ) {
744 TopoDS_Iterator it( aSubShape );
746 index = _myMeshDS->AddCompoundSubmesh( aSubShape, it.Value().ShapeType() );
749 // return NULL; // neither sub-shape nor a group
751 map <int, SMESH_subMesh *>::iterator i_sm = _mapSubMesh.find(index);
752 if ( i_sm != _mapSubMesh.end())
754 aSubMesh = i_sm->second;
758 aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape);
759 _mapSubMesh[index] = aSubMesh;
764 //=============================================================================
766 * Get the SMESH_subMesh object implementation. Dont create it, return null
767 * if it does not exist.
769 //=============================================================================
771 SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape) const
772 throw(SALOME_Exception)
774 Unexpect aCatch(SalomeException);
775 SMESH_subMesh *aSubMesh = NULL;
777 int index = _myMeshDS->ShapeToIndex(aSubShape);
779 map <int, SMESH_subMesh *>::const_iterator i_sm = _mapSubMesh.find(index);
780 if ( i_sm != _mapSubMesh.end())
781 aSubMesh = i_sm->second;
785 //=============================================================================
787 * Get the SMESH_subMesh object implementation. Dont create it, return null
788 * if it does not exist.
790 //=============================================================================
792 SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const int aShapeID) const
793 throw(SALOME_Exception)
795 Unexpect aCatch(SalomeException);
797 map <int, SMESH_subMesh *>::const_iterator i_sm = _mapSubMesh.find(aShapeID);
798 if (i_sm == _mapSubMesh.end())
802 //================================================================================
804 * \brief Return submeshes of groups containing the given subshape
806 //================================================================================
809 SMESH_Mesh::GetGroupSubMeshesContaining(const TopoDS_Shape & aSubShape) const
810 throw(SALOME_Exception)
812 Unexpect aCatch(SalomeException);
813 list<SMESH_subMesh*> found;
815 SMESH_subMesh * subMesh = GetSubMeshContaining(aSubShape);
819 // submeshes of groups have max IDs, so search from the map end
820 map<int, SMESH_subMesh *>::const_reverse_iterator i_sm;
821 for ( i_sm = _mapSubMesh.rbegin(); i_sm != _mapSubMesh.rend(); ++i_sm) {
822 SMESHDS_SubMesh * ds = i_sm->second->GetSubMeshDS();
823 if ( ds && ds->IsComplexSubmesh() ) {
824 TopExp_Explorer exp( i_sm->second->GetSubShape(), aSubShape.ShapeType() );
825 for ( ; exp.More(); exp.Next() ) {
826 if ( aSubShape.IsSame( exp.Current() )) {
827 found.push_back( i_sm->second );
837 //=======================================================================
838 //function : IsUsedHypothesis
839 //purpose : Return True if anHyp is used to mesh aSubShape
840 //=======================================================================
842 bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
843 const SMESH_subMesh* aSubMesh)
845 SMESH_Hypothesis* hyp = static_cast<SMESH_Hypothesis*>(anHyp);
847 // check if anHyp can be used to mesh aSubMesh
848 if ( !aSubMesh || !aSubMesh->IsApplicableHypotesis( hyp ))
851 const TopoDS_Shape & aSubShape = const_cast<SMESH_subMesh*>( aSubMesh )->GetSubShape();
853 SMESH_Algo *algo = _gen->GetAlgo(*this, aSubShape );
856 if (anHyp->GetType() > SMESHDS_Hypothesis::PARAM_ALGO)
857 return ( anHyp == algo );
859 // algorithm parameter
862 // look trough hypotheses used by algo
863 SMESH_HypoFilter hypoKind;
864 if ( algo->InitCompatibleHypoFilter( hypoKind, !hyp->IsAuxiliary() )) {
865 list <const SMESHDS_Hypothesis * > usedHyps;
866 if ( GetHypotheses( aSubShape, hypoKind, usedHyps, true ))
867 return ( find( usedHyps.begin(), usedHyps.end(), anHyp ) != usedHyps.end() );
871 // look through all assigned hypotheses
872 //SMESH_HypoFilter filter( SMESH_HypoFilter::Is( hyp ));
873 return false; //GetHypothesis( aSubShape, filter, true );
876 //=============================================================================
880 //=============================================================================
882 const list < SMESH_subMesh * >&
883 SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
884 throw(SALOME_Exception)
886 Unexpect aCatch(SalomeException);
887 if(MYDEBUG) MESSAGE("SMESH_Mesh::GetSubMeshUsingHypothesis");
888 map < int, SMESH_subMesh * >::iterator itsm;
889 _subMeshesUsingHypothesisList.clear();
890 for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
892 SMESH_subMesh *aSubMesh = (*itsm).second;
893 if ( IsUsedHypothesis ( anHyp, aSubMesh ))
894 _subMeshesUsingHypothesisList.push_back(aSubMesh);
896 return _subMeshesUsingHypothesisList;
899 //=======================================================================
900 //function : NotifySubMeshesHypothesisModification
901 //purpose : Say all submeshes using theChangedHyp that it has been modified
902 //=======================================================================
904 void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* hyp)
906 Unexpect aCatch(SalomeException);
908 const SMESH_Algo *foundAlgo = 0;
909 SMESH_HypoFilter algoKind, compatibleHypoKind;
910 list <const SMESHDS_Hypothesis * > usedHyps;
913 map < int, SMESH_subMesh * >::iterator itsm;
914 for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
916 SMESH_subMesh *aSubMesh = (*itsm).second;
917 if ( aSubMesh->IsApplicableHypotesis( hyp ))
919 const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape();
921 if ( !foundAlgo ) // init filter for algo search
922 algoKind.Init( THypType::IsAlgo() ).And( THypType::IsApplicableTo( aSubShape ));
924 const SMESH_Algo *algo = static_cast<const SMESH_Algo*>
925 ( GetHypothesis( aSubShape, algoKind, true ));
929 bool sameAlgo = ( algo == foundAlgo );
930 if ( !sameAlgo && foundAlgo )
931 sameAlgo = ( strcmp( algo->GetName(), foundAlgo->GetName() ) == 0);
933 if ( !sameAlgo ) { // init filter for used hypos search
934 if ( !algo->InitCompatibleHypoFilter( compatibleHypoKind, !hyp->IsAuxiliary() ))
935 continue; // algo does not use any hypothesis
939 // check if hyp is used by algo
941 if ( GetHypotheses( aSubShape, compatibleHypoKind, usedHyps, true ) &&
942 find( usedHyps.begin(), usedHyps.end(), hyp ) != usedHyps.end() )
944 aSubMesh->AlgoStateEngine(SMESH_subMesh::MODIF_HYP,
945 const_cast< SMESH_Hypothesis*>( hyp ));
952 //=============================================================================
954 * Auto color functionality
956 //=============================================================================
957 void SMESH_Mesh::SetAutoColor(bool theAutoColor) throw(SALOME_Exception)
959 Unexpect aCatch(SalomeException);
960 _isAutoColor = theAutoColor;
963 bool SMESH_Mesh::GetAutoColor() throw(SALOME_Exception)
965 Unexpect aCatch(SalomeException);
969 //=============================================================================
971 * To store mesh contents on disk in different formats.
973 //=============================================================================
975 bool SMESH_Mesh::HasDuplicatedGroupNamesMED()
977 set<string> aGroupNames;
978 for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
979 SMESH_Group* aGroup = it->second;
980 string aGroupName = aGroup->GetName();
981 aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
982 if (!aGroupNames.insert(aGroupName).second)
989 void SMESH_Mesh::ExportMED(const char *file,
990 const char* theMeshName,
993 throw(SALOME_Exception)
995 Unexpect aCatch(SalomeException);
997 DriverMED_W_SMESHDS_Mesh myWriter;
998 myWriter.SetFile ( file, MED::EVersion(theVersion) );
999 myWriter.SetMesh ( _myMeshDS );
1001 myWriter.SetMeshId ( _idDoc );
1003 myWriter.SetMeshId ( -1 );
1004 myWriter.SetMeshName( theMeshName );
1007 if ( theAutoGroups ) {
1008 myWriter.AddGroupOfNodes();
1009 myWriter.AddGroupOfEdges();
1010 myWriter.AddGroupOfFaces();
1011 myWriter.AddGroupOfVolumes();
1014 // Pass groups to writer. Provide unique group names.
1015 set<string> aGroupNames;
1017 int maxNbIter = 10000; // to guarantee cycle finish
1018 for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
1019 SMESH_Group* aGroup = it->second;
1020 SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
1022 string aGroupName0 = aGroup->GetName();
1023 aGroupName0.resize(MAX_MED_GROUP_NAME_LENGTH);
1024 string aGroupName = aGroupName0;
1025 for (int i = 1; !aGroupNames.insert(aGroupName).second && i < maxNbIter; i++) {
1026 sprintf(&aString[0], "GR_%d_%s", i, aGroupName0.c_str());
1027 aGroupName = aString;
1028 aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
1030 aGroupDS->SetStoreName( aGroupName.c_str() );
1031 myWriter.AddGroup( aGroupDS );
1039 void SMESH_Mesh::ExportDAT(const char *file) throw(SALOME_Exception)
1041 Unexpect aCatch(SalomeException);
1042 DriverDAT_W_SMDS_Mesh myWriter;
1043 myWriter.SetFile(string(file));
1044 myWriter.SetMesh(_myMeshDS);
1045 myWriter.SetMeshId(_idDoc);
1049 void SMESH_Mesh::ExportUNV(const char *file) throw(SALOME_Exception)
1051 Unexpect aCatch(SalomeException);
1052 DriverUNV_W_SMDS_Mesh myWriter;
1053 myWriter.SetFile(string(file));
1054 myWriter.SetMesh(_myMeshDS);
1055 myWriter.SetMeshId(_idDoc);
1056 // myWriter.SetGroups(_mapGroup);
1058 for ( map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
1059 SMESH_Group* aGroup = it->second;
1060 SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
1062 string aGroupName = aGroup->GetName();
1063 aGroupDS->SetStoreName( aGroupName.c_str() );
1064 myWriter.AddGroup( aGroupDS );
1070 void SMESH_Mesh::ExportSTL(const char *file, const bool isascii) throw(SALOME_Exception)
1072 Unexpect aCatch(SalomeException);
1073 DriverSTL_W_SMDS_Mesh myWriter;
1074 myWriter.SetFile(string(file));
1075 myWriter.SetIsAscii( isascii );
1076 myWriter.SetMesh(_myMeshDS);
1077 myWriter.SetMeshId(_idDoc);
1081 //================================================================================
1083 * \brief Return number of nodes in the mesh
1085 //================================================================================
1087 int SMESH_Mesh::NbNodes() throw(SALOME_Exception)
1089 Unexpect aCatch(SalomeException);
1090 return _myMeshDS->NbNodes();
1093 //================================================================================
1095 * \brief Return number of edges of given order in the mesh
1097 //================================================================================
1099 int SMESH_Mesh::NbEdges(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1101 Unexpect aCatch(SalomeException);
1102 return _myMeshDS->GetMeshInfo().NbEdges(order);
1105 //================================================================================
1107 * \brief Return number of faces of given order in the mesh
1109 //================================================================================
1111 int SMESH_Mesh::NbFaces(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1113 Unexpect aCatch(SalomeException);
1114 return _myMeshDS->GetMeshInfo().NbFaces(order);
1117 //================================================================================
1119 * \brief Return the number of faces in the mesh
1121 //================================================================================
1123 int SMESH_Mesh::NbTriangles(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1125 Unexpect aCatch(SalomeException);
1126 return _myMeshDS->GetMeshInfo().NbTriangles(order);
1129 //================================================================================
1131 * \brief Return the number nodes faces in the mesh
1133 //================================================================================
1135 int SMESH_Mesh::NbQuadrangles(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1137 Unexpect aCatch(SalomeException);
1138 return _myMeshDS->GetMeshInfo().NbQuadrangles(order);
1141 //================================================================================
1143 * \brief Return the number of polygonal faces in the mesh
1145 //================================================================================
1147 int SMESH_Mesh::NbPolygons() throw(SALOME_Exception)
1149 Unexpect aCatch(SalomeException);
1150 return _myMeshDS->GetMeshInfo().NbPolygons();
1153 //================================================================================
1155 * \brief Return number of volumes of given order in the mesh
1157 //================================================================================
1159 int SMESH_Mesh::NbVolumes(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1161 Unexpect aCatch(SalomeException);
1162 return _myMeshDS->GetMeshInfo().NbVolumes(order);
1165 //================================================================================
1167 * \brief Return number of tetrahedrons of given order in the mesh
1169 //================================================================================
1171 int SMESH_Mesh::NbTetras(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1173 Unexpect aCatch(SalomeException);
1174 return _myMeshDS->GetMeshInfo().NbTetras(order);
1177 //================================================================================
1179 * \brief Return number of hexahedrons of given order in the mesh
1181 //================================================================================
1183 int SMESH_Mesh::NbHexas(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1185 Unexpect aCatch(SalomeException);
1186 return _myMeshDS->GetMeshInfo().NbHexas(order);
1189 //================================================================================
1191 * \brief Return number of pyramids of given order in the mesh
1193 //================================================================================
1195 int SMESH_Mesh::NbPyramids(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1197 Unexpect aCatch(SalomeException);
1198 return _myMeshDS->GetMeshInfo().NbPyramids(order);
1201 //================================================================================
1203 * \brief Return number of prisms (penthahedrons) of given order in the mesh
1205 //================================================================================
1207 int SMESH_Mesh::NbPrisms(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1209 Unexpect aCatch(SalomeException);
1210 return _myMeshDS->GetMeshInfo().NbPrisms(order);
1213 //================================================================================
1215 * \brief Return number of polyhedrons in the mesh
1217 //================================================================================
1219 int SMESH_Mesh::NbPolyhedrons() throw(SALOME_Exception)
1221 Unexpect aCatch(SalomeException);
1222 return _myMeshDS->GetMeshInfo().NbPolyhedrons();
1225 //================================================================================
1227 * \brief Return number of submeshes in the mesh
1229 //================================================================================
1231 int SMESH_Mesh::NbSubMesh() throw(SALOME_Exception)
1233 Unexpect aCatch(SalomeException);
1234 return _myMeshDS->NbSubMesh();
1237 //=======================================================================
1238 //function : IsNotConformAllowed
1239 //purpose : check if a hypothesis alowing notconform mesh is present
1240 //=======================================================================
1242 bool SMESH_Mesh::IsNotConformAllowed() const
1244 if(MYDEBUG) MESSAGE("SMESH_Mesh::IsNotConformAllowed");
1246 static SMESH_HypoFilter filter( SMESH_HypoFilter::HasName( "NotConformAllowed" ));
1247 return GetHypothesis( _myMeshDS->ShapeToMesh(), filter, false );
1250 //=======================================================================
1251 //function : IsMainShape
1253 //=======================================================================
1255 bool SMESH_Mesh::IsMainShape(const TopoDS_Shape& theShape) const
1257 return theShape.IsSame(_myMeshDS->ShapeToMesh() );
1260 //=============================================================================
1264 //=============================================================================
1266 SMESH_Group* SMESH_Mesh::AddGroup (const SMDSAbs_ElementType theType,
1267 const char* theName,
1269 const TopoDS_Shape& theShape)
1271 if (_mapGroup.find(_groupId) != _mapGroup.end())
1274 SMESH_Group* aGroup = new SMESH_Group (theId, this, theType, theName, theShape);
1275 GetMeshDS()->AddGroup( aGroup->GetGroupDS() );
1276 _mapGroup[_groupId++] = aGroup;
1280 //================================================================================
1282 * \brief Return iterator on all existing groups
1284 //================================================================================
1286 SMESH_Mesh::GroupIteratorPtr SMESH_Mesh::GetGroups() const
1288 typedef map <int, SMESH_Group *> TMap;
1289 return GroupIteratorPtr( new SMDS_mapIterator<TMap>( _mapGroup ));
1292 //=============================================================================
1294 * \brief Return a group by ID
1296 //=============================================================================
1298 SMESH_Group* SMESH_Mesh::GetGroup (const int theGroupID)
1300 if (_mapGroup.find(theGroupID) == _mapGroup.end())
1302 return _mapGroup[theGroupID];
1306 //=============================================================================
1308 * \brief Return IDs of all groups
1310 //=============================================================================
1312 list<int> SMESH_Mesh::GetGroupIds() const
1315 for ( map<int, SMESH_Group*>::const_iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ )
1316 anIds.push_back( it->first );
1322 //=============================================================================
1326 //=============================================================================
1328 void SMESH_Mesh::RemoveGroup (const int theGroupID)
1330 if (_mapGroup.find(theGroupID) == _mapGroup.end())
1332 GetMeshDS()->RemoveGroup( _mapGroup[theGroupID]->GetGroupDS() );
1333 delete _mapGroup[theGroupID];
1334 _mapGroup.erase (theGroupID);
1337 //=======================================================================
1338 //function : GetAncestors
1339 //purpose : return list of ancestors of theSubShape in the order
1340 // that lower dimention shapes come first.
1341 //=======================================================================
1343 const TopTools_ListOfShape& SMESH_Mesh::GetAncestors(const TopoDS_Shape& theS) const
1345 if ( _mapAncestors.Contains( theS ) )
1346 return _mapAncestors.FindFromKey( theS );
1348 static TopTools_ListOfShape emptyList;
1352 //=======================================================================
1354 //purpose : dumps contents of mesh to stream [ debug purposes ]
1355 //=======================================================================
1357 ostream& SMESH_Mesh::Dump(ostream& save)
1360 save << "========================== Dump contents of mesh ==========================" << endl << endl;
1361 save << ++clause << ") Total number of nodes: \t" << NbNodes() << endl;
1362 save << ++clause << ") Total number of edges: \t" << NbEdges() << endl;
1363 save << ++clause << ") Total number of faces: \t" << NbFaces() << endl;
1364 save << ++clause << ") Total number of polygons:\t" << NbPolygons() << endl;
1365 save << ++clause << ") Total number of volumes:\t" << NbVolumes() << endl;
1366 save << ++clause << ") Total number of polyhedrons:\t" << NbPolyhedrons() << endl << endl;
1367 for ( int isQuadratic = 0; isQuadratic < 2; ++isQuadratic )
1369 string orderStr = isQuadratic ? "quadratic" : "linear";
1370 SMDSAbs_ElementOrder order = isQuadratic ? ORDER_QUADRATIC : ORDER_LINEAR;
1372 save << ++clause << ") Total number of " << orderStr << " edges:\t" << NbEdges(order) << endl;
1373 save << ++clause << ") Total number of " << orderStr << " faces:\t" << NbFaces(order) << endl;
1374 if ( NbFaces(order) > 0 ) {
1375 int nb3 = NbTriangles(order);
1376 int nb4 = NbQuadrangles(order);
1377 save << clause << ".1) Number of " << orderStr << " triangles: \t" << nb3 << endl;
1378 save << clause << ".2) Number of " << orderStr << " quadrangles:\t" << nb4 << endl;
1379 if ( nb3 + nb4 != NbFaces(order) ) {
1380 map<int,int> myFaceMap;
1381 SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
1382 while( itFaces->more( ) ) {
1383 int nbNodes = itFaces->next()->NbNodes();
1384 if ( myFaceMap.find( nbNodes ) == myFaceMap.end() )
1385 myFaceMap[ nbNodes ] = 0;
1386 myFaceMap[ nbNodes ] = myFaceMap[ nbNodes ] + 1;
1388 save << clause << ".3) Faces in detail: " << endl;
1389 map <int,int>::iterator itF;
1390 for (itF = myFaceMap.begin(); itF != myFaceMap.end(); itF++)
1391 save << "--> nb nodes: " << itF->first << " - nb elemens:\t" << itF->second << endl;
1394 save << ++clause << ") Total number of " << orderStr << " volumes:\t" << NbVolumes(order) << endl;
1395 if ( NbVolumes(order) > 0 ) {
1396 int nb8 = NbHexas(order);
1397 int nb4 = NbTetras(order);
1398 int nb5 = NbPyramids(order);
1399 int nb6 = NbPrisms(order);
1400 save << clause << ".1) Number of " << orderStr << " hexahedrons:\t" << nb8 << endl;
1401 save << clause << ".2) Number of " << orderStr << " tetrahedrons:\t" << nb4 << endl;
1402 save << clause << ".3) Number of " << orderStr << " prisms: \t" << nb6 << endl;
1403 save << clause << ".4) Number of " << orderStr << " pyramids:\t" << nb5 << endl;
1404 if ( nb8 + nb4 + nb5 + nb6 != NbVolumes(order) ) {
1405 map<int,int> myVolumesMap;
1406 SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
1407 while( itVolumes->more( ) ) {
1408 int nbNodes = itVolumes->next()->NbNodes();
1409 if ( myVolumesMap.find( nbNodes ) == myVolumesMap.end() )
1410 myVolumesMap[ nbNodes ] = 0;
1411 myVolumesMap[ nbNodes ] = myVolumesMap[ nbNodes ] + 1;
1413 save << clause << ".5) Volumes in detail: " << endl;
1414 map <int,int>::iterator itV;
1415 for (itV = myVolumesMap.begin(); itV != myVolumesMap.end(); itV++)
1416 save << "--> nb nodes: " << itV->first << " - nb elemens:\t" << itV->second << endl;
1421 save << "===========================================================================" << endl;
1425 //=======================================================================
1426 //function : GetElementType
1427 //purpose : Returns type of mesh element with certain id
1428 //=======================================================================
1430 SMDSAbs_ElementType SMESH_Mesh::GetElementType( const int id, const bool iselem )
1432 return _myMeshDS->GetElementType( id, iselem );