-# Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2016 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
# @package StdMeshersBuilder
# Python API for the standard meshing plug-in module.
+LIBRARY = "libStdMeshersEngine.so"
+
from salome.smesh.smesh_algorithm import Mesh_Algorithm
import StdMeshers
RADIAL_QUAD = "RadialQuadrangle_1D2D"
## Algorithm type: Quadrangle (Medial Axis Projection) 1D-2D algorithm, see StdMeshersBuilder_QuadMA_1D2D
QUAD_MA_PROJ = "QuadFromMedialAxis_1D2D"
+## Algorithm type: Polygon Per Face 2D algorithm, see StdMeshersBuilder_PolygonPerFace
+POLYGON = "PolygonPerFace_2D"
# import items of enums
for e in StdMeshers.QuadType._items: exec('%s = StdMeshers.%s'%(e,e))
## type of algorithm used with helper function in smeshBuilder.Mesh class
# @internal
algoType = REGULAR
- ## flag pointing either this algorithm should be used by default in dynamic method
+ ## flag pointing whether this algorithm should be used by default in dynamic method
# of smeshBuilder.Mesh class
# @internal
isDefault = True
# on curve from 0 to 1 (additionally it is neecessary to check
# orientation of edges and create list of reversed edges if it is
# needed) and sets numbers of segments between given points (default
- # values are equals 1
+ # values are 1)
# @param points defines the list of parameters on curve
# @param nbSegs defines the list of numbers of segments
# @param reversedEdges is a list of edges to mesh using reversed orientation.
def LengthNearVertex(self, length, vertex=0, UseExisting=0):
import types
store_geom = self.geom
- if type(vertex) is types.IntType:
+ if isinstance(vertex, int):
if vertex == 0 or vertex == 1:
from salome.geom import geomBuilder
vertex = self.mesh.geompyD.ExtractShapes(self.geom, geomBuilder.geomBuilder.ShapeType["VERTEX"],True)[vertex]
pass
# 0D algorithm
if self.geom is None:
- raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
+ self.geom = store_geom
+ raise RuntimeError("Attempt to create SegmentAroundVertex_0D algorithm on None shape")
from salome.smesh.smeshBuilder import AssureGeomPublished, GetName, TreatHypoStatus
AssureGeomPublished( self.mesh, self.geom )
name = GetName(self.geom)
## type of algorithm used with helper function in smeshBuilder.Mesh class
# @internal
algoType = COMPOSITE
- ## flag pointing either this algorithm should be used by default in dynamic method
+ ## flag pointing whether this algorithm should be used by default in dynamic method
# of smeshBuilder.Mesh class
# @internal
isDefault = False
## type of algorithm used with helper function in smeshBuilder.Mesh class
# @internal
algoType = MEFISTO
- ## flag pointing either this algorithm should be used by default in dynamic method
+ ## flag pointing whether this algorithm should be used by default in dynamic method
# of smeshBuilder.Mesh class
# @internal
isDefault = True
## type of algorithm used with helper function in smeshBuilder.Mesh class
# @internal
algoType = QUADRANGLE
- ## flag pointing either this algorithm should be used by default in dynamic method
+ ## flag pointing whether this algorithm should be used by default in dynamic method
# of smeshBuilder.Mesh class
# @internal
isDefault = True
## type of algorithm used with helper function in smeshBuilder.Mesh class
# @internal
algoType = Hexa
- ## flag pointing either this algorithm should be used by default in dynamic method
+ ## flag pointing whether this algorithm should be used by default in dynamic method
# of smeshBuilder.Mesh class
# @internal
isDefault = True
## type of algorithm used with helper function in smeshBuilder.Mesh class
# @internal
algoType = "Projection_1D"
- ## flag pointing either this algorithm should be used by default in dynamic method
+ ## flag pointing whether this algorithm should be used by default in dynamic method
# of smeshBuilder.Mesh class
# @internal
isDefault = True
## type of algorithm used with helper function in smeshBuilder.Mesh class
# @internal
algoType = "Projection_2D"
- ## flag pointing either this algorithm should be used by default in dynamic method
+ ## flag pointing whether this algorithm should be used by default in dynamic method
# of smeshBuilder.Mesh class
# @internal
isDefault = True
shape = geom
if not shape:
shape = mesh.geom
- from salome.geom import geomBuilder
- nbSolids = len( geomBuilder.geom.SubShapeAll( shape, geomBuilder.geomBuilder.ShapeType["SOLID"] ))
- nbShells = len( geomBuilder.geom.SubShapeAll( shape, geomBuilder.geomBuilder.ShapeType["SHELL"] ))
- if nbSolids == 0 or nbSolids == nbShells:
+ isRadial = mesh.smeshpyD.IsApplicable("RadialPrism_3D", LIBRARY, shape, False )
+ if not isRadial:
self.Create(mesh, geom, "Prism_3D")
pass
else:
## Return 3D hypothesis holding the 1D one
def Get3DHypothesis(self):
if self.algoType != "RadialPrism_3D":
- print "Prism_3D algorith doesn't support any hyposesis"
+ print("Prism_3D algorith doesn't support any hyposesis")
return None
return self.distribHyp
# hypothesis. Returns the created hypothesis
def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
if self.algoType != "RadialPrism_3D":
- print "Prism_3D algorith doesn't support any hyposesis"
+ print("Prism_3D algorith doesn't support any hyposesis")
return None
if not self.nbLayers is None:
self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
- study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
- self.mesh.smeshpyD.SetCurrentStudy( None )
+ self.mesh.smeshpyD.SetEnablePublish( False ) # prevents publishing own 1D hypothesis
hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
- self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
+ self.mesh.smeshpyD.SetEnablePublish( True ) # enables publishing
if not self.distribHyp:
self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
self.distribHyp.SetLayerDistribution( hyp )
# the same parameters, else (default) - creates a new one
def NumberOfLayers(self, n, UseExisting=0):
if self.algoType != "RadialPrism_3D":
- print "Prism_3D algorith doesn't support any hyposesis"
+ print("Prism_3D algorith doesn't support any hyposesis")
return None
self.mesh.RemoveHypothesis( self.distribHyp, self.geom )
from salome.smesh.smeshBuilder import IsEqual
# @param p the precision of rounding
def LocalLength(self, l, p=1e-07):
if self.algoType != "RadialPrism_3D":
- print "Prism_3D algorith doesn't support any hyposesis"
+ print("Prism_3D algorith doesn't support any hyposesis")
return None
hyp = self.OwnHypothesis("LocalLength", [l,p])
hyp.SetLength(l)
# @param s the scale factor (optional)
def NumberOfSegments(self, n, s=[]):
if self.algoType != "RadialPrism_3D":
- print "Prism_3D algorith doesn't support any hyposesis"
+ print("Prism_3D algorith doesn't support any hyposesis")
return None
if not s:
hyp = self.OwnHypothesis("NumberOfSegments", [n])
# @param end the length of the last segment
def Arithmetic1D(self, start, end ):
if self.algoType != "RadialPrism_3D":
- print "Prism_3D algorith doesn't support any hyposesis"
+ print("Prism_3D algorith doesn't support any hyposesis")
return None
hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
hyp.SetLength(start, 1)
# @param ratio the common ratio of the geometric progression
def GeometricProgression(self, start, ratio ):
if self.algoType != "RadialPrism_3D":
- print "Prism_3D algorith doesn't support any hyposesis"
+ print("Prism_3D algorith doesn't support any hyposesis")
return None
hyp = self.OwnHypothesis("GeometricProgression", [start, ratio])
hyp.SetStartLength( start )
# @param end for the length of the last segment
def StartEndLength(self, start, end):
if self.algoType != "RadialPrism_3D":
- print "Prism_3D algorith doesn't support any hyposesis"
+ print("Prism_3D algorith doesn't support any hyposesis")
return None
hyp = self.OwnHypothesis("StartEndLength", [start, end])
hyp.SetLength(start, 1)
# @param fineness defines the quality of the mesh within the range [0-1]
def AutomaticLength(self, fineness=0):
if self.algoType != "RadialPrism_3D":
- print "Prism_3D algorith doesn't support any hyposesis"
+ print("Prism_3D algorith doesn't support any hyposesis")
return None
hyp = self.OwnHypothesis("AutomaticLength")
hyp.SetFineness( fineness )
pass # end of StdMeshersBuilder_Prism3D class
-## Defines a Prism 3D algorithm, which is either "Extrusion 3D" or "Radial Prism"
-# depending on geometry
+## Defines Radial Prism 3D algorithm
#
# It is created by calling smeshBuilder.Mesh.Prism(geom=0)
#
self.nbLayers = None
return
-## Defines a Radial Quadrangle 1D-2D algorithm
+## Base class for algorithms supporting radial distribution hypotheses
#
-# It is created by calling smeshBuilder.Mesh.Quadrangle(smeshBuilder.RADIAL_QUAD,geom=0)
-#
-# @ingroup l2_algos_radialq
-class StdMeshersBuilder_RadialQuadrangle1D2D(Mesh_Algorithm):
+class StdMeshersBuilder_RadialAlgorithm(Mesh_Algorithm):
- ## name of the dynamic method in smeshBuilder.Mesh class
- # @internal
- meshMethod = "Quadrangle"
- ## type of algorithm used with helper function in smeshBuilder.Mesh class
- # @internal
- algoType = RADIAL_QUAD
- ## doc string of the method
- # @internal
- docHelper = "Creates quadrangle 1D-2D algorithm for faces having a shape of disk or a disk segment"
-
- ## 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):
+ def __init__(self):
Mesh_Algorithm.__init__(self)
- self.Create(mesh, geom, self.algoType)
self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
self.nbLayers = None
self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
else:
self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
- study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
- self.mesh.smeshpyD.SetCurrentStudy( None )
+ self.mesh.smeshpyD.SetEnablePublish( False )
hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
- self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
+ self.mesh.smeshpyD.SetEnablePublish( True )
self.distribHyp.SetLayerDistribution( hyp )
return hyp
pass # end of StdMeshersBuilder_RadialQuadrangle1D2D class
+## Defines a Radial Quadrangle 1D-2D algorithm
+#
+# It is created by calling smeshBuilder.Mesh.Quadrangle(smeshBuilder.RADIAL_QUAD,geom=0)
+#
+# @ingroup l2_algos_radialq
+class StdMeshersBuilder_RadialQuadrangle1D2D(StdMeshersBuilder_RadialAlgorithm):
+
+ ## name of the dynamic method in smeshBuilder.Mesh class
+ # @internal
+ meshMethod = "Quadrangle"
+ ## type of algorithm used with helper function in smeshBuilder.Mesh class
+ # @internal
+ algoType = RADIAL_QUAD
+ ## doc string of the method
+ # @internal
+ docHelper = "Creates quadrangle 1D-2D algorithm for faces having a shape of disk or a disk segment"
+
+ ## 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):
+ StdMeshersBuilder_RadialAlgorithm.__init__(self)
+ self.Create(mesh, geom, self.algoType)
+
+ self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
+ self.nbLayers = None
+ pass
+
+
## Defines a Quadrangle (Medial Axis Projection) 1D-2D algorithm
#
# It is created by calling smeshBuilder.Mesh.Quadrangle(smeshBuilder.QUAD_MA_PROJ,geom=0)
#
# @ingroup l2_algos_quad_ma
-class StdMeshersBuilder_QuadMA_1D2D(Mesh_Algorithm):
+class StdMeshersBuilder_QuadMA_1D2D(StdMeshersBuilder_RadialAlgorithm):
## name of the dynamic method in smeshBuilder.Mesh class
# @internal
# @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):
- Mesh_Algorithm.__init__(self)
+ StdMeshersBuilder_RadialAlgorithm.__init__(self)
self.Create(mesh, geom, self.algoType)
pass
pass
+## Defines a Polygon Per Face 2D algorithm
+#
+# It is created by calling smeshBuilder.Mesh.Polygon(geom=0)
+#
+# @ingroup l2_algos_quad_ma
+class StdMeshersBuilder_PolygonPerFace(Mesh_Algorithm):
+
+ ## name of the dynamic method in smeshBuilder.Mesh class
+ # @internal
+ meshMethod = "Polygon"
+ ## type of algorithm used with helper function in smeshBuilder.Mesh class
+ # @internal
+ algoType = POLYGON
+ ## flag pointing whether this algorithm should be used by default in dynamic method
+ # of smeshBuilder.Mesh class
+ # @internal
+ isDefault = True
+ ## doc string of the method
+ # @internal
+ docHelper = "Creates polygon 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;
+ # if it is @c 0 (default), the algorithm is assigned to the main shape
+ def __init__(self, mesh, geom=0):
+ Mesh_Algorithm.__init__(self)
+ self.Create(mesh, geom, self.algoType)
+ pass
+
+ pass
## Defines a Use Existing Elements 1D algorithm
#
## type of algorithm used with helper function in smeshBuilder.Mesh class
# @internal
algoType = "Import_1D"
- ## flag pointing either this algorithm should be used by default in dynamic method
+ ## flag pointing whether this algorithm should be used by default in dynamic method
# of smeshBuilder.Mesh class
# @internal
isDefault = True
## type of algorithm used with helper function in smeshBuilder.Mesh class
# @internal
algoType = "Import_1D2D"
- ## flag pointing either this algorithm should be used by default in dynamic method
+ ## flag pointing whether this algorithm should be used by default in dynamic method
# of smeshBuilder.Mesh class
# @internal
isDefault = True
# @param UseExisting if ==true - searches for the existing hypothesis created with
# the same parameters, else (default) - creates a new one
def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
+ import SMESH
compFun = lambda hyp, args: ( hyp.GetSourceFaces() == args[0] and \
hyp.GetCopySourceMesh() == args[1], args[2] )
hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
UseExisting=UseExisting, CompareMethod=compFun, toAdd=False)
+ if groups and isinstance( groups, SMESH._objref_SMESH_GroupBase ):
+ groups = [groups]
hyp.SetSourceFaces(groups)
hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
self.mesh.AddHypothesis(hyp, self.geom)
## type of algorithm used with helper function in smeshBuilder.Mesh class
# @internal
algoType = "Cartesian_3D"
- ## flag pointing either this algorithm should be used by default in dynamic method
+ ## flag pointing whether this algorithm should be used by default in dynamic method
# of smeshBuilder.Mesh class
# @internal
isDefault = True
# several functions, they must be accompanied by relative coordinates of
# points dividing the whole shape into ranges where the functions apply; points
# coodrinates should vary within (0.0, 1.0) range. Parameter \a t of the spacing
- # function f(t) varies from 0.0 to 1.0 witin a shape range.
+ # function f(t) varies from 0.0 to 1.0 within a shape range.
# Examples:
# - "10.5" - defines a grid with a constant spacing
# - [["1", "1+10*t", "11"] [0.1, 0.6]] - defines different spacing in 3 ranges.
self.mesh.AddHypothesis( self.hyp, self.geom )
for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef] ):
- if not gridDef: raise ValueError, "Empty grid definition"
+ if not gridDef: raise ValueError("Empty grid definition")
if isinstance( gridDef, str ):
self.hyp.SetGridSpacing( [gridDef], [], axis )
elif isinstance( gridDef[0], str ):
pass # end of StdMeshersBuilder_Cartesian_3D class
## Defines a stub 1D algorithm, which enables "manual" creation of nodes and
-# segments usable by 2D algoritms
+# segments usable by 2D algorithms
#
# It is created by calling smeshBuilder.Mesh.UseExistingSegments(geom=0)
#
pass # end of StdMeshersBuilder_UseExisting_1D class
## Defines a stub 2D algorithm, which enables "manual" creation of nodes and
-# faces usable by 3D algoritms
+# faces usable by 3D algorithms
#
# It is created by calling smeshBuilder.Mesh.UseExistingFaces(geom=0)
#