X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH_SWIG%2FStdMeshersBuilder.py;h=6d275f6d4350c2efd0f694158c1ef9527b017174;hb=7ce6e800256c653b878d88163ff8576d16ed5a27;hp=4b2999f26a63cd3d37ae097aa3146efd0b884f7c;hpb=8d297d6698f361d4f2dde723050bcfbaea050920;p=modules%2Fsmesh.git diff --git a/src/SMESH_SWIG/StdMeshersBuilder.py b/src/SMESH_SWIG/StdMeshersBuilder.py index 4b2999f26..6d275f6d4 100644 --- a/src/SMESH_SWIG/StdMeshersBuilder.py +++ b/src/SMESH_SWIG/StdMeshersBuilder.py @@ -1,4 +1,4 @@ -# Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2022 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 @@ -42,13 +42,8 @@ Algorithm type: Python 1D algorithm, see :class:`~StdMeshersBuilder.StdMeshersBu COMPOSITE = "CompositeSegment_1D" """ - Algorithm type: Composite segment 1D algorithm, see :class:`~StdMeshersBuilder.StdMeshersBuilder_CompositeSegment` """ -MEFISTO = "MEFISTO_2D" -""" -Algorithm type: Triangle MEFISTO 2D algorithm, see :class:`~StdMeshersBuilder.StdMeshersBuilder_Triangle_MEFISTO` -""" Hexa = "Hexa_3D" """ @@ -75,6 +70,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 +174,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() ) @@ -617,72 +618,6 @@ class StdMeshersBuilder_Segment_Python(Mesh_Algorithm): pass # end of StdMeshersBuilder_Segment_Python class -class StdMeshersBuilder_Triangle_MEFISTO(Mesh_Algorithm): - """ - Triangle MEFISTO 2D algorithm. - It is created by calling smeshBuilder.Mesh.Triangle(smeshBuilder.MEFISTO,geom=0) - """ - - - meshMethod = "Triangle" - """ - name of the dynamic method in smeshBuilder.Mesh class - """ - algoType = MEFISTO - """ - 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 triangle 2D algorithm for faces" - """ - 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 - - def MaxElementArea(self, area, UseExisting=0): - """ - Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle - - Parameters: - area: for the maximum area of each triangle - UseExisting: if ==true - searches for an existing hypothesis created with the - same parameters, else (default) - Create a new one - """ - - from salome.smesh.smeshBuilder import IsEqual - comparator = lambda hyp, args: IsEqual(hyp.GetMaxElementArea(), args[0]) - hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting, - CompareMethod=comparator) - hyp.SetMaxElementArea(area) - return hyp - - def LengthFromEdges(self): - """ - Defines "LengthFromEdges" hypothesis to build triangles - based on the length of the edges taken from the wire - """ - - hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp) - return hyp - - pass # end of StdMeshersBuilder_Triangle_MEFISTO class - class StdMeshersBuilder_Quadrangle(Mesh_Algorithm): """ Defines a quadrangle 2D algorithm. @@ -726,7 +661,7 @@ class StdMeshersBuilder_Quadrangle(Mesh_Algorithm): pass def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, - enfVertices=[],enfPoints=[],UseExisting=0): + enfVertices=[],enfPoints=[],corners=[],UseExisting=0): """ Defines "QuadrangleParameters" hypothesis quadType defines the algorithm of transition between differently descretized @@ -762,6 +697,13 @@ class StdMeshersBuilder_Quadrangle(Mesh_Algorithm): or triples of values ([[x1,y1,z1], [x2,y2,z2], ...]). In the case if the defined QuadrangleParameters() refer to a sole face, all given points must lie on this face, else the mesher fails. + corners: list of vertices that should be used as quadrangle corners. + The parameter can be useful for faces with more than four vertices, + since in some cases Quadrangle Mapping algorithm chooses corner vertices + differently than it is desired. + A hypothesis can be global and define corners for all CAD faces that + require it, but be sure that each specified vertex is a corner in all + faces the hypothesis will be applied to. UseExisting: if *True* - searches for the existing hypothesis created with the same parameters, else (default) - Create a new one """ @@ -774,6 +716,7 @@ class StdMeshersBuilder_Quadrangle(Mesh_Algorithm): if isinstance( enfVertices, int ) and not enfPoints and not UseExisting: # a call of old syntax, before inserting enfVertices and enfPoints before UseExisting UseExisting, enfVertices = enfVertices, [] + pStructs, xyz = [], [] for p in enfPoints: if isinstance( p, SMESH.PointStruct ): @@ -791,6 +734,10 @@ class StdMeshersBuilder_Quadrangle(Mesh_Algorithm): self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID,entries,xyz], UseExisting = UseExisting, CompareMethod=compFun) pass + + if corners and isinstance( corners[0], GEOM._objref_GEOM_Object ): + corners = [ self.mesh.geompyD.GetSubShapeID( self.mesh.geom, v ) for v in corners ] + if self.params.GetQuadType() != quadType: self.params.SetQuadType(quadType) if vertexID > 0: @@ -799,6 +746,7 @@ class StdMeshersBuilder_Quadrangle(Mesh_Algorithm): for v in enfVertices: AssureGeomPublished( self.mesh, v ) self.params.SetEnforcedNodes( enfVertices, pStructs ) + self.params.SetCorners( corners ) return self.params def QuadranglePreference(self, reversed=False, UseExisting=0): @@ -897,8 +845,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): @@ -1657,6 +1614,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. @@ -1834,6 +1829,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