Salome HOME
54381: TC8.5.0: SMESH: Regression reading HDF files
[modules/smesh.git] / src / SMESH_I / SMESH_PreMeshInfo.cxx
index 3d8980ff9a3751a9efc1b144ceb9b4ba705bcf1d..38c13009cc5bfc1dffbce082c3a746fedc897753 100644 (file)
@@ -287,10 +287,12 @@ namespace
  */
 //================================================================================
 
-void SMESH_PreMeshInfo::hdf2meshInfo( const std::string& name,
-                                      HDFgroup*          hdfGroup)
+void SMESH_PreMeshInfo::hdf2meshInfo( const std::string&              name,
+                                      HDFgroup*                       hdfGroup,
+                                      const TColStd_MapOfAsciiString& allHdfNames)
 {
-  if ( hdfGroup->ExistInternalObject( name.c_str()) )
+  //if ( hdfGroup->ExistInternalObject( name.c_str()) ) PAL23514
+  if ( allHdfNames.Contains( name.c_str() ))
   {
     HDFdataset* dataset = new HDFdataset( name.c_str(), hdfGroup );
     dataset->OpenOnDisk();
@@ -419,7 +421,17 @@ bool SMESH_PreMeshInfo::readPreInfoFromHDF()
     HDFgroup* infoHdfGroup = new HDFgroup( hdfGroupName, aFile );
     infoHdfGroup->OpenOnDisk();
 
-    _mesh->changePreMeshInfo()->hdf2meshInfo( "Mesh", infoHdfGroup );
+    // PAL23514: get all names from the HDFgroup to avoid iteration on its contents
+    // within aGroup->ExistInternalObject( name )
+    TColStd_MapOfAsciiString mapOfNames;
+    {
+      std::vector< std::string > subNames;
+      infoHdfGroup->GetAllObjects( subNames );
+      for ( size_t iN = 0; iN < subNames.size(); ++iN )
+        mapOfNames.Add( subNames[ iN ].c_str() );
+    }
+
+    _mesh->changePreMeshInfo()->hdf2meshInfo( "Mesh", infoHdfGroup, mapOfNames );
 
     // read SMESH_PreMeshInfo of groups
     map<int, SMESH::SMESH_GroupBase_ptr>::const_iterator i2group = _mesh->_mapGroups.begin();
@@ -432,7 +444,7 @@ bool SMESH_PreMeshInfo::readPreInfoFromHDF()
         if ( SMESHDS_GroupBase* group = group_i->GetGroupDS() )
         {
           const std::string name = group->GetStoreName();
-          group_i->changePreMeshInfo()->hdf2meshInfo( name, infoHdfGroup );
+          group_i->changePreMeshInfo()->hdf2meshInfo( name, infoHdfGroup, mapOfNames );
         }
       }
     }
@@ -444,7 +456,9 @@ bool SMESH_PreMeshInfo::readPreInfoFromHDF()
       if ( SMESH_subMesh_i* sm = SMESH::DownCast<SMESH_subMesh_i*>( id2sm->second ))
       {
         sm->changePreMeshInfo() = newInstance();
-        sm->changePreMeshInfo()->hdf2meshInfo( SMESH_Comment( sm->GetId()), infoHdfGroup );
+        sm->changePreMeshInfo()->hdf2meshInfo( SMESH_Comment( sm->GetId()),
+                                               infoHdfGroup,
+                                               mapOfNames );
       }
     }
   }
@@ -944,7 +958,7 @@ void SMESH_PreMeshInfo::readSubMeshes(DriverMED_R_SMESHDS_Mesh* reader) const
             if ( isNode ) {
               SMDS_PositionPtr pos = aPositionCreator.MakePosition( smType[ smID ]);
               SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>( static_cast<const SMDS_MeshNode*>( elem ));
-              node->SetPosition( pos );
+              node->SetPosition( pos, sm->GetID() );
               sm->AddNode( node );
             } else {
               sm->AddElement( elem );
@@ -1045,8 +1059,7 @@ void SMESH_PreMeshInfo::readSubMeshes(DriverMED_R_SMESHDS_Mesh* reader) const
             // -- Most probably a bad study was saved when there were
             // not fixed bugs in SMDS_MeshInfo
             if ( aPos->GetTypeOfPosition() == SMDS_TOP_FACE ) {
-              SMDS_FacePosition* fPos = const_cast<SMDS_FacePosition*>
-                ( static_cast<const SMDS_FacePosition*>( aPos ));
+              SMDS_FacePositionPtr fPos = aPos;
               fPos->SetUParameter( aUPos[ iNode ]);
               fPos->SetVParameter( aVPos[ iNode ]);
             }
@@ -1054,9 +1067,8 @@ void SMESH_PreMeshInfo::readSubMeshes(DriverMED_R_SMESHDS_Mesh* reader) const
           else {
             // ASSERT( aPos->GetTypeOfPosition() == SMDS_TOP_EDGE );-- issue 20182
             if ( aPos->GetTypeOfPosition() == SMDS_TOP_EDGE ) {
-              SMDS_EdgePosition* fPos = const_cast<SMDS_EdgePosition*>
-                ( static_cast<const SMDS_EdgePosition*>( aPos ));
-              fPos->SetUParameter( aUPos[ iNode ]);
+              SMDS_EdgePositionPtr ePos = aPos;
+              ePos->SetUParameter( aUPos[ iNode ]);
             }
           }
         }