-# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2015 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
# 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
QUADRANGLE = "Quadrangle_2D"
## Algorithm type: Radial Quadrangle 1D-2D algorithm, see StdMeshersBuilder_RadialQuadrangle1D2D
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 enum QuadType
+# 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))
#----------------------
# Algorithms
## 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
reversedEdges, UseExisting = [], reversedEdges
entry = self.MainShapeEntry()
reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
- if s == []:
+ if not s:
hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdgeInd, entry],
UseExisting=UseExisting,
CompareMethod=self._compareNumberOfSegments)
hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdgeInd, entry],
UseExisting=UseExisting,
CompareMethod=self._compareNumberOfSegments)
- hyp.SetDistrType( 1 )
hyp.SetScaleFactor(s)
hyp.SetNumberOfSegments(n)
hyp.SetReversedEdges( reversedEdgeInd )
algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
pass
status = self.mesh.mesh.AddHypothesis(self.geom, algo)
- TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
+ TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True, self.mesh)
#
from salome.smesh.smeshBuilder import IsEqual
comFun = lambda hyp, args: IsEqual(hyp.GetLength(), args[0])
## 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
algoType = PYTHON
## doc string of the method
# @internal
- docHelper = "Creates tetrahedron 3D algorithm for solids"
- ## doc string of the method
- # @internal
docHelper = "Creates segment 1D algorithm for edges"
## Private constructor.
## 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
# must be created by the mesher. Shapes can be of any type,
# vertices of given shapes define positions of enforced nodes.
# Only vertices successfully projected to the face are used.
- # @param enfPoint: list of points giving positions of enforced nodes.
+ # @param enfPoints: list of points giving positions of enforced nodes.
# Point can be defined either as SMESH.PointStruct's
# ([SMESH.PointStruct(x1,y1,z1), SMESH.PointStruct(x2,y2,z2),...])
# or triples of values ([[x1,y1,z1], [x2,y2,z2], ...]).
## 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
from salome.smesh.smeshBuilder import AssureGeomPublished
AssureGeomPublished( self.mesh, geom )
hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
- UseExisting=0)
+ UseExisting=0, toAdd=False)
# it does not seem to be useful to reuse the existing "SourceFace" hypothesis
#UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
hyp.SetSourceFace( face )
hyp.SetSourceMesh( mesh )
hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
+ self.mesh.AddHypothesis(hyp, self.geom)
return hyp
pass # end of StdMeshersBuilder_Projection2D class
algoType = "Projection_1D2D"
## doc string of the method
# @internal
- docHelper = "Creates projection 1D-2D algorithm for edges and faces"
+ docHelper = "Creates projection 1D-2D algorithm for faces"
## Private constructor.
# @param mesh parent mesh object algorithm is assigned to
if self.algoType != "RadialPrism_3D":
print "Prism_3D algorith doesn't support any hyposesis"
return None
- if s == []:
+ if not s:
hyp = self.OwnHypothesis("NumberOfSegments", [n])
else:
hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
- hyp.SetDistrType( 1 )
hyp.SetScaleFactor(s)
hyp.SetNumberOfSegments(n)
return hyp
pass # end of StdMeshersBuilder_Prism3D class
-## Defines a Prism 3D algorithm, which is either "Extrusion 3D" or "Radial Prism"
-# depending on geometry
+## Defines a Prism 3D algorithm
#
# It is created by calling smeshBuilder.Mesh.Prism(geom=0)
#
algoType = "RadialPrism_3D"
## doc string of the method
# @internal
- docHelper = "Creates prism 3D algorithm for volumes"
+ docHelper = "Creates Raial Prism 3D algorithm for volumes"
## Private constructor.
# @param mesh parent mesh object algorithm is assigned to
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 triangular 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):
+ def __init__(self):
Mesh_Algorithm.__init__(self)
- self.Create(mesh, geom, self.algoType)
self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
self.nbLayers = None
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(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 = QUAD_MA_PROJ
+ ## doc string of the method
+ # @internal
+ docHelper = "Creates quadrangle 1D-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):
+ 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
#
# It is created by calling smeshBuilder.Mesh.UseExisting1DElements(geom=0)
## 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
## doc string of the method
# @internal
- docHelper = "Creates 1D-2D algorithm for edges/faces with reusing of existing mesh elements"
+ docHelper = "Creates 1D-2D algorithm for faces with reusing of existing mesh elements"
## Private constructor.
# @param mesh parent mesh object algorithm is assigned to
# @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):
- for group in groups:
- from salome.smesh.smeshBuilder import AssureGeomPublished
- AssureGeomPublished( self.mesh, group )
+ 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)
+ 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)
return hyp
pass # end of StdMeshersBuilder_UseExistingElements_1D2D class
## 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
## doc string of the method
# @internal
- docHelper = "Creates body fitting 3D algorithm for volumes"
+ docHelper = "Creates Body Fitting 3D algorithm for volumes"
## Private constructor.
# @param mesh parent mesh object algorithm is assigned to
# 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.
- # @param yGridDef defines the grid along the Y asix the same way as \a xGridDef does
- # @param zGridDef defines the grid along the Z asix the same way as \a xGridDef does
+ # @param yGridDef defines the grid along the Y asix the same way as \a xGridDef does.
+ # @param zGridDef defines the grid along the Z asix the same way as \a xGridDef does.
# @param sizeThreshold (> 1.0) defines a minimal size of a polyhedron so that
- # a polyhedron of size less than hexSize/sizeThreshold is not created
- # @param UseExisting if ==true - searches for the existing hypothesis created with
- # the same parameters, else (default) - creates a new one
- def SetGrid(self, xGridDef, yGridDef, zGridDef, sizeThreshold=4.0, UseExisting=False):
+ # a polyhedron of size less than hexSize/sizeThreshold is not created.
+ # @param implEdges enables implementation of geometrical edges into the mesh.
+ def SetGrid(self, xGridDef, yGridDef, zGridDef, sizeThreshold=4.0, implEdges=False):
if not self.hyp:
compFun = lambda hyp, args: False
self.hyp = self.Hypothesis("CartesianParameters3D",
[xGridDef, yGridDef, zGridDef, sizeThreshold],
- UseExisting=UseExisting, CompareMethod=compFun)
+ UseExisting=False, CompareMethod=compFun)
if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
self.mesh.AddHypothesis( self.hyp, self.geom )
- for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef]):
+ for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef] ):
if not gridDef: raise ValueError, "Empty grid definition"
if isinstance( gridDef, str ):
self.hyp.SetGridSpacing( [gridDef], [], axis )
else:
self.hyp.SetGridSpacing( gridDef[0], gridDef[1], axis )
self.hyp.SetSizeThreshold( sizeThreshold )
+ self.hyp.SetToAddEdges( implEdges )
+ return self.hyp
+
+ ## Defines custom directions of axes of the grid
+ # @param xAxis either SMESH.DirStruct or a vector, or 3 vector components
+ # @param yAxis either SMESH.DirStruct or a vector, or 3 vector components
+ # @param zAxis either SMESH.DirStruct or a vector, or 3 vector components
+ def SetAxesDirs( self, xAxis, yAxis, zAxis ):
+ import GEOM
+ if hasattr( xAxis, "__getitem__" ):
+ xAxis = self.mesh.smeshpyD.MakeDirStruct( xAxis[0],xAxis[1],xAxis[2] )
+ elif isinstance( xAxis, GEOM._objref_GEOM_Object ):
+ xAxis = self.mesh.smeshpyD.GetDirStruct( xAxis )
+ if hasattr( yAxis, "__getitem__" ):
+ yAxis = self.mesh.smeshpyD.MakeDirStruct( yAxis[0],yAxis[1],yAxis[2] )
+ elif isinstance( yAxis, GEOM._objref_GEOM_Object ):
+ yAxis = self.mesh.smeshpyD.GetDirStruct( yAxis )
+ if hasattr( zAxis, "__getitem__" ):
+ zAxis = self.mesh.smeshpyD.MakeDirStruct( zAxis[0],zAxis[1],zAxis[2] )
+ elif isinstance( zAxis, GEOM._objref_GEOM_Object ):
+ zAxis = self.mesh.smeshpyD.GetDirStruct( zAxis )
+ if not self.hyp:
+ self.hyp = self.Hypothesis("CartesianParameters3D")
+ if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
+ self.mesh.AddHypothesis( self.hyp, self.geom )
+ self.hyp.SetAxesDirs( xAxis, yAxis, zAxis )
+ return self.hyp
+
+ ## Automatically defines directions of axes of the grid at which
+ # a number of generated hexahedra is maximal
+ # @param isOrthogonal defines whether the axes mush be orthogonal
+ def SetOptimalAxesDirs(self, isOrthogonal=True):
+ if not self.hyp:
+ self.hyp = self.Hypothesis("CartesianParameters3D")
+ if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
+ self.mesh.AddHypothesis( self.hyp, self.geom )
+ x,y,z = self.hyp.ComputeOptimalAxesDirs( self.geom, isOrthogonal )
+ self.hyp.SetAxesDirs( x,y,z )
return self.hyp
+ ## Sets/unsets a fixed point. The algorithm makes a plane of the grid pass
+ # through the fixed point in each direction at which the grid is defined
+ # by spacing
+ # @param p coordinates of the fixed point. Either SMESH.PointStruct or
+ # a vertex or 3 components of coordinates.
+ # @param toUnset defines whether the fixed point is defined or removed.
+ def SetFixedPoint( self, p, toUnset=False ):
+ import SMESH, GEOM
+ if toUnset:
+ if not self.hyp: return
+ p = SMESH.PointStruct(0,0,0)
+ elif hasattr( p, "__getitem__" ):
+ p = SMESH.PointStruct( p[0],p[1],p[2] )
+ elif isinstance( p, GEOM._objref_GEOM_Object ):
+ p = self.mesh.smeshpyD.GetPointStruct( p )
+ if not self.hyp:
+ self.hyp = self.Hypothesis("CartesianParameters3D")
+ if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
+ self.mesh.AddHypothesis( self.hyp, self.geom )
+ self.hyp.SetFixedPoint( p, toUnset )
+ return self.hyp
+
+
pass # end of StdMeshersBuilder_Cartesian_3D class
## Defines a stub 1D algorithm, which enables "manual" creation of nodes and
algoType = "UseExisting_1D"
## doc string of the method
# @internal
- docHelper = "Creates 1D algorithm for edges with reusing of existing mesh elements"
+ docHelper = "Creates 1D algorithm allowing batch meshing of edges"
## Private constructor.
# @param mesh parent mesh object algorithm is assigned to
algoType = "UseExisting_2D"
## doc string of the method
# @internal
- docHelper = "Creates 2D algorithm for faces with reusing of existing mesh elements"
+ docHelper = "Creates 2D algorithm allowing batch meshing of faces"
## Private constructor.
# @param mesh parent mesh object algorithm is assigned to