X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FNETGENPlugin%2FNETGENPluginBuilder.py;h=9ff05ad58762e0640282e5f26fd0f72595b8e00a;hb=ccecac5e15a24f8da73b0ed44cfbbbb20b15b0db;hp=ba3958cbd0885bf929d799d5293634acb1e19156;hpb=db7aa8538fc7d6d7f1a9b5522e6f2605e3c143df;p=plugins%2Fnetgenplugin.git diff --git a/src/NETGENPlugin/NETGENPluginBuilder.py b/src/NETGENPlugin/NETGENPluginBuilder.py index ba3958c..9ff05ad 100644 --- a/src/NETGENPlugin/NETGENPluginBuilder.py +++ b/src/NETGENPlugin/NETGENPluginBuilder.py @@ -1,9 +1,9 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either -# version 2.1 of the License. +# version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -32,23 +32,29 @@ except ImportError: noNETGENPlugin = 1 pass +LIBRARY = "libNETGENEngine.so" + +NETGEN_VERSION_MAJOR = NETGENPlugin.NETGEN_VERSION_MAJOR + #---------------------------- # Mesh algo type identifiers #---------------------------- -## Algorithm type: Netgen tetrahedron 3D algorithm, see NETGEN_3D_Algorithm +## Algorithm type: Netgen tetrahedron 3D algorithm, see NETGEN_3D_Algorithm NETGEN_3D = "NETGEN_3D" -## Algorithm type: Netgen tetrahedron 1D-2D-3D algorithm, see NETGEN_1D2D3D_Algorithm +NETGEN_3D_Remote = "NETGEN_3D_Remote" +## Algorithm type: Netgen tetrahedron 1D-2D-3D algorithm, see NETGEN_1D2D3D_Algorithm NETGEN_1D2D3D = "NETGEN_2D3D" -## Algorithm type: Netgen triangle 1D-2D algorithm, see NETGEN_1D2D_Algorithm +## Algorithm type: Netgen triangle 1D-2D algorithm, see NETGEN_1D2D_Algorithm NETGEN_1D2D = "NETGEN_2D" ## Algorithm type: Netgen triangle 2D algorithm, see NETGEN_2D_Only_Algorithm NETGEN_2D = "NETGEN_2D_ONLY" -## Algorithm type: Synonim of NETGEN_1D2D3D, see NETGEN_1D2D3D_Algorithm +NETGEN_2D_Remote = "NETGEN_2D_Remote" +## Algorithm type: Synonim of NETGEN_1D2D3D, see NETGEN_1D2D3D_Algorithm NETGEN_FULL = NETGEN_1D2D3D -## Algorithm type: Synonim of NETGEN_3D, see NETGEN_3D_Algorithm +## Algorithm type: Synonim of NETGEN_3D, see NETGEN_3D_Algorithm NETGEN = NETGEN_3D -## Algorithm type: Synonim of NETGEN_1D2D3D, see NETGEN_1D2D3D_Algorithm +## Algorithm type: Synonim of NETGEN_1D2D3D, see NETGEN_1D2D3D_Algorithm FULL_NETGEN = NETGEN_FULL #---------------------------- @@ -103,8 +109,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 @@ -139,6 +149,12 @@ class NETGEN_Algorithm(Mesh_Algorithm): if self.Parameters(): self.params.SetGrowthRate(theRate) pass + ## Sets @c NbThreads parameter + # @param theRate new value of the @c NbThreads parameter + def SetNbThreads(self, theNumber): + if self.Parameters(): self.params.SetNbThreads(theNumber) + pass + ## Creates meshing hypothesis according to the chosen algorithm type # and initializes it with default parameters # @param which hypothesis type; can be either @ref SOLE (default) or @ref SIMPLE @@ -159,28 +175,45 @@ 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 ## Tetrahedron 1D-2D-3D algorithm. # -# It can be created by calling smesh.Mesh.Tetrahedron( smesh.NETGEN_1D2D3D, geom=0 ). +# It can be created by calling smeshBuilder.Mesh.Tetrahedron( smeshBuilder.NETGEN_1D2D3D, geom=0 ). # This algorithm generates all 1D (edges), 2D (faces) and 3D (volumes) elements # for given geometrical shape. class NETGEN_1D2D3D_Algorithm(NETGEN_Algorithm): - ## name of the dynamic method in smesh.Mesh class + ## name of the dynamic method in smeshBuilder.Mesh class # @internal meshMethod = "Tetrahedron" - ## type of algorithm used with helper function in smesh.Mesh class + ## type of algorithm used with helper function in smeshBuilder.Mesh class # @internal algoType = NETGEN_1D2D3D ## doc string of the method @@ -213,11 +246,36 @@ 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): if self.Parameters(): self.params.SetQuadAllowed(toAllow) pass + ## Sets @c UseSurfaceCurvature flag + # @param toUse new value of the @c UseSurfaceCurvature parameter (@c True by default) + def SetUseSurfaceCurvature(self, toUse=True): + if self.Parameters(): self.params.SetUseSurfaceCurvature(toUse) + pass + ## Sets @c FuseEdges flag + # @param toFuse new value of the @c FuseEdges parameter (@c False by default) + def SetFuseEdges(self, toFuse=False): + if self.Parameters(): self.params.SetFuseEdges(toFuse) + pass ## Sets number of segments overriding the value set by SetLocalLength() # @param theVal new value of number of segments parameter @@ -260,24 +318,25 @@ class NETGEN_1D2D3D_Algorithm(NETGEN_Algorithm): pass # end of NETGEN_1D2D3D_Algorithm class -## Triangle NETGEN 1D-2D algorithm. +## Triangle NETGEN 1D-2D algorithm. # -# It can be created by calling smesh.Mesh.Triangle( smesh.NETGEN_1D2D, geom=0 ) +# It can be created by calling smeshBuilder.Mesh.Triangle( smeshBuilder.NETGEN_1D2D, geom=0 ) # # This algorithm generates 1D (edges) and 2D (faces) elements # for given geometrical shape. class NETGEN_1D2D_Algorithm(NETGEN_1D2D3D_Algorithm): - ## name of the dynamic method in smesh.Mesh class + ## name of the dynamic method in smeshBuilder.Mesh class # @internal meshMethod = "Triangle" - ## type of algorithm used with helper function in smesh.Mesh class + ## type of algorithm used with helper function in smeshBuilder.Mesh class # @internal algoType = NETGEN_1D2D ## doc string of the method # @internal docHelper = "Creates triangle 2D algorithm for faces" + ## Private constructor. # @param mesh parent mesh object algorithm is assigned to # @param geom geometry (shape/sub-shape) algorithm is assigned to; @@ -291,23 +350,28 @@ class NETGEN_1D2D_Algorithm(NETGEN_1D2D3D_Algorithm): ## Triangle NETGEN 2D algorithm # -# It can be created by calling smesh.Mesh.Triangle( smesh.NETGEN_2D, geom=0 ) +# It can be created by calling smeshBuilder.Mesh.Triangle( smeshBuilder.NETGEN_2D, geom=0 ) # # This algorithm generates only 2D (faces) elements for given geometrical shape # and, in contrast to NETGEN_1D2D_Algorithm class, should be used in conjunction # with other 1D meshing algorithm. class NETGEN_2D_Only_Algorithm(NETGEN_Algorithm): - ## name of the dynamic method in smesh.Mesh class + ## name of the dynamic method in smeshBuilder.Mesh class # @internal meshMethod = "Triangle" - ## type of algorithm used with helper function in smesh.Mesh class + ## type of algorithm used with helper function in smeshBuilder.Mesh class # @internal algoType = NETGEN_2D + ## flag pointing whether this algorithm should be used by default in dynamic method + # of smeshBuilder.Mesh class + isDefault = True ## doc string of the method # @internal docHelper = "Creates triangle 2D algorithm for faces" - + + isDefault = True + ## Private constructor. # @param mesh parent mesh object algorithm is assigned to # @param geom geometry (shape/sub-shape) algorithm is assigned to; @@ -336,6 +400,12 @@ class NETGEN_2D_Only_Algorithm(NETGEN_Algorithm): hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp) return hyp + ## Sets @c UseSurfaceCurvature flag + # @param toUse new value of the @c UseSurfaceCurvature parameter (@c True by default) + def SetUseSurfaceCurvature(self, toUse=True): + if self.Parameters(): self.params.SetUseSurfaceCurvature(toUse) + pass + ## Sets @c QuadAllowed flag. # @param toAllow new value of the @c QuadAllowed parameter (@c True by default) # @return hypothesis object @@ -368,21 +438,21 @@ class NETGEN_2D_Only_Algorithm(NETGEN_Algorithm): ## Tetrahedron 3D algorithm # -# It can be created by calling smesh.Mesh.Tetrahedron() or smesh.Mesh.Tetrahedron( smesh.NETGEN, geom=0 ) +# It can be created by calling smeshBuilder.Mesh.Tetrahedron() or smeshBuilder.Mesh.Tetrahedron( smeshBuilder.NETGEN, geom=0 ) # # This algorithm generates only 3D (volumes) elements for given geometrical shape # and, in contrast to NETGEN_1D2D3D_Algorithm class, should be used in conjunction # with other 1D and 2D meshing algorithms. class NETGEN_3D_Algorithm(NETGEN_Algorithm): - ## name of the dynamic method in smesh.Mesh class + ## name of the dynamic method in smeshBuilder.Mesh class # @internal meshMethod = "Tetrahedron" - ## type of algorithm used with helper function in smesh.Mesh class + ## type of algorithm used with helper function in smeshBuilder.Mesh class # @internal algoType = NETGEN ## flag pointing either this algorithm should be used by default in dynamic method - # of smesh.Mesh class + # of smeshBuilder.Mesh class # @internal isDefault = True ## doc string of the method @@ -411,18 +481,76 @@ class NETGEN_3D_Algorithm(NETGEN_Algorithm): pass # end of NETGEN_3D_Algorithm class +## Tetrahedron 3D algorithm +# +# It can be created by calling smeshBuilder.Mesh.Tetrahedron() or smeshBuilder.Mesh.Tetrahedron( smeshBuilder.NETGEN, geom=0 ) +# +# This algorithm generates only 3D (volumes) elements for given geometrical shape +# and, in contrast to NETGEN_1D2D3D_Algorithm class, should be used in conjunction +# with other 1D and 2D meshing algorithms. +class NETGEN_3D_Remote_Algorithm(NETGEN_3D_Algorithm): + + ## type of algorithm used with helper function in smeshBuilder.Mesh class + # @internal + algoType = NETGEN_3D_Remote + ## flag pointing either this algorithm should be used by default in dynamic method + # of smeshBuilder.Mesh class + # @internal + isDefault = False + ## doc string of the method + # @internal + docHelper = "Remotely Creates tetrahedron 3D algorithm for solids" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + NETGEN_3D_Algorithm.__init__(self, mesh, geom) + pass + + pass # end of NETGEN_3D_Remote_Algorithm class + +## Tetrahedron 2D algorithm +# +# It can be created by calling smeshBuilder.Mesh.Triangle() or smeshBuilder.Mesh.Triangle( smeshBuilder.NETGEN, geom=0 ) +# +class NETGEN_2D_Remote_Algorithm(NETGEN_2D_Only_Algorithm): + + ## type of algorithm used with helper function in smeshBuilder.Mesh class + # @internal + algoType = NETGEN_2D_Remote + ## flag pointing either this algorithm should be used by default in dynamic method + # of smeshBuilder.Mesh class + # @internal + isDefault = False + ## doc string of the method + # @internal + docHelper = "Remotely Creates triangles in face of solids" + + ## Private constructor. + # @param mesh parent mesh object algorithm is assigned to + # @param geom geometry (shape/sub-shape) algorithm is assigned to; + # if it is @c 0 (default), the algorithm is assigned to the main shape + def __init__(self, mesh, geom=0): + self.algoType = NETGEN_2D_Remote + NETGEN_2D_Only_Algorithm.__init__(self, mesh, geom) + pass + + pass # end of NETGEN_2D_Remote_Algorithm class + ## Triangle (helper) 1D-2D algorithm # # This is the helper class that is used just to allow creating of create NETGEN_1D2D algorithm -# by calling smesh.Mesh.Triangle( smesh.NETGEN, geom=0 ); this is required for backward compatibility +# by calling smeshBuilder.Mesh.Triangle( smeshBuilder.NETGEN, geom=0 ); this is required for backward compatibility # with old Python scripts. # -# @note This class (and corresponding smesh.Mesh function) is obsolete; -# use smesh.Mesh.Triangle( smesh.NETGEN_1D2D, geom=0 ) instead. +# @note This class (and corresponding smeshBuilder.Mesh function) is obsolete; +# use smeshBuilder.Mesh.Triangle( smeshBuilder.NETGEN_1D2D, geom=0 ) instead. class NETGEN_1D2D_Algorithm_2(NETGEN_1D2D_Algorithm): - ## name of the dynamic method in smesh.Mesh class + ## name of the dynamic method in smeshBuilder.Mesh class # @internal algoType = NETGEN @@ -441,13 +569,13 @@ class NETGEN_1D2D_Algorithm_2(NETGEN_1D2D_Algorithm): ## Tetrahedron (helper) 1D-2D-3D algorithm. # # This is the helper class that is used just to allow creating of create NETGEN_1D2D3D -# by calling smesh.Mesh.Netgen(); this is required for backward compatibility with old Python scripts. +# by calling smeshBuilder.Mesh.Netgen(); this is required for backward compatibility with old Python scripts. # -# @note This class (and corresponding smesh.Mesh function) is obsolete; -# use smesh.Mesh.Tetrahedron( smesh.NETGEN_1D2D3D, geom=0 ) instead. +# @note This class (and corresponding smeshBuilder.Mesh function) is obsolete; +# use smeshBuilder.Mesh.Tetrahedron( smeshBuilder.NETGEN_1D2D3D, geom=0 ) instead. class NETGEN_1D2D3D_Algorithm_2(NETGEN_1D2D3D_Algorithm): - ## name of the dynamic method in smesh.Mesh class + ## name of the dynamic method in smeshBuilder.Mesh class # @internal meshMethod = "Netgen" ## doc string of the method