Salome HOME
Merge branch 'eap/23514'
authorrnv <rnv@opencascade.com>
Thu, 14 Dec 2017 15:04:38 +0000 (18:04 +0300)
committerrnv <rnv@opencascade.com>
Thu, 14 Dec 2017 15:04:38 +0000 (18:04 +0300)
1  2 
src/SMESH_I/SMESH_Gen_i.cxx

index 89317f87fe79d11376029812723c79cb781f3123,65d22dab71e0059b4159139526f9e7a1531048f9..b3c0f73b1e63af618e416794c0b6127e7462f489
  //  Author : Paul RASCLE, EDF
  //  Module : SMESH
  
+ #include <BRepPrimAPI_MakeBox.hxx>
+ #include <BRepPrimAPI_MakeCylinder.hxx>
+ #include <BRepPrimAPI_MakeSphere.hxx>
+ #include <BRep_Tool.hxx>
+ #include <OSD.hxx>
+ #include <TColStd_MapOfAsciiString.hxx>
+ #include <TCollection_AsciiString.hxx>
  #include <TopExp.hxx>
  #include <TopExp_Explorer.hxx>
+ #include <TopTools_IndexedMapOfShape.hxx>
+ #include <TopTools_ListIteratorOfListOfShape.hxx>
+ #include <TopTools_ListOfShape.hxx>
+ #include <TopTools_MapOfShape.hxx>
  #include <TopoDS.hxx>
- #include <TopoDS_Iterator.hxx>
- #include <TopoDS_Compound.hxx>
  #include <TopoDS_CompSolid.hxx>
- #include <TopoDS_Solid.hxx>
- #include <TopoDS_Shell.hxx>
- #include <TopoDS_Face.hxx>
- #include <TopoDS_Wire.hxx>
+ #include <TopoDS_Compound.hxx>
  #include <TopoDS_Edge.hxx>
- #include <TopoDS_Vertex.hxx>
+ #include <TopoDS_Face.hxx>
+ #include <TopoDS_Iterator.hxx>
  #include <TopoDS_Shape.hxx>
- #include <TopTools_MapOfShape.hxx>
- #include <TopTools_IndexedMapOfShape.hxx>
- #include <TopTools_ListOfShape.hxx>
- #include <TopTools_ListIteratorOfListOfShape.hxx>
+ #include <TopoDS_Shell.hxx>
+ #include <TopoDS_Solid.hxx>
+ #include <TopoDS_Vertex.hxx>
+ #include <TopoDS_Wire.hxx>
  #include <gp_Pnt.hxx>
- #include <BRep_Tool.hxx>
- #include <TCollection_AsciiString.hxx>
- #include <OSD.hxx>
- #include <BRepPrimAPI_MakeSphere.hxx>
- #include <BRepPrimAPI_MakeCylinder.hxx>
- #include <BRepPrimAPI_MakeBox.hxx>
  
  
  #ifdef WIN32
@@@ -3827,7 -3828,7 +3828,7 @@@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( S
                  // "Face V positions" - V parameter of node on face
  
                  // Find out nb of nodes on edges and faces
 -                // Collect corresponing sub-meshes
 +                // Collect corresponding sub-meshes
                  int nbEdgeNodes = 0, nbFaceNodes = 0;
                  list<SMESHDS_SubMesh*> aEdgeSM, aFaceSM;
                  // loop on SMESHDS_SubMesh'es
@@@ -4682,18 -4683,23 +4683,23 @@@ bool SMESH_Gen_i::Load( SALOMEDS::SComp
          if ( aTopGroup->ExistInternalObject( name_group ) ) {
            aGroup = new HDFgroup( name_group, aTopGroup );
            aGroup->OpenOnDisk();
-           // get number of groups
-           int aNbSubObjects = aGroup->nInternalObjects();
-           for ( int j = 0; j < aNbSubObjects; j++ ) {
-             char name_dataset[ HDF_NAME_MAX_LEN+1 ];
-             aGroup->InternalObjectIndentify( j, name_dataset );
-             // check if it is an group
-             if ( string( name_dataset ).substr( 0, 5 ) == string( "Group" ) ) {
+           // PAL23514: get all names from the HDFgroup to avoid iteration on its contents
+           // within aGroup->ExistInternalObject( name )
+           std::vector< std::string > subNames;
+           TColStd_MapOfAsciiString mapOfNames;
+           aGroup->GetAllObjects( subNames );
+           for ( size_t iN = 0; iN < subNames.size(); ++iN )
+             mapOfNames.Add( subNames[ iN ].c_str() );
+           // loop on groups
+           for ( size_t j = 0; j < subNames.size(); j++ ) {
+             const std::string& name_dataset = subNames[ j ];
+             // check if it is a group
+             if ( name_dataset.substr( 0, 5 ) == "Group" ) {
                // --> get group id
-               int subid = atoi( string( name_dataset ).substr( 5 ).c_str() );
+               int subid = atoi( name_dataset.substr( 5 ).c_str() );
                if ( subid <= 0 )
                  continue;
-               aDataset = new HDFdataset( name_dataset, aGroup );
+               aDataset = new HDFdataset( name_dataset.c_str(), aGroup );
                aDataset->OpenOnDisk();
  
                // Retrieve actual group name
                TopoDS_Shape aShape;
                char aRefName[ 30 ];
                sprintf( aRefName, "Ref on shape %d", subid);
-               if ( aGroup->ExistInternalObject( aRefName ) ) {
+               if ( mapOfNames.Contains( aRefName ))
+               {
                  // load mesh "Ref on shape" - it's an entry to SObject
                  aDataset = new HDFdataset( aRefName, aGroup );
                  aDataset->OpenOnDisk();
                // Try to read a filter of SMESH_GroupOnFilter
                SMESH::Filter_var filter;
                SMESH_PredicatePtr predicate;
-               std::string hdfGrpName = "Filter " + SMESH_Comment(subid);
-               if ( aGroup->ExistInternalObject( hdfGrpName.c_str() ))
+               std::string hdfGrpName = ( SMESH_Comment( "Filter ") << subid );
+               if ( mapOfNames.Contains( hdfGrpName.c_str() ))
                {
                  aDataset = new HDFdataset( hdfGrpName.c_str(), aGroup );
                  aDataset->OpenOnDisk();
                if ( !aGroupBaseDS )
                  continue;
  
-               aGroupBaseDS->SetStoreName( name_dataset );
+               aGroupBaseDS->SetStoreName( name_dataset.c_str() );
  
                // ouv : NPAL12872
                // Read color of the group
                char aGroupColorName[ 30 ];
                sprintf( aGroupColorName, "ColorGroup %d", subid);
-               if ( aGroup->ExistInternalObject( aGroupColorName ) )
+               if ( mapOfNames.Contains( aGroupColorName ))
                {
                  aDataset = new HDFdataset( aGroupColorName, aGroup );
                  aDataset->OpenOnDisk();