Salome HOME
Fix: getCellsContainingPoints() in case of polyhedron with a face containing colinear...
[tools/medcoupling.git] / src / MEDCoupling_Swig / MEDCouplingExamplesTest.py
index 26499420cc05b4ccc5df82fe420bc3c48fd3c8c3..e715b4634b1cfc193364aee4abe8618223b08170 100644 (file)
@@ -1,5 +1,5 @@
 #  -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2019  CEA/DEN, EDF R&D
+# Copyright (C) 2007-2024  CEA, EDF
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 
 
 import sys
-if sys.platform == "win32":
-    from MEDCouplingCompat import *
-else:
-    from medcoupling import *
+from medcoupling import *
 import unittest
 from math import pi, sqrt
 
+def WriteInTmpDir(func):
+    def decoratedFunc(*args,**kwargs):
+        import tempfile,os
+        ret = None
+        with tempfile.TemporaryDirectory() as tmpdirname:
+            os.chdir(tmpdirname)
+            ret = func(*args,**kwargs)
+            os.chdir(os.path.dirname(tmpdirname))
+            pass
+        return ret
+    return decoratedFunc
+
 class MEDCouplingBasicsTest(unittest.TestCase):
 
+    @WriteInTmpDir
     def testExample_MEDCouplingFieldDouble_WriteVTK(self):
         #! [PySnippet_MEDCouplingFieldDouble_WriteVTK_1]
         # mesh
@@ -694,6 +704,17 @@ class MEDCouplingBasicsTest(unittest.TestCase):
         badCellIds=mesh.are2DCellsNotCorrectlyOriented( vec, False )
         assert len( badCellIds ) == 0 # the orientation is OK
         #! [PySnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_2]
+        #! [PySnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_3]
+        mesh.orientCorrectly2DCells( None )
+        #! [PySnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_3]
+        #! [PySnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_4]
+        refCells = [ 0,2 ]
+        objCells = [ 1,3 ]
+        refGroup = mesh.buildPartOfMySelf( refCells )
+        objGroup = mesh.buildPartOfMySelf( objCells )
+        objGroup.orientCorrectly2DCells( refGroup )
+        mesh.setPartOfMySelf( objCells, objGroup )
+        #! [PySnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_4]
         return
 
     def testExample_MEDCouplingUMesh_getCellsContainingPoints(self):