1 # Copyright (C) 2007-2024 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 quadType is None - will used default parameter ( StdMeshers.QUAD_STANDARD )
743 if quadType and self.params.GetQuadType() != quadType:
744 self.params.SetQuadType(quadType)
745 #If triangleVertex is None - will used default parameter ( -1 ):
746 if triangleVertex and vertexID > 0:
747 self.params.SetTriaVertex( vertexID )
748 from salome.smesh.smeshBuilder import AssureGeomPublished
749 for v in enfVertices:
750 AssureGeomPublished( self.mesh, v )
751 self.params.SetEnforcedNodes( enfVertices, pStructs )
752 self.params.SetCorners( corners )
755 def QuadranglePreference(self, reversed=False, UseExisting=0):
757 Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
758 quadrangles are built in the transition area along the finer meshed sides,
759 if the total quantity of segments on all four sides of the face is even.
762 reversed: if True, transition area is located along the coarser meshed sides.
763 UseExisting: if ==true - searches for the existing hypothesis created with
764 the same parameters, else (default) - Create a new one
768 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
769 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
771 def TrianglePreference(self, UseExisting=0):
773 Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
774 triangles are built in the transition area along the finer meshed sides.
777 UseExisting: if ==true - searches for the existing hypothesis created with
778 the same parameters, else (default) - Create a new one
781 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
783 def Reduced(self, UseExisting=0):
785 Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
786 quadrangles are built and the transition between the sides is made gradually,
787 layer by layer. This type has a limitation on the number of segments: one pair
788 of opposite sides must have the same number of segments, the other pair must
789 have an even difference between the numbers of segments on the sides.
792 UseExisting: if ==true - searches for the existing hypothesis created with
793 the same parameters, else (default) - Create a new one
796 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
798 def TriangleVertex(self, vertex, UseExisting=0):
800 Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
803 vertex: vertex of a trilateral geometrical face, around which triangles
804 will be created while other elements will be quadrangles.
805 Vertex can be either a GEOM_Object or a vertex ID within the
807 UseExisting: if ==true - searches for the existing hypothesis created with
808 the same parameters, else (default) - Create a new one
811 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
813 pass # end of StdMeshersBuilder_Quadrangle class
815 class StdMeshersBuilder_Hexahedron(Mesh_Algorithm):
817 Defines a hexahedron 3D algorithm.
818 It is created by calling smeshBuilder.Mesh.Hexahedron(geom=0)
822 meshMethod = "Hexahedron"
824 name of the dynamic method in smeshBuilder.Mesh class
828 type of algorithm used with helper function in smeshBuilder.Mesh class
832 flag pointing whether this algorithm should be used by default in dynamic method
833 of smeshBuilder.Mesh class
835 docHelper = "Create hexahedron 3D algorithm for volumes"
837 doc string of the method
840 def __init__(self, mesh, geom=0):
845 mesh: parent mesh object algorithm is assigned to
846 geom: geometry (shape/sub-shape) algorithm is assigned to;
847 if it is :code:`0` (default), the algorithm is assigned to the main shape
849 Mesh_Algorithm.__init__(self)
850 self.Create(mesh, geom, Hexa)
851 self.renumHypothesis = 0
854 def Renumber(self, blockCSList=[] ):
855 if isinstance( blockCSList, StdMeshers.BlockCS ):
856 blockCSList = [blockCSList]
857 if not self.renumHypothesis:
858 self.renumHypothesis = self.Hypothesis("BlockRenumber", blockCSList, UseExisting=0)
859 self.renumHypothesis.SetBlocksOrientation( blockCSList )
860 return self.renumHypothesis
862 pass # end of StdMeshersBuilder_Hexahedron class
864 class StdMeshersBuilder_Projection1D(Mesh_Algorithm):
866 Defines a projection 1D algorithm.
867 It is created by calling smeshBuilder.Mesh.Projection1D(geom=0)
871 meshMethod = "Projection1D"
873 name of the dynamic method in smeshBuilder.Mesh class
875 algoType = "Projection_1D"
877 type of algorithm used with helper function in smeshBuilder.Mesh class
881 flag pointing whether this algorithm should be used by default in dynamic method
882 of smeshBuilder.Mesh class
884 docHelper = "Create projection 1D algorithm for edges"
886 doc string of the method
888 def __init__(self, mesh, geom=0):
893 mesh: parent mesh object algorithm is assigned to
894 geom: geometry (shape/sub-shape) algorithm is assigned to;
895 if it is :code:`0` (default), the algorithm is assigned to the main shape
897 Mesh_Algorithm.__init__(self)
898 self.Create(mesh, geom, self.algoType)
901 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
903 Defines "Source Edge" hypothesis, specifying a meshed edge, from where
904 a mesh pattern is taken, and, optionally, the association of vertices
905 between the source edge and a target edge (to which a hypothesis is assigned)
908 edge: from which nodes distribution is taken
909 mesh: from which nodes distribution is taken (optional)
910 srcV: a vertex of *edge* to associate with *tgtV* (optional)
911 tgtV: a vertex of *the edge* to which the algorithm is assigned, to associate with *srcV* (optional)
912 UseExisting: if ==true - searches for the existing hypothesis created with
913 the same parameters, else (default) - Create a new one
915 from salome.smesh.smeshBuilder import AssureGeomPublished, Mesh
916 AssureGeomPublished( self.mesh, edge )
917 AssureGeomPublished( self.mesh, srcV )
918 AssureGeomPublished( self.mesh, tgtV )
919 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
921 # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
922 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
923 hyp.SetSourceEdge( edge )
924 if not mesh is None and isinstance(mesh, Mesh):
925 mesh = mesh.GetMesh()
926 hyp.SetSourceMesh( mesh )
927 hyp.SetVertexAssociation( srcV, tgtV )
930 pass # end of StdMeshersBuilder_Projection1D class
932 class StdMeshersBuilder_Projection2D(Mesh_Algorithm):
934 Defines a projection 2D algorithm.
935 It is created by calling smeshBuilder.Mesh.Projection2D(geom=0)
939 meshMethod = "Projection2D"
941 name of the dynamic method in smeshBuilder.Mesh class
943 algoType = "Projection_2D"
945 type of algorithm used with helper function in smeshBuilder.Mesh class
949 flag pointing whether this algorithm should be used by default in dynamic method
950 of smeshBuilder.Mesh class
952 docHelper = "Create projection 2D algorithm for faces"
954 doc string of the method
957 def __init__(self, mesh, geom=0):
962 mesh: parent mesh object algorithm is assigned to
963 geom: geometry (shape/sub-shape) algorithm is assigned to;
964 if it is :code:`0` (default), the algorithm is assigned to the main shape
966 Mesh_Algorithm.__init__(self)
967 self.Create(mesh, geom, self.algoType)
971 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
972 srcV2=None, tgtV2=None, UseExisting=0):
974 Defines "Source Face" hypothesis, specifying a meshed face, from where
975 a mesh pattern is taken, and, optionally, the association of vertices
976 between the source face and the target face (to which a hypothesis is assigned)
979 face: from which the mesh pattern is taken
980 mesh: from which the mesh pattern is taken (optional)
981 srcV1: a vertex of *face* to associate with *tgtV1* (optional)
982 tgtV1: a vertex of *the face* to which the algorithm is assigned, to associate with *srcV1* (optional)
983 srcV2: a vertex of *face* to associate with *tgtV1* (optional)
984 tgtV2: a vertex of *the face* to which the algorithm is assigned, to associate with *srcV2* (optional)
985 UseExisting: if ==true - forces the search for the existing hypothesis created with
986 he same parameters, else (default) - forces the creation a new one
989 all association vertices must belong to one edge of a face
991 from salome.smesh.smeshBuilder import Mesh
992 if isinstance(mesh, Mesh):
993 mesh = mesh.GetMesh()
994 for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
995 from salome.smesh.smeshBuilder import AssureGeomPublished
996 AssureGeomPublished( self.mesh, geom )
997 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
998 UseExisting=0, toAdd=False)
999 # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
1000 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
1001 hyp.SetSourceFace( face )
1002 hyp.SetSourceMesh( mesh )
1003 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
1004 self.mesh.AddHypothesis(hyp, self.geom)
1007 pass # end of StdMeshersBuilder_Projection2D class
1009 class StdMeshersBuilder_Projection1D2D(StdMeshersBuilder_Projection2D):
1011 Defines a projection 1D-2D algorithm.
1012 It is created by calling smeshBuilder.Mesh.Projection1D2D(geom=0)
1016 meshMethod = "Projection1D2D"
1018 name of the dynamic method in smeshBuilder.Mesh class
1020 algoType = "Projection_1D2D"
1022 type of algorithm used with helper function in smeshBuilder.Mesh class
1024 docHelper = "Create projection 1D-2D algorithm for faces"
1026 doc string of the method
1029 def __init__(self, mesh, geom=0):
1031 Private constructor.
1034 mesh: parent mesh object algorithm is assigned to
1035 geom: geometry (shape/sub-shape) algorithm is assigned to;
1036 if it is :code:`0` (default), the algorithm is assigned to the main shape
1038 StdMeshersBuilder_Projection2D.__init__(self, mesh, geom)
1041 pass # end of StdMeshersBuilder_Projection1D2D class
1043 class StdMeshersBuilder_Projection3D(Mesh_Algorithm):
1045 Defines a projection 3D algorithm.
1046 It is created by calling smeshBuilder.Mesh.Projection3D(geom=0)
1050 meshMethod = "Projection3D"
1052 name of the dynamic method in smeshBuilder.Mesh class
1054 algoType = "Projection_3D"
1056 type of algorithm used with helper function in smeshBuilder.Mesh class
1058 docHelper = "Create projection 3D algorithm for volumes"
1060 doc string of the method
1063 def __init__(self, mesh, geom=0):
1065 Private constructor.
1068 mesh: parent mesh object algorithm is assigned to
1069 geom" geometry (shape/sub-shape) algorithm is assigned to;
1070 if it is :code:`0` (default), the algorithm is assigned to the main shape
1072 Mesh_Algorithm.__init__(self)
1073 self.Create(mesh, geom, self.algoType)
1076 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
1077 srcV2=0, tgtV2=0, UseExisting=0):
1079 Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
1080 the mesh pattern is taken, and, optionally, the association of vertices
1081 between the source and the target solid (to which a hipothesis is assigned)
1084 solid: from where the mesh pattern is taken
1085 mesh: from where the mesh pattern is taken (optional)
1086 srcV1: a vertex of *solid* to associate with *tgtV1* (optional)
1087 tgtV1: a vertex of *the solid* where the algorithm is assigned, to associate with *srcV1* (optional)
1088 srcV2: a vertex of *solid* to associate with *tgtV1* (optional)
1089 tgtV2: a vertex of *the solid* to which the algorithm is assigned,to associate with *srcV2* (optional)
1090 UseExisting: if ==true - searches for the existing hypothesis created with
1091 the same parameters, else (default) - Create a new one
1094 association vertices must belong to one edge of a solid
1096 for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
1097 from salome.smesh.smeshBuilder import AssureGeomPublished
1098 AssureGeomPublished( self.mesh, geom )
1099 hyp = self.Hypothesis("ProjectionSource3D",
1100 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
1102 # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
1103 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
1104 hyp.SetSource3DShape( solid )
1105 from salome.smesh.smeshBuilder import Mesh
1106 if isinstance(mesh, Mesh):
1107 mesh = mesh.GetMesh()
1109 hyp.SetSourceMesh( mesh )
1110 if srcV1 and srcV2 and tgtV1 and tgtV2:
1111 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
1112 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
1115 pass # end of StdMeshersBuilder_Projection3D class
1117 class StdMeshersBuilder_Prism3D(Mesh_Algorithm):
1119 Defines a Prism 3D algorithm, which is either "Extrusion 3D" or "Radial Prism" depending on geometry.
1120 It is created by calling smeshBuilder.Mesh.Prism(geom=0)
1124 meshMethod = "Prism"
1126 name of the dynamic method in smeshBuilder.Mesh class
1128 algoType = "Prism_3D"
1130 type of algorithm used with helper function in smeshBuilder.Mesh class
1132 docHelper = "Create prism 3D algorithm for volumes"
1134 doc string of the method
1138 flag pointing whether this algorithm should be used by default in dynamic method
1139 of smeshBuilder.Mesh class
1142 def __init__(self, mesh, geom=0):
1144 Private constructor.
1147 mesh: parent mesh object algorithm is assigned to
1148 geom: geometry (shape/sub-shape) algorithm is assigned to;
1149 if it is :code:`0` (default), the algorithm is assigned to the main shape
1151 Mesh_Algorithm.__init__(self)
1156 isRadial = mesh.smeshpyD.IsApplicable("RadialPrism_3D", LIBRARY, shape, False )
1158 self.Create(mesh, geom, "Prism_3D")
1161 self.algoType = "RadialPrism_3D"
1162 self.Create(mesh, geom, "RadialPrism_3D")
1163 self.distribHyp = None #self.Hypothesis("LayerDistribution", UseExisting=0)
1164 self.nbLayers = None
1168 def Get3DHypothesis(self):
1171 3D hypothesis holding the 1D one
1173 if self.algoType != "RadialPrism_3D":
1174 print("Prism_3D algorithm doesn't support any hypothesis")
1176 return self.distribHyp
1178 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
1180 Private method creating a 1D hypothesis and storing it in the LayerDistribution
1184 the created hypothesis
1186 if self.algoType != "RadialPrism_3D":
1187 print("Prism_3D algorithm doesn't support any hypothesis")
1189 if not self.nbLayers is None:
1190 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
1191 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
1192 self.mesh.smeshpyD.SetEnablePublish( False ) # prevents publishing own 1D hypothesis
1193 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
1194 self.mesh.smeshpyD.SetEnablePublish( True ) # enables publishing
1195 if not self.distribHyp:
1196 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
1197 self.distribHyp.SetLayerDistribution( hyp )
1200 def NumberOfLayers(self, n, UseExisting=0):
1202 Defines "NumberOfLayers" hypothesis, specifying the number of layers of
1203 prisms to build between the inner and outer shells
1207 UseExisting: if ==true - searches for the existing hypothesis created with
1208 the same parameters, else (default) - Create a new one
1210 if self.algoType != "RadialPrism_3D":
1211 print("Prism_3D algorithm doesn't support any hypothesis")
1213 self.mesh.RemoveHypothesis( self.distribHyp, self.geom )
1214 from salome.smesh.smeshBuilder import IsEqual
1215 compFun = lambda hyp, args: IsEqual(hyp.GetNumberOfLayers(), args[0])
1216 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
1217 CompareMethod=compFun)
1218 self.nbLayers.SetNumberOfLayers( n )
1219 return self.nbLayers
1221 def LocalLength(self, l, p=1e-07):
1223 Defines "LocalLength" hypothesis, specifying the segment length
1224 to build between the inner and the outer shells
1227 l: the length of segments
1228 p: the precision of rounding
1230 if self.algoType != "RadialPrism_3D":
1231 print("Prism_3D algorithm doesn't support any hypothesis")
1233 hyp = self.OwnHypothesis("LocalLength", [l,p])
1238 def NumberOfSegments(self, n, s=[]):
1240 Defines "NumberOfSegments" hypothesis, specifying the number of layers of
1241 prisms to build between the inner and the outer shells.
1244 n: the number of layers
1245 s: the scale factor (optional)
1247 if self.algoType != "RadialPrism_3D":
1248 print("Prism_3D algorithm doesn't support any hypothesis")
1251 hyp = self.OwnHypothesis("NumberOfSegments", [n])
1253 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
1254 hyp.SetScaleFactor(s)
1255 hyp.SetNumberOfSegments(n)
1258 def Arithmetic1D(self, start, end ):
1260 Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
1261 to build between the inner and the outer shells with a length that changes
1262 in arithmetic progression
1265 start: the length of the first segment
1266 end: the length of the last segment
1268 if self.algoType != "RadialPrism_3D":
1269 print("Prism_3D algorithm doesn't support any hypothesis")
1271 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
1272 hyp.SetLength(start, 1)
1273 hyp.SetLength(end , 0)
1276 def GeometricProgression(self, start, ratio ):
1278 Defines "GeometricProgression" hypothesis, specifying the distribution of segments
1279 to build between the inner and the outer shells with a length that changes
1280 in Geometric progression
1283 start: the length of the first segment
1284 ratio: the common ratio of the geometric progression
1286 if self.algoType != "RadialPrism_3D":
1287 print("Prism_3D algorithm doesn't support any hypothesis")
1289 hyp = self.OwnHypothesis("GeometricProgression", [start, ratio])
1290 hyp.SetStartLength( start )
1291 hyp.SetCommonRatio( ratio )
1294 def StartEndLength(self, start, end):
1296 Defines "StartEndLength" hypothesis, specifying distribution of segments
1297 to build between the inner and the outer shells as geometric length increasing
1300 start: for the length of the first segment
1301 end: for the length of the last segment
1303 if self.algoType != "RadialPrism_3D":
1304 print("Prism_3D algorithm doesn't support any hypothesis")
1306 hyp = self.OwnHypothesis("StartEndLength", [start, end])
1307 hyp.SetLength(start, 1)
1308 hyp.SetLength(end , 0)
1311 def AutomaticLength(self, fineness=0):
1313 Defines "AutomaticLength" hypothesis, specifying the number of segments
1314 to build between the inner and outer shells
1317 fineness: defines the quality of the mesh within the range [0-1]
1319 if self.algoType != "RadialPrism_3D":
1320 print("Prism_3D algorithm doesn't support any hypothesis")
1322 hyp = self.OwnHypothesis("AutomaticLength")
1323 hyp.SetFineness( fineness )
1326 pass # end of StdMeshersBuilder_Prism3D class
1328 class StdMeshersBuilder_RadialPrism3D(StdMeshersBuilder_Prism3D):
1330 Defines Radial Prism 3D algorithm.
1331 It is created by calling smeshBuilder.Mesh.Prism(geom=0).
1332 See :class:`StdMeshersBuilder_Prism3D` for methods defining distribution of mesh layers
1333 build between the inner and outer shells.
1336 meshMethod = "Prism"
1338 name of the dynamic method in smeshBuilder.Mesh class
1340 algoType = "RadialPrism_3D"
1342 type of algorithm used with helper function in smeshBuilder.Mesh class
1344 docHelper = "Create Raial Prism 3D algorithm for volumes"
1346 doc string of the method
1349 def __init__(self, mesh, geom=0):
1351 Private constructor.
1354 mesh: parent mesh object algorithm is assigned to
1355 geom: geometry (shape/sub-shape) algorithm is assigned to;
1356 if it is :code:`0` (default), the algorithm is assigned to the main shape
1358 Mesh_Algorithm.__init__(self)
1363 self.Create(mesh, geom, "RadialPrism_3D")
1364 self.distribHyp = None
1365 self.nbLayers = None
1368 class StdMeshersBuilder_RadialAlgorithm(Mesh_Algorithm):
1370 Base class for algorithms supporting radial distribution hypotheses
1374 Mesh_Algorithm.__init__(self)
1376 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
1377 self.nbLayers = None
1380 def Get2DHypothesis(self):
1383 2D hypothesis holding the 1D one
1385 if not self.distribHyp:
1386 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
1387 return self.distribHyp
1389 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
1391 Private method creating a 1D hypothesis and storing it in the LayerDistribution
1395 the created hypothesis
1398 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
1399 if self.distribHyp is None:
1400 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
1402 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
1403 self.mesh.smeshpyD.SetEnablePublish( False )
1404 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
1405 self.mesh.smeshpyD.SetEnablePublish( True )
1406 self.distribHyp.SetLayerDistribution( hyp )
1409 def NumberOfLayers(self, n, UseExisting=0):
1411 Defines "NumberOfLayers" hypothesis, specifying the number of layers
1415 UseExisting: if ==true - searches for the existing hypothesis created with
1416 the same parameters, else (default) - Create a new one
1419 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
1420 from salome.smesh.smeshBuilder import IsEqual
1421 compFun = lambda hyp, args: IsEqual(hyp.GetNumberOfLayers(), args[0])
1422 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
1423 CompareMethod=compFun)
1424 self.nbLayers.SetNumberOfLayers( n )
1425 return self.nbLayers
1427 def LocalLength(self, l, p=1e-07):
1429 Defines "LocalLength" hypothesis, specifying the segment length
1432 l: the length of segments
1433 p: the precision of rounding
1435 hyp = self.OwnHypothesis("LocalLength", [l,p])
1440 def NumberOfSegments(self, n, s=[]):
1442 Defines "NumberOfSegments" hypothesis, specifying the number of layers
1445 n: the number of layers
1446 s: the scale factor (optional)
1449 hyp = self.OwnHypothesis("NumberOfSegments", [n])
1451 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
1452 hyp.SetDistrType( 1 )
1453 hyp.SetScaleFactor(s)
1454 hyp.SetNumberOfSegments(n)
1457 def Arithmetic1D(self, start, end ):
1459 Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
1460 with a length that changes in arithmetic progression
1463 start: the length of the first segment
1464 end: the length of the last segment
1466 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
1467 hyp.SetLength(start, 1)
1468 hyp.SetLength(end , 0)
1471 def GeometricProgression(self, start, ratio ):
1473 Defines "GeometricProgression" hypothesis, specifying the distribution of segments
1474 with a length that changes in Geometric progression
1477 start: the length of the first segment
1478 ratio: the common ratio of the geometric progression
1480 hyp = self.OwnHypothesis("GeometricProgression", [start, ratio])
1481 hyp.SetStartLength( start )
1482 hyp.SetCommonRatio( ratio )
1485 def StartEndLength(self, start, end):
1487 Defines "StartEndLength" hypothesis, specifying distribution of segments
1488 as geometric length increasing
1491 start: for the length of the first segment
1492 end: for the length of the last segment
1494 hyp = self.OwnHypothesis("StartEndLength", [start, end])
1495 hyp.SetLength(start, 1)
1496 hyp.SetLength(end , 0)
1499 def AutomaticLength(self, fineness=0):
1501 Defines "AutomaticLength" hypothesis, specifying the number of segments
1504 fineness: defines the quality of the mesh within the range [0-1]
1506 hyp = self.OwnHypothesis("AutomaticLength")
1507 hyp.SetFineness( fineness )
1510 pass # end of StdMeshersBuilder_RadialQuadrangle1D2D class
1512 class StdMeshersBuilder_RadialQuadrangle1D2D(StdMeshersBuilder_RadialAlgorithm):
1514 Defines a Radial Quadrangle 1D-2D algorithm.
1515 It is created by calling smeshBuilder.Mesh.Quadrangle(smeshBuilder.RADIAL_QUAD,geom=0)
1518 meshMethod = "Quadrangle"
1520 name of the dynamic method in smeshBuilder.Mesh class
1522 algoType = RADIAL_QUAD
1524 type of algorithm used with helper function in smeshBuilder.Mesh class
1526 docHelper = "Create quadrangle 1D-2D algorithm for faces having a shape of disk or a disk segment"
1528 doc string of the method
1531 def __init__(self, mesh, geom=0):
1533 Private constructor.
1536 mesh: parent mesh object algorithm is assigned to
1537 geom: geometry (shape/sub-shape) algorithm is assigned to;
1538 if it is :code:`0` (default), the algorithm is assigned to the main shape
1540 StdMeshersBuilder_RadialAlgorithm.__init__(self)
1541 self.Create(mesh, geom, self.algoType)
1543 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
1544 self.nbLayers = None
1548 class StdMeshersBuilder_QuadMA_1D2D(StdMeshersBuilder_RadialAlgorithm):
1550 Defines a Quadrangle (Medial Axis Projection) 1D-2D algorithm .
1551 It is created by calling smeshBuilder.Mesh.Quadrangle(smeshBuilder.QUAD_MA_PROJ,geom=0)
1554 meshMethod = "Quadrangle"
1556 name of the dynamic method in smeshBuilder.Mesh class
1558 algoType = QUAD_MA_PROJ
1560 type of algorithm used with helper function in smeshBuilder.Mesh class
1562 docHelper = "Create quadrangle 1D-2D algorithm for faces"
1564 doc string of the method
1567 def __init__(self, mesh, geom=0):
1569 Private constructor.
1572 mesh: parent mesh object algorithm is assigned to
1573 geom: geometry (shape/sub-shape) algorithm is assigned to;
1574 if it is :code:`0` (default), the algorithm is assigned to the main shape
1576 StdMeshersBuilder_RadialAlgorithm.__init__(self)
1577 self.Create(mesh, geom, self.algoType)
1582 class StdMeshersBuilder_PolygonPerFace(Mesh_Algorithm):
1583 """ Defines a Polygon Per Face 2D algorithm.
1584 It is created by calling smeshBuilder.Mesh.Polygon(geom=0)
1587 meshMethod = "Polygon"
1589 name of the dynamic method in smeshBuilder.Mesh class
1593 type of algorithm used with helper function in smeshBuilder.Mesh class
1597 flag pointing whether this algorithm should be used by default in dynamic method
1598 of smeshBuilder.Mesh class
1600 docHelper = "Create polygon 2D algorithm for faces"
1602 doc string of the method
1605 def __init__(self, mesh, geom=0):
1607 Private constructor.
1610 mesh: parent mesh object algorithm is assigned to
1611 geom: geometry (shape/sub-shape) algorithm is assigned to;
1612 if it is :code:`0` (default), the algorithm is assigned to the main shape
1614 Mesh_Algorithm.__init__(self)
1615 self.Create(mesh, geom, self.algoType)
1620 class StdMeshersBuilder_PolyhedronPerSolid(Mesh_Algorithm):
1621 """ Defines a Polyhedron Per Solid 3D algorithm.
1622 It is created by calling smeshBuilder.Mesh.Polyhedron(geom=0)
1625 meshMethod = "Polyhedron"
1627 name of the dynamic method in smeshBuilder.Mesh class
1629 algoType = POLYHEDRON
1631 type of algorithm used with helper function in smeshBuilder.Mesh class
1635 flag pointing whether this algorithm should be used by default in dynamic method
1636 of smeshBuilder.Mesh class
1638 docHelper = "Create polyhedron 3D algorithm for solids"
1640 doc string of the method
1643 def __init__(self, mesh, geom=0):
1645 Private constructor.
1648 mesh: parent mesh object algorithm is assigned to
1649 geom: geometry (shape/sub-shape) algorithm is assigned to;
1650 if it is :code:`0` (default), the algorithm is assigned to the main shape
1652 Mesh_Algorithm.__init__(self)
1653 self.Create(mesh, geom, self.algoType)
1658 class StdMeshersBuilder_UseExistingElements_1D(Mesh_Algorithm):
1659 """ Defines a Use Existing Elements 1D algorithm.
1661 It is created by calling smeshBuilder.Mesh.UseExisting1DElements(geom=0)
1665 meshMethod = "UseExisting1DElements"
1667 name of the dynamic method in smeshBuilder.Mesh class
1669 algoType = "Import_1D"
1671 type of algorithm used with helper function in smeshBuilder.Mesh class
1675 flag pointing whether this algorithm should be used by default in dynamic method
1676 of smeshBuilder.Mesh class
1678 docHelper = "Create 1D algorithm for edges with reusing of existing mesh elements"
1680 doc string of the method
1683 def __init__(self, mesh, geom=0):
1685 Private constructor.
1688 mesh: parent mesh object algorithm is assigned to
1689 geom: geometry (shape/sub-shape) algorithm is assigned to;
1690 if it is :code:`0` (default), the algorithm is assigned to the main shape
1692 Mesh_Algorithm.__init__(self)
1693 self.Create(mesh, geom, self.algoType)
1696 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
1698 Defines "Source edges" hypothesis, specifying groups of edges to import
1701 groups: list of groups of edges
1702 toCopyMesh: if True, the whole mesh *groups* belong to is imported
1703 toCopyGroups: if True, all groups of the mesh *groups* belong to are imported
1704 UseExisting: if ==true - searches for the existing hypothesis created with
1705 the same parameters, else (default) - Create a new one
1707 for group in groups:
1708 from salome.smesh.smeshBuilder import AssureGeomPublished
1709 AssureGeomPublished( self.mesh, group )
1710 compFun = lambda hyp, args: ( hyp.GetSourceEdges() == args[0] and \
1711 hyp.GetCopySourceMesh() == args[1], args[2] )
1712 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
1713 UseExisting=UseExisting, CompareMethod=compFun)
1714 hyp.SetSourceEdges(groups)
1715 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
1718 pass # end of StdMeshersBuilder_UseExistingElements_1D class
1720 class StdMeshersBuilder_UseExistingElements_1D2D(Mesh_Algorithm):
1721 """ Defines a Use Existing Elements 1D-2D algorithm.
1723 It is created by calling smeshBuilder.Mesh.UseExisting2DElements(geom=0)
1727 meshMethod = "UseExisting2DElements"
1729 name of the dynamic method in smeshBuilder.Mesh class
1731 algoType = "Import_1D2D"
1733 type of algorithm used with helper function in smeshBuilder.Mesh class
1737 flag pointing whether this algorithm should be used by default in dynamic method
1738 of smeshBuilder.Mesh class
1740 docHelper = "Create 1D-2D algorithm for faces with reusing of existing mesh elements"
1742 doc string of the method
1745 def __init__(self, mesh, geom=0):
1747 Private constructor.
1750 mesh: parent mesh object algorithm is assigned to
1751 geom: geometry (shape/sub-shape) algorithm is assigned to;
1752 if it is :code:`0` (default), the algorithm is assigned to the main shape
1754 Mesh_Algorithm.__init__(self)
1755 self.Create(mesh, geom, self.algoType)
1758 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
1760 Defines "Source faces" hypothesis, specifying groups of faces to import
1763 groups: list of groups of faces
1764 toCopyMesh: if True, the whole mesh *groups* belong to is imported
1765 toCopyGroups: if True, all groups of the mesh *groups* belong to are imported
1766 UseExisting: if ==true - searches for the existing hypothesis created with
1767 the same parameters, else (default) - Create a new one
1770 compFun = lambda hyp, args: ( hyp.GetSourceFaces() == args[0] and \
1771 hyp.GetCopySourceMesh() == args[1], args[2] )
1772 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
1773 UseExisting=UseExisting, CompareMethod=compFun, toAdd=False)
1774 if groups and isinstance( groups, SMESH._objref_SMESH_GroupBase ):
1776 hyp.SetSourceFaces(groups)
1777 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
1778 self.mesh.AddHypothesis(hyp, self.geom)
1781 pass # end of StdMeshersBuilder_UseExistingElements_1D2D class
1783 class StdMeshersBuilder_Cartesian_3D(Mesh_Algorithm):
1784 """ Defines a Body Fitting 3D algorithm.
1786 It is created by calling smeshBuilder.Mesh.BodyFitted(geom=0)
1790 meshMethod = "BodyFitted"
1792 name of the dynamic method in smeshBuilder.Mesh class
1794 algoType = "Cartesian_3D"
1796 type of algorithm used with helper function in smeshBuilder.Mesh class
1800 flag pointing whether this algorithm should be used by default in dynamic method
1801 of smeshBuilder.Mesh class
1803 docHelper = "Create Body Fitting 3D algorithm for volumes"
1805 doc string of the method
1808 def __init__(self, mesh, geom=0):
1810 Private constructor.
1813 mesh: parent mesh object algorithm is assigned to
1814 geom: geometry (shape/sub-shape) algorithm is assigned to;
1815 if it is :code:`0` (default), the algorithm is assigned to the main shape
1817 self.Create(mesh, geom, self.algoType)
1821 def SetGrid(self, xGridDef, yGridDef, zGridDef, sizeThreshold=4.0, implEdges=False):
1823 Defines "Body Fitting parameters" hypothesis
1826 xGridDef: is definition of the grid along the X asix.
1827 It can be in either of two following forms:
1829 - Explicit coordinates of nodes, e.g. [-1.5, 0.0, 3.1] or range( -100,200,10)
1830 - Functions f(t) defining grid spacing at each point on grid axis. If there are
1831 several functions, they must be accompanied by relative coordinates of
1832 points dividing the whole shape into ranges where the functions apply; points
1833 coordinates should vary within (0.0, 1.0) range. Parameter *t* of the spacing
1834 function f(t) varies from 0.0 to 1.0 within a shape range.
1836 The actual grid spacing can slightly differ from the defined one. This is done for the
1837 best fitting of polyhedrons and for a better mesh quality on the interval boundaries.
1838 For example, if a constant **Spacing** is defined along an axis, the actual grid will
1839 fill the shape's dimension L along this axis with round number of equal cells:
1840 Spacing_actual = L / round( L / Spacing_defined ).
1843 "10.5" - defines a grid with a constant spacing
1844 [["1", "1+10*t", "11"] [0.1, 0.6]] - defines different spacing in 3 ranges.
1847 yGridDef: defines the grid along the Y asix the same way as *xGridDef* does.
1848 zGridDef: defines the grid along the Z asix the same way as *xGridDef* does.
1849 sizeThreshold: (> 1.0) defines a minimal size of a polyhedron so that
1850 a polyhedron of size less than hexSize/sizeThreshold is not created.
1851 implEdges: enables implementation of geometrical edges into the mesh.
1854 compFun = lambda hyp, args: False
1855 self.hyp = self.Hypothesis("CartesianParameters3D",
1856 [xGridDef, yGridDef, zGridDef, sizeThreshold],
1857 UseExisting=False, CompareMethod=compFun)
1858 if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
1859 self.mesh.AddHypothesis( self.hyp, self.geom )
1861 for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef] ):
1862 if not gridDef: raise ValueError("Empty grid definition")
1863 if isinstance( gridDef, str ):
1864 self.hyp.SetGridSpacing( [gridDef], [], axis )
1865 elif isinstance( gridDef[0], str ):
1866 self.hyp.SetGridSpacing( gridDef, [], axis )
1867 elif isinstance( gridDef[0], int ) or \
1868 isinstance( gridDef[0], float ):
1869 self.hyp.SetGrid(gridDef, axis )
1871 self.hyp.SetGridSpacing( gridDef[0], gridDef[1], axis )
1872 self.hyp.SetSizeThreshold( sizeThreshold )
1873 self.hyp.SetToAddEdges( implEdges )
1876 def SetAxesDirs( self, xAxis, yAxis, zAxis ):
1878 Defines custom directions of axes of the grid
1881 xAxis: either SMESH.DirStruct or a vector, or 3 vector components
1882 yAxis: either SMESH.DirStruct or a vector, or 3 vector components
1883 zAxis: either SMESH.DirStruct or a vector, or 3 vector components
1886 if hasattr( xAxis, "__getitem__" ):
1887 xAxis = self.mesh.smeshpyD.MakeDirStruct( xAxis[0],xAxis[1],xAxis[2] )
1888 elif isinstance( xAxis, GEOM._objref_GEOM_Object ):
1889 xAxis = self.mesh.smeshpyD.GetDirStruct( xAxis )
1890 if hasattr( yAxis, "__getitem__" ):
1891 yAxis = self.mesh.smeshpyD.MakeDirStruct( yAxis[0],yAxis[1],yAxis[2] )
1892 elif isinstance( yAxis, GEOM._objref_GEOM_Object ):
1893 yAxis = self.mesh.smeshpyD.GetDirStruct( yAxis )
1894 if hasattr( zAxis, "__getitem__" ):
1895 zAxis = self.mesh.smeshpyD.MakeDirStruct( zAxis[0],zAxis[1],zAxis[2] )
1896 elif isinstance( zAxis, GEOM._objref_GEOM_Object ):
1897 zAxis = self.mesh.smeshpyD.GetDirStruct( zAxis )
1899 self.hyp = self.Hypothesis("CartesianParameters3D")
1900 if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
1901 self.mesh.AddHypothesis( self.hyp, self.geom )
1902 self.hyp.SetAxesDirs( xAxis, yAxis, zAxis )
1905 def SetOptimalAxesDirs(self, isOrthogonal=True):
1907 Automatically defines directions of axes of the grid at which
1908 a number of generated hexahedra is maximal
1911 isOrthogonal: defines whether the axes mush be orthogonal
1914 self.hyp = self.Hypothesis("CartesianParameters3D")
1915 if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
1916 self.mesh.AddHypothesis( self.hyp, self.geom )
1917 x,y,z = self.hyp.ComputeOptimalAxesDirs( self.geom, isOrthogonal )
1918 self.hyp.SetAxesDirs( x,y,z )
1921 def SetFixedPoint( self, p, toUnset=False ):
1923 Sets/unsets a fixed point. The algorithm makes a plane of the grid pass
1924 through the fixed point in each direction at which the grid is defined
1928 p: coordinates of the fixed point. Either SMESH.PointStruct or
1929 a vertex or 3 components of coordinates.
1930 toUnset: defines whether the fixed point is defined or removed.
1934 if not self.hyp: return
1935 p = SMESH.PointStruct(0,0,0)
1936 elif hasattr( p, "__getitem__" ):
1937 p = SMESH.PointStruct( p[0],p[1],p[2] )
1938 elif isinstance( p, GEOM._objref_GEOM_Object ):
1939 p = self.mesh.smeshpyD.GetPointStruct( p )
1941 self.hyp = self.Hypothesis("CartesianParameters3D")
1942 if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
1943 self.mesh.AddHypothesis( self.hyp, self.geom )
1944 self.hyp.SetFixedPoint( p, toUnset )
1948 pass # end of StdMeshersBuilder_Cartesian_3D class
1950 class StdMeshersBuilder_UseExisting_1D(Mesh_Algorithm):
1951 """ Defines a stub 1D algorithm, which enables "manual" creation of nodes and
1952 segments usable by 2D algorithms.
1954 It is created by calling smeshBuilder.Mesh.UseExistingSegments(geom=0)
1958 meshMethod = "UseExistingSegments"
1960 name of the dynamic method in smeshBuilder.Mesh class
1962 algoType = "UseExisting_1D"
1964 type of algorithm used with helper function in smeshBuilder.Mesh class
1966 docHelper = "Create 1D algorithm allowing batch meshing of edges"
1968 doc string of the method
1971 def __init__(self, mesh, geom=0):
1973 Private constructor.
1976 mesh: parent mesh object algorithm is assigned to
1977 geom: geometry (shape/sub-shape) algorithm is assigned to;
1978 if it is :code:`0` (default), the algorithm is assigned to the main shape
1980 self.Create(mesh, geom, self.algoType)
1983 pass # end of StdMeshersBuilder_UseExisting_1D class
1985 class StdMeshersBuilder_UseExisting_2D(Mesh_Algorithm):
1986 """ Defines a stub 2D algorithm, which enables "manual" creation of nodes and
1987 faces usable by 3D algorithms.
1989 It is created by calling smeshBuilder.Mesh.UseExistingFaces(geom=0)
1993 meshMethod = "UseExistingFaces"
1995 name of the dynamic method in smeshBuilder.Mesh class
1997 algoType = "UseExisting_2D"
1999 type of algorithm used with helper function in smeshBuilder.Mesh class
2001 docHelper = "Create 2D algorithm allowing batch meshing of faces"
2003 doc string of the method
2006 def __init__(self, mesh, geom=0):
2008 Private constructor.
2011 mesh: parent mesh object algorithm is assigned to
2012 geom: geometry (shape/sub-shape) algorithm is assigned to;
2013 if it is :code:`0` (default), the algorithm is assigned to the main shape
2015 self.Create(mesh, geom, self.algoType)
2018 pass # end of StdMeshersBuilder_UseExisting_2D class
2020 class StdMeshersBuilder_ViscousLayer(Mesh_Algorithm):
2021 """ Defines the prismatic layer builder.
2023 It is created by calling smeshBuilder.Mesh.ViscousLayerBuilder(geom=TheGeometry)
2026 meshMethod = "ViscousLayerBuilder"
2028 name of the dynamic method in smeshBuilder.Mesh class
2030 algoType = "ViscousLayerBuilder"
2032 type of algorithm used with helper function in smeshBuilder.Mesh class
2034 docHelper = "Viscous layer builder for 2D and 3D geometries"
2036 doc string of the method
2039 # On create method it will call create method from mesh python class
2041 def __init__(self, mesh, geom = 0 ):
2043 Private constructor.
2046 mesh: parent mesh object algorithm is assigned to
2047 geom: geometry (shape/sub-shape) algorithm is assigned to;
2048 if it is :code:`0` (default), the algorithm is assigned to the main shape
2050 self.thickness = None
2051 self.numberOfLayers = None
2052 self.stretchFactor = None
2053 self.elementsId = []
2054 self.isElementToIgnore = True
2055 self.extrMethod = StdMeshers.SURF_OFFSET_SMOOTH
2057 self.shrinkGeometry = None
2058 self.algo = self.Create(mesh, geom, self.algoType)
2061 def setBuilderParameters( self, thickness, numberOfLayers, stretchFactor, elementsId=[],
2062 isElementToIgnore=True, extrMethod=StdMeshers.SURF_OFFSET_SMOOTH, groupName="" ):
2063 self.thickness = thickness
2064 self.numberOfLayers = numberOfLayers
2065 self.stretchFactor = stretchFactor
2066 self.elementsId = elementsId # can be faces or edges
2067 self.isElementToIgnore = isElementToIgnore
2068 self.extrMethod = extrMethod
2069 self.groupName = groupName
2071 self.algo.SetTotalThickness( thickness )
2072 self.algo.SetNumberLayers( numberOfLayers )
2073 self.algo.SetStretchFactor( stretchFactor )
2075 #Faces are set based on int ids so if a collection of face geom objects is recived cast it to int
2076 if elementsId and isinstance( elementsId, geomBuilder.GEOM._objref_GEOM_Object ):
2077 elementsId = [ elementsId ]
2078 if elementsId and isinstance( elementsId[0], geomBuilder.GEOM._objref_GEOM_Object ):
2080 for shape in elementsId:
2082 ff = self.mesh.geompyD.SubShapeAll( shape, self.mesh.geompyD.ShapeType["FACE"] )
2083 if ( len( ff ) == 0 ):
2085 ff = self.mesh.geompyD.SubShapeAll( shape, self.mesh.geompyD.ShapeType["EDGE"] )
2088 elementsIDs.append( self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f))
2090 # try to get the SHAPERSTUDY engine directly, because GetGen does not work because of
2091 # simplification of access in geomBuilder: omniORB.registerObjref
2092 from SHAPERSTUDY_utils import getEngine
2095 aShapeOp = gen.GetIShapesOperations()
2096 ff = aShapeOp.ExtractSubShapes( shape, self.mesh.geompyD.ShapeType["FACE"], False)
2099 ff = aShapeOp.ExtractSubShapes( shape, self.mesh.geompyD.ShapeType["EDGE"], False)
2101 elementsIDs.append( aShapeOp.GetSubShapeIndex( self.mesh.geom, f ))
2102 elementsId = elementsIDs
2104 self.algo.SetFaces( elementsId, isElementToIgnore )
2105 self.algo.SetGroupName( groupName )
2106 self.algo.SetMethod( extrMethod )
2108 def GetShrinkGeometry( self ):
2109 if isinstance(self.geom, geomBuilder.GEOM._objref_GEOM_Object):
2110 self.shrinkGeometry = self.algo.GetShrinkGeometry( self.mesh.GetMesh(), self.geom )
2112 return self.shrinkGeometry
2114 def AddLayers( self, shrinkMesh ):
2115 success = self.algo.AddLayers( shrinkMesh.GetMesh(), self.mesh.GetMesh(), self.geom )
2117 return self.mesh #Return the original mesh of the builder
2121 pass # end of StdMeshersBuilder_ViscousLayer class