X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH%2FSMESH_Mesh.cxx;h=6905e7584b593ad367b53f679242f49a890699a3;hp=a7c20a0c5d844fc7fa88e65648da134d2e11e8ef;hb=de00066f64e01e9028cc5bfc0390911a590a9428;hpb=a3ee66b0371b361bf97d6261c61a35995b4595bb diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index a7c20a0c5..6905e7584 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,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)) @@ -226,7 +234,27 @@ SMESH_Mesh::~SMESH_Mesh() bool SMESH_Mesh::MeshExists( int meshId ) const { - return _myDocument ? _myDocument->GetMesh( meshId ) : false; + 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; } //============================================================================= @@ -327,8 +355,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; } @@ -601,12 +639,16 @@ SMESH_ComputeErrorPtr SMESH_Mesh::GMFToMesh(const char* theFileName, //============================================================================= SMESH_Hypothesis::Hypothesis_Status - SMESH_Mesh::AddHypothesis(const TopoDS_Shape & aSubShape, - int anHypId ) throw(SALOME_Exception) +SMESH_Mesh::AddHypothesis(const TopoDS_Shape & aSubShape, + int anHypId, + std::string* anError ) throw(SALOME_Exception) { Unexpect aCatch(SalomeException); if(MYDEBUG) MESSAGE("SMESH_Mesh::AddHypothesis"); + if ( anError ) + anError->clear(); + SMESH_subMesh *subMesh = GetSubMesh(aSubShape); if ( !subMesh || !subMesh->GetId()) return SMESH_Hypothesis::HYP_BAD_SUBSHAPE; @@ -631,23 +673,36 @@ SMESH_Hypothesis::Hypothesis_Status } } - // shape + // shape - bool isAlgo = ( !anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO ); - int event = isAlgo ? SMESH_subMesh::ADD_ALGO : SMESH_subMesh::ADD_HYP; + bool isAlgo = ( anHyp->GetType() != SMESHDS_Hypothesis::PARAM_ALGO ); + int event = isAlgo ? SMESH_subMesh::ADD_ALGO : SMESH_subMesh::ADD_HYP; SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp); + if ( anError && SMESH_Hypothesis::IsStatusFatal(ret) && subMesh->GetComputeError() ) + *anError = subMesh->GetComputeError()->myComment; + // sub-shapes - if (!SMESH_Hypothesis::IsStatusFatal(ret) && - anHyp->GetDim() <= SMESH_Gen::GetShapeDim(aSubShape)) // is added on father + if ( !SMESH_Hypothesis::IsStatusFatal(ret) && + anHyp->GetDim() <= SMESH_Gen::GetShapeDim(aSubShape)) // is added on father { event = isAlgo ? SMESH_subMesh::ADD_FATHER_ALGO : SMESH_subMesh::ADD_FATHER_HYP; SMESH_Hypothesis::Hypothesis_Status ret2 = - subMesh->SubMeshesAlgoStateEngine(event, anHyp); + subMesh->SubMeshesAlgoStateEngine(event, anHyp, /*exitOnFatal=*/true); if (ret2 > ret) + { ret = ret2; + if ( SMESH_Hypothesis::IsStatusFatal( ret )) + { + if ( anError && subMesh->GetComputeError() ) + *anError = subMesh->GetComputeError()->myComment; + // remove anHyp + event = isAlgo ? SMESH_subMesh::REMOVE_ALGO : SMESH_subMesh::REMOVE_HYP; + subMesh->AlgoStateEngine(event, anHyp); + } + } // check concurent hypotheses on ancestors if (ret < SMESH_Hypothesis::HYP_CONCURENT && !isGlobalHyp ) @@ -773,7 +828,30 @@ const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubS const bool andAncestors, TopoDS_Shape* assignedTo) const { + return GetHypothesis( const_cast< SMESH_Mesh* >(this)->GetSubMesh( aSubShape ), + aFilter, andAncestors, assignedTo ); +} + +//======================================================================= +/*! + * \brief Return the hypothesis assigned to the shape of a sub-mesh + * \param aSubMesh - the sub-mesh to check + * \param aFilter - the hypothesis filter + * \param andAncestors - flag to check hypos assigned to ancestors of the shape + * \param assignedTo - to return the shape the found hypo is assigned to + * \retval SMESH_Hypothesis* - the first hypo passed through aFilter + */ +//======================================================================= + +const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const SMESH_subMesh * aSubMesh, + const SMESH_HypoFilter& aFilter, + const bool andAncestors, + TopoDS_Shape* assignedTo) const +{ + if ( !aSubMesh ) return 0; + { + const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape(); const list& hypList = _myMeshDS->GetHypothesis(aSubShape); list::const_iterator hyp = hypList.begin(); for ( ; hyp != hypList.end(); hyp++ ) { @@ -787,9 +865,12 @@ const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubS if ( andAncestors ) { // user sorted submeshes of ancestors, according to stored submesh priority - getAncestorsSubMeshes( aSubShape, _ancestorSubMeshes ); - vector::const_iterator smIt = _ancestorSubMeshes.begin(); - for ( ; smIt != _ancestorSubMeshes.end(); smIt++ ) + std::vector< SMESH_subMesh * > & ancestors = + const_cast< std::vector< SMESH_subMesh * > & > ( aSubMesh->GetAncestors() ); + SortByMeshOrder( ancestors ); + + vector::const_iterator smIt = ancestors.begin(); + for ( ; smIt != ancestors.end(); smIt++ ) { const TopoDS_Shape& curSh = (*smIt)->GetSubShape(); const list& hypList = _myMeshDS->GetHypothesis(curSh); @@ -808,7 +889,7 @@ const SMESH_Hypothesis * SMESH_Mesh::GetHypothesis(const TopoDS_Shape & aSubS //================================================================================ /*! - * \brief Return hypothesis assigned to the shape + * \brief Return hypotheses assigned to the shape * \param aSubShape - the shape to check * \param aFilter - the hypothesis filter * \param aHypList - the list of the found hypotheses @@ -823,6 +904,29 @@ int SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape, const bool andAncestors, list< TopoDS_Shape > * assignedTo/*=0*/) const { + return GetHypotheses( const_cast< SMESH_Mesh* >(this)->GetSubMesh( aSubShape ), + aFilter, aHypList, andAncestors, assignedTo ); +} + +//================================================================================ +/*! + * \brief Return hypotheses assigned to the shape of a sub-mesh + * \param aSubShape - the sub-mesh to check + * \param aFilter - the hypothesis filter + * \param aHypList - the list of the found hypotheses + * \param andAncestors - flag to check hypos assigned to ancestors of the shape + * \retval int - number of unique hypos in aHypList + */ +//================================================================================ + +int SMESH_Mesh::GetHypotheses(const SMESH_subMesh * aSubMesh, + const SMESH_HypoFilter& aFilter, + list & aHypList, + const bool andAncestors, + list< TopoDS_Shape > * assignedTo/*=0*/) const +{ + if ( !aSubMesh ) return 0; + set hypTypes; // to exclude same type hypos from the result list int nbHyps = 0; @@ -840,45 +944,51 @@ int SMESH_Mesh::GetHypotheses(const TopoDS_Shape & aSubShape, // get hypos from aSubShape { + const TopoDS_Shape & aSubShape = aSubMesh->GetSubShape(); const list& hypList = _myMeshDS->GetHypothesis(aSubShape); for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ ) - if ( aFilter.IsOk (cSMESH_Hyp( *hyp ), aSubShape) && - ( cSMESH_Hyp(*hyp)->IsAuxiliary() || !mainHypFound ) && - hypTypes.insert( (*hyp)->GetName() ).second ) + { + const SMESH_Hypothesis* h = cSMESH_Hyp( *hyp ); + if (( aFilter.IsOk( h, aSubShape )) && + ( h->IsAuxiliary() || !mainHypFound ) && + ( h->IsAuxiliary() || hypTypes.insert( h->GetName() ).second )) { aHypList.push_back( *hyp ); nbHyps++; - if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() ) + if ( !h->IsAuxiliary() ) mainHypFound = true; if ( assignedTo ) assignedTo->push_back( aSubShape ); } + } } // get hypos from ancestors of aSubShape if ( andAncestors ) { - TopTools_MapOfShape map; - // user sorted submeshes of ancestors, according to stored submesh priority - getAncestorsSubMeshes( aSubShape, _ancestorSubMeshes ); - vector::const_iterator smIt = _ancestorSubMeshes.begin(); - for ( ; smIt != _ancestorSubMeshes.end(); smIt++ ) + std::vector< SMESH_subMesh * > & ancestors = + const_cast< std::vector< SMESH_subMesh * > & > ( aSubMesh->GetAncestors() ); + SortByMeshOrder( ancestors ); + + vector::const_iterator smIt = ancestors.begin(); + for ( ; smIt != ancestors.end(); smIt++ ) { const TopoDS_Shape& curSh = (*smIt)->GetSubShape(); - if ( !map.Add( curSh )) - continue; const list& hypList = _myMeshDS->GetHypothesis(curSh); for ( hyp = hypList.begin(); hyp != hypList.end(); hyp++ ) - if (( aFilter.IsOk( cSMESH_Hyp( *hyp ), curSh )) && - ( cSMESH_Hyp(*hyp)->IsAuxiliary() || !mainHypFound ) && - ( hypTypes.insert( (*hyp)->GetName() ).second )) + { + const SMESH_Hypothesis* h = cSMESH_Hyp( *hyp ); + if (( aFilter.IsOk( h, curSh )) && + ( h->IsAuxiliary() || !mainHypFound ) && + ( h->IsAuxiliary() || hypTypes.insert( h->GetName() ).second )) { aHypList.push_back( *hyp ); nbHyps++; - if ( !cSMESH_Hyp(*hyp)->IsAuxiliary() ) + if ( !h->IsAuxiliary() ) mainHypFound = true; if ( assignedTo ) assignedTo->push_back( curSh ); } + } } } return nbHyps; @@ -935,6 +1045,8 @@ SMESH_subMesh *SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape) throw(SALOME_Exception) { int index = _myMeshDS->ShapeToIndex(aSubShape); + if ( !index && aSubShape.IsNull() ) + return 0; // for submeshes on GEOM Group if (( !index || index > _nbSubShapes ) && aSubShape.ShapeType() == TopAbs_COMPOUND ) { @@ -947,14 +1059,29 @@ SMESH_subMesh *SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape) fillAncestorsMap( _myMeshDS->IndexToShape( ++_nbSubShapes )); } } -// if ( !index ) -// return NULL; // neither sub-shape nor a group + // if ( !index ) + // return NULL; // neither sub-shape nor a group SMESH_subMesh* aSubMesh = _subMeshHolder->Get( index ); if ( !aSubMesh ) { aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape); _subMeshHolder->Add( index, aSubMesh ); + + // include non-computable sub-meshes in SMESH_subMesh::_ancestors of sub-submeshes + switch ( aSubShape.ShapeType() ) { + case TopAbs_COMPOUND: + case TopAbs_WIRE: + case TopAbs_SHELL: + for ( TopoDS_Iterator subIt( aSubShape ); subIt.More(); subIt.Next() ) + { + SMESH_subMesh* sm = GetSubMesh( subIt.Value() ); + SMESH_subMeshIteratorPtr smIt = sm->getDependsOnIterator(/*inclideSelf=*/true); + while ( smIt->more() ) + smIt->next()->ClearAncestors(); + } + default:; + } } return aSubMesh; } @@ -990,7 +1117,7 @@ throw(SALOME_Exception) //================================================================================ /*! - * \brief Return submeshes of groups containing the given sub-shape + * \brief Return sub-meshes of groups containing the given sub-shape */ //================================================================================ @@ -1004,8 +1131,8 @@ SMESH_Mesh::GetGroupSubMeshesContaining(const TopoDS_Shape & aSubShape) const if ( !subMesh ) return found; - // submeshes of groups have max IDs, so search from the map end -SMESH_subMeshIteratorPtr smIt( _subMeshHolder->GetIterator( /*reverse=*/true ) ); + // sub-meshes of groups have max IDs, so search from the map end + SMESH_subMeshIteratorPtr smIt( _subMeshHolder->GetIterator( /*reverse=*/true ) ); while ( smIt->more() ) { SMESH_subMesh* sm = smIt->next(); SMESHDS_SubMesh * ds = sm->GetSubMeshDS(); @@ -1031,6 +1158,12 @@ SMESH_subMeshIteratorPtr smIt( _subMeshHolder->GetIterator( /*reverse=*/true ) ) found.push_back( mainSM ); } } + else // issue 0023068 + { + if ( SMESH_subMesh * mainSM = GetSubMeshContaining(1) ) + if ( mainSM->GetSubShape().ShapeType() == TopAbs_COMPOUND ) + found.push_back( mainSM ); + } return found; } //======================================================================= @@ -1047,9 +1180,7 @@ bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp, if ( !aSubMesh || !aSubMesh->IsApplicableHypotesis( hyp )) return false; - const TopoDS_Shape & aSubShape = const_cast( aSubMesh )->GetSubShape(); - - SMESH_Algo *algo = _gen->GetAlgo(*this, aSubShape ); + SMESH_Algo *algo = aSubMesh->GetAlgo(); // algorithm if (anHyp->GetType() > SMESHDS_Hypothesis::PARAM_ALGO) @@ -1062,7 +1193,7 @@ bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp, const SMESH_HypoFilter* hypoKind; if (( hypoKind = algo->GetCompatibleHypoFilter( !hyp->IsAuxiliary() ))) { list usedHyps; - if ( GetHypotheses( aSubShape, *hypoKind, usedHyps, true )) + if ( GetHypotheses( aSubMesh, *hypoKind, usedHyps, true )) return ( find( usedHyps.begin(), usedHyps.end(), anHyp ) != usedHyps.end() ); } } @@ -1110,6 +1241,9 @@ void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* h const SMESH_HypoFilter* compatibleHypoKind; list usedHyps; + // keep sub-meshes not to miss ones whose state can change due to notifying others + vector< SMESH_subMesh* > smToNotify; + SMESH_subMeshIteratorPtr smIt( _subMeshHolder->GetIterator() ); while ( smIt->more() ) { @@ -1122,7 +1256,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(); @@ -1134,14 +1269,20 @@ void SMESH_Mesh::NotifySubMeshesHypothesisModification(const SMESH_Hypothesis* h { // check if hyp is used by algo usedHyps.clear(); - if ( GetHypotheses( aSubShape, *compatibleHypoKind, usedHyps, true ) && + if ( GetHypotheses( aSubMesh, *compatibleHypoKind, usedHyps, true ) && find( usedHyps.begin(), usedHyps.end(), hyp ) != usedHyps.end() ) { - aSubMesh->AlgoStateEngine(SMESH_subMesh::MODIF_HYP, - const_cast< SMESH_Hypothesis*>( hyp )); + smToNotify.push_back( aSubMesh ); } } } + + for ( size_t i = 0; i < smToNotify.size(); ++i ) + { + smToNotify[i]->AlgoStateEngine(SMESH_subMesh::MODIF_HYP, + const_cast< SMESH_Hypothesis*>( hyp )); + } + HasModificationsToDiscard(); // to reset _isModified flag if mesh becomes empty GetMeshDS()->Modified(); } @@ -1193,7 +1334,7 @@ bool SMESH_Mesh::HasModificationsToDiscard() const // return true if the next Compute() will be partial and // existing but changed elements may prevent successful re-compute bool hasComputed = false, hasNotComputed = false; -SMESH_subMeshIteratorPtr smIt( _subMeshHolder->GetIterator() ); + SMESH_subMeshIteratorPtr smIt( _subMeshHolder->GetIterator() ); while ( smIt->more() ) { const SMESH_subMesh* aSubMesh = smIt->next(); @@ -1437,7 +1578,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 @@ -1445,6 +1587,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 ) @@ -1645,10 +1789,10 @@ int SMESH_Mesh::NbBiQuadQuadrangles() const throw(SALOME_Exception) */ //================================================================================ -int SMESH_Mesh::NbPolygons() const throw(SALOME_Exception) +int SMESH_Mesh::NbPolygons(SMDSAbs_ElementOrder order) const throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - return _myMeshDS->GetMeshInfo().NbPolygons(); + return _myMeshDS->GetMeshInfo().NbPolygons(order); } //================================================================================ @@ -1771,6 +1915,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 @@ -1966,11 +2122,11 @@ ostream& SMESH_Mesh::Dump(ostream& save) { int clause = 0; save << "========================== Dump contents of mesh ==========================" << endl << endl; - save << ++clause << ") Total number of nodes: \t" << NbNodes() << endl; - save << ++clause << ") Total number of edges: \t" << NbEdges() << endl; - save << ++clause << ") Total number of faces: \t" << NbFaces() << endl; - save << ++clause << ") Total number of polygons:\t" << NbPolygons() << endl; - save << ++clause << ") Total number of volumes:\t" << NbVolumes() << endl; + save << ++clause << ") Total number of nodes: \t" << NbNodes() << endl; + save << ++clause << ") Total number of edges: \t" << NbEdges() << endl; + save << ++clause << ") Total number of faces: \t" << NbFaces() << endl; + save << ++clause << ") Total number of polygons: \t" << NbPolygons() << endl; + save << ++clause << ") Total number of volumes: \t" << NbVolumes() << endl; save << ++clause << ") Total number of polyhedrons:\t" << NbPolyhedrons() << endl << endl; for ( int isQuadratic = 0; isQuadratic < 2; ++isQuadratic ) { @@ -2005,10 +2161,10 @@ ostream& SMESH_Mesh::Dump(ostream& save) int nb4 = NbTetras(order); int nb5 = NbPyramids(order); int nb6 = NbPrisms(order); - save << clause << ".1) Number of " << orderStr << " hexahedrons:\t" << nb8 << endl; + save << clause << ".1) Number of " << orderStr << " hexahedrons: \t" << nb8 << endl; save << clause << ".2) Number of " << orderStr << " tetrahedrons:\t" << nb4 << endl; save << clause << ".3) Number of " << orderStr << " prisms: \t" << nb6 << endl; - save << clause << ".4) Number of " << orderStr << " pyramids:\t" << nb5 << endl; + save << clause << ".4) Number of " << orderStr << " pyramids: \t" << nb5 << endl; if ( nb8 + nb4 + nb5 + nb6 != NbVolumes(order) ) { map myVolumesMap; SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); @@ -2054,9 +2210,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() ); @@ -2137,10 +2293,11 @@ 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 { for ( desType = TopAbs_VERTEX; desType > TopAbs_COMPOUND; desType-- ) for ( ancType = desType - 1; ancType >= TopAbs_COMPOUND; ancType-- ) @@ -2152,9 +2309,11 @@ void SMESH_Mesh::fillAncestorsMap(const TopoDS_Shape& theShape) // visit COMPOUNDs inside a COMPOUND that are not reachable by TopExp_Explorer if ( theShape.ShapeType() == TopAbs_COMPOUND ) { - for ( TopoDS_Iterator sIt(theShape); sIt.More(); sIt.Next() ) - if ( sIt.Value().ShapeType() == TopAbs_COMPOUND ) - fillAncestorsMap( sIt.Value() ); + TopoDS_Iterator sIt(theShape); + if ( sIt.More() && sIt.Value().ShapeType() == TopAbs_COMPOUND ) + for ( ; sIt.More(); sIt.Next() ) + if ( sIt.Value().ShapeType() == TopAbs_COMPOUND ) + fillAncestorsMap( sIt.Value() ); } }