1 # Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 Python API for the standard meshing plug-in module.
24 LIBRARY = "libStdMeshersEngine.so"
26 from salome.smesh.smesh_algorithm import Mesh_Algorithm
28 from salome.geom import geomBuilder
30 #----------------------------
31 # Mesh algo type identifiers
32 #----------------------------
34 REGULAR = "Regular_1D"
36 Algorithm type: Regular 1D algorithm, see :class:`~StdMeshersBuilder.StdMeshersBuilder_Segment`
41 Algorithm type: Python 1D algorithm, see :class:`~StdMeshersBuilder.StdMeshersBuilder_Segment_Python`
44 COMPOSITE = "CompositeSegment_1D"
46 Algorithm type: Composite segment 1D algorithm, see :class:`~StdMeshersBuilder.StdMeshersBuilder_CompositeSegment`
51 Algorithm type: Hexahedron 3D (i-j-k) algorithm, see :class:`~StdMeshersBuilder.StdMeshersBuilder_Hexahedron`
54 QUADRANGLE = "Quadrangle_2D"
56 Algorithm type: Quadrangle 2D algorithm, see :class:`~StdMeshersBuilder.StdMeshersBuilder_Quadrangle`
59 RADIAL_QUAD = "RadialQuadrangle_1D2D"
61 Algorithm type: Radial Quadrangle 1D-2D algorithm, see :class:`~StdMeshersBuilder.StdMeshersBuilder_RadialQuadrangle1D2D`
64 QUAD_MA_PROJ = "QuadFromMedialAxis_1D2D"
66 Algorithm type: Quadrangle (Medial Axis Projection) 1D-2D algorithm, see :class:`~StdMeshersBuilder.StdMeshersBuilder_QuadMA_1D2D`
69 POLYGON = "PolygonPerFace_2D"
71 Algorithm type: Polygon Per Face 2D algorithm, see :class:`~StdMeshersBuilder.StdMeshersBuilder_PolygonPerFace`
74 POLYHEDRON = "PolyhedronPerSolid_3D"
76 Algorithm type: Polyhedron Per Solid 3D algorithm, see :class:`~StdMeshersBuilder.StdMeshersBuilder_PolyhedronPerSolid`
79 # import items of enums
80 for e in StdMeshers.QuadType._items: exec('%s = StdMeshers.%s'%(e,e))
81 for e in StdMeshers.VLExtrusionMethod._items: exec('%s = StdMeshers.%s'%(e,e))
83 #----------------------
85 #----------------------
87 class StdMeshersBuilder_Segment(Mesh_Algorithm):
89 Defines segment 1D algorithm for edges discretization.
91 It can be created by calling smeshBuilder.Mesh.Segment(geom=0)
95 meshMethod = "Segment"
97 name of the dynamic method in smeshBuilder.Mesh class
102 type of algorithm used with helper function in smeshBuilder.Mesh class
107 flag pointing whether this algorithm should be used by default in dynamic method
108 of smeshBuilder.Mesh class
111 docHelper = "Create segment 1D algorithm for edges"
113 doc string of the method
116 def __init__(self, mesh, geom=0):
120 mesh: parent mesh object algorithm is assigned to
121 geom: geometry (shape/sub-shape) algorithm is assigned to;
122 if it is :code:`0` (default), the algorithm is assigned to the main shape
124 Mesh_Algorithm.__init__(self)
125 self.Create(mesh, geom, self.algoType)
128 def LocalLength(self, l, UseExisting=0, p=1e-07):
130 Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
133 l : for the length of segments that cut an edge
134 UseExisting : if == true - searches for an existing hypothesis created with
135 the same parameters, else (default) - Create a new one
136 p : precision, used for calculation of the number of segments.
137 The precision should be a positive, meaningful value within the range [0,1].
138 In general, the number of segments is calculated with the formula:
139 nb = ceil((edge_length / l) - p)
140 Function ceil rounds its argument to the higher integer.
141 So, p=0 means rounding of (edge_length / l) to the higher integer,
142 p=0.5 means rounding of (edge_length / l) to the nearest integer,
143 p=1 means rounding of (edge_length / l) to the lower integer.
144 Default value is 1e-07.
147 an instance of StdMeshers_LocalLength hypothesis
150 from salome.smesh.smeshBuilder import IsEqual
151 comFun=lambda hyp, args: IsEqual(hyp.GetLength(), args[0]) and IsEqual(hyp.GetPrecision(), args[1])
152 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting, CompareMethod=comFun)
157 def MaxSize(self, length=0.0, UseExisting=0):
159 Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
162 length : is optional maximal allowed length of segment, if it is omitted
163 the preestimated length is used that depends on geometry size
164 UseExisting : if ==true - searches for an existing hypothesis created with
165 the same parameters, else (default) - Create a new one
168 an instance of StdMeshers_MaxLength hypothesis
172 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
173 if isinstance(length,str) or length > 0:
175 hyp.SetLength(length)
177 # set preestimated length
179 gen = self.mesh.smeshpyD
180 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
181 self.mesh.GetMesh(), self.mesh.GetShape(),
182 SMESH.HypInitParams( 1, 1.0, False ))
183 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
185 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
188 hyp.SetUsePreestimatedLength( length == 0.0 )
191 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
193 Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
196 n: for the number of segments that cut an edge
197 s: for the scale factor (optional)
198 reversedEdges: is a list of edges to mesh using reversed orientation.
199 A list item can also be a tuple (edge, 1st_vertex_of_edge)
200 UseExisting: if ==true - searches for an existing hypothesis created with
201 the same parameters, else (default) - create a new one
204 an instance of StdMeshers_NumberOfSegments hypothesis
208 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
209 reversedEdges, UseExisting = [], reversedEdges
210 entry = self.MainShapeEntry()
211 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
213 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdgeInd, entry],
214 UseExisting=UseExisting,
215 CompareMethod=self._compareNumberOfSegments)
217 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdgeInd, entry],
218 UseExisting=UseExisting,
219 CompareMethod=self._compareNumberOfSegments)
220 hyp.SetScaleFactor(s)
221 hyp.SetNumberOfSegments(n)
222 hyp.SetReversedEdges( reversedEdgeInd )
223 hyp.SetObjectEntry( entry )
226 def _compareNumberOfSegments(self, hyp, args):
229 Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
231 if hyp.GetNumberOfSegments() == args[0]:
233 if hyp.GetReversedEdges() == args[1]:
234 if not args[1] or hyp.GetObjectEntry() == args[2]:
237 from salome.smesh.smeshBuilder import IsEqual
238 if hyp.GetReversedEdges() == args[2]:
239 if not args[2] or hyp.GetObjectEntry() == args[3]:
240 if hyp.GetDistrType() == 1:
241 if IsEqual(hyp.GetScaleFactor(), args[1]):
245 def Adaptive(self, minSize, maxSize, deflection, UseExisting=False):
247 Defines "Adaptive" hypothesis to cut an edge into segments keeping segment size
248 within the given range and considering (1) deflection of segments from the edge
249 and (2) distance from segments to closest edges and faces to have segment length
250 not longer than two times shortest distances to edges and faces.
253 minSize: defines the minimal allowed segment length
254 maxSize: defines the maximal allowed segment length
255 deflection: defines the maximal allowed distance from a segment to an edge
256 UseExisting: if ==true - searches for an existing hypothesis created with
257 the same parameters, else (default) - Create a new one
260 an instance of StdMeshers_Adaptive1D hypothesis
263 from salome.smesh.smeshBuilder import IsEqual
264 compFun = lambda hyp, args: ( IsEqual(hyp.GetMinSize(), args[0]) and \
265 IsEqual(hyp.GetMaxSize(), args[1]) and \
266 IsEqual(hyp.GetDeflection(), args[2]))
267 hyp = self.Hypothesis("Adaptive1D", [minSize, maxSize, deflection],
268 UseExisting=UseExisting, CompareMethod=compFun)
269 hyp.SetMinSize(minSize)
270 hyp.SetMaxSize(maxSize)
271 hyp.SetDeflection(deflection)
274 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
276 Defines "Arithmetic1D" hypothesis to cut an edge in several segments with a length
277 that changes in arithmetic progression
280 start: defines the length of the first segment
281 end: defines the length of the last segment
282 reversedEdges: is a list of edges to mesh using reversed orientation.
283 A list item can also be a tuple (edge, 1st_vertex_of_edge)
284 UseExisting: if ==true - searches for an existing hypothesis created with
285 the same parameters, else (default) - Create a new one
288 an instance of StdMeshers_Arithmetic1D hypothesis
291 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
292 reversedEdges, UseExisting = [], reversedEdges
293 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
294 entry = self.MainShapeEntry()
295 from salome.smesh.smeshBuilder import IsEqual
296 compFun = lambda hyp, args: ( IsEqual(hyp.GetLength(1), args[0]) and \
297 IsEqual(hyp.GetLength(0), args[1]) and \
298 hyp.GetReversedEdges() == args[2] and \
299 (not args[2] or hyp.GetObjectEntry() == args[3]))
300 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdgeInd, entry],
301 UseExisting=UseExisting, CompareMethod=compFun)
302 hyp.SetStartLength(start)
303 hyp.SetEndLength(end)
304 hyp.SetReversedEdges( reversedEdgeInd )
305 hyp.SetObjectEntry( entry )
308 def GeometricProgression(self, start, ratio, reversedEdges=[], UseExisting=0):
310 Defines "GeometricProgression" hypothesis to cut an edge in several
311 segments with a length that changes in Geometric progression
314 start: defines the length of the first segment
315 ratio: defines the common ratio of the geometric progression
316 reversedEdges: is a list of edges to mesh using reversed orientation.
317 A list item can also be a tuple (edge, 1st_vertex_of_edge)
318 UseExisting: if ==true - searches for an existing hypothesis created with
319 the same parameters, else (default) - Create a new one
322 an instance of StdMeshers_Geometric1D hypothesis
325 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
326 entry = self.MainShapeEntry()
327 from salome.smesh.smeshBuilder import IsEqual
328 compFun = lambda hyp, args: ( IsEqual(hyp.GetLength(1), args[0]) and \
329 IsEqual(hyp.GetLength(0), args[1]) and \
330 hyp.GetReversedEdges() == args[2] and \
331 (not args[2] or hyp.GetObjectEntry() == args[3]))
332 hyp = self.Hypothesis("GeometricProgression", [start, ratio, reversedEdgeInd, entry],
333 UseExisting=UseExisting, CompareMethod=compFun)
334 hyp.SetStartLength( start )
335 hyp.SetCommonRatio( ratio )
336 hyp.SetReversedEdges( reversedEdgeInd )
337 hyp.SetObjectEntry( entry )
340 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
342 Defines "FixedPoints1D" hypothesis to cut an edge using parameter
343 on curve from 0 to 1 (additionally it is neecessary to check
344 orientation of edges and create list of reversed edges if it is
345 needed) and sets numbers of segments between given points (default
349 points: defines the list of parameters on curve
350 nbSegs: defines the list of numbers of segments
351 reversedEdges: is a list of edges to mesh using reversed orientation.
352 A list item can also be a tuple (edge, 1st_vertex_of_edge)
353 UseExisting: if ==true - searches for an existing hypothesis created with
354 the same parameters, else (default) - Create a new one
357 an instance of StdMeshers_FixedPoints1D hypothesis
360 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
361 reversedEdges, UseExisting = [], reversedEdges
362 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
363 entry = self.MainShapeEntry()
364 compFun = lambda hyp, args: ( hyp.GetPoints() == args[0] and \
365 hyp.GetNbSegments() == args[1] and \
366 hyp.GetReversedEdges() == args[2] and \
367 (not args[2] or hyp.GetObjectEntry() == args[3]))
368 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdgeInd, entry],
369 UseExisting=UseExisting, CompareMethod=compFun)
370 hyp.SetPoints(points)
371 hyp.SetNbSegments(nbSegs)
372 hyp.SetReversedEdges(reversedEdgeInd)
373 hyp.SetObjectEntry(entry)
376 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
378 Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
381 start: defines the length of the first segment
382 end: defines the length of the last segment
383 reversedEdges: is a list of edges to mesh using reversed orientation.
384 A list item can also be a tuple (edge, 1st_vertex_of_edge)
385 UseExisting: if ==true - searches for an existing hypothesis created with
386 the same parameters, else (default) - Create a new one
389 an instance of StdMeshers_StartEndLength hypothesis
392 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
393 reversedEdges, UseExisting = [], reversedEdges
394 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
395 entry = self.MainShapeEntry()
396 from salome.smesh.smeshBuilder import IsEqual
397 compFun = lambda hyp, args: ( IsEqual(hyp.GetLength(1), args[0]) and \
398 IsEqual(hyp.GetLength(0), args[1]) and \
399 hyp.GetReversedEdges() == args[2] and \
400 (not args[2] or hyp.GetObjectEntry() == args[3]))
401 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdgeInd, entry],
402 UseExisting=UseExisting, CompareMethod=compFun)
403 hyp.SetStartLength(start)
404 hyp.SetEndLength(end)
405 hyp.SetReversedEdges( reversedEdgeInd )
406 hyp.SetObjectEntry( entry )
409 def Deflection1D(self, d, UseExisting=0):
411 Defines "Deflection1D" hypothesis
414 d: for the deflection
415 UseExisting: if ==true - searches for an existing hypothesis created with
416 the same parameters, else (default) - create a new one
419 from salome.smesh.smeshBuilder import IsEqual
420 compFun = lambda hyp, args: IsEqual(hyp.GetDeflection(), args[0])
421 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting, CompareMethod=compFun)
425 def Propagation(self):
427 Defines "Propagation" hypothesis that propagates 1D hypotheses
428 from an edge where this hypothesis is assigned to
429 on all other edges that are at the opposite side in case of quadrangular faces
430 This hypothesis should be assigned to an edge to propagate a hypothesis from.
433 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
435 def PropagationOfDistribution(self):
437 Defines "Propagation of Node Distribution" hypothesis that propagates
438 distribution of nodes from an edge where this hypothesis is assigned to,
439 to opposite edges of quadrangular faces, so that number of segments on all these
440 edges will be the same, as well as relations between segment lengths.
443 return self.Hypothesis("PropagOfDistribution", UseExisting=1,
444 CompareMethod=self.CompareEqualHyp)
446 def AutomaticLength(self, fineness=0, UseExisting=0):
448 Defines "AutomaticLength" hypothesis
451 fineness: for the fineness [0-1]
452 UseExisting: if ==true - searches for an existing hypothesis created with the
453 same parameters, else (default) - create a new one
456 from salome.smesh.smeshBuilder import IsEqual
457 compFun = lambda hyp, args: IsEqual(hyp.GetFineness(), args[0])
458 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
459 CompareMethod=compFun)
460 hyp.SetFineness( fineness )
463 def LengthNearVertex(self, length, vertex=-1, UseExisting=0):
465 Defines "SegmentLengthAroundVertex" hypothesis
468 length: for the segment length
469 vertex: for the length localization: the vertex index [0,1] | vertex object.
470 Any other integer value means that the hypothesis will be set on the
471 whole 1D shape, where Mesh_Segment algorithm is assigned.
472 UseExisting: if ==true - searches for an existing hypothesis created with
473 the same parameters, else (default) - Create a new one
477 store_geom = self.geom
478 if isinstance(vertex, int):
479 if vertex == 0 or vertex == 1:
480 from salome.geom import geomBuilder
481 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geomBuilder.geomBuilder.ShapeType["VERTEX"],True)[vertex]
489 if self.geom is None:
490 self.geom = store_geom
491 raise RuntimeError("Attempt to create SegmentAroundVertex_0D algorithm on None shape")
492 from salome.smesh.smeshBuilder import AssureGeomPublished, GetName, TreatHypoStatus
493 AssureGeomPublished( self.mesh, self.geom )
494 name = GetName(self.geom)
496 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
498 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
500 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
501 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True, self.mesh)
503 from salome.smesh.smeshBuilder import IsEqual
504 comFun = lambda hyp, args: IsEqual(hyp.GetLength(), args[0])
505 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
506 CompareMethod=comFun)
507 self.geom = store_geom
508 hyp.SetLength( length )
511 def QuadraticMesh(self):
513 Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
514 If the 2D mesher sees that all boundary edges are quadratic,
515 it generates quadratic faces, else it generates linear faces using
516 medium nodes as if they are vertices.
517 The 3D mesher generates quadratic volumes only if all boundary faces
518 are quadratic, else it fails.
521 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
524 pass # end of StdMeshersBuilder_Segment class
526 class StdMeshersBuilder_CompositeSegment(StdMeshersBuilder_Segment):
528 Segment 1D algorithm for discretization of a set of adjacent edges as one edge.
530 It is created by calling smeshBuilder.Mesh.Segment(smeshBuilder.COMPOSITE,geom=0)
534 meshMethod = "Segment"
536 name of the dynamic method in smeshBuilder.Mesh class
541 type of algorithm used with helper function in smeshBuilder.Mesh class
546 flag pointing whether this algorithm should be used by default in dynamic method
547 of smeshBuilder.Mesh class
550 docHelper = "Create segment 1D algorithm for edges"
552 doc string of the method
555 def __init__(self, mesh, geom=0):
560 mesh: parent mesh object algorithm is assigned to
561 geom: geometry (shape/sub-shape) algorithm is assigned to;
562 if it is :code:`0` (default), the algorithm is assigned to the main shape
564 self.Create(mesh, geom, self.algoType)
567 pass # end of StdMeshersBuilder_CompositeSegment class
569 class StdMeshersBuilder_Segment_Python(Mesh_Algorithm):
571 Defines a segment 1D algorithm for discretization of edges with Python function.
572 It is created by calling smeshBuilder.Mesh.Segment(smeshBuilder.PYTHON,geom=0)
576 meshMethod = "Segment"
578 name of the dynamic method in smeshBuilder.Mesh class
582 type of algorithm used with helper function in smeshBuilder.Mesh class
584 docHelper = "Create segment 1D algorithm for edges"
586 doc string of the method
589 def __init__(self, mesh, geom=0):
594 mesh: parent mesh object algorithm is assigned to
595 geom: geometry (shape/sub-shape) algorithm is assigned to;
596 if it is :code:`0` (default), the algorithm is assigned to the main shape
598 import Python1dPlugin
599 self.Create(mesh, geom, self.algoType, "libPython1dEngine.so")
602 def PythonSplit1D(self, n, func, UseExisting=0):
604 Defines "PythonSplit1D" hypothesis
607 n: for the number of segments that cut an edge
608 func: for the python function that calculates the length of all segments
609 UseExisting: if ==true - searches for the existing hypothesis created with
610 the same parameters, else (default) - Create a new one
613 compFun = lambda hyp, args: False
614 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
615 UseExisting=UseExisting, CompareMethod=compFun)
616 hyp.SetNumberOfSegments(n)
617 hyp.SetPythonLog10RatioFunction(func)
620 pass # end of StdMeshersBuilder_Segment_Python class
622 class StdMeshersBuilder_Quadrangle(Mesh_Algorithm):
624 Defines a quadrangle 2D algorithm.
625 It is created by calling smeshBuilder.Mesh.Quadrangle(geom=0)
629 meshMethod = "Quadrangle"
631 name of the dynamic method in smeshBuilder.Mesh class
633 algoType = QUADRANGLE
635 type of algorithm used with helper function in smeshBuilder.Mesh class
639 flag pointing whether this algorithm should be used by default in dynamic method
640 of smeshBuilder.Mesh class
642 docHelper = "Create quadrangle 2D algorithm for faces"
644 doc string of the method
648 hypothesis associated with algorithm
651 def __init__(self, mesh, geom=0):
656 mesh: parent mesh object algorithm is assigned to
657 geom: geometry (shape/sub-shape) algorithm is assigned to;
658 if it is :code:`0` (default), the algorithm is assigned to the main shape
660 Mesh_Algorithm.__init__(self)
661 self.Create(mesh, geom, self.algoType)
664 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0,
665 enfVertices=[],enfPoints=[],corners=[],UseExisting=0):
667 Defines "QuadrangleParameters" hypothesis
668 quadType defines the algorithm of transition between differently descretized
669 sides of a geometrical face:
671 - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
672 area along the finer meshed sides.
673 - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
675 - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
676 the finer meshed sides, iff the total quantity of segments on
677 all four sides of the face is even (divisible by 2).
678 - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
679 area is located along the coarser meshed sides.
680 - QUAD_REDUCED - only quadrangles are built and the transition between the sides
681 is made gradually, layer by layer. This type has a limitation on
682 the number of segments: one pair of opposite sides must have the
683 same number of segments, the other pair must have an even difference
684 between the numbers of segments on the sides.
687 triangleVertex: vertex of a trilateral geometrical face, around which triangles
688 will be created while other elements will be quadrangles.
689 Vertex can be either a GEOM_Object or a vertex ID within the
691 enfVertices: list of shapes defining positions where nodes (enforced nodes)
692 must be created by the mesher. Shapes can be of any type,
693 vertices of given shapes define positions of enforced nodes.
694 Only vertices successfully projected to the face are used.
695 enfPoints: list of points giving positions of enforced nodes.
696 Point can be defined either as SMESH.PointStruct's
697 ([SMESH.PointStruct(x1,y1,z1), SMESH.PointStruct(x2,y2,z2),...])
698 or triples of values ([[x1,y1,z1], [x2,y2,z2], ...]).
699 In the case if the defined QuadrangleParameters() refer to a sole face,
700 all given points must lie on this face, else the mesher fails.
701 corners: list of vertices that should be used as quadrangle corners.
702 The parameter can be useful for faces with more than four vertices,
703 since in some cases Quadrangle Mapping algorithm chooses corner vertices
704 differently than it is desired.
705 A hypothesis can be global and define corners for all CAD faces that
706 require it, but be sure that each specified vertex is a corner in all
707 faces the hypothesis will be applied to.
708 UseExisting: if *True* - searches for the existing hypothesis created with
709 the same parameters, else (default) - Create a new one
714 vertexID = triangleVertex
715 if isinstance( triangleVertex, GEOM._objref_GEOM_Object ):
716 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
717 if isinstance( enfVertices, int ) and not enfPoints and not UseExisting:
718 # a call of old syntax, before inserting enfVertices and enfPoints before UseExisting
719 UseExisting, enfVertices = enfVertices, []
721 pStructs, xyz = [], []
723 if isinstance( p, SMESH.PointStruct ):
724 xyz.append(( p.x, p.y, p.z ))
727 xyz.append(( p[0], p[1], p[2] ))
728 pStructs.append( SMESH.PointStruct( p[0], p[1], p[2] ))
730 compFun = lambda hyp,args: \
731 hyp.GetQuadType() == args[0] and \
732 (hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1)) and \
733 ((hyp.GetEnforcedNodes()) == (args[2],args[3])) # True w/o enfVertices only
734 entries = [ shape.GetStudyEntry() for shape in enfVertices ]
735 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID,entries,xyz],
736 UseExisting = UseExisting, CompareMethod=compFun)
739 if corners and isinstance( corners[0], GEOM._objref_GEOM_Object ):
740 corners = [ self.mesh.geompyD.GetSubShapeID( self.mesh.geom, v ) for v in corners ]
742 if self.params.GetQuadType() != quadType:
743 self.params.SetQuadType(quadType)
745 self.params.SetTriaVertex( vertexID )
746 from salome.smesh.smeshBuilder import AssureGeomPublished
747 for v in enfVertices:
748 AssureGeomPublished( self.mesh, v )
749 self.params.SetEnforcedNodes( enfVertices, pStructs )
750 self.params.SetCorners( corners )
753 def QuadranglePreference(self, reversed=False, UseExisting=0):
755 Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
756 quadrangles are built in the transition area along the finer meshed sides,
757 if the total quantity of segments on all four sides of the face is even.
760 reversed: if True, transition area is located along the coarser meshed sides.
761 UseExisting: if ==true - searches for the existing hypothesis created with
762 the same parameters, else (default) - Create a new one
766 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
767 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
769 def TrianglePreference(self, UseExisting=0):
771 Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
772 triangles are built in the transition area along the finer meshed sides.
775 UseExisting: if ==true - searches for the existing hypothesis created with
776 the same parameters, else (default) - Create a new one
779 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
781 def Reduced(self, UseExisting=0):
783 Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
784 quadrangles are built and the transition between the sides is made gradually,
785 layer by layer. This type has a limitation on the number of segments: one pair
786 of opposite sides must have the same number of segments, the other pair must
787 have an even difference between the numbers of segments on the sides.
790 UseExisting: if ==true - searches for the existing hypothesis created with
791 the same parameters, else (default) - Create a new one
794 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
796 def TriangleVertex(self, vertex, UseExisting=0):
798 Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
801 vertex: vertex of a trilateral geometrical face, around which triangles
802 will be created while other elements will be quadrangles.
803 Vertex can be either a GEOM_Object or a vertex ID within the
805 UseExisting: if ==true - searches for the existing hypothesis created with
806 the same parameters, else (default) - Create a new one
809 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
811 pass # end of StdMeshersBuilder_Quadrangle class
813 class StdMeshersBuilder_Hexahedron(Mesh_Algorithm):
815 Defines a hexahedron 3D algorithm.
816 It is created by calling smeshBuilder.Mesh.Hexahedron(geom=0)
820 meshMethod = "Hexahedron"
822 name of the dynamic method in smeshBuilder.Mesh class
826 type of algorithm used with helper function in smeshBuilder.Mesh class
830 flag pointing whether this algorithm should be used by default in dynamic method
831 of smeshBuilder.Mesh class
833 docHelper = "Create hexahedron 3D algorithm for volumes"
835 doc string of the method
838 def __init__(self, mesh, geom=0):
843 mesh: parent mesh object algorithm is assigned to
844 geom: geometry (shape/sub-shape) algorithm is assigned to;
845 if it is :code:`0` (default), the algorithm is assigned to the main shape
847 Mesh_Algorithm.__init__(self)
848 self.Create(mesh, geom, Hexa)
849 self.renumHypothesis = 0
852 def Renumber(self, blockCSList=[] ):
853 if isinstance( blockCSList, StdMeshers.BlockCS ):
854 blockCSList = [blockCSList]
855 if not self.renumHypothesis:
856 self.renumHypothesis = self.Hypothesis("BlockRenumber", blockCSList, UseExisting=0)
857 self.renumHypothesis.SetBlocksOrientation( blockCSList )
858 return self.renumHypothesis
860 pass # end of StdMeshersBuilder_Hexahedron class
862 class StdMeshersBuilder_Projection1D(Mesh_Algorithm):
864 Defines a projection 1D algorithm.
865 It is created by calling smeshBuilder.Mesh.Projection1D(geom=0)
869 meshMethod = "Projection1D"
871 name of the dynamic method in smeshBuilder.Mesh class
873 algoType = "Projection_1D"
875 type of algorithm used with helper function in smeshBuilder.Mesh class
879 flag pointing whether this algorithm should be used by default in dynamic method
880 of smeshBuilder.Mesh class
882 docHelper = "Create projection 1D algorithm for edges"
884 doc string of the method
886 def __init__(self, mesh, geom=0):
891 mesh: parent mesh object algorithm is assigned to
892 geom: geometry (shape/sub-shape) algorithm is assigned to;
893 if it is :code:`0` (default), the algorithm is assigned to the main shape
895 Mesh_Algorithm.__init__(self)
896 self.Create(mesh, geom, self.algoType)
899 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
901 Defines "Source Edge" hypothesis, specifying a meshed edge, from where
902 a mesh pattern is taken, and, optionally, the association of vertices
903 between the source edge and a target edge (to which a hypothesis is assigned)
906 edge: from which nodes distribution is taken
907 mesh: from which nodes distribution is taken (optional)
908 srcV: a vertex of *edge* to associate with *tgtV* (optional)
909 tgtV: a vertex of *the edge* to which the algorithm is assigned, to associate with *srcV* (optional)
910 UseExisting: if ==true - searches for the existing hypothesis created with
911 the same parameters, else (default) - Create a new one
913 from salome.smesh.smeshBuilder import AssureGeomPublished, Mesh
914 AssureGeomPublished( self.mesh, edge )
915 AssureGeomPublished( self.mesh, srcV )
916 AssureGeomPublished( self.mesh, tgtV )
917 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
919 # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
920 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
921 hyp.SetSourceEdge( edge )
922 if not mesh is None and isinstance(mesh, Mesh):
923 mesh = mesh.GetMesh()
924 hyp.SetSourceMesh( mesh )
925 hyp.SetVertexAssociation( srcV, tgtV )
928 pass # end of StdMeshersBuilder_Projection1D class
930 class StdMeshersBuilder_Projection2D(Mesh_Algorithm):
932 Defines a projection 2D algorithm.
933 It is created by calling smeshBuilder.Mesh.Projection2D(geom=0)
937 meshMethod = "Projection2D"
939 name of the dynamic method in smeshBuilder.Mesh class
941 algoType = "Projection_2D"
943 type of algorithm used with helper function in smeshBuilder.Mesh class
947 flag pointing whether this algorithm should be used by default in dynamic method
948 of smeshBuilder.Mesh class
950 docHelper = "Create projection 2D algorithm for faces"
952 doc string of the method
955 def __init__(self, mesh, geom=0):
960 mesh: parent mesh object algorithm is assigned to
961 geom: geometry (shape/sub-shape) algorithm is assigned to;
962 if it is :code:`0` (default), the algorithm is assigned to the main shape
964 Mesh_Algorithm.__init__(self)
965 self.Create(mesh, geom, self.algoType)
969 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
970 srcV2=None, tgtV2=None, UseExisting=0):
972 Defines "Source Face" hypothesis, specifying a meshed face, from where
973 a mesh pattern is taken, and, optionally, the association of vertices
974 between the source face and the target face (to which a hypothesis is assigned)
977 face: from which the mesh pattern is taken
978 mesh: from which the mesh pattern is taken (optional)
979 srcV1: a vertex of *face* to associate with *tgtV1* (optional)
980 tgtV1: a vertex of *the face* to which the algorithm is assigned, to associate with *srcV1* (optional)
981 srcV2: a vertex of *face* to associate with *tgtV1* (optional)
982 tgtV2: a vertex of *the face* to which the algorithm is assigned, to associate with *srcV2* (optional)
983 UseExisting: if ==true - forces the search for the existing hypothesis created with
984 he same parameters, else (default) - forces the creation a new one
987 all association vertices must belong to one edge of a face
989 from salome.smesh.smeshBuilder import Mesh
990 if isinstance(mesh, Mesh):
991 mesh = mesh.GetMesh()
992 for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
993 from salome.smesh.smeshBuilder import AssureGeomPublished
994 AssureGeomPublished( self.mesh, geom )
995 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
996 UseExisting=0, toAdd=False)
997 # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
998 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
999 hyp.SetSourceFace( face )
1000 hyp.SetSourceMesh( mesh )
1001 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
1002 self.mesh.AddHypothesis(hyp, self.geom)
1005 pass # end of StdMeshersBuilder_Projection2D class
1007 class StdMeshersBuilder_Projection1D2D(StdMeshersBuilder_Projection2D):
1009 Defines a projection 1D-2D algorithm.
1010 It is created by calling smeshBuilder.Mesh.Projection1D2D(geom=0)
1014 meshMethod = "Projection1D2D"
1016 name of the dynamic method in smeshBuilder.Mesh class
1018 algoType = "Projection_1D2D"
1020 type of algorithm used with helper function in smeshBuilder.Mesh class
1022 docHelper = "Create projection 1D-2D algorithm for faces"
1024 doc string of the method
1027 def __init__(self, mesh, geom=0):
1029 Private constructor.
1032 mesh: parent mesh object algorithm is assigned to
1033 geom: geometry (shape/sub-shape) algorithm is assigned to;
1034 if it is :code:`0` (default), the algorithm is assigned to the main shape
1036 StdMeshersBuilder_Projection2D.__init__(self, mesh, geom)
1039 pass # end of StdMeshersBuilder_Projection1D2D class
1041 class StdMeshersBuilder_Projection3D(Mesh_Algorithm):
1043 Defines a projection 3D algorithm.
1044 It is created by calling smeshBuilder.Mesh.Projection3D(geom=0)
1048 meshMethod = "Projection3D"
1050 name of the dynamic method in smeshBuilder.Mesh class
1052 algoType = "Projection_3D"
1054 type of algorithm used with helper function in smeshBuilder.Mesh class
1056 docHelper = "Create projection 3D algorithm for volumes"
1058 doc string of the method
1061 def __init__(self, mesh, geom=0):
1063 Private constructor.
1066 mesh: parent mesh object algorithm is assigned to
1067 geom" geometry (shape/sub-shape) algorithm is assigned to;
1068 if it is :code:`0` (default), the algorithm is assigned to the main shape
1070 Mesh_Algorithm.__init__(self)
1071 self.Create(mesh, geom, self.algoType)
1074 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
1075 srcV2=0, tgtV2=0, UseExisting=0):
1077 Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
1078 the mesh pattern is taken, and, optionally, the association of vertices
1079 between the source and the target solid (to which a hipothesis is assigned)
1082 solid: from where the mesh pattern is taken
1083 mesh: from where the mesh pattern is taken (optional)
1084 srcV1: a vertex of *solid* to associate with *tgtV1* (optional)
1085 tgtV1: a vertex of *the solid* where the algorithm is assigned, to associate with *srcV1* (optional)
1086 srcV2: a vertex of *solid* to associate with *tgtV1* (optional)
1087 tgtV2: a vertex of *the solid* to which the algorithm is assigned,to associate with *srcV2* (optional)
1088 UseExisting: if ==true - searches for the existing hypothesis created with
1089 the same parameters, else (default) - Create a new one
1092 association vertices must belong to one edge of a solid
1094 for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
1095 from salome.smesh.smeshBuilder import AssureGeomPublished
1096 AssureGeomPublished( self.mesh, geom )
1097 hyp = self.Hypothesis("ProjectionSource3D",
1098 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
1100 # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
1101 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
1102 hyp.SetSource3DShape( solid )
1103 from salome.smesh.smeshBuilder import Mesh
1104 if isinstance(mesh, Mesh):
1105 mesh = mesh.GetMesh()
1107 hyp.SetSourceMesh( mesh )
1108 if srcV1 and srcV2 and tgtV1 and tgtV2:
1109 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
1110 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
1113 pass # end of StdMeshersBuilder_Projection3D class
1115 class StdMeshersBuilder_Prism3D(Mesh_Algorithm):
1117 Defines a Prism 3D algorithm, which is either "Extrusion 3D" or "Radial Prism" depending on geometry.
1118 It is created by calling smeshBuilder.Mesh.Prism(geom=0)
1122 meshMethod = "Prism"
1124 name of the dynamic method in smeshBuilder.Mesh class
1126 algoType = "Prism_3D"
1128 type of algorithm used with helper function in smeshBuilder.Mesh class
1130 docHelper = "Create prism 3D algorithm for volumes"
1132 doc string of the method
1136 flag pointing whether this algorithm should be used by default in dynamic method
1137 of smeshBuilder.Mesh class
1140 def __init__(self, mesh, geom=0):
1142 Private constructor.
1145 mesh: parent mesh object algorithm is assigned to
1146 geom: geometry (shape/sub-shape) algorithm is assigned to;
1147 if it is :code:`0` (default), the algorithm is assigned to the main shape
1149 Mesh_Algorithm.__init__(self)
1154 isRadial = mesh.smeshpyD.IsApplicable("RadialPrism_3D", LIBRARY, shape, False )
1156 self.Create(mesh, geom, "Prism_3D")
1159 self.algoType = "RadialPrism_3D"
1160 self.Create(mesh, geom, "RadialPrism_3D")
1161 self.distribHyp = None #self.Hypothesis("LayerDistribution", UseExisting=0)
1162 self.nbLayers = None
1166 def Get3DHypothesis(self):
1169 3D hypothesis holding the 1D one
1171 if self.algoType != "RadialPrism_3D":
1172 print("Prism_3D algorithm doesn't support any hypothesis")
1174 return self.distribHyp
1176 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
1178 Private method creating a 1D hypothesis and storing it in the LayerDistribution
1182 the created hypothesis
1184 if self.algoType != "RadialPrism_3D":
1185 print("Prism_3D algorithm doesn't support any hypothesis")
1187 if not self.nbLayers is None:
1188 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
1189 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
1190 self.mesh.smeshpyD.SetEnablePublish( False ) # prevents publishing own 1D hypothesis
1191 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
1192 self.mesh.smeshpyD.SetEnablePublish( True ) # enables publishing
1193 if not self.distribHyp:
1194 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
1195 self.distribHyp.SetLayerDistribution( hyp )
1198 def NumberOfLayers(self, n, UseExisting=0):
1200 Defines "NumberOfLayers" hypothesis, specifying the number of layers of
1201 prisms to build between the inner and outer shells
1205 UseExisting: if ==true - searches for the existing hypothesis created with
1206 the same parameters, else (default) - Create a new one
1208 if self.algoType != "RadialPrism_3D":
1209 print("Prism_3D algorithm doesn't support any hypothesis")
1211 self.mesh.RemoveHypothesis( self.distribHyp, self.geom )
1212 from salome.smesh.smeshBuilder import IsEqual
1213 compFun = lambda hyp, args: IsEqual(hyp.GetNumberOfLayers(), args[0])
1214 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
1215 CompareMethod=compFun)
1216 self.nbLayers.SetNumberOfLayers( n )
1217 return self.nbLayers
1219 def LocalLength(self, l, p=1e-07):
1221 Defines "LocalLength" hypothesis, specifying the segment length
1222 to build between the inner and the outer shells
1225 l: the length of segments
1226 p: the precision of rounding
1228 if self.algoType != "RadialPrism_3D":
1229 print("Prism_3D algorithm doesn't support any hypothesis")
1231 hyp = self.OwnHypothesis("LocalLength", [l,p])
1236 def NumberOfSegments(self, n, s=[]):
1238 Defines "NumberOfSegments" hypothesis, specifying the number of layers of
1239 prisms to build between the inner and the outer shells.
1242 n: the number of layers
1243 s: the scale factor (optional)
1245 if self.algoType != "RadialPrism_3D":
1246 print("Prism_3D algorithm doesn't support any hypothesis")
1249 hyp = self.OwnHypothesis("NumberOfSegments", [n])
1251 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
1252 hyp.SetScaleFactor(s)
1253 hyp.SetNumberOfSegments(n)
1256 def Arithmetic1D(self, start, end ):
1258 Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
1259 to build between the inner and the outer shells with a length that changes
1260 in arithmetic progression
1263 start: the length of the first segment
1264 end: the length of the last segment
1266 if self.algoType != "RadialPrism_3D":
1267 print("Prism_3D algorithm doesn't support any hypothesis")
1269 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
1270 hyp.SetLength(start, 1)
1271 hyp.SetLength(end , 0)
1274 def GeometricProgression(self, start, ratio ):
1276 Defines "GeometricProgression" hypothesis, specifying the distribution of segments
1277 to build between the inner and the outer shells with a length that changes
1278 in Geometric progression
1281 start: the length of the first segment
1282 ratio: the common ratio of the geometric progression
1284 if self.algoType != "RadialPrism_3D":
1285 print("Prism_3D algorithm doesn't support any hypothesis")
1287 hyp = self.OwnHypothesis("GeometricProgression", [start, ratio])
1288 hyp.SetStartLength( start )
1289 hyp.SetCommonRatio( ratio )
1292 def StartEndLength(self, start, end):
1294 Defines "StartEndLength" hypothesis, specifying distribution of segments
1295 to build between the inner and the outer shells as geometric length increasing
1298 start: for the length of the first segment
1299 end: for the length of the last segment
1301 if self.algoType != "RadialPrism_3D":
1302 print("Prism_3D algorithm doesn't support any hypothesis")
1304 hyp = self.OwnHypothesis("StartEndLength", [start, end])
1305 hyp.SetLength(start, 1)
1306 hyp.SetLength(end , 0)
1309 def AutomaticLength(self, fineness=0):
1311 Defines "AutomaticLength" hypothesis, specifying the number of segments
1312 to build between the inner and outer shells
1315 fineness: defines the quality of the mesh within the range [0-1]
1317 if self.algoType != "RadialPrism_3D":
1318 print("Prism_3D algorithm doesn't support any hypothesis")
1320 hyp = self.OwnHypothesis("AutomaticLength")
1321 hyp.SetFineness( fineness )
1324 pass # end of StdMeshersBuilder_Prism3D class
1326 class StdMeshersBuilder_RadialPrism3D(StdMeshersBuilder_Prism3D):
1328 Defines Radial Prism 3D algorithm.
1329 It is created by calling smeshBuilder.Mesh.Prism(geom=0).
1330 See :class:`StdMeshersBuilder_Prism3D` for methods defining distribution of mesh layers
1331 build between the inner and outer shells.
1334 meshMethod = "Prism"
1336 name of the dynamic method in smeshBuilder.Mesh class
1338 algoType = "RadialPrism_3D"
1340 type of algorithm used with helper function in smeshBuilder.Mesh class
1342 docHelper = "Create Raial Prism 3D algorithm for volumes"
1344 doc string of the method
1347 def __init__(self, mesh, geom=0):
1349 Private constructor.
1352 mesh: parent mesh object algorithm is assigned to
1353 geom: geometry (shape/sub-shape) algorithm is assigned to;
1354 if it is :code:`0` (default), the algorithm is assigned to the main shape
1356 Mesh_Algorithm.__init__(self)
1361 self.Create(mesh, geom, "RadialPrism_3D")
1362 self.distribHyp = None
1363 self.nbLayers = None
1366 class StdMeshersBuilder_RadialAlgorithm(Mesh_Algorithm):
1368 Base class for algorithms supporting radial distribution hypotheses
1372 Mesh_Algorithm.__init__(self)
1374 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
1375 self.nbLayers = None
1378 def Get2DHypothesis(self):
1381 2D hypothesis holding the 1D one
1383 if not self.distribHyp:
1384 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
1385 return self.distribHyp
1387 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
1389 Private method creating a 1D hypothesis and storing it in the LayerDistribution
1393 the created hypothesis
1396 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
1397 if self.distribHyp is None:
1398 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
1400 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
1401 self.mesh.smeshpyD.SetEnablePublish( False )
1402 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
1403 self.mesh.smeshpyD.SetEnablePublish( True )
1404 self.distribHyp.SetLayerDistribution( hyp )
1407 def NumberOfLayers(self, n, UseExisting=0):
1409 Defines "NumberOfLayers" hypothesis, specifying the number of layers
1413 UseExisting: if ==true - searches for the existing hypothesis created with
1414 the same parameters, else (default) - Create a new one
1417 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
1418 from salome.smesh.smeshBuilder import IsEqual
1419 compFun = lambda hyp, args: IsEqual(hyp.GetNumberOfLayers(), args[0])
1420 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
1421 CompareMethod=compFun)
1422 self.nbLayers.SetNumberOfLayers( n )
1423 return self.nbLayers
1425 def LocalLength(self, l, p=1e-07):
1427 Defines "LocalLength" hypothesis, specifying the segment length
1430 l: the length of segments
1431 p: the precision of rounding
1433 hyp = self.OwnHypothesis("LocalLength", [l,p])
1438 def NumberOfSegments(self, n, s=[]):
1440 Defines "NumberOfSegments" hypothesis, specifying the number of layers
1443 n: the number of layers
1444 s: the scale factor (optional)
1447 hyp = self.OwnHypothesis("NumberOfSegments", [n])
1449 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
1450 hyp.SetDistrType( 1 )
1451 hyp.SetScaleFactor(s)
1452 hyp.SetNumberOfSegments(n)
1455 def Arithmetic1D(self, start, end ):
1457 Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
1458 with a length that changes in arithmetic progression
1461 start: the length of the first segment
1462 end: the length of the last segment
1464 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
1465 hyp.SetLength(start, 1)
1466 hyp.SetLength(end , 0)
1469 def GeometricProgression(self, start, ratio ):
1471 Defines "GeometricProgression" hypothesis, specifying the distribution of segments
1472 with a length that changes in Geometric progression
1475 start: the length of the first segment
1476 ratio: the common ratio of the geometric progression
1478 hyp = self.OwnHypothesis("GeometricProgression", [start, ratio])
1479 hyp.SetStartLength( start )
1480 hyp.SetCommonRatio( ratio )
1483 def StartEndLength(self, start, end):
1485 Defines "StartEndLength" hypothesis, specifying distribution of segments
1486 as geometric length increasing
1489 start: for the length of the first segment
1490 end: for the length of the last segment
1492 hyp = self.OwnHypothesis("StartEndLength", [start, end])
1493 hyp.SetLength(start, 1)
1494 hyp.SetLength(end , 0)
1497 def AutomaticLength(self, fineness=0):
1499 Defines "AutomaticLength" hypothesis, specifying the number of segments
1502 fineness: defines the quality of the mesh within the range [0-1]
1504 hyp = self.OwnHypothesis("AutomaticLength")
1505 hyp.SetFineness( fineness )
1508 pass # end of StdMeshersBuilder_RadialQuadrangle1D2D class
1510 class StdMeshersBuilder_RadialQuadrangle1D2D(StdMeshersBuilder_RadialAlgorithm):
1512 Defines a Radial Quadrangle 1D-2D algorithm.
1513 It is created by calling smeshBuilder.Mesh.Quadrangle(smeshBuilder.RADIAL_QUAD,geom=0)
1516 meshMethod = "Quadrangle"
1518 name of the dynamic method in smeshBuilder.Mesh class
1520 algoType = RADIAL_QUAD
1522 type of algorithm used with helper function in smeshBuilder.Mesh class
1524 docHelper = "Create quadrangle 1D-2D algorithm for faces having a shape of disk or a disk segment"
1526 doc string of the method
1529 def __init__(self, mesh, geom=0):
1531 Private constructor.
1534 mesh: parent mesh object algorithm is assigned to
1535 geom: geometry (shape/sub-shape) algorithm is assigned to;
1536 if it is :code:`0` (default), the algorithm is assigned to the main shape
1538 StdMeshersBuilder_RadialAlgorithm.__init__(self)
1539 self.Create(mesh, geom, self.algoType)
1541 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
1542 self.nbLayers = None
1546 class StdMeshersBuilder_QuadMA_1D2D(StdMeshersBuilder_RadialAlgorithm):
1548 Defines a Quadrangle (Medial Axis Projection) 1D-2D algorithm .
1549 It is created by calling smeshBuilder.Mesh.Quadrangle(smeshBuilder.QUAD_MA_PROJ,geom=0)
1552 meshMethod = "Quadrangle"
1554 name of the dynamic method in smeshBuilder.Mesh class
1556 algoType = QUAD_MA_PROJ
1558 type of algorithm used with helper function in smeshBuilder.Mesh class
1560 docHelper = "Create quadrangle 1D-2D algorithm for faces"
1562 doc string of the method
1565 def __init__(self, mesh, geom=0):
1567 Private constructor.
1570 mesh: parent mesh object algorithm is assigned to
1571 geom: geometry (shape/sub-shape) algorithm is assigned to;
1572 if it is :code:`0` (default), the algorithm is assigned to the main shape
1574 StdMeshersBuilder_RadialAlgorithm.__init__(self)
1575 self.Create(mesh, geom, self.algoType)
1580 class StdMeshersBuilder_PolygonPerFace(Mesh_Algorithm):
1581 """ Defines a Polygon Per Face 2D algorithm.
1582 It is created by calling smeshBuilder.Mesh.Polygon(geom=0)
1585 meshMethod = "Polygon"
1587 name of the dynamic method in smeshBuilder.Mesh class
1591 type of algorithm used with helper function in smeshBuilder.Mesh class
1595 flag pointing whether this algorithm should be used by default in dynamic method
1596 of smeshBuilder.Mesh class
1598 docHelper = "Create polygon 2D algorithm for faces"
1600 doc string of the method
1603 def __init__(self, mesh, geom=0):
1605 Private constructor.
1608 mesh: parent mesh object algorithm is assigned to
1609 geom: geometry (shape/sub-shape) algorithm is assigned to;
1610 if it is :code:`0` (default), the algorithm is assigned to the main shape
1612 Mesh_Algorithm.__init__(self)
1613 self.Create(mesh, geom, self.algoType)
1618 class StdMeshersBuilder_PolyhedronPerSolid(Mesh_Algorithm):
1619 """ Defines a Polyhedron Per Solid 3D algorithm.
1620 It is created by calling smeshBuilder.Mesh.Polyhedron(geom=0)
1623 meshMethod = "Polyhedron"
1625 name of the dynamic method in smeshBuilder.Mesh class
1627 algoType = POLYHEDRON
1629 type of algorithm used with helper function in smeshBuilder.Mesh class
1633 flag pointing whether this algorithm should be used by default in dynamic method
1634 of smeshBuilder.Mesh class
1636 docHelper = "Create polyhedron 3D algorithm for solids"
1638 doc string of the method
1641 def __init__(self, mesh, geom=0):
1643 Private constructor.
1646 mesh: parent mesh object algorithm is assigned to
1647 geom: geometry (shape/sub-shape) algorithm is assigned to;
1648 if it is :code:`0` (default), the algorithm is assigned to the main shape
1650 Mesh_Algorithm.__init__(self)
1651 self.Create(mesh, geom, self.algoType)
1656 class StdMeshersBuilder_UseExistingElements_1D(Mesh_Algorithm):
1657 """ Defines a Use Existing Elements 1D algorithm.
1659 It is created by calling smeshBuilder.Mesh.UseExisting1DElements(geom=0)
1663 meshMethod = "UseExisting1DElements"
1665 name of the dynamic method in smeshBuilder.Mesh class
1667 algoType = "Import_1D"
1669 type of algorithm used with helper function in smeshBuilder.Mesh class
1673 flag pointing whether this algorithm should be used by default in dynamic method
1674 of smeshBuilder.Mesh class
1676 docHelper = "Create 1D algorithm for edges with reusing of existing mesh elements"
1678 doc string of the method
1681 def __init__(self, mesh, geom=0):
1683 Private constructor.
1686 mesh: parent mesh object algorithm is assigned to
1687 geom: geometry (shape/sub-shape) algorithm is assigned to;
1688 if it is :code:`0` (default), the algorithm is assigned to the main shape
1690 Mesh_Algorithm.__init__(self)
1691 self.Create(mesh, geom, self.algoType)
1694 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
1696 Defines "Source edges" hypothesis, specifying groups of edges to import
1699 groups: list of groups of edges
1700 toCopyMesh: if True, the whole mesh *groups* belong to is imported
1701 toCopyGroups: if True, all groups of the mesh *groups* belong to are imported
1702 UseExisting: if ==true - searches for the existing hypothesis created with
1703 the same parameters, else (default) - Create a new one
1705 for group in groups:
1706 from salome.smesh.smeshBuilder import AssureGeomPublished
1707 AssureGeomPublished( self.mesh, group )
1708 compFun = lambda hyp, args: ( hyp.GetSourceEdges() == args[0] and \
1709 hyp.GetCopySourceMesh() == args[1], args[2] )
1710 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
1711 UseExisting=UseExisting, CompareMethod=compFun)
1712 hyp.SetSourceEdges(groups)
1713 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
1716 pass # end of StdMeshersBuilder_UseExistingElements_1D class
1718 class StdMeshersBuilder_UseExistingElements_1D2D(Mesh_Algorithm):
1719 """ Defines a Use Existing Elements 1D-2D algorithm.
1721 It is created by calling smeshBuilder.Mesh.UseExisting2DElements(geom=0)
1725 meshMethod = "UseExisting2DElements"
1727 name of the dynamic method in smeshBuilder.Mesh class
1729 algoType = "Import_1D2D"
1731 type of algorithm used with helper function in smeshBuilder.Mesh class
1735 flag pointing whether this algorithm should be used by default in dynamic method
1736 of smeshBuilder.Mesh class
1738 docHelper = "Create 1D-2D algorithm for faces with reusing of existing mesh elements"
1740 doc string of the method
1743 def __init__(self, mesh, geom=0):
1745 Private constructor.
1748 mesh: parent mesh object algorithm is assigned to
1749 geom: geometry (shape/sub-shape) algorithm is assigned to;
1750 if it is :code:`0` (default), the algorithm is assigned to the main shape
1752 Mesh_Algorithm.__init__(self)
1753 self.Create(mesh, geom, self.algoType)
1756 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
1758 Defines "Source faces" hypothesis, specifying groups of faces to import
1761 groups: list of groups of faces
1762 toCopyMesh: if True, the whole mesh *groups* belong to is imported
1763 toCopyGroups: if True, all groups of the mesh *groups* belong to are imported
1764 UseExisting: if ==true - searches for the existing hypothesis created with
1765 the same parameters, else (default) - Create a new one
1768 compFun = lambda hyp, args: ( hyp.GetSourceFaces() == args[0] and \
1769 hyp.GetCopySourceMesh() == args[1], args[2] )
1770 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
1771 UseExisting=UseExisting, CompareMethod=compFun, toAdd=False)
1772 if groups and isinstance( groups, SMESH._objref_SMESH_GroupBase ):
1774 hyp.SetSourceFaces(groups)
1775 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
1776 self.mesh.AddHypothesis(hyp, self.geom)
1779 pass # end of StdMeshersBuilder_UseExistingElements_1D2D class
1781 class StdMeshersBuilder_Cartesian_3D(Mesh_Algorithm):
1782 """ Defines a Body Fitting 3D algorithm.
1784 It is created by calling smeshBuilder.Mesh.BodyFitted(geom=0)
1788 meshMethod = "BodyFitted"
1790 name of the dynamic method in smeshBuilder.Mesh class
1792 algoType = "Cartesian_3D"
1794 type of algorithm used with helper function in smeshBuilder.Mesh class
1798 flag pointing whether this algorithm should be used by default in dynamic method
1799 of smeshBuilder.Mesh class
1801 docHelper = "Create Body Fitting 3D algorithm for volumes"
1803 doc string of the method
1806 def __init__(self, mesh, geom=0):
1808 Private constructor.
1811 mesh: parent mesh object algorithm is assigned to
1812 geom: geometry (shape/sub-shape) algorithm is assigned to;
1813 if it is :code:`0` (default), the algorithm is assigned to the main shape
1815 self.Create(mesh, geom, self.algoType)
1819 def SetGrid(self, xGridDef, yGridDef, zGridDef, sizeThreshold=4.0, implEdges=False):
1821 Defines "Body Fitting parameters" hypothesis
1824 xGridDef: is definition of the grid along the X asix.
1825 It can be in either of two following forms:
1827 - Explicit coordinates of nodes, e.g. [-1.5, 0.0, 3.1] or range( -100,200,10)
1828 - Functions f(t) defining grid spacing at each point on grid axis. If there are
1829 several functions, they must be accompanied by relative coordinates of
1830 points dividing the whole shape into ranges where the functions apply; points
1831 coordinates should vary within (0.0, 1.0) range. Parameter *t* of the spacing
1832 function f(t) varies from 0.0 to 1.0 within a shape range.
1834 The actual grid spacing can slightly differ from the defined one. This is done for the
1835 best fitting of polyhedrons and for a better mesh quality on the interval boundaries.
1836 For example, if a constant **Spacing** is defined along an axis, the actual grid will
1837 fill the shape's dimension L along this axis with round number of equal cells:
1838 Spacing_actual = L / round( L / Spacing_defined ).
1841 "10.5" - defines a grid with a constant spacing
1842 [["1", "1+10*t", "11"] [0.1, 0.6]] - defines different spacing in 3 ranges.
1845 yGridDef: defines the grid along the Y asix the same way as *xGridDef* does.
1846 zGridDef: defines the grid along the Z asix the same way as *xGridDef* does.
1847 sizeThreshold: (> 1.0) defines a minimal size of a polyhedron so that
1848 a polyhedron of size less than hexSize/sizeThreshold is not created.
1849 implEdges: enables implementation of geometrical edges into the mesh.
1852 compFun = lambda hyp, args: False
1853 self.hyp = self.Hypothesis("CartesianParameters3D",
1854 [xGridDef, yGridDef, zGridDef, sizeThreshold],
1855 UseExisting=False, CompareMethod=compFun)
1856 if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
1857 self.mesh.AddHypothesis( self.hyp, self.geom )
1859 for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef] ):
1860 if not gridDef: raise ValueError("Empty grid definition")
1861 if isinstance( gridDef, str ):
1862 self.hyp.SetGridSpacing( [gridDef], [], axis )
1863 elif isinstance( gridDef[0], str ):
1864 self.hyp.SetGridSpacing( gridDef, [], axis )
1865 elif isinstance( gridDef[0], int ) or \
1866 isinstance( gridDef[0], float ):
1867 self.hyp.SetGrid(gridDef, axis )
1869 self.hyp.SetGridSpacing( gridDef[0], gridDef[1], axis )
1870 self.hyp.SetSizeThreshold( sizeThreshold )
1871 self.hyp.SetToAddEdges( implEdges )
1874 def SetAxesDirs( self, xAxis, yAxis, zAxis ):
1876 Defines custom directions of axes of the grid
1879 xAxis: either SMESH.DirStruct or a vector, or 3 vector components
1880 yAxis: either SMESH.DirStruct or a vector, or 3 vector components
1881 zAxis: either SMESH.DirStruct or a vector, or 3 vector components
1884 if hasattr( xAxis, "__getitem__" ):
1885 xAxis = self.mesh.smeshpyD.MakeDirStruct( xAxis[0],xAxis[1],xAxis[2] )
1886 elif isinstance( xAxis, GEOM._objref_GEOM_Object ):
1887 xAxis = self.mesh.smeshpyD.GetDirStruct( xAxis )
1888 if hasattr( yAxis, "__getitem__" ):
1889 yAxis = self.mesh.smeshpyD.MakeDirStruct( yAxis[0],yAxis[1],yAxis[2] )
1890 elif isinstance( yAxis, GEOM._objref_GEOM_Object ):
1891 yAxis = self.mesh.smeshpyD.GetDirStruct( yAxis )
1892 if hasattr( zAxis, "__getitem__" ):
1893 zAxis = self.mesh.smeshpyD.MakeDirStruct( zAxis[0],zAxis[1],zAxis[2] )
1894 elif isinstance( zAxis, GEOM._objref_GEOM_Object ):
1895 zAxis = self.mesh.smeshpyD.GetDirStruct( zAxis )
1897 self.hyp = self.Hypothesis("CartesianParameters3D")
1898 if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
1899 self.mesh.AddHypothesis( self.hyp, self.geom )
1900 self.hyp.SetAxesDirs( xAxis, yAxis, zAxis )
1903 def SetOptimalAxesDirs(self, isOrthogonal=True):
1905 Automatically defines directions of axes of the grid at which
1906 a number of generated hexahedra is maximal
1909 isOrthogonal: defines whether the axes mush be orthogonal
1912 self.hyp = self.Hypothesis("CartesianParameters3D")
1913 if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
1914 self.mesh.AddHypothesis( self.hyp, self.geom )
1915 x,y,z = self.hyp.ComputeOptimalAxesDirs( self.geom, isOrthogonal )
1916 self.hyp.SetAxesDirs( x,y,z )
1919 def SetFixedPoint( self, p, toUnset=False ):
1921 Sets/unsets a fixed point. The algorithm makes a plane of the grid pass
1922 through the fixed point in each direction at which the grid is defined
1926 p: coordinates of the fixed point. Either SMESH.PointStruct or
1927 a vertex or 3 components of coordinates.
1928 toUnset: defines whether the fixed point is defined or removed.
1932 if not self.hyp: return
1933 p = SMESH.PointStruct(0,0,0)
1934 elif hasattr( p, "__getitem__" ):
1935 p = SMESH.PointStruct( p[0],p[1],p[2] )
1936 elif isinstance( p, GEOM._objref_GEOM_Object ):
1937 p = self.mesh.smeshpyD.GetPointStruct( p )
1939 self.hyp = self.Hypothesis("CartesianParameters3D")
1940 if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
1941 self.mesh.AddHypothesis( self.hyp, self.geom )
1942 self.hyp.SetFixedPoint( p, toUnset )
1946 pass # end of StdMeshersBuilder_Cartesian_3D class
1948 class StdMeshersBuilder_UseExisting_1D(Mesh_Algorithm):
1949 """ Defines a stub 1D algorithm, which enables "manual" creation of nodes and
1950 segments usable by 2D algorithms.
1952 It is created by calling smeshBuilder.Mesh.UseExistingSegments(geom=0)
1956 meshMethod = "UseExistingSegments"
1958 name of the dynamic method in smeshBuilder.Mesh class
1960 algoType = "UseExisting_1D"
1962 type of algorithm used with helper function in smeshBuilder.Mesh class
1964 docHelper = "Create 1D algorithm allowing batch meshing of edges"
1966 doc string of the method
1969 def __init__(self, mesh, geom=0):
1971 Private constructor.
1974 mesh: parent mesh object algorithm is assigned to
1975 geom: geometry (shape/sub-shape) algorithm is assigned to;
1976 if it is :code:`0` (default), the algorithm is assigned to the main shape
1978 self.Create(mesh, geom, self.algoType)
1981 pass # end of StdMeshersBuilder_UseExisting_1D class
1983 class StdMeshersBuilder_UseExisting_2D(Mesh_Algorithm):
1984 """ Defines a stub 2D algorithm, which enables "manual" creation of nodes and
1985 faces usable by 3D algorithms.
1987 It is created by calling smeshBuilder.Mesh.UseExistingFaces(geom=0)
1991 meshMethod = "UseExistingFaces"
1993 name of the dynamic method in smeshBuilder.Mesh class
1995 algoType = "UseExisting_2D"
1997 type of algorithm used with helper function in smeshBuilder.Mesh class
1999 docHelper = "Create 2D algorithm allowing batch meshing of faces"
2001 doc string of the method
2004 def __init__(self, mesh, geom=0):
2006 Private constructor.
2009 mesh: parent mesh object algorithm is assigned to
2010 geom: geometry (shape/sub-shape) algorithm is assigned to;
2011 if it is :code:`0` (default), the algorithm is assigned to the main shape
2013 self.Create(mesh, geom, self.algoType)
2016 pass # end of StdMeshersBuilder_UseExisting_2D class
2018 class StdMeshersBuilder_ViscousLayer(Mesh_Algorithm):
2019 """ Defines the prismatic layer builder.
2021 It is created by calling smeshBuilder.Mesh.ViscousLayerBuilder(geom=TheGeometry)
2024 meshMethod = "ViscousLayerBuilder"
2026 name of the dynamic method in smeshBuilder.Mesh class
2028 algoType = "ViscousLayerBuilder"
2030 type of algorithm used with helper function in smeshBuilder.Mesh class
2032 docHelper = "Viscous layer builder for 2D and 3D geometries"
2034 doc string of the method
2037 # On create method it will call create method from mesh python class
2039 def __init__(self, mesh, geom = 0 ):
2041 Private constructor.
2044 mesh: parent mesh object algorithm is assigned to
2045 geom: geometry (shape/sub-shape) algorithm is assigned to;
2046 if it is :code:`0` (default), the algorithm is assigned to the main shape
2048 self.thickness = None
2049 self.numberOfLayers = None
2050 self.stretchFactor = None
2051 self.elementsId = []
2052 self.isElementToIgnore = True
2053 self.extrMethod = StdMeshers.SURF_OFFSET_SMOOTH
2055 self.shrinkGeometry = None
2056 self.algo = self.Create(mesh, geom, self.algoType)
2059 def setBuilderParameters( self, thickness, numberOfLayers, stretchFactor, elementsId=[],
2060 isElementToIgnore=True, extrMethod=StdMeshers.SURF_OFFSET_SMOOTH, groupName="" ):
2061 self.thickness = thickness
2062 self.numberOfLayers = numberOfLayers
2063 self.stretchFactor = stretchFactor
2064 self.elementsId = elementsId # can be faces or edges
2065 self.isElementToIgnore = isElementToIgnore
2066 self.extrMethod = extrMethod
2067 self.groupName = groupName
2069 self.algo.SetTotalThickness( thickness )
2070 self.algo.SetNumberLayers( numberOfLayers )
2071 self.algo.SetStretchFactor( stretchFactor )
2073 #Faces are set based on int ids so if a collection of face geom objects is recived cast it to int
2074 if elementsId and isinstance( elementsId, geomBuilder.GEOM._objref_GEOM_Object ):
2075 elementsId = [ elementsId ]
2076 if elementsId and isinstance( elementsId[0], geomBuilder.GEOM._objref_GEOM_Object ):
2078 for shape in elementsId:
2080 ff = self.mesh.geompyD.SubShapeAll( shape, self.mesh.geompyD.ShapeType["FACE"] )
2081 if ( len( ff ) == 0 ):
2083 ff = self.mesh.geompyD.SubShapeAll( shape, self.mesh.geompyD.ShapeType["EDGE"] )
2086 elementsIDs.append( self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f))
2088 # try to get the SHAPERSTUDY engine directly, because GetGen does not work because of
2089 # simplification of access in geomBuilder: omniORB.registerObjref
2090 from SHAPERSTUDY_utils import getEngine
2093 aShapeOp = gen.GetIShapesOperations()
2094 ff = aShapeOp.ExtractSubShapes( shape, self.mesh.geompyD.ShapeType["FACE"], False)
2097 ff = aShapeOp.ExtractSubShapes( shape, self.mesh.geompyD.ShapeType["EDGE"], False)
2099 elementsIDs.append( aShapeOp.GetSubShapeIndex( self.mesh.geom, f ))
2100 elementsId = elementsIDs
2102 self.algo.SetFaces( elementsId, isElementToIgnore )
2103 self.algo.SetGroupName( groupName )
2104 self.algo.SetMethod( extrMethod )
2106 def GetShrinkGeometry( self ):
2107 if isinstance(self.geom, geomBuilder.GEOM._objref_GEOM_Object):
2108 self.shrinkGeometry = self.algo.GetShrinkGeometry( self.mesh.GetMesh(), self.geom )
2110 return self.shrinkGeometry
2112 def AddLayers( self, shrinkMesh ):
2113 success = self.algo.AddLayers( shrinkMesh.GetMesh(), self.mesh.GetMesh(), self.geom )
2115 return self.mesh #Return the original mesh of the builder
2119 pass # end of StdMeshersBuilder_ViscousLayer class