X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH%2FSMESH_Mesh.cxx;h=94b1b7a72c22313edf9cb2d51fd369b3afac1de5;hp=72d7ef193b7e9c3950ba27c43e99c3a6db75bfdb;hb=22463abfc977f33a756ce1d6398c840b7a8e3af2;hpb=324d433f277a1ec6552c93db878504f447f8fbad diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index 72d7ef193..94b1b7a72 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -58,7 +58,7 @@ #include #undef _Precision_HeaderFile -//#include +#include #include #include #include @@ -72,11 +72,12 @@ #include "SMESH_TryCatch.hxx" // include after OCCT headers! #include "Utils_ExceptHandlers.hxx" + #ifndef WIN32 #include #include #else -#include +#include #endif using namespace std; @@ -180,6 +181,11 @@ SMESH_Mesh::~SMESH_Mesh() { MESSAGE("SMESH_Mesh::~SMESH_Mesh"); + // avoid usual removal of elements while processing RemoveHypothesis( algo ) event + SMESHDS_SubMeshIteratorPtr smIt = _myMeshDS->SubMeshes(); + while ( smIt->more() ) + const_cast( smIt->next() )->Clear(); + // issue 0020340: EDF 1022 SMESH : Crash with FindNodeClosestTo in a second new study // Notify event listeners at least that something happens if ( SMESH_subMesh * sm = GetSubMeshContaining(1)) @@ -231,6 +237,26 @@ bool SMESH_Mesh::MeshExists( int meshId ) const return _myDocument ? bool( _myDocument->GetMesh( meshId )) : false; } +//================================================================================ +/*! + * \brief Return a mesh by id + */ +//================================================================================ + +SMESH_Mesh* SMESH_Mesh::FindMesh( int meshId ) const +{ + if ( _id == meshId ) + return (SMESH_Mesh*) this; + + if ( StudyContextStruct *aStudyContext = _gen->GetStudyContext( _studyId )) + { + std::map < int, SMESH_Mesh * >::iterator i_m = aStudyContext->mapMesh.find( meshId ); + if ( i_m != aStudyContext->mapMesh.end() ) + return i_m->second; + } + return NULL; +} + //============================================================================= /*! * \brief Set geometry to be meshed @@ -329,7 +355,16 @@ double SMESH_Mesh::GetShapeDiagonalSize(const TopoDS_Shape & aShape) { if ( !aShape.IsNull() ) { Bnd_Box Box; - GEOMUtils::PreciseBoundingBox(aShape, Box); + // avoid too long waiting on large shapes. PreciseBoundingBox() was added + // to assure same result which else depends on presence of triangulation (IPAL52557). + const int maxNbFaces = 4000; + int nbFaces = 0; + for ( TopExp_Explorer f( aShape, TopAbs_FACE ); f.More() && nbFaces < maxNbFaces; f.Next() ) + ++nbFaces; + if ( nbFaces < maxNbFaces ) + GEOMUtils::PreciseBoundingBox(aShape, Box); + else + BRepBndLib::Add( aShape, Box); if ( !Box.IsVoid() ) return sqrt( Box.SquareExtent() ); } @@ -1215,7 +1250,8 @@ void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* h // other possible changes are not interesting. (IPAL0052457 - assigning hyp performance pb) if ( aSubMesh->GetComputeState() != SMESH_subMesh::COMPUTE_OK && aSubMesh->GetComputeState() != SMESH_subMesh::FAILED_TO_COMPUTE && - aSubMesh->GetAlgoState() != SMESH_subMesh::MISSING_HYP ) + aSubMesh->GetAlgoState() != SMESH_subMesh::MISSING_HYP && + !hyp->DataDependOnParams() ) continue; const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape(); @@ -1536,7 +1572,8 @@ void SMESH_Mesh::ExportSTL(const char * file, //================================================================================ void SMESH_Mesh::ExportCGNS(const char * file, - const SMESHDS_Mesh* meshDS) + const SMESHDS_Mesh* meshDS, + const char * meshName) { int res = Driver_Mesh::DRS_FAIL; #ifdef WITH_CGNS @@ -1544,6 +1581,8 @@ void SMESH_Mesh::ExportCGNS(const char * file, myWriter.SetFile( file ); myWriter.SetMesh( const_cast( meshDS )); myWriter.SetMeshName( SMESH_Comment("Mesh_") << meshDS->GetPersistentId()); + if ( meshName && meshName[0] ) + myWriter.SetMeshName( meshName ); res = myWriter.Perform(); #endif if ( res != Driver_Mesh::DRS_OK ) @@ -1870,6 +1909,18 @@ int SMESH_Mesh::NbSubMesh() const throw(SALOME_Exception) return _myMeshDS->NbSubMesh(); } +//================================================================================ +/*! + * \brief Returns number of meshes in the Study, that is supposed to be + * equal to SMESHDS_Document::NbMeshes() + */ +//================================================================================ + +int SMESH_Mesh::NbMeshes() const // nb meshes in the Study +{ + return _myDocument->NbMeshes(); +} + //======================================================================= //function : IsNotConformAllowed //purpose : check if a hypothesis alowing notconform mesh is present @@ -2153,9 +2204,9 @@ SMESH_Group* SMESH_Mesh::ConvertToStandalone ( int theGroupID ) return aGroup; SMESH_Group* anOldGrp = (*itg).second; - SMESHDS_GroupBase* anOldGrpDS = anOldGrp->GetGroupDS(); - if ( !anOldGrp || !anOldGrpDS ) + if ( !anOldGrp || !anOldGrp->GetGroupDS() ) return aGroup; + SMESHDS_GroupBase* anOldGrpDS = anOldGrp->GetGroupDS(); // create new standalone group aGroup = new SMESH_Group (theGroupID, this, anOldGrpDS->GetType(), anOldGrp->GetName() ); @@ -2236,8 +2287,8 @@ void SMESH_Mesh::fillAncestorsMap(const TopoDS_Shape& theShape) TopTools_ListIteratorOfListOfShape ancIt (ancList); while ( ancIt.More() && ancIt.Value().ShapeType() >= memberType ) ancIt.Next(); - if ( ancIt.More() ) - ancList.InsertBefore( theShape, ancIt ); + if ( ancIt.More() ) ancList.InsertBefore( theShape, ancIt ); + else ancList.Append( theShape ); } } else // else added for 52457: Addition of hypotheses is 8 time longer than meshing