Salome HOME
Copyright update 2021
[plugins/netgenplugin.git] / src / NETGENPlugin / NETGENPluginBuilder.py
index 1035553d20363b809fed3bc2fb220f49b411ecb3..b9131aa27b43d620204abf290e3553e298dfd279 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -32,6 +32,8 @@ except ImportError:
     noNETGENPlugin = 1
     pass
 
+LIBRARY = "libNETGENEngine.so"
+
 #----------------------------
 # Mesh algo type identifiers
 #----------------------------
@@ -103,8 +105,12 @@ class NETGEN_Algorithm(Mesh_Algorithm):
     #              if it is @c 0 (default), the algorithm is assigned to the main shape
     def __init__(self, mesh, geom=0):
         Mesh_Algorithm.__init__(self)
-        if noNETGENPlugin: print "Warning: NETGENPlugin module unavailable"
-        self.Create(mesh, geom, self.algoType, "libNETGENEngine.so")
+        if noNETGENPlugin: print("Warning: NETGENPlugin module unavailable")
+        if not mesh.GetMesh().HasShapeToMesh() and \
+           self.meshMethod == "Triangle": # create a 2D remesher
+            self.Create(mesh, geom, "NETGEN_Remesher_2D", LIBRARY)
+        else:
+            self.Create(mesh, geom, self.algoType, LIBRARY)
         self.params = None
         pass
 
@@ -159,14 +165,31 @@ class NETGEN_Algorithm(Mesh_Algorithm):
         else:
             hypType = "NETGEN_Parameters_3D"
 
+        if self.algo.GetName() == "NETGEN_Remesher_2D":
+            hypType = "NETGEN_RemesherParameters_2D"
+
         if self.params and self.params.GetName() != hypType:
             self.mesh.RemoveHypothesis( self.params, self.geom )
             self.params = None
         if not self.params:
-            self.params = self.Hypothesis(hypType, [],"libNETGENEngine.so",UseExisting=0)
+            self.params = self.Hypothesis(hypType, [], LIBRARY, UseExisting=0)
 
         return self.params
 
+    ## Defines a file specifying size of elements at points and lines
+    #  @param file name of the file
+    def SetMeshSizeFile(self, file):
+        self.Parameters().SetMeshSizeFile(file)
+        pass
+
+    ## Set size of elements on a shape
+    #  @param shape - geometry
+    #  @param size - element size
+    def SetLocalSizeOnShape(self, shape, size ):
+        self.Parameters().SetLocalSizeOnShape(shape, size)
+        pass
+        
+
     pass # end of NETGEN_Algorithm class
 
 
@@ -213,6 +236,21 @@ class NETGEN_1D2D3D_Algorithm(NETGEN_Algorithm):
         if self.Parameters(): self.params.SetNbSegPerRadius(theVal)
         pass
 
+    ## Sets @c ChordalError parameter
+    #  @param theVal new value of the @c ChordalError parameter
+    def SetChordalError(self, theVal):
+        if self.Parameters():
+            self.params.SetChordalError(theVal)
+            self.params.SetChordalErrorEnabled( theVal > 0 )
+        pass
+
+    ## Sets @c RidgeAngle parameter
+    #  @param theVal new value of the @c RidgeAngle parameter
+    def SetRidgeAngle(self, theVal):
+        if self.Parameters():
+            self.params.SetRidgeAngle(theVal)
+        pass
+
     ## Sets @c QuadAllowed flag
     #  @param toAllow new value of the @c QuadAllowed parameter (@c True by default)
     def SetQuadAllowed(self, toAllow=True):