X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH%2FSMESH_Mesh.cxx;h=4119c5fba0735eeec5c70d5342465522c6db1801;hp=aac87a540f26e24a594d6c852ca88b4508e7a38d;hb=7eda9ca931ed2a11cb5e4637e4ffe19f5c061115;hpb=e6d6fd4aa127fce6f9750cc84b025a333a3c78a3 diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index aac87a540..4119c5fba 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 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 @@ -181,22 +181,10 @@ SMESH_Mesh::~SMESH_Mesh() { MESSAGE("SMESH_Mesh::~SMESH_Mesh"); - // Unassign algorithms in order to have all SMESH_subMeshEventListenerData deleted (22874) + // avoid usual removal of elements while processing RemoveHypothesis( algo ) event SMESHDS_SubMeshIteratorPtr smIt = _myMeshDS->SubMeshes(); - while ( smIt->more() ) { - // avoid usual removal of elements while processing RemoveHypothesis( algo ) event + while ( smIt->more() ) 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 @@ -249,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 @@ -528,6 +536,10 @@ int SMESH_Mesh::MEDToMesh(const char* theFileName, const char* theMeshName) MESSAGE("MEDToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces()); MESSAGE("MEDToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes()); } +#ifdef _DEBUG_ + SMESH_ComputeErrorPtr er = myReader.GetError(); + if ( er && !er->IsOK() ) cout << er->myComment << endl; +#endif // Reading groups (sub-meshes are out of scope of MED import functionality) list aGroupNames = myReader.GetGroupNamesAndTypes(); @@ -667,8 +679,8 @@ SMESH_Mesh::AddHypothesis(const TopoDS_Shape & aSubShape, // 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 ); + SMESH_subMesh::algo_event event = isAlgo ? SMESH_subMesh::ADD_ALGO : SMESH_subMesh::ADD_HYP; SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp); @@ -743,8 +755,8 @@ SMESH_Hypothesis::Hypothesis_Status // shape - bool isAlgo = ( !anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO ); - int event = isAlgo ? SMESH_subMesh::REMOVE_ALGO : SMESH_subMesh::REMOVE_HYP; + bool isAlgo = ( !anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO ); + SMESH_subMesh::algo_event event = isAlgo ? SMESH_subMesh::REMOVE_ALGO : SMESH_subMesh::REMOVE_HYP; SMESH_subMesh *subMesh = GetSubMesh(aSubShape); @@ -1109,7 +1121,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 */ //================================================================================ @@ -1123,8 +1135,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(); @@ -1150,6 +1162,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; } //======================================================================= @@ -1320,7 +1338,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(); @@ -1335,6 +1353,8 @@ SMESH_subMeshIteratorPtr smIt( _subMeshHolder->GetIterator() ); hasNotComputed = true; if ( hasComputed && hasNotComputed) return true; + + default:; } } if ( NbNodes() < 1 ) @@ -1564,7 +1584,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 @@ -1572,6 +1593,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 ) @@ -1772,10 +1795,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); } //================================================================================ @@ -1993,7 +2016,7 @@ SMESH_Group* SMESH_Mesh::AddGroup (SMESHDS_GroupBase* groupDS) throw(SALOME_Exce bool SMESH_Mesh::SynchronizeGroups() { - int nbGroups = _mapGroup.size(); + size_t nbGroups = _mapGroup.size(); const set& groups = _myMeshDS->GetGroups(); set::const_iterator gIt = groups.begin(); for ( ; gIt != groups.end(); ++gIt ) @@ -2105,11 +2128,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 ) { @@ -2144,10 +2167,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(); @@ -2193,9 +2216,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() ); @@ -2276,8 +2299,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