]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
021382: EDF 1985 SMESH: Read/write of .mesh files (GMF format)
authoreap <eap@opencascade.com>
Mon, 24 Sep 2012 11:31:06 +0000 (11:31 +0000)
committereap <eap@opencascade.com>
Mon, 24 Sep 2012 11:31:06 +0000 (11:31 +0000)
+  SMESH::SMESH_Mesh_ptr CreateMeshesFromGMF( const char*             theFileName,
+                                             SMESH::ComputeError_out theError)

src/SMESH_I/SMESH_Gen_i.cxx
src/SMESH_I/SMESH_Gen_i.hxx

index 87c47de8faa1b22a98083b7348e338dc11a7bb94..e505af6934aa4f7a948a9b37b2f0b70206b9a2e0 100644 (file)
@@ -1222,6 +1222,41 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromCGNS( const char* theFileName,
   return aResult._retn();
 }
 
+//================================================================================
+/*!
+ * \brief Create a mesh and import data from a GMF file
+ */
+//================================================================================
+
+SMESH::SMESH_Mesh_ptr
+SMESH_Gen_i::CreateMeshesFromGMF( const char*             theFileName,
+                                  SMESH::ComputeError_out theError)
+    throw ( SALOME::SALOME_Exception )
+{
+  Unexpect aCatch(SALOME_SalomeException);
+
+  SMESH::SMESH_Mesh_var aMesh = createMesh();
+  string aFileName = basename( theFileName );
+  // publish mesh in the study
+  if ( CanPublishInStudy( aMesh ) ) {
+    SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
+    aStudyBuilder->NewCommand();  // There is a transaction
+    SALOMEDS::SObject_var aSO = PublishInStudy
+      ( myCurrentStudy, SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() );
+    aStudyBuilder->CommitCommand();
+    if ( !aSO->_is_nil() ) {
+      // Update Python script
+      TPythonDump() << aSO << " = " << this << ".CreateMeshesFromGMF(r'" << theFileName << "')";
+    }
+  }
+  SMESH_Mesh_i* aServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( aMesh ).in() );
+  ASSERT( aServant );
+  theError = aServant->ImportGMFFile( theFileName );
+  aServant->GetImpl().GetMeshDS()->Modified();
+  return aMesh._retn();
+}
+
+
 //=============================================================================
 /*!
  *  SMESH_Gen_i::IsReadyToCompute
index a72c466f31c9f97daff0038896330d1ced30e95f..1165ac142fa8c8267f707d0c112d9e6d48aa7e87 100644 (file)
@@ -238,7 +238,7 @@ public:
   SMESH::SMESH_Mesh_ptr CreateEmptyMesh()
     throw ( SALOME::SALOME_Exception );
 
-  //  Create mesh(es) and import data from UNV fileter
+  //  Create a mesh and import data from an UNV file
   SMESH::SMESH_Mesh_ptr CreateMeshesFromUNV( const char* theFileName )
     throw ( SALOME::SALOME_Exception );
 
@@ -252,7 +252,7 @@ public:
                                            SMESH::DriverMED_ReadStatus& theStatus )
     throw ( SALOME::SALOME_Exception );
 
-  //  Create mesh(es) and import data from STL file
+  //  Create a mesh and import data from a STL file
   SMESH::SMESH_Mesh_ptr CreateMeshesFromSTL( const char* theFileName )
     throw ( SALOME::SALOME_Exception );
 
@@ -261,6 +261,11 @@ public:
                                            SMESH::DriverMED_ReadStatus& theStatus )
     throw ( SALOME::SALOME_Exception );
 
+  //  Create a mesh and import data from a GMF file
+  SMESH::SMESH_Mesh_ptr CreateMeshesFromGMF( const char*             theFileName,
+                                             SMESH::ComputeError_out theError)
+    throw ( SALOME::SALOME_Exception );
+
   // Copy a part of mesh
   SMESH::SMESH_Mesh_ptr CopyMesh(SMESH::SMESH_IDSource_ptr meshPart,
                                  const char*               meshName,