]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Some useful helpers into medcoupling python module
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 29 Dec 2017 09:04:35 +0000 (10:04 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 29 Dec 2017 09:04:35 +0000 (10:04 +0100)
src/PyWrapping/medcoupling.i
src/PyWrapping/medcoupling_pycode

index 783471359fa3c3c74622f053fa59bb95a15be650..e95cb251037439b29b4047daa242d019b5ae9047 100644 (file)
     std::vector<std::string> ret(EXTENSIONS,EXTENSIONS+NB_OF_EXTENSIONS);
     return ret;
   }
+
+  bool HasMEDFileExt()
+  {
+#ifdef WITH_MED_FILE
+    return true;
+#else
+    return false;
+#endif
+  }
+
+  bool HasRenumberExt()
+  {
+#ifdef WITH_RENUMBER
+    return true;
+#else
+    return false;
+#endif
+  }
+
+  bool HasPartitionerExt()
+  {
+#ifdef WITH_PARTITIONER
+    return true;
+#else
+    return false;
+#endif
+  }
+
+  bool HasParallelInterpolator()
+  {
+#ifdef WITH_PARALLEL_INTERPOLATOR
+    return true;
+#else
+    return false;
+#endif
+  }
   
   std::vector<std::string> ActiveExtensions()
   {
index 08914fce54218665f7624bdc7284587beb038c4d..a3dfe1a20cdd8546aa4fb08706a91041c50df741 100644 (file)
@@ -58,4 +58,34 @@ def AdvancedExtensionsStr(sz=60):
 def ShowAdvancedExtensions(sz=60):
     print(AdvancedExtensionsStr(sz))
 
+def MEDCouplingWriterHelper(mci,fileName,medFunc):
+    import os
+    fileWithoutExt,ext=os.path.splitext(fileName)
+    if ext in [".med",".rmed",""]:
+        outFileName=fileName
+        if ext=="":
+            outFileName=fileWithoutExt+".med"
+        if HasMEDFileExt():
+            medFunc(outFileName,mci,True)
+            pass
+        else:
+            raise InterpKernelException("Request for writing \"%s\" MED file, but MED file is not activated in your medcoupling !")
+        pass
+    elif ext[:3]==".vt" and len(ext)==4:
+        mci.writeVTK(fileName)
+    else:
+        raise InterpKernelException("The extension \"%s\" of input file \"%s\" is not recognized !"%(ext,fileName))
+    pass
+
+def MEDCouplingMesh_write(self,fileName):
+    MEDCouplingWriterHelper(self,fileName,WriteMesh)
+
+def MEDCouplingField_write(self,fileName):
+    MEDCouplingWriterHelper(self,fileName,WriteField)
+        
+MEDCouplingMesh.write=MEDCouplingMesh_write
+del MEDCouplingMesh_write
+MEDCouplingField.write=MEDCouplingField_write
+del MEDCouplingField_write
+
 %}