X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH%2FSMESH_Mesh.cxx;h=aac87a540f26e24a594d6c852ca88b4508e7a38d;hp=b0dcee9ac22247bc2be4a404f940989f404466ad;hb=e6d6fd4aa127fce6f9750cc84b025a333a3c78a3;hpb=ddab513d8534a495dc72450293b85da465198743 diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index b0dcee9ac..aac87a540 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 @@ -55,6 +55,8 @@ #include "DriverCGNS_Write.hxx" #endif +#include + #undef _Precision_HeaderFile #include #include @@ -70,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; @@ -178,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)) @@ -327,8 +347,18 @@ double SMESH_Mesh::GetShapeDiagonalSize(const TopoDS_Shape & aShape) { if ( !aShape.IsNull() ) { Bnd_Box Box; - BRepBndLib::Add(aShape, Box); - return sqrt( Box.SquareExtent() ); + // 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() ); } return 0; } @@ -1212,7 +1242,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(); @@ -1867,6 +1898,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