Salome HOME
PAL13460 (PAL EDF 301 force the mesh to go through a point)
[modules/smesh.git] / src / SMESH_I / SMESH_Gen_i.cxx
index 067e88089018c4cdc350f6690eddf05e84a93900..2492eb127b28ce6dcb4bc457666ab3a7c1d3a2e4 100644 (file)
@@ -238,7 +238,7 @@ SMESH_Gen_i::SMESH_Gen_i( CORBA::ORB_ptr            orb,
                           const char*               interfaceName )
      : Engines_Component_i( orb, poa, contId, instanceName, interfaceName )
 {
-  INFOS( "SMESH_Gen_i::SMESH_Gen_i : standard constructor" );
+  MESSAGE( "SMESH_Gen_i::SMESH_Gen_i : standard constructor" );
 
   myOrb = CORBA::ORB::_duplicate(orb);
   myPoa = PortableServer::POA::_duplicate(poa);
@@ -939,7 +939,7 @@ SMESH::algo_error_array* SMESH_Gen_i::GetAlgoState( SMESH::SMESH_Mesh_ptr theMes
           THROW_SALOME_CORBA_EXCEPTION( "bad error name",SALOME::BAD_PARAM );
         }
         // algo name
-        CORBA::String_var algoName;
+        CORBA::String_var algoName = "";
         if ( error->_algo ) {
           if ( !myCurrentStudy->_is_nil() ) {
             // find algo in the study
@@ -969,7 +969,7 @@ SMESH::algo_error_array* SMESH_Gen_i::GetAlgoState( SMESH::SMESH_Mesh_ptr theMes
           }
           if ( algoName.in() == 0 )
             // use algo type name
-            algoName = CORBA::string_dup( error->_algo->GetName() );
+            algoName = error->_algo->GetName();
         }
         // fill AlgoStateError structure
         SMESH::AlgoStateError & errStruct = error_array[ i++ ];
@@ -2389,6 +2389,32 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
          string iorString = GetORB()->object_to_string( myNewMesh );
          int newId = myStudyContext->findId( iorString );
          myStudyContext->mapOldToNew( id, newId );
+
+          // try to read and set reference to shape
+          GEOM::GEOM_Object_var aShapeObject;
+          if ( aTopGroup->ExistInternalObject( "Ref on shape" ) ) {
+            // load mesh "Ref on shape" - it's an entry to SObject
+            aDataset = new HDFdataset( "Ref on shape", aTopGroup );
+            aDataset->OpenOnDisk();
+            size = aDataset->GetSize();
+            char* refFromFile = new char[ size ];
+            aDataset->ReadFromDisk( refFromFile );
+            aDataset->CloseOnDisk();
+            if ( strlen( refFromFile ) > 0 ) {
+              SALOMEDS::SObject_var shapeSO = myCurrentStudy->FindObjectID( refFromFile );
+
+              // Make sure GEOM data are loaded first
+              //loadGeomData( shapeSO->GetFatherComponent() );
+
+              CORBA::Object_var shapeObject = SObjectToObject( shapeSO );
+              if ( !CORBA::is_nil( shapeObject ) ) {
+                aShapeObject = GEOM::GEOM_Object::_narrow( shapeObject );
+                if ( !aShapeObject->_is_nil() )
+                  myNewMeshImpl->SetShape( aShapeObject );
+              }
+            }
+          }
+
         }
       }
     }
@@ -2414,6 +2440,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
       ::SMESH_Mesh& myLocMesh     = myNewMeshImpl->GetImpl();
       SMESHDS_Mesh* mySMESHDSMesh = myLocMesh.GetMeshDS();
 
+      GEOM::GEOM_Object_var aShapeObject = myNewMeshImpl->GetShapeToMesh();
       bool hasData = false;
 
       // get mesh old id
@@ -2439,31 +2466,6 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
         }
       }
 
-      // try to read and set reference to shape
-      GEOM::GEOM_Object_var aShapeObject;
-      if ( aTopGroup->ExistInternalObject( "Ref on shape" ) ) {
-        // load mesh "Ref on shape" - it's an entry to SObject
-        aDataset = new HDFdataset( "Ref on shape", aTopGroup );
-        aDataset->OpenOnDisk();
-        size = aDataset->GetSize();
-        char* refFromFile = new char[ size ];
-        aDataset->ReadFromDisk( refFromFile );
-        aDataset->CloseOnDisk();
-        if ( strlen( refFromFile ) > 0 ) {
-          SALOMEDS::SObject_var shapeSO = myCurrentStudy->FindObjectID( refFromFile );
-
-          // Make sure GEOM data are loaded first
-          //loadGeomData( shapeSO->GetFatherComponent() );
-
-          CORBA::Object_var shapeObject = SObjectToObject( shapeSO );
-          if ( !CORBA::is_nil( shapeObject ) ) {
-            aShapeObject = GEOM::GEOM_Object::_narrow( shapeObject );
-            if ( !aShapeObject->_is_nil() )
-              myNewMeshImpl->SetShape( aShapeObject );
-          }
-        }
-      }
-
       // try to get applied algorithms
       if ( aTopGroup->ExistInternalObject( "Applied Algorithms" ) ) {
         aGroup = new HDFgroup( "Applied Algorithms", aTopGroup );
@@ -2747,7 +2749,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
               aDataset->CloseOnDisk();
 
               // get elements sorted by ID
-              ::SMESH_MeshEditor::TIDSortedElemSet elemSet;
+              TIDSortedElemSet elemSet;
               if ( isNode )
                 while ( nIt->more() ) elemSet.insert( nIt->next() );
               else
@@ -2755,7 +2757,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
               ASSERT( elemSet.size() == nbElems );
 
               // add elements to submeshes
-              ::SMESH_MeshEditor::TIDSortedElemSet::iterator iE = elemSet.begin();
+              TIDSortedElemSet::iterator iE = elemSet.begin();
               for ( int i = 0; i < nbElems; ++i, ++iE )
               {
                 int smID = smIDs[ i ];
@@ -2779,7 +2781,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
                   sm->AddElement( elem );
                 }
               }
-              delete smIDs;
+              delete [] smIDs;
             }
           }
         } // end reading submeshes