1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMESH : implementaion of SMESH idl descriptions
23 // File : SMESH_Mesh.cxx
24 // Author : Paul RASCLE, EDF
28 #include "SMESH_Mesh.hxx"
29 #include "SMESH_subMesh.hxx"
30 #include "SMESH_Gen.hxx"
31 #include "SMESH_Hypothesis.hxx"
32 #include "SMESH_Group.hxx"
33 #include "SMESH_HypoFilter.hxx"
34 #include "SMESHDS_Group.hxx"
35 #include "SMESHDS_Script.hxx"
36 #include "SMESHDS_GroupOnGeom.hxx"
37 #include "SMESHDS_Document.hxx"
38 #include "SMDS_MeshVolume.hxx"
39 #include "SMDS_SetIterator.hxx"
41 #include "utilities.h"
43 #include "DriverMED_W_SMESHDS_Mesh.h"
44 #include "DriverDAT_W_SMDS_Mesh.h"
45 #include "DriverUNV_W_SMDS_Mesh.h"
46 #include "DriverSTL_W_SMDS_Mesh.h"
48 #include "DriverMED_R_SMESHDS_Mesh.h"
49 #include "DriverUNV_R_SMDS_Mesh.h"
50 #include "DriverSTL_R_SMDS_Mesh.h"
52 #undef _Precision_HeaderFile
53 #include <BRepPrimAPI_MakeBox.hxx>
55 #include <TopExp_Explorer.hxx>
56 #include <TopTools_ListIteratorOfListOfShape.hxx>
57 #include <TopTools_ListOfShape.hxx>
58 #include <TopTools_MapOfShape.hxx>
59 #include <TopoDS_Iterator.hxx>
61 #include "Utils_ExceptHandlers.hxx"
63 // maximum stored group name length in MED file
64 #define MAX_MED_GROUP_NAME_LENGTH 80
67 static int MYDEBUG = 0;
69 static int MYDEBUG = 0;
74 #define cSMESH_Hyp(h) static_cast<const SMESH_Hypothesis*>(h)
76 typedef SMESH_HypoFilter THypType;
78 //=============================================================================
82 //=============================================================================
84 SMESH_Mesh::SMESH_Mesh(int theLocalId,
87 bool theIsEmbeddedMode,
88 SMESHDS_Document* theDocument):
89 _groupId( 0 ), _nbSubShapes( 0 )
91 MESSAGE("SMESH_Mesh::SMESH_Mesh(int localId)");
93 _studyId = theStudyId;
95 _myDocument = theDocument;
96 _idDoc = theDocument->NewMesh(theIsEmbeddedMode);
97 _myMeshDS = theDocument->GetMesh(_idDoc);
98 _isShapeToMesh = false;
100 _myMeshDS->ShapeToMesh( PseudoShape() );
103 //=============================================================================
107 //=============================================================================
109 SMESH_Mesh::~SMESH_Mesh()
111 INFOS("SMESH_Mesh::~SMESH_Mesh");
114 std::map < int, SMESH_Group * >::iterator itg;
115 for (itg = _mapGroup.begin(); itg != _mapGroup.end(); itg++) {
116 SMESH_Group *aGroup = (*itg).second;
122 //=============================================================================
124 * \brief Set geometry to be meshed
126 //=============================================================================
128 void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape)
130 if(MYDEBUG) MESSAGE("SMESH_Mesh::ShapeToMesh");
132 if ( !aShape.IsNull() && _isShapeToMesh )
133 throw SALOME_Exception(LOCALIZED ("a shape to mesh has already been defined"));
135 // clear current data
136 if ( !_myMeshDS->ShapeToMesh().IsNull() )
138 // removal of a shape to mesh, delete objects referring to sub-shapes:
140 std::map <int, SMESH_subMesh *>::iterator i_sm = _mapSubMesh.begin();
141 for ( ; i_sm != _mapSubMesh.end(); ++i_sm )
144 // - groups on geometry
145 std::map <int, SMESH_Group *>::iterator i_gr = _mapGroup.begin();
146 while ( i_gr != _mapGroup.end() ) {
147 if ( dynamic_cast<SMESHDS_GroupOnGeom*>( i_gr->second->GetGroupDS() )) {
148 _myMeshDS->RemoveGroup( i_gr->second->GetGroupDS() );
150 _mapGroup.erase( i_gr++ );
155 _mapAncestors.Clear();
158 TopoDS_Shape aNullShape;
159 _myMeshDS->ShapeToMesh( aNullShape );
162 // set a new geometry
163 if ( !aShape.IsNull() )
165 _myMeshDS->ShapeToMesh(aShape);
166 _isShapeToMesh = true;
167 _nbSubShapes = _myMeshDS->MaxShapeIndex();
169 // fill _mapAncestors
170 int desType, ancType;
171 for ( desType = TopAbs_VERTEX; desType > TopAbs_COMPOUND; desType-- )
172 for ( ancType = desType - 1; ancType >= TopAbs_COMPOUND; ancType-- )
173 TopExp::MapShapesAndAncestors ( aShape,
174 (TopAbs_ShapeEnum) desType,
175 (TopAbs_ShapeEnum) ancType,
180 _isShapeToMesh = false;
181 _myMeshDS->ShapeToMesh( PseudoShape() );
185 //=======================================================================
187 * \brief Return geometry to be meshed. (It may be a PseudoShape()!)
189 //=======================================================================
191 TopoDS_Shape SMESH_Mesh::GetShapeToMesh() const
193 return _myMeshDS->ShapeToMesh();
196 //=======================================================================
198 * \brief Return a solid which is returned by GetShapeToMesh() if
199 * a real geometry to be meshed was not set
201 //=======================================================================
203 const TopoDS_Solid& SMESH_Mesh::PseudoShape()
205 static TopoDS_Solid aSolid;
206 if ( aSolid.IsNull() )
208 aSolid = BRepPrimAPI_MakeBox(1,1,1);
213 //=======================================================================
215 * \brief Remove all nodes and elements
217 //=======================================================================
219 void SMESH_Mesh::Clear()
222 _myMeshDS->ClearMesh();
224 // update compute state of submeshes
225 if ( SMESH_subMesh *sm = GetSubMeshContaining( GetShapeToMesh() ) ) {
226 SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(/*includeSelf=*/true,
227 /*complexShapeFirst=*/false);
228 while ( smIt->more() ) {
230 sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
234 // // clear sub-meshes; get ready to re-compute as a side-effect
236 // if ( SMESH_subMesh *sm = GetSubMeshContaining( GetShapeToMesh() ) )
238 // SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(/*includeSelf=*/true,
239 // /*complexShapeFirst=*/false);
240 // while ( smIt->more() )
242 // sm = smIt->next();
243 // TopAbs_ShapeEnum shapeType = sm->GetSubShape().ShapeType();
244 // if ( shapeType == TopAbs_VERTEX || shapeType < TopAbs_SOLID )
245 // // all other shapes depends on vertices so they are already cleaned
246 // sm->ComputeStateEngine( SMESH_subMesh::CLEAN );
247 // // to recompute even if failed
248 // sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
252 // // clear entities not on sub-meshes
254 // SMDS_VolumeIteratorPtr vIt = _myMeshDS->volumesIterator();
255 // while ( vIt->more() )
256 // _myMeshDS->RemoveFreeElement( vIt->next(), 0 );
258 // SMDS_FaceIteratorPtr fIt = _myMeshDS->facesIterator();
259 // while ( fIt->more() )
260 // _myMeshDS->RemoveFreeElement( fIt->next(), 0 );
262 // SMDS_EdgeIteratorPtr eIt = _myMeshDS->edgesIterator();
263 // while ( eIt->more() )
264 // _myMeshDS->RemoveFreeElement( eIt->next(), 0 );
266 // SMDS_NodeIteratorPtr nIt = _myMeshDS->nodesIterator();
267 // while ( nIt->more() ) {
268 // const SMDS_MeshNode * node = nIt->next();
269 // if ( node->NbInverseElements() == 0 )
270 // _myMeshDS->RemoveFreeNode( node, 0 );
272 // _myMeshDS->RemoveNode(node);
276 //=======================================================================
277 //function : UNVToMesh
279 //=======================================================================
281 int SMESH_Mesh::UNVToMesh(const char* theFileName)
283 if(MYDEBUG) MESSAGE("UNVToMesh - theFileName = "<<theFileName);
285 throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
286 _isShapeToMesh = false;
287 DriverUNV_R_SMDS_Mesh myReader;
288 myReader.SetMesh(_myMeshDS);
289 myReader.SetFile(theFileName);
290 myReader.SetMeshId(-1);
293 MESSAGE("UNVToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
294 MESSAGE("UNVToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
295 MESSAGE("UNVToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
296 MESSAGE("UNVToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
298 SMDS_MeshGroup* aGroup = (SMDS_MeshGroup*) myReader.GetGroup();
300 TGroupNamesMap aGroupNames = myReader.GetGroupNamesMap();
301 //const TGroupIdMap& aGroupId = myReader.GetGroupIdMap();
302 aGroup->InitSubGroupsIterator();
303 while (aGroup->MoreSubGroups()) {
304 SMDS_MeshGroup* aSubGroup = (SMDS_MeshGroup*) aGroup->NextSubGroup();
305 std::string aName = aGroupNames[aSubGroup];
308 SMESH_Group* aSMESHGroup = AddGroup( aSubGroup->GetType(), aName.c_str(), aId );
310 if(MYDEBUG) MESSAGE("UNVToMesh - group added: "<<aName);
311 SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( aSMESHGroup->GetGroupDS() );
313 aGroupDS->SetStoreName(aName.c_str());
314 aSubGroup->InitIterator();
315 const SMDS_MeshElement* aElement = 0;
316 while (aSubGroup->More()) {
317 aElement = aSubGroup->Next();
319 aGroupDS->SMDSGroup().Add(aElement);
323 aGroupDS->SetType(aElement->GetType());
331 //=======================================================================
332 //function : MEDToMesh
334 //=======================================================================
336 int SMESH_Mesh::MEDToMesh(const char* theFileName, const char* theMeshName)
338 if(MYDEBUG) MESSAGE("MEDToMesh - theFileName = "<<theFileName<<", mesh name = "<<theMeshName);
340 throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
341 _isShapeToMesh = false;
342 DriverMED_R_SMESHDS_Mesh myReader;
343 myReader.SetMesh(_myMeshDS);
344 myReader.SetMeshId(-1);
345 myReader.SetFile(theFileName);
346 myReader.SetMeshName(theMeshName);
347 Driver_Mesh::Status status = myReader.Perform();
349 MESSAGE("MEDToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
350 MESSAGE("MEDToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
351 MESSAGE("MEDToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
352 MESSAGE("MEDToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
355 // Reading groups (sub-meshes are out of scope of MED import functionality)
356 std::list<TNameAndType> aGroupNames = myReader.GetGroupNamesAndTypes();
357 if(MYDEBUG) MESSAGE("MEDToMesh - Nb groups = "<<aGroupNames.size());
359 std::list<TNameAndType>::iterator name_type = aGroupNames.begin();
360 for ( ; name_type != aGroupNames.end(); name_type++ ) {
361 SMESH_Group* aGroup = AddGroup( name_type->second, name_type->first.c_str(), anId );
363 if(MYDEBUG) MESSAGE("MEDToMesh - group added: "<<name_type->first.c_str());
364 SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( aGroup->GetGroupDS() );
366 aGroupDS->SetStoreName( name_type->first.c_str() );
367 myReader.GetGroup( aGroupDS );
374 //=======================================================================
375 //function : STLToMesh
377 //=======================================================================
379 int SMESH_Mesh::STLToMesh(const char* theFileName)
381 if(MYDEBUG) MESSAGE("STLToMesh - theFileName = "<<theFileName);
383 throw SALOME_Exception(LOCALIZED("a shape to mesh has already been defined"));
384 _isShapeToMesh = false;
385 DriverSTL_R_SMDS_Mesh myReader;
386 myReader.SetMesh(_myMeshDS);
387 myReader.SetFile(theFileName);
388 myReader.SetMeshId(-1);
391 MESSAGE("STLToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes());
392 MESSAGE("STLToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges());
393 MESSAGE("STLToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces());
394 MESSAGE("STLToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes());
399 //=============================================================================
403 //=============================================================================
405 SMESH_Hypothesis::Hypothesis_Status
406 SMESH_Mesh::AddHypothesis(const TopoDS_Shape & aSubShape,
407 int anHypId ) throw(SALOME_Exception)
409 Unexpect aCatch(SalomeException);
410 if(MYDEBUG) MESSAGE("SMESH_Mesh::AddHypothesis");
412 SMESH_subMesh *subMesh = GetSubMesh(aSubShape);
413 if ( !subMesh || !subMesh->GetId())
414 return SMESH_Hypothesis::HYP_BAD_SUBSHAPE;
416 SMESHDS_SubMesh *subMeshDS = subMesh->GetSubMeshDS();
417 if ( subMeshDS && subMeshDS->IsComplexSubmesh() ) // group of sub-shapes and maybe of not sub-
419 MESSAGE("AddHypothesis() to complex submesh");
420 // return the worst but not fatal state of all group memebers
421 SMESH_Hypothesis::Hypothesis_Status aBestRet, aWorstNotFatal, ret;
422 aBestRet = SMESH_Hypothesis::HYP_BAD_DIM;
423 aWorstNotFatal = SMESH_Hypothesis::HYP_OK;
424 for ( TopoDS_Iterator itS ( aSubShape ); itS.More(); itS.Next())
426 if ( !GetMeshDS()->ShapeToIndex( itS.Value() ))
427 continue; // not sub-shape
428 ret = AddHypothesis( itS.Value(), anHypId );
429 if ( !SMESH_Hypothesis::IsStatusFatal( ret ) && ret > aWorstNotFatal )
430 aWorstNotFatal = ret;
431 if ( ret < aBestRet )
434 // bind hypotheses to a group just to know
435 SMESH_Hypothesis *anHyp = _gen->GetStudyContext(_studyId)->mapHypothesis[anHypId];
436 GetMeshDS()->AddHypothesis( aSubShape, anHyp );
438 if ( SMESH_Hypothesis::IsStatusFatal( aBestRet ))
440 return aWorstNotFatal;
443 StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
444 if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
446 if(MYDEBUG) MESSAGE("Hypothesis ID does not give an hypothesis");
451 throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
454 SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
455 MESSAGE( "SMESH_Mesh::AddHypothesis " << anHyp->GetName() );
457 bool isGlobalHyp = IsMainShape( aSubShape );
459 // NotConformAllowed can be only global
462 string hypName = anHyp->GetName();
463 if ( hypName == "NotConformAllowed" )
465 if(MYDEBUG) MESSAGE( "Hypotesis <NotConformAllowed> can be only global" );
466 return SMESH_Hypothesis::HYP_INCOMPATIBLE;
472 bool isAlgo = ( !anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO );
473 int event = isAlgo ? SMESH_subMesh::ADD_ALGO : SMESH_subMesh::ADD_HYP;
475 SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp);
478 if (!SMESH_Hypothesis::IsStatusFatal(ret) &&
479 anHyp->GetDim() <= SMESH_Gen::GetShapeDim(aSubShape)) // is added on father
481 event = isAlgo ? SMESH_subMesh::ADD_FATHER_ALGO : SMESH_subMesh::ADD_FATHER_HYP;
483 SMESH_Hypothesis::Hypothesis_Status ret2 =
484 subMesh->SubMeshesAlgoStateEngine(event, anHyp);
488 // check concurent hypotheses on ansestors
489 if (ret < SMESH_Hypothesis::HYP_CONCURENT && !isGlobalHyp )
491 SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false);
492 while ( smIt->more() ) {
493 SMESH_subMesh* sm = smIt->next();
494 if ( sm->IsApplicableHypotesis( anHyp )) {
495 ret2 = sm->CheckConcurentHypothesis( anHyp->GetType() );
505 if(MYDEBUG) subMesh->DumpAlgoState(true);
510 //=============================================================================
514 //=============================================================================
516 SMESH_Hypothesis::Hypothesis_Status
517 SMESH_Mesh::RemoveHypothesis(const TopoDS_Shape & aSubShape,
518 int anHypId)throw(SALOME_Exception)
520 Unexpect aCatch(SalomeException);
521 if(MYDEBUG) MESSAGE("SMESH_Mesh::RemoveHypothesis");
523 SMESH_subMesh *subMesh = GetSubMesh(aSubShape);
524 SMESHDS_SubMesh *subMeshDS = subMesh->GetSubMeshDS();
525 if ( subMeshDS && subMeshDS->IsComplexSubmesh() )
527 // return the worst but not fatal state of all group memebers
528 SMESH_Hypothesis::Hypothesis_Status aBestRet, aWorstNotFatal, ret;
529 aBestRet = SMESH_Hypothesis::HYP_BAD_DIM;
530 aWorstNotFatal = SMESH_Hypothesis::HYP_OK;
531 for ( TopoDS_Iterator itS ( aSubShape ); itS.More(); itS.Next())
533 if ( !GetMeshDS()->ShapeToIndex( itS.Value() ))
534 continue; // not sub-shape
535 ret = RemoveHypothesis( itS.Value(), anHypId );
536 if ( !SMESH_Hypothesis::IsStatusFatal( ret ) && ret > aWorstNotFatal )
537 aWorstNotFatal = ret;
538 if ( ret < aBestRet )
541 SMESH_Hypothesis *anHyp = _gen->GetStudyContext(_studyId)->mapHypothesis[anHypId];
542 GetMeshDS()->RemoveHypothesis( aSubShape, anHyp );
544 if ( SMESH_Hypothesis::IsStatusFatal( aBestRet ))
546 return aWorstNotFatal;
549 StudyContextStruct *sc = _gen->GetStudyContext(_studyId);
550 if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end())
551 throw SALOME_Exception(LOCALIZED("hypothesis does not exist"));
553 SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId];
554 int hypType = anHyp->GetType();
555 if(MYDEBUG) SCRUTE(hypType);
559 bool isAlgo = ( !anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO );
560 int event = isAlgo ? SMESH_subMesh::REMOVE_ALGO : SMESH_subMesh::REMOVE_HYP;
562 SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp);
564 // there may appear concurrent hyps that were covered by the removed hyp
565 if (ret < SMESH_Hypothesis::HYP_CONCURENT &&
566 subMesh->IsApplicableHypotesis( anHyp ) &&
567 subMesh->CheckConcurentHypothesis( anHyp->GetType() ) != SMESH_Hypothesis::HYP_OK)
568 ret = SMESH_Hypothesis::HYP_CONCURENT;
571 if (!SMESH_Hypothesis::IsStatusFatal(ret) &&
572 anHyp->GetDim() <= SMESH_Gen::GetShapeDim(aSubShape)) // is removed from father
574 event = isAlgo ? SMESH_subMesh::REMOVE_FATHER_ALGO : SMESH_subMesh::REMOVE_FATHER_HYP;
576 SMESH_Hypothesis::Hypothesis_Status ret2 =
577 subMesh->SubMeshesAlgoStateEngine(event, anHyp);
578 if (ret2 > ret) // more severe
581 // check concurent hypotheses on ansestors
582 if (ret < SMESH_Hypothesis::HYP_CONCURENT && !IsMainShape( aSubShape ) )
584 SMESH_subMeshIteratorPtr smIt = subMesh->getDependsOnIterator(false,false);
585 while ( smIt->more() ) {
586 SMESH_subMesh* sm = smIt->next();
587 if ( sm->IsApplicableHypotesis( anHyp )) {
588 ret2 = sm->CheckConcurentHypothesis( anHyp->GetType() );
598 if(MYDEBUG) subMesh->DumpAlgoState(true);
599 if(MYDEBUG) SCRUTE(ret);
603 //=============================================================================
607 //=============================================================================
609 const std::list<const SMESHDS_Hypothesis*>&
610 SMESH_Mesh::GetHypothesisList(const TopoDS_Shape & aSubShape) const
611 throw(SALOME_Exception)
613 Unexpect aCatch(SalomeException);
614 return _myMeshDS->GetHypothesis(aSubShape);
617 //=======================================================================
619 * \brief Return the hypothesis assigned to the shape
620 * \param aSubShape - the shape to check
621 * \param aFilter - the hypothesis filter
622 * \param andAncestors - flag to check hypos assigned to ancestors of the shape
623 * \param assignedTo - to return the shape the found hypo is assigned to
624 * \retval SMESH_Hypothesis* - the first hypo passed through aFilter
626 //=======================================================================
628 const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubShape,
629 const SMESH_HypoFilter& aFilter,
630 const bool andAncestors,
631 TopoDS_Shape* assignedTo) const
634 const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
635 std::list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
636 for ( ; hyp != hypList.end(); hyp++ ) {
637 const SMESH_Hypothesis * h = cSMESH_Hyp( *hyp );
638 if ( aFilter.IsOk( h, aSubShape)) {
639 if ( assignedTo ) *assignedTo = aSubShape;
646 TopTools_ListIteratorOfListOfShape it( GetAncestors( aSubShape ));
647 for (; it.More(); it.Next() )
649 const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value());
650 std::list<const SMESHDS_Hypothesis*>::const_iterator hyp = hypList.begin();
651 for ( ; hyp != hypList.end(); hyp++ ) {
652 const SMESH_Hypothesis * h = cSMESH_Hyp( *hyp );
653 if (aFilter.IsOk( h, it.Value() )) {
654 if ( assignedTo ) *assignedTo = it.Value();
663 //================================================================================
665 * \brief Return hypothesis assigned to the shape
666 * \param aSubShape - the shape to check
667 * \param aFilter - the hypothesis filter
668 * \param aHypList - the list of the found hypotheses
669 * \param andAncestors - flag to check hypos assigned to ancestors of the shape
670 * \retval int - number of unique hypos in aHypList
672 //================================================================================
674 int SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape,
675 const SMESH_HypoFilter& aFilter,
676 list <const SMESHDS_Hypothesis * >& aHypList,
677 const bool andAncestors) const
679 set<string> hypTypes; // to exclude same type hypos from the result list
682 // only one main hypothesis is allowed
683 bool mainHypFound = false;
686 std::list<const SMESHDS_Hypothesis*>::const_iterator hyp;
687 for ( hyp = aHypList.begin(); hyp != aHypList.end(); hyp++ ) {
688 if ( hypTypes.insert( (*hyp)->GetName() ).second )
690 if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
694 // get hypos from aSubShape
696 const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(aSubShape);
697 for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
698 if ( aFilter.IsOk (cSMESH_Hyp( *hyp ), aSubShape) &&
699 ( cSMESH_Hyp(*hyp)->IsAuxiliary() || !mainHypFound ) &&
700 hypTypes.insert( (*hyp)->GetName() ).second )
702 aHypList.push_back( *hyp );
704 if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
709 // get hypos from ancestors of aSubShape
712 TopTools_MapOfShape map;
713 TopTools_ListIteratorOfListOfShape it( GetAncestors( aSubShape ));
714 for (; it.More(); it.Next() )
716 if ( !map.Add( it.Value() ))
718 const std::list<const SMESHDS_Hypothesis*>& hypList = _myMeshDS->GetHypothesis(it.Value());
719 for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ )
720 if (aFilter.IsOk( cSMESH_Hyp( *hyp ), it.Value() ) &&
721 ( cSMESH_Hyp(*hyp)->IsAuxiliary() || !mainHypFound ) &&
722 hypTypes.insert( (*hyp)->GetName() ).second )
724 aHypList.push_back( *hyp );
726 if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() )
734 //=============================================================================
738 //=============================================================================
740 const std::list<SMESHDS_Command*> & SMESH_Mesh::GetLog() throw(SALOME_Exception)
742 Unexpect aCatch(SalomeException);
743 if(MYDEBUG) MESSAGE("SMESH_Mesh::GetLog");
744 return _myMeshDS->GetScript()->GetCommands();
747 //=============================================================================
751 //=============================================================================
752 void SMESH_Mesh::ClearLog() throw(SALOME_Exception)
754 Unexpect aCatch(SalomeException);
755 if(MYDEBUG) MESSAGE("SMESH_Mesh::ClearLog");
756 _myMeshDS->GetScript()->Clear();
759 //=============================================================================
761 * Get or Create the SMESH_subMesh object implementation
763 //=============================================================================
765 SMESH_subMesh *SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape)
766 throw(SALOME_Exception)
768 Unexpect aCatch(SalomeException);
769 SMESH_subMesh *aSubMesh;
770 int index = _myMeshDS->ShapeToIndex(aSubShape);
772 // for submeshes on GEOM Group
773 if (( !index || index > _nbSubShapes ) && aSubShape.ShapeType() == TopAbs_COMPOUND ) {
774 TopoDS_Iterator it( aSubShape );
776 index = _myMeshDS->AddCompoundSubmesh( aSubShape, it.Value().ShapeType() );
779 // return NULL; // neither sub-shape nor a group
781 map <int, SMESH_subMesh *>::iterator i_sm = _mapSubMesh.find(index);
782 if ( i_sm != _mapSubMesh.end())
784 aSubMesh = i_sm->second;
788 aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape);
789 _mapSubMesh[index] = aSubMesh;
794 //=============================================================================
796 * Get the SMESH_subMesh object implementation. Dont create it, return null
797 * if it does not exist.
799 //=============================================================================
801 SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape) const
802 throw(SALOME_Exception)
804 Unexpect aCatch(SalomeException);
805 SMESH_subMesh *aSubMesh = NULL;
807 int index = _myMeshDS->ShapeToIndex(aSubShape);
809 map <int, SMESH_subMesh *>::const_iterator i_sm = _mapSubMesh.find(index);
810 if ( i_sm != _mapSubMesh.end())
811 aSubMesh = i_sm->second;
815 //=============================================================================
817 * Get the SMESH_subMesh object implementation. Dont create it, return null
818 * if it does not exist.
820 //=============================================================================
822 SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const int aShapeID) const
823 throw(SALOME_Exception)
825 Unexpect aCatch(SalomeException);
827 map <int, SMESH_subMesh *>::const_iterator i_sm = _mapSubMesh.find(aShapeID);
828 if (i_sm == _mapSubMesh.end())
832 //================================================================================
834 * \brief Return submeshes of groups containing the given subshape
836 //================================================================================
838 std::list<SMESH_subMesh*>
839 SMESH_Mesh::GetGroupSubMeshesContaining(const TopoDS_Shape & aSubShape) const
840 throw(SALOME_Exception)
842 Unexpect aCatch(SalomeException);
843 std::list<SMESH_subMesh*> found;
845 SMESH_subMesh * subMesh = GetSubMeshContaining(aSubShape);
849 // submeshes of groups have max IDs, so search from the map end
850 std::map<int, SMESH_subMesh *>::const_reverse_iterator i_sm;
851 for ( i_sm = _mapSubMesh.rbegin(); i_sm != _mapSubMesh.rend(); ++i_sm) {
852 SMESHDS_SubMesh * ds = i_sm->second->GetSubMeshDS();
853 if ( ds && ds->IsComplexSubmesh() ) {
854 TopExp_Explorer exp( i_sm->second->GetSubShape(), aSubShape.ShapeType() );
855 for ( ; exp.More(); exp.Next() ) {
856 if ( aSubShape.IsSame( exp.Current() )) {
857 found.push_back( i_sm->second );
867 //=======================================================================
868 //function : IsUsedHypothesis
869 //purpose : Return True if anHyp is used to mesh aSubShape
870 //=======================================================================
872 bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp,
873 const SMESH_subMesh* aSubMesh)
875 SMESH_Hypothesis* hyp = static_cast<SMESH_Hypothesis*>(anHyp);
877 // check if anHyp can be used to mesh aSubMesh
878 if ( !aSubMesh || !aSubMesh->IsApplicableHypotesis( hyp ))
881 const TopoDS_Shape & aSubShape = const_cast<SMESH_subMesh*>( aSubMesh )->GetSubShape();
883 SMESH_Algo *algo = _gen->GetAlgo(*this, aSubShape );
886 if (anHyp->GetType() > SMESHDS_Hypothesis::PARAM_ALGO)
887 return ( anHyp == algo );
889 // algorithm parameter
892 // look trough hypotheses used by algo
893 SMESH_HypoFilter hypoKind;
894 if ( algo->InitCompatibleHypoFilter( hypoKind, !hyp->IsAuxiliary() )) {
895 list <const SMESHDS_Hypothesis * > usedHyps;
896 if ( GetHypotheses( aSubShape, hypoKind, usedHyps, true ))
897 return ( find( usedHyps.begin(), usedHyps.end(), anHyp ) != usedHyps.end() );
901 // look through all assigned hypotheses
902 //SMESH_HypoFilter filter( SMESH_HypoFilter::Is( hyp ));
903 return false; //GetHypothesis( aSubShape, filter, true );
906 //=============================================================================
910 //=============================================================================
912 const list < SMESH_subMesh * >&
913 SMESH_Mesh::GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp)
914 throw(SALOME_Exception)
916 Unexpect aCatch(SalomeException);
917 if(MYDEBUG) MESSAGE("SMESH_Mesh::GetSubMeshUsingHypothesis");
918 map < int, SMESH_subMesh * >::iterator itsm;
919 _subMeshesUsingHypothesisList.clear();
920 for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
922 SMESH_subMesh *aSubMesh = (*itsm).second;
923 if ( IsUsedHypothesis ( anHyp, aSubMesh ))
924 _subMeshesUsingHypothesisList.push_back(aSubMesh);
926 return _subMeshesUsingHypothesisList;
929 //=======================================================================
930 //function : NotifySubMeshesHypothesisModification
931 //purpose : Say all submeshes using theChangedHyp that it has been modified
932 //=======================================================================
934 void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* hyp)
936 Unexpect aCatch(SalomeException);
938 const SMESH_Algo *foundAlgo = 0;
939 SMESH_HypoFilter algoKind, compatibleHypoKind;
940 list <const SMESHDS_Hypothesis * > usedHyps;
943 map < int, SMESH_subMesh * >::iterator itsm;
944 for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++)
946 SMESH_subMesh *aSubMesh = (*itsm).second;
947 if ( aSubMesh->IsApplicableHypotesis( hyp ))
949 const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape();
951 if ( !foundAlgo ) // init filter for algo search
952 algoKind.Init( THypType::IsAlgo() ).And( THypType::IsApplicableTo( aSubShape ));
954 const SMESH_Algo *algo = static_cast<const SMESH_Algo*>
955 ( GetHypothesis( aSubShape, algoKind, true ));
959 bool sameAlgo = ( algo == foundAlgo );
960 if ( !sameAlgo && foundAlgo )
961 sameAlgo = ( strcmp( algo->GetName(), foundAlgo->GetName() ) == 0);
963 if ( !sameAlgo ) { // init filter for used hypos search
964 if ( !algo->InitCompatibleHypoFilter( compatibleHypoKind, !hyp->IsAuxiliary() ))
965 continue; // algo does not use any hypothesis
969 // check if hyp is used by algo
971 if ( GetHypotheses( aSubShape, compatibleHypoKind, usedHyps, true ) &&
972 find( usedHyps.begin(), usedHyps.end(), hyp ) != usedHyps.end() )
974 aSubMesh->AlgoStateEngine(SMESH_subMesh::MODIF_HYP,
975 const_cast< SMESH_Hypothesis*>( hyp ));
982 //=============================================================================
984 * Auto color functionality
986 //=============================================================================
987 void SMESH_Mesh::SetAutoColor(bool theAutoColor) throw(SALOME_Exception)
989 Unexpect aCatch(SalomeException);
990 _isAutoColor = theAutoColor;
993 bool SMESH_Mesh::GetAutoColor() throw(SALOME_Exception)
995 Unexpect aCatch(SalomeException);
999 //=============================================================================
1000 /*! Export* methods.
1001 * To store mesh contents on disk in different formats.
1003 //=============================================================================
1005 bool SMESH_Mesh::HasDuplicatedGroupNamesMED()
1007 set<string> aGroupNames;
1008 for ( std::map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
1009 SMESH_Group* aGroup = it->second;
1010 std::string aGroupName = aGroup->GetName();
1011 aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
1012 if (!aGroupNames.insert(aGroupName).second)
1019 void SMESH_Mesh::ExportMED(const char *file,
1020 const char* theMeshName,
1023 throw(SALOME_Exception)
1025 Unexpect aCatch(SalomeException);
1027 DriverMED_W_SMESHDS_Mesh myWriter;
1028 myWriter.SetFile ( file, MED::EVersion(theVersion) );
1029 myWriter.SetMesh ( _myMeshDS );
1031 myWriter.SetMeshId ( _idDoc );
1033 myWriter.SetMeshId ( -1 );
1034 myWriter.SetMeshName( theMeshName );
1037 if ( theAutoGroups ) {
1038 myWriter.AddGroupOfNodes();
1039 myWriter.AddGroupOfEdges();
1040 myWriter.AddGroupOfFaces();
1041 myWriter.AddGroupOfVolumes();
1044 // Pass groups to writer. Provide unique group names.
1045 set<string> aGroupNames;
1047 int maxNbIter = 10000; // to guarantee cycle finish
1048 for ( std::map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
1049 SMESH_Group* aGroup = it->second;
1050 SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
1052 string aGroupName0 = aGroup->GetName();
1053 aGroupName0.resize(MAX_MED_GROUP_NAME_LENGTH);
1054 string aGroupName = aGroupName0;
1055 for (int i = 1; !aGroupNames.insert(aGroupName).second && i < maxNbIter; i++) {
1056 sprintf(&aString[0], "GR_%d_%s", i, aGroupName0.c_str());
1057 aGroupName = aString;
1058 aGroupName.resize(MAX_MED_GROUP_NAME_LENGTH);
1060 aGroupDS->SetStoreName( aGroupName.c_str() );
1061 myWriter.AddGroup( aGroupDS );
1069 void SMESH_Mesh::ExportDAT(const char *file) throw(SALOME_Exception)
1071 Unexpect aCatch(SalomeException);
1072 DriverDAT_W_SMDS_Mesh myWriter;
1073 myWriter.SetFile(string(file));
1074 myWriter.SetMesh(_myMeshDS);
1075 myWriter.SetMeshId(_idDoc);
1079 void SMESH_Mesh::ExportUNV(const char *file) throw(SALOME_Exception)
1081 Unexpect aCatch(SalomeException);
1082 DriverUNV_W_SMDS_Mesh myWriter;
1083 myWriter.SetFile(string(file));
1084 myWriter.SetMesh(_myMeshDS);
1085 myWriter.SetMeshId(_idDoc);
1086 // myWriter.SetGroups(_mapGroup);
1088 for ( std::map<int, SMESH_Group*>::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) {
1089 SMESH_Group* aGroup = it->second;
1090 SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
1092 std::string aGroupName = aGroup->GetName();
1093 aGroupDS->SetStoreName( aGroupName.c_str() );
1094 myWriter.AddGroup( aGroupDS );
1100 void SMESH_Mesh::ExportSTL(const char *file, const bool isascii) throw(SALOME_Exception)
1102 Unexpect aCatch(SalomeException);
1103 DriverSTL_W_SMDS_Mesh myWriter;
1104 myWriter.SetFile(string(file));
1105 myWriter.SetIsAscii( isascii );
1106 myWriter.SetMesh(_myMeshDS);
1107 myWriter.SetMeshId(_idDoc);
1111 //================================================================================
1113 * \brief Return number of nodes in the mesh
1115 //================================================================================
1117 int SMESH_Mesh::NbNodes() throw(SALOME_Exception)
1119 Unexpect aCatch(SalomeException);
1120 return _myMeshDS->NbNodes();
1123 //================================================================================
1125 * \brief Return number of edges of given order in the mesh
1127 //================================================================================
1129 int SMESH_Mesh::NbEdges(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1131 Unexpect aCatch(SalomeException);
1132 return _myMeshDS->GetMeshInfo().NbEdges(order);
1135 //================================================================================
1137 * \brief Return number of faces of given order in the mesh
1139 //================================================================================
1141 int SMESH_Mesh::NbFaces(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1143 Unexpect aCatch(SalomeException);
1144 return _myMeshDS->GetMeshInfo().NbFaces(order);
1147 //================================================================================
1149 * \brief Return the number of faces in the mesh
1151 //================================================================================
1153 int SMESH_Mesh::NbTriangles(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1155 Unexpect aCatch(SalomeException);
1156 return _myMeshDS->GetMeshInfo().NbTriangles(order);
1159 //================================================================================
1161 * \brief Return the number nodes faces in the mesh
1163 //================================================================================
1165 int SMESH_Mesh::NbQuadrangles(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1167 Unexpect aCatch(SalomeException);
1168 return _myMeshDS->GetMeshInfo().NbQuadrangles(order);
1171 //================================================================================
1173 * \brief Return the number of polygonal faces in the mesh
1175 //================================================================================
1177 int SMESH_Mesh::NbPolygons() throw(SALOME_Exception)
1179 Unexpect aCatch(SalomeException);
1180 return _myMeshDS->GetMeshInfo().NbPolygons();
1183 //================================================================================
1185 * \brief Return number of volumes of given order in the mesh
1187 //================================================================================
1189 int SMESH_Mesh::NbVolumes(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1191 Unexpect aCatch(SalomeException);
1192 return _myMeshDS->GetMeshInfo().NbVolumes(order);
1195 //================================================================================
1197 * \brief Return number of tetrahedrons of given order in the mesh
1199 //================================================================================
1201 int SMESH_Mesh::NbTetras(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1203 Unexpect aCatch(SalomeException);
1204 return _myMeshDS->GetMeshInfo().NbTetras(order);
1207 //================================================================================
1209 * \brief Return number of hexahedrons of given order in the mesh
1211 //================================================================================
1213 int SMESH_Mesh::NbHexas(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1215 Unexpect aCatch(SalomeException);
1216 return _myMeshDS->GetMeshInfo().NbHexas(order);
1219 //================================================================================
1221 * \brief Return number of pyramids of given order in the mesh
1223 //================================================================================
1225 int SMESH_Mesh::NbPyramids(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1227 Unexpect aCatch(SalomeException);
1228 return _myMeshDS->GetMeshInfo().NbPyramids(order);
1231 //================================================================================
1233 * \brief Return number of prisms (penthahedrons) of given order in the mesh
1235 //================================================================================
1237 int SMESH_Mesh::NbPrisms(SMDSAbs_ElementOrder order) throw(SALOME_Exception)
1239 Unexpect aCatch(SalomeException);
1240 return _myMeshDS->GetMeshInfo().NbPrisms(order);
1243 //================================================================================
1245 * \brief Return number of polyhedrons in the mesh
1247 //================================================================================
1249 int SMESH_Mesh::NbPolyhedrons() throw(SALOME_Exception)
1251 Unexpect aCatch(SalomeException);
1252 return _myMeshDS->GetMeshInfo().NbPolyhedrons();
1255 //================================================================================
1257 * \brief Return number of submeshes in the mesh
1259 //================================================================================
1261 int SMESH_Mesh::NbSubMesh() throw(SALOME_Exception)
1263 Unexpect aCatch(SalomeException);
1264 return _myMeshDS->NbSubMesh();
1267 //=======================================================================
1268 //function : IsNotConformAllowed
1269 //purpose : check if a hypothesis alowing notconform mesh is present
1270 //=======================================================================
1272 bool SMESH_Mesh::IsNotConformAllowed() const
1274 if(MYDEBUG) MESSAGE("SMESH_Mesh::IsNotConformAllowed");
1276 static SMESH_HypoFilter filter( SMESH_HypoFilter::HasName( "NotConformAllowed" ));
1277 return GetHypothesis( _myMeshDS->ShapeToMesh(), filter, false );
1280 //=======================================================================
1281 //function : IsMainShape
1283 //=======================================================================
1285 bool SMESH_Mesh::IsMainShape(const TopoDS_Shape& theShape) const
1287 return theShape.IsSame(_myMeshDS->ShapeToMesh() );
1290 //=============================================================================
1294 //=============================================================================
1296 SMESH_Group* SMESH_Mesh::AddGroup (const SMDSAbs_ElementType theType,
1297 const char* theName,
1299 const TopoDS_Shape& theShape)
1301 if (_mapGroup.find(_groupId) != _mapGroup.end())
1304 SMESH_Group* aGroup = new SMESH_Group (theId, this, theType, theName, theShape);
1305 GetMeshDS()->AddGroup( aGroup->GetGroupDS() );
1306 _mapGroup[_groupId++] = aGroup;
1310 //================================================================================
1312 * \brief Return iterator on all existing groups
1314 //================================================================================
1316 SMESH_Mesh::GroupIteratorPtr SMESH_Mesh::GetGroups() const
1318 typedef map <int, SMESH_Group *> TMap;
1319 return GroupIteratorPtr( new SMDS_mapIterator<TMap>( _mapGroup ));
1322 //=============================================================================
1324 * \brief Return a group by ID
1326 //=============================================================================
1328 SMESH_Group* SMESH_Mesh::GetGroup (const int theGroupID)
1330 if (_mapGroup.find(theGroupID) == _mapGroup.end())
1332 return _mapGroup[theGroupID];
1336 //=============================================================================
1338 * \brief Return IDs of all groups
1340 //=============================================================================
1342 std::list<int> SMESH_Mesh::GetGroupIds() const
1344 std::list<int> anIds;
1345 for ( std::map<int, SMESH_Group*>::const_iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ )
1346 anIds.push_back( it->first );
1352 //=============================================================================
1356 //=============================================================================
1358 void SMESH_Mesh::RemoveGroup (const int theGroupID)
1360 if (_mapGroup.find(theGroupID) == _mapGroup.end())
1362 GetMeshDS()->RemoveGroup( _mapGroup[theGroupID]->GetGroupDS() );
1363 delete _mapGroup[theGroupID];
1364 _mapGroup.erase (theGroupID);
1367 //=======================================================================
1368 //function : GetAncestors
1369 //purpose : return list of ancestors of theSubShape in the order
1370 // that lower dimention shapes come first.
1371 //=======================================================================
1373 const TopTools_ListOfShape& SMESH_Mesh::GetAncestors(const TopoDS_Shape& theS) const
1375 if ( _mapAncestors.Contains( theS ) )
1376 return _mapAncestors.FindFromKey( theS );
1378 static TopTools_ListOfShape emptyList;
1382 //=======================================================================
1384 //purpose : dumps contents of mesh to stream [ debug purposes ]
1385 //=======================================================================
1387 ostream& SMESH_Mesh::Dump(ostream& save)
1390 save << "========================== Dump contents of mesh ==========================" << endl << endl;
1391 save << ++clause << ") Total number of nodes: \t" << NbNodes() << endl;
1392 save << ++clause << ") Total number of edges: \t" << NbEdges() << endl;
1393 save << ++clause << ") Total number of faces: \t" << NbFaces() << endl;
1394 save << ++clause << ") Total number of polygons:\t" << NbPolygons() << endl;
1395 save << ++clause << ") Total number of volumes:\t" << NbVolumes() << endl;
1396 save << ++clause << ") Total number of polyhedrons:\t" << NbPolyhedrons() << endl << endl;
1397 for ( int isQuadratic = 0; isQuadratic < 2; ++isQuadratic )
1399 string orderStr = isQuadratic ? "quadratic" : "linear";
1400 SMDSAbs_ElementOrder order = isQuadratic ? ORDER_QUADRATIC : ORDER_LINEAR;
1402 save << ++clause << ") Total number of " << orderStr << " edges:\t" << NbEdges(order) << endl;
1403 save << ++clause << ") Total number of " << orderStr << " faces:\t" << NbFaces(order) << endl;
1404 if ( NbFaces(order) > 0 ) {
1405 int nb3 = NbTriangles(order);
1406 int nb4 = NbQuadrangles(order);
1407 save << clause << ".1) Number of " << orderStr << " triangles: \t" << nb3 << endl;
1408 save << clause << ".2) Number of " << orderStr << " quadrangles:\t" << nb4 << endl;
1409 if ( nb3 + nb4 != NbFaces(order) ) {
1410 std::map<int,int> myFaceMap;
1411 SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator();
1412 while( itFaces->more( ) ) {
1413 int nbNodes = itFaces->next()->NbNodes();
1414 if ( myFaceMap.find( nbNodes ) == myFaceMap.end() )
1415 myFaceMap[ nbNodes ] = 0;
1416 myFaceMap[ nbNodes ] = myFaceMap[ nbNodes ] + 1;
1418 save << clause << ".3) Faces in detail: " << endl;
1419 map <int,int>::iterator itF;
1420 for (itF = myFaceMap.begin(); itF != myFaceMap.end(); itF++)
1421 save << "--> nb nodes: " << itF->first << " - nb elemens:\t" << itF->second << endl;
1424 save << ++clause << ") Total number of " << orderStr << " volumes:\t" << NbVolumes(order) << endl;
1425 if ( NbVolumes(order) > 0 ) {
1426 int nb8 = NbHexas(order);
1427 int nb4 = NbTetras(order);
1428 int nb5 = NbPyramids(order);
1429 int nb6 = NbPrisms(order);
1430 save << clause << ".1) Number of " << orderStr << " hexahedrons:\t" << nb8 << endl;
1431 save << clause << ".2) Number of " << orderStr << " tetrahedrons:\t" << nb4 << endl;
1432 save << clause << ".3) Number of " << orderStr << " prisms: \t" << nb6 << endl;
1433 save << clause << ".4) Number of " << orderStr << " pyramids:\t" << nb5 << endl;
1434 if ( nb8 + nb4 + nb5 + nb6 != NbVolumes(order) ) {
1435 std::map<int,int> myVolumesMap;
1436 SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator();
1437 while( itVolumes->more( ) ) {
1438 int nbNodes = itVolumes->next()->NbNodes();
1439 if ( myVolumesMap.find( nbNodes ) == myVolumesMap.end() )
1440 myVolumesMap[ nbNodes ] = 0;
1441 myVolumesMap[ nbNodes ] = myVolumesMap[ nbNodes ] + 1;
1443 save << clause << ".5) Volumes in detail: " << endl;
1444 map <int,int>::iterator itV;
1445 for (itV = myVolumesMap.begin(); itV != myVolumesMap.end(); itV++)
1446 save << "--> nb nodes: " << itV->first << " - nb elemens:\t" << itV->second << endl;
1451 save << "===========================================================================" << endl;
1455 //=======================================================================
1456 //function : GetElementType
1457 //purpose : Returns type of mesh element with certain id
1458 //=======================================================================
1460 SMDSAbs_ElementType SMESH_Mesh::GetElementType( const int id, const bool iselem )
1462 return _myMeshDS->GetElementType( id, iselem );