X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH%2FSMESH_Mesh.cxx;h=992e317351bb767b9400786990889eed35f050a9;hp=20deb04a6c678e1684b8ad5387a530c350463cef;hb=0921263864977d53ebb778e3d1c9d88d61a4912f;hpb=bbca2cb797c37bb7695d3f35490bcd328fbddd4e diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index 20deb04a6..992e31735 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -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,23 @@ SMESH_Mesh::~SMESH_Mesh() { MESSAGE("SMESH_Mesh::~SMESH_Mesh"); + // Unassign algorithms in order to have all SMESH_subMeshEventListenerData deleted (22874) + SMESHDS_SubMeshIteratorPtr smIt = _myMeshDS->SubMeshes(); + while ( smIt->more() ) { + // avoid usual removal of elements while processing RemoveHypothesis( algo ) event + const_cast( smIt->next() )->Clear(); + } + const ShapeToHypothesis & hyps = _myMeshDS->GetHypotheses(); + for ( ShapeToHypothesis::Iterator s2hyps( hyps ); s2hyps.More(); s2hyps.Next() ) + { + const TopoDS_Shape& s = s2hyps.Key(); + THypList hyps = s2hyps.ChangeValue(); // copy + THypList::const_iterator h = hyps.begin(); + for ( ; h != hyps.end(); ++h ) + if ( (*h)->GetType() != SMESHDS_Hypothesis::PARAM_ALGO ) + RemoveHypothesis( s, (*h)->GetID() ); + } + // 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)) @@ -329,7 +347,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() ); }