Salome HOME
simplification
[modules/smesh.git] / src / SMESH_SWIG / StdMeshersBuilder.py
index 858820238ad520dc15547e89a0b6bbd581b030d3..71e1a50d6e268796a0d0e65aaf6fb82446596472 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2007-2019  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
@@ -75,6 +75,11 @@ POLYGON     = "PolygonPerFace_2D"
 Algorithm type: Polygon Per Face 2D algorithm, see :class:`~StdMeshersBuilder.StdMeshersBuilder_PolygonPerFace`
 """
 
+POLYHEDRON = "PolyhedronPerSolid_3D"
+"""
+Algorithm type: Polyhedron Per Solid 3D algorithm, see :class:`~StdMeshersBuilder.StdMeshersBuilder_PolyhedronPerSolid`
+"""
+
 # import items of enums
 for e in StdMeshers.QuadType._items: exec('%s = StdMeshers.%s'%(e,e))
 for e in StdMeshers.VLExtrusionMethod._items: exec('%s = StdMeshers.%s'%(e,e))
@@ -174,10 +179,11 @@ class StdMeshersBuilder_Segment(Mesh_Algorithm):
             hyp.SetLength(length)
         if not UseExisting:
             # set preestimated length
+            import SMESH
             gen = self.mesh.smeshpyD
             initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
                                                        self.mesh.GetMesh(), self.mesh.GetShape(),
-                                                       False) # <- byMesh
+                                                       SMESH.HypInitParams( 1, 1.0, False ))
             preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
             if preHyp:
                 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
@@ -910,8 +916,17 @@ class StdMeshersBuilder_Hexahedron(Mesh_Algorithm):
         """
         Mesh_Algorithm.__init__(self)
         self.Create(mesh, geom, Hexa)
+        self.renumHypothesis = 0
         pass
 
+    def Renumber(self, blockCSList=[] ):
+        if isinstance( blockCSList, StdMeshers.BlockCS ):
+            blockCSList = [blockCSList]
+        if not self.renumHypothesis:
+            self.renumHypothesis = self.Hypothesis("BlockRenumber", blockCSList, UseExisting=0)
+        self.renumHypothesis.SetBlocksOrientation( blockCSList )
+        return self.renumHypothesis
+
     pass # end of StdMeshersBuilder_Hexahedron class
 
 class StdMeshersBuilder_Projection1D(Mesh_Algorithm):
@@ -1670,6 +1685,44 @@ class StdMeshersBuilder_PolygonPerFace(Mesh_Algorithm):
 
     pass
 
+class StdMeshersBuilder_PolyhedronPerSolid(Mesh_Algorithm):
+    """ Defines a Polyhedron Per Solid 3D algorithm.
+        It is created by calling smeshBuilder.Mesh.Polyhedron(geom=0)
+    """
+
+    meshMethod = "Polyhedron"
+    """
+    name of the dynamic method in smeshBuilder.Mesh class
+    """
+    algoType   = POLYHEDRON
+    """
+    type of algorithm used with helper function in smeshBuilder.Mesh class
+    """
+    isDefault  = True
+    """
+    flag pointing whether this algorithm should be used by default in dynamic method
+        of smeshBuilder.Mesh class
+    """
+    docHelper  = "Create polyhedron 3D algorithm for solids"
+    """
+    doc string of the method
+    """
+
+    def __init__(self, mesh, geom=0):
+        """
+        Private constructor.
+
+        Parameters:
+            mesh: parent mesh object algorithm is assigned to
+            geom: geometry (shape/sub-shape) algorithm is assigned to;
+                if it is :code:`0` (default), the algorithm is assigned to the main shape
+        """
+        Mesh_Algorithm.__init__(self)
+        self.Create(mesh, geom, self.algoType)
+        pass
+
+    pass
+
 class StdMeshersBuilder_UseExistingElements_1D(Mesh_Algorithm):
     """ Defines a Use Existing Elements 1D algorithm.
 
@@ -1847,6 +1900,12 @@ class StdMeshersBuilder_Cartesian_3D(Mesh_Algorithm):
                         points dividing the whole shape into ranges where the functions apply; points
                         coordinates should vary within (0.0, 1.0) range. Parameter *t* of the spacing
                         function f(t) varies from 0.0 to 1.0 within a shape range. 
+        Note: 
+            The actual grid spacing can slightly differ from the defined one. This is done for the
+            best fitting of polyhedrons and for a better mesh quality on the interval boundaries.
+            For example, if a constant **Spacing** is defined along an axis, the actual grid will
+            fill the shape's dimension L along this axis with round number of equal cells:
+            Spacing_actual = L / round( L / Spacing_defined ).
 
         Examples:
             "10.5" - defines a grid with a constant spacing