1 # Copyright (C) 2007-2013 CEA/DEN, EDF R&D, 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.
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 # @package StdMeshersDC
22 # Python API for the standard meshing plug-in module.
24 from smesh_algorithm import Mesh_Algorithm
25 from smesh import AssureGeomPublished, IsEqual, ParseParameters
26 from smesh import GetName, TreatHypoStatus
27 from smeshDC import Mesh
31 #----------------------------
32 # Mesh algo type identifiers
33 #----------------------------
35 ## Algorithm type: Regular 1D algorithm, see StdMeshersDC_Segment
36 REGULAR = "Regular_1D"
37 ## Algorithm type: Python 1D algorithm, see StdMeshersDC_Segment_Python
39 ## Algorithm type: Composite segment 1D algorithm, see StdMeshersDC_CompositeSegment
40 COMPOSITE = "CompositeSegment_1D"
41 ## Algorithm type: Triangle MEFISTO 2D algorithm, see StdMeshersDC_Triangle_MEFISTO
42 MEFISTO = "MEFISTO_2D"
43 ## Algorithm type: Hexahedron 3D (i-j-k) algorithm, see StdMeshersDC_Hexahedron
45 ## Algorithm type: Quadrangle 2D algorithm, see StdMeshersDC_Quadrangle
46 QUADRANGLE = "Quadrangle_2D"
47 ## Algorithm type: Radial Quadrangle 1D-2D algorithm, see StdMeshersDC_RadialQuadrangle1D2D
48 RADIAL_QUAD = "RadialQuadrangle_1D2D"
50 # import items of enum QuadType
51 for e in StdMeshers.QuadType._items: exec('%s = StdMeshers.%s'%(e,e))
53 #----------------------
55 #----------------------
57 ## Defines segment 1D algorithm for edges discretization.
59 # It can be created by calling smesh.Mesh.Segment(geom=0)
61 # @ingroup l3_algos_basic
62 class StdMeshersDC_Segment(Mesh_Algorithm):
64 ## name of the dynamic method in smesh.Mesh class
66 meshMethod = "Segment"
67 ## type of algorithm used with helper function in smesh.Mesh class
70 ## flag pointing either this algorithm should be used by default in dynamic method
74 ## doc string of the method
76 docHelper = "Creates segment 1D algorithm for edges"
78 ## Private constructor.
79 # @param mesh parent mesh object algorithm is assigned to
80 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
81 # if it is @c 0 (default), the algorithm is assigned to the main shape
82 def __init__(self, mesh, geom=0):
83 Mesh_Algorithm.__init__(self)
84 self.Create(mesh, geom, self.algoType)
87 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
88 # @param l for the length of segments that cut an edge
89 # @param UseExisting if ==true - searches for an existing hypothesis created with
90 # the same parameters, else (default) - creates a new one
91 # @param p precision, used for calculation of the number of segments.
92 # The precision should be a positive, meaningful value within the range [0,1].
93 # In general, the number of segments is calculated with the formula:
94 # nb = ceil((edge_length / l) - p)
95 # Function ceil rounds its argument to the higher integer.
96 # So, p=0 means rounding of (edge_length / l) to the higher integer,
97 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
98 # p=1 means rounding of (edge_length / l) to the lower integer.
99 # Default value is 1e-07.
100 # @return an instance of StdMeshers_LocalLength hypothesis
101 # @ingroup l3_hypos_1dhyps
102 def LocalLength(self, l, UseExisting=0, p=1e-07):
103 comFun=lambda hyp, args: IsEqual(hyp.GetLength(), args[0]) and IsEqual(hyp.GetPrecision(), args[1])
104 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting, CompareMethod=comFun)
109 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
110 # @param length is optional maximal allowed length of segment, if it is omitted
111 # the preestimated length is used that depends on geometry size
112 # @param UseExisting if ==true - searches for an existing hypothesis created with
113 # the same parameters, else (default) - creates a new one
114 # @return an instance of StdMeshers_MaxLength hypothesis
115 # @ingroup l3_hypos_1dhyps
116 def MaxSize(self, length=0.0, UseExisting=0):
117 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
120 hyp.SetLength(length)
122 # set preestimated length
123 gen = self.mesh.smeshpyD
124 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
125 self.mesh.GetMesh(), self.mesh.GetShape(),
127 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
129 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
132 hyp.SetUsePreestimatedLength( length == 0.0 )
135 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
136 # @param n for the number of segments that cut an edge
137 # @param s for the scale factor (optional)
138 # @param reversedEdges is a list of edges to mesh using reversed orientation.
139 # A list item can also be a tuple (edge, 1st_vertex_of_edge)
140 # @param UseExisting if ==true - searches for an existing hypothesis created with
141 # the same parameters, else (default) - create a new one
142 # @return an instance of StdMeshers_NumberOfSegments hypothesis
143 # @ingroup l3_hypos_1dhyps
144 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
145 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
146 reversedEdges, UseExisting = [], reversedEdges
147 entry = self.MainShapeEntry()
148 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
150 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdgeInd, entry],
151 UseExisting=UseExisting,
152 CompareMethod=self._compareNumberOfSegments)
154 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdgeInd, entry],
155 UseExisting=UseExisting,
156 CompareMethod=self._compareNumberOfSegments)
157 hyp.SetDistrType( 1 )
158 hyp.SetScaleFactor(s)
159 hyp.SetNumberOfSegments(n)
160 hyp.SetReversedEdges( reversedEdgeInd )
161 hyp.SetObjectEntry( entry )
166 # Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
167 def _compareNumberOfSegments(self, hyp, args):
168 if hyp.GetNumberOfSegments() == args[0]:
170 if hyp.GetReversedEdges() == args[1]:
171 if not args[1] or hyp.GetObjectEntry() == args[2]:
174 if hyp.GetReversedEdges() == args[2]:
175 if not args[2] or hyp.GetObjectEntry() == args[3]:
176 if hyp.GetDistrType() == 1:
177 if IsEqual(hyp.GetScaleFactor(), args[1]):
181 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
182 # @param start defines the length of the first segment
183 # @param end defines the length of the last segment
184 # @param reversedEdges is a list of edges to mesh using reversed orientation.
185 # A list item can also be a tuple (edge, 1st_vertex_of_edge)
186 # @param UseExisting if ==true - searches for an existing hypothesis created with
187 # the same parameters, else (default) - creates a new one
188 # @return an instance of StdMeshers_Arithmetic1D hypothesis
189 # @ingroup l3_hypos_1dhyps
190 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
191 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
192 reversedEdges, UseExisting = [], reversedEdges
193 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
194 entry = self.MainShapeEntry()
195 compFun = lambda hyp, args: ( IsEqual(hyp.GetLength(1), args[0]) and \
196 IsEqual(hyp.GetLength(0), args[1]) and \
197 hyp.GetReversedEdges() == args[2] and \
198 (not args[2] or hyp.GetObjectEntry() == args[3]))
199 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdgeInd, entry],
200 UseExisting=UseExisting, CompareMethod=compFun)
201 hyp.SetStartLength(start)
202 hyp.SetEndLength(end)
203 hyp.SetReversedEdges( reversedEdgeInd )
204 hyp.SetObjectEntry( entry )
207 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
208 # on curve from 0 to 1 (additionally it is neecessary to check
209 # orientation of edges and create list of reversed edges if it is
210 # needed) and sets numbers of segments between given points (default
211 # values are equals 1
212 # @param points defines the list of parameters on curve
213 # @param nbSegs defines the list of numbers of segments
214 # @param reversedEdges is a list of edges to mesh using reversed orientation.
215 # A list item can also be a tuple (edge, 1st_vertex_of_edge)
216 # @param UseExisting if ==true - searches for an existing hypothesis created with
217 # the same parameters, else (default) - creates a new one
218 # @return an instance of StdMeshers_Arithmetic1D hypothesis
219 # @ingroup l3_hypos_1dhyps
220 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
221 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
222 reversedEdges, UseExisting = [], reversedEdges
223 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
224 entry = self.MainShapeEntry()
225 compFun = lambda hyp, args: ( hyp.GetPoints() == args[0] and \
226 hyp.GetNbSegments() == args[1] and \
227 hyp.GetReversedEdges() == args[2] and \
228 (not args[2] or hyp.GetObjectEntry() == args[3]))
229 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdgeInd, entry],
230 UseExisting=UseExisting, CompareMethod=compFun)
231 hyp.SetPoints(points)
232 hyp.SetNbSegments(nbSegs)
233 hyp.SetReversedEdges(reversedEdgeInd)
234 hyp.SetObjectEntry(entry)
237 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
238 # @param start defines the length of the first segment
239 # @param end defines the length of the last segment
240 # @param reversedEdges is a list of edges to mesh using reversed orientation.
241 # A list item can also be a tuple (edge, 1st_vertex_of_edge)
242 # @param UseExisting if ==true - searches for an existing hypothesis created with
243 # the same parameters, else (default) - creates a new one
244 # @return an instance of StdMeshers_StartEndLength hypothesis
245 # @ingroup l3_hypos_1dhyps
246 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
247 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
248 reversedEdges, UseExisting = [], reversedEdges
249 reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
250 entry = self.MainShapeEntry()
251 compFun = lambda hyp, args: ( IsEqual(hyp.GetLength(1), args[0]) and \
252 IsEqual(hyp.GetLength(0), args[1]) and \
253 hyp.GetReversedEdges() == args[2] and \
254 (not args[2] or hyp.GetObjectEntry() == args[3]))
255 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdgeInd, entry],
256 UseExisting=UseExisting, CompareMethod=compFun)
257 hyp.SetStartLength(start)
258 hyp.SetEndLength(end)
259 hyp.SetReversedEdges( reversedEdgeInd )
260 hyp.SetObjectEntry( entry )
263 ## Defines "Deflection1D" hypothesis
264 # @param d for the deflection
265 # @param UseExisting if ==true - searches for an existing hypothesis created with
266 # the same parameters, else (default) - create a new one
267 # @ingroup l3_hypos_1dhyps
268 def Deflection1D(self, d, UseExisting=0):
269 compFun = lambda hyp, args: IsEqual(hyp.GetDeflection(), args[0])
270 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting, CompareMethod=compFun)
274 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
275 # the opposite side in case of quadrangular faces
276 # @ingroup l3_hypos_additi
277 def Propagation(self):
278 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
280 ## Defines "AutomaticLength" hypothesis
281 # @param fineness for the fineness [0-1]
282 # @param UseExisting if ==true - searches for an existing hypothesis created with the
283 # same parameters, else (default) - create a new one
284 # @ingroup l3_hypos_1dhyps
285 def AutomaticLength(self, fineness=0, UseExisting=0):
286 compFun = lambda hyp, args: IsEqual(hyp.GetFineness(), args[0])
287 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
288 CompareMethod=compFun)
289 hyp.SetFineness( fineness )
292 ## Defines "SegmentLengthAroundVertex" hypothesis
293 # @param length for the segment length
294 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
295 # Any other integer value means that the hypothesis will be set on the
296 # whole 1D shape, where Mesh_Segment algorithm is assigned.
297 # @param UseExisting if ==true - searches for an existing hypothesis created with
298 # the same parameters, else (default) - creates a new one
299 # @ingroup l3_algos_segmarv
300 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
302 store_geom = self.geom
303 if type(vertex) is types.IntType:
304 if vertex == 0 or vertex == 1:
306 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
314 if self.geom is None:
315 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
316 AssureGeomPublished( self.mesh, self.geom )
317 name = GetName(self.geom)
319 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
321 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
323 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
324 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
326 comFun = lambda hyp, args: IsEqual(hyp.GetLength(), args[0])
327 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
328 CompareMethod=comFun)
329 self.geom = store_geom
330 hyp.SetLength( length )
333 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
334 # If the 2D mesher sees that all boundary edges are quadratic,
335 # it generates quadratic faces, else it generates linear faces using
336 # medium nodes as if they are vertices.
337 # The 3D mesher generates quadratic volumes only if all boundary faces
338 # are quadratic, else it fails.
340 # @ingroup l3_hypos_additi
341 def QuadraticMesh(self):
342 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
345 pass # end of StdMeshersDC_Segment class
347 ## Segment 1D algorithm for discretization of a set of adjacent edges as one edge.
349 # It is created by calling smesh.Mesh.Segment(smesh.COMPOSITE,geom=0)
351 # @ingroup l3_algos_basic
352 class StdMeshersDC_CompositeSegment(StdMeshersDC_Segment):
354 ## name of the dynamic method in smesh.Mesh class
356 meshMethod = "Segment"
357 ## type of algorithm used with helper function in smesh.Mesh class
360 ## flag pointing either this algorithm should be used by default in dynamic method
361 # of smesh.Mesh class
364 ## doc string of the method
366 docHelper = "Creates segment 1D algorithm for edges"
368 ## Private constructor.
369 # @param mesh parent mesh object algorithm is assigned to
370 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
371 # if it is @c 0 (default), the algorithm is assigned to the main shape
372 def __init__(self, mesh, geom=0):
373 self.Create(mesh, geom, self.algoType)
376 pass # end of StdMeshersDC_CompositeSegment class
378 ## Defines a segment 1D algorithm for discretization of edges with Python function
380 # It is created by calling smesh.Mesh.Segment(smesh.PYTHON,geom=0)
382 # @ingroup l3_algos_basic
383 class StdMeshersDC_Segment_Python(Mesh_Algorithm):
385 ## name of the dynamic method in smesh.Mesh class
387 meshMethod = "Segment"
388 ## type of algorithm used with helper function in smesh.Mesh class
391 ## doc string of the method
393 docHelper = "Creates tetrahedron 3D algorithm for solids"
394 ## doc string of the method
396 docHelper = "Creates segment 1D algorithm for edges"
398 ## Private constructor.
399 # @param mesh parent mesh object algorithm is assigned to
400 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
401 # if it is @c 0 (default), the algorithm is assigned to the main shape
402 def __init__(self, mesh, geom=0):
403 import Python1dPlugin
404 self.Create(mesh, geom, self.algoType, "libPython1dEngine.so")
407 ## Defines "PythonSplit1D" hypothesis
408 # @param n for the number of segments that cut an edge
409 # @param func for the python function that calculates the length of all segments
410 # @param UseExisting if ==true - searches for the existing hypothesis created with
411 # the same parameters, else (default) - creates a new one
412 # @ingroup l3_hypos_1dhyps
413 def PythonSplit1D(self, n, func, UseExisting=0):
414 compFun = lambda hyp, args: False
415 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
416 UseExisting=UseExisting, CompareMethod=compFun)
417 hyp.SetNumberOfSegments(n)
418 hyp.SetPythonLog10RatioFunction(func)
421 pass # end of StdMeshersDC_Segment_Python class
423 ## Triangle MEFISTO 2D algorithm
425 # It is created by calling smesh.Mesh.Triangle(smesh.MEFISTO,geom=0)
427 # @ingroup l3_algos_basic
428 class StdMeshersDC_Triangle_MEFISTO(Mesh_Algorithm):
430 ## name of the dynamic method in smesh.Mesh class
432 meshMethod = "Triangle"
433 ## type of algorithm used with helper function in smesh.Mesh class
436 ## flag pointing either this algorithm should be used by default in dynamic method
437 # of smesh.Mesh class
440 ## doc string of the method
442 docHelper = "Creates triangle 2D algorithm for faces"
444 ## Private constructor.
445 # @param mesh parent mesh object algorithm is assigned to
446 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
447 # if it is @c 0 (default), the algorithm is assigned to the main shape
448 def __init__(self, mesh, geom=0):
449 Mesh_Algorithm.__init__(self)
450 self.Create(mesh, geom, self.algoType)
453 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
454 # @param area for the maximum area of each triangle
455 # @param UseExisting if ==true - searches for an existing hypothesis created with the
456 # same parameters, else (default) - creates a new one
458 # @ingroup l3_hypos_2dhyps
459 def MaxElementArea(self, area, UseExisting=0):
460 comparator = lambda hyp, args: IsEqual(hyp.GetMaxElementArea(), args[0])
461 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
462 CompareMethod=comparator)
463 hyp.SetMaxElementArea(area)
466 ## Defines "LengthFromEdges" hypothesis to build triangles
467 # based on the length of the edges taken from the wire
469 # @ingroup l3_hypos_2dhyps
470 def LengthFromEdges(self):
471 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
474 pass # end of StdMeshersDC_Triangle_MEFISTO class
476 ## Defines a quadrangle 2D algorithm
478 # It is created by calling smesh.Mesh.Quadrangle(geom=0)
480 # @ingroup l3_algos_basic
481 class StdMeshersDC_Quadrangle(Mesh_Algorithm):
483 ## name of the dynamic method in smesh.Mesh class
485 meshMethod = "Quadrangle"
486 ## type of algorithm used with helper function in smesh.Mesh class
488 algoType = QUADRANGLE
489 ## flag pointing either this algorithm should be used by default in dynamic method
490 # of smesh.Mesh class
493 ## doc string of the method
495 docHelper = "Creates quadrangle 2D algorithm for faces"
496 ## hypothesis associated with algorithm
500 ## Private constructor.
501 # @param mesh parent mesh object algorithm is assigned to
502 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
503 # if it is @c 0 (default), the algorithm is assigned to the main shape
504 def __init__(self, mesh, geom=0):
505 Mesh_Algorithm.__init__(self)
506 self.Create(mesh, geom, self.algoType)
509 ## Defines "QuadrangleParameters" hypothesis
510 # @param quadType defines the algorithm of transition between differently descretized
511 # sides of a geometrical face:
512 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
513 # area along the finer meshed sides.
514 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
515 # finer meshed sides.
516 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
517 # the finer meshed sides, iff the total quantity of segments on
518 # all four sides of the face is even (divisible by 2).
519 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
520 # area is located along the coarser meshed sides.
521 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
522 # is made gradually, layer by layer. This type has a limitation on
523 # the number of segments: one pair of opposite sides must have the
524 # same number of segments, the other pair must have an even difference
525 # between the numbers of segments on the sides.
526 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
527 # will be created while other elements will be quadrangles.
528 # Vertex can be either a GEOM_Object or a vertex ID within the
530 # @param UseExisting: if ==true - searches for the existing hypothesis created with
531 # the same parameters, else (default) - creates a new one
532 # @ingroup l3_hypos_quad
533 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
535 vertexID = triangleVertex
536 if isinstance( triangleVertex, GEOM._objref_GEOM_Object ):
537 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
539 compFun = lambda hyp,args: \
540 hyp.GetQuadType() == args[0] and \
541 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
542 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
543 UseExisting = UseExisting, CompareMethod=compFun)
545 if self.params.GetQuadType() != quadType:
546 self.params.SetQuadType(quadType)
548 self.params.SetTriaVertex( vertexID )
551 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
552 # quadrangles are built in the transition area along the finer meshed sides,
553 # iff the total quantity of segments on all four sides of the face is even.
554 # @param reversed if True, transition area is located along the coarser meshed sides.
555 # @param UseExisting: if ==true - searches for the existing hypothesis created with
556 # the same parameters, else (default) - creates a new one
557 # @ingroup l3_hypos_quad
558 def QuadranglePreference(self, reversed=False, UseExisting=0):
560 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
561 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
563 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
564 # triangles are built in the transition area along the finer meshed sides.
565 # @param UseExisting: if ==true - searches for the existing hypothesis created with
566 # the same parameters, else (default) - creates a new one
567 # @ingroup l3_hypos_quad
568 def TrianglePreference(self, UseExisting=0):
569 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
571 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
572 # quadrangles are built and the transition between the sides is made gradually,
573 # layer by layer. This type has a limitation on the number of segments: one pair
574 # of opposite sides must have the same number of segments, the other pair must
575 # have an even difference between the numbers of segments on the sides.
576 # @param UseExisting: if ==true - searches for the existing hypothesis created with
577 # the same parameters, else (default) - creates a new one
578 # @ingroup l3_hypos_quad
579 def Reduced(self, UseExisting=0):
580 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
582 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
583 # @param vertex: vertex of a trilateral geometrical face, around which triangles
584 # will be created while other elements will be quadrangles.
585 # Vertex can be either a GEOM_Object or a vertex ID within the
587 # @param UseExisting: if ==true - searches for the existing hypothesis created with
588 # the same parameters, else (default) - creates a new one
589 # @ingroup l3_hypos_quad
590 def TriangleVertex(self, vertex, UseExisting=0):
591 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
593 pass # end of StdMeshersDC_Quadrangle class
595 ## Defines a hexahedron 3D algorithm
597 # It is created by calling smesh.Mesh.Hexahedron(geom=0)
599 # @ingroup l3_algos_basic
600 class StdMeshersDC_Hexahedron(Mesh_Algorithm):
602 ## name of the dynamic method in smesh.Mesh class
604 meshMethod = "Hexahedron"
605 ## type of algorithm used with helper function in smesh.Mesh class
608 ## flag pointing either this algorithm should be used by default in dynamic method
609 # of smesh.Mesh class
612 ## doc string of the method
614 docHelper = "Creates hexahedron 3D algorithm for volumes"
616 ## Private constructor.
617 # @param mesh parent mesh object algorithm is assigned to
618 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
619 # if it is @c 0 (default), the algorithm is assigned to the main shape
620 def __init__(self, mesh, geom=0):
621 Mesh_Algorithm.__init__(self)
622 self.Create(mesh, geom, Hexa)
625 pass # end of StdMeshersDC_Hexahedron class
627 ## Defines a projection 1D algorithm
629 # It is created by calling smesh.Mesh.Projection1D(geom=0)
631 # @ingroup l3_algos_proj
632 class StdMeshersDC_Projection1D(Mesh_Algorithm):
634 ## name of the dynamic method in smesh.Mesh class
636 meshMethod = "Projection1D"
637 ## type of algorithm used with helper function in smesh.Mesh class
639 algoType = "Projection_1D"
640 ## flag pointing either this algorithm should be used by default in dynamic method
641 # of smesh.Mesh class
644 ## doc string of the method
646 docHelper = "Creates projection 1D algorithm for edges"
648 ## Private constructor.
649 # @param mesh parent mesh object algorithm is assigned to
650 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
651 # if it is @c 0 (default), the algorithm is assigned to the main shape
652 def __init__(self, mesh, geom=0):
653 Mesh_Algorithm.__init__(self)
654 self.Create(mesh, geom, self.algoType)
657 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
658 # a mesh pattern is taken, and, optionally, the association of vertices
659 # between the source edge and a target edge (to which a hypothesis is assigned)
660 # @param edge from which nodes distribution is taken
661 # @param mesh from which nodes distribution is taken (optional)
662 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
663 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
664 # to associate with \a srcV (optional)
665 # @param UseExisting if ==true - searches for the existing hypothesis created with
666 # the same parameters, else (default) - creates a new one
667 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
668 AssureGeomPublished( self.mesh, edge )
669 AssureGeomPublished( self.mesh, srcV )
670 AssureGeomPublished( self.mesh, tgtV )
671 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
673 # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
674 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
675 hyp.SetSourceEdge( edge )
676 if not mesh is None and isinstance(mesh, Mesh):
677 mesh = mesh.GetMesh()
678 hyp.SetSourceMesh( mesh )
679 hyp.SetVertexAssociation( srcV, tgtV )
682 pass # end of StdMeshersDC_Projection1D class
684 ## Defines a projection 2D algorithm
686 # It is created by calling smesh.Mesh.Projection2D(geom=0)
688 # @ingroup l3_algos_proj
689 class StdMeshersDC_Projection2D(Mesh_Algorithm):
691 ## name of the dynamic method in smesh.Mesh class
693 meshMethod = "Projection2D"
694 ## type of algorithm used with helper function in smesh.Mesh class
696 algoType = "Projection_2D"
697 ## flag pointing either this algorithm should be used by default in dynamic method
698 # of smesh.Mesh class
701 ## doc string of the method
703 docHelper = "Creates projection 2D algorithm for faces"
705 ## Private constructor.
706 # @param mesh parent mesh object algorithm is assigned to
707 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
708 # if it is @c 0 (default), the algorithm is assigned to the main shape
709 def __init__(self, mesh, geom=0):
710 Mesh_Algorithm.__init__(self)
711 self.Create(mesh, geom, self.algoType)
714 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
715 # a mesh pattern is taken, and, optionally, the association of vertices
716 # between the source face and the target face (to which a hypothesis is assigned)
717 # @param face from which the mesh pattern is taken
718 # @param mesh from which the mesh pattern is taken (optional)
719 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
720 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
721 # to associate with \a srcV1 (optional)
722 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
723 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
724 # to associate with \a srcV2 (optional)
725 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
726 # the same parameters, else (default) - forces the creation a new one
728 # Note: all association vertices must belong to one edge of a face
729 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
730 srcV2=None, tgtV2=None, UseExisting=0):
731 from smeshDC import Mesh
732 if isinstance(mesh, Mesh):
733 mesh = mesh.GetMesh()
734 for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
735 AssureGeomPublished( self.mesh, geom )
736 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
738 # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
739 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
740 hyp.SetSourceFace( face )
741 hyp.SetSourceMesh( mesh )
742 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
745 pass # end of StdMeshersDC_Projection2D class
747 ## Defines a projection 1D-2D algorithm
749 # It is created by calling smesh.Mesh.Projection1D2D(geom=0)
751 # @ingroup l3_algos_proj
752 class StdMeshersDC_Projection1D2D(StdMeshersDC_Projection2D):
754 ## name of the dynamic method in smesh.Mesh class
756 meshMethod = "Projection1D2D"
757 ## type of algorithm used with helper function in smesh.Mesh class
759 algoType = "Projection_1D2D"
760 ## doc string of the method
762 docHelper = "Creates projection 1D-2D algorithm for edges and faces"
764 ## Private constructor.
765 # @param mesh parent mesh object algorithm is assigned to
766 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
767 # if it is @c 0 (default), the algorithm is assigned to the main shape
768 def __init__(self, mesh, geom=0):
769 StdMeshersDC_Projection2D.__init__(self, mesh, geom)
772 pass # end of StdMeshersDC_Projection1D2D class
774 ## Defines a projection 3D algorithm
776 # It is created by calling smesh.Mesh.Projection3D(geom=0)
778 # @ingroup l3_algos_proj
779 class StdMeshersDC_Projection3D(Mesh_Algorithm):
781 ## name of the dynamic method in smesh.Mesh class
783 meshMethod = "Projection3D"
784 ## type of algorithm used with helper function in smesh.Mesh class
786 algoType = "Projection_3D"
787 ## doc string of the method
789 docHelper = "Creates projection 3D algorithm for volumes"
791 ## Private constructor.
792 # @param mesh parent mesh object algorithm is assigned to
793 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
794 # if it is @c 0 (default), the algorithm is assigned to the main shape
795 def __init__(self, mesh, geom=0):
796 Mesh_Algorithm.__init__(self)
797 self.Create(mesh, geom, self.algoType)
800 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
801 # the mesh pattern is taken, and, optionally, the association of vertices
802 # between the source and the target solid (to which a hipothesis is assigned)
803 # @param solid from where the mesh pattern is taken
804 # @param mesh from where the mesh pattern is taken (optional)
805 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
806 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
807 # to associate with \a srcV1 (optional)
808 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
809 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
810 # to associate with \a srcV2 (optional)
811 # @param UseExisting - if ==true - searches for the existing hypothesis created with
812 # the same parameters, else (default) - creates a new one
814 # Note: association vertices must belong to one edge of a solid
815 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
816 srcV2=0, tgtV2=0, UseExisting=0):
817 for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
818 AssureGeomPublished( self.mesh, geom )
819 hyp = self.Hypothesis("ProjectionSource3D",
820 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
822 # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
823 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
824 hyp.SetSource3DShape( solid )
825 if isinstance(mesh, Mesh):
826 mesh = mesh.GetMesh()
828 hyp.SetSourceMesh( mesh )
829 if srcV1 and srcV2 and tgtV1 and tgtV2:
830 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
831 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
834 pass # end of StdMeshersDC_Projection3D class
836 ## Defines a Prism 3D algorithm, which is either "Extrusion 3D" or "Radial Prism"
837 # depending on geometry
839 # It is created by calling smesh.Mesh.Prism(geom=0)
841 # @ingroup l3_algos_3dextr
842 class StdMeshersDC_Prism3D(Mesh_Algorithm):
844 ## name of the dynamic method in smesh.Mesh class
847 ## type of algorithm used with helper function in smesh.Mesh class
849 algoType = "Prism_3D"
850 ## doc string of the method
852 docHelper = "Creates prism 3D algorithm for volumes"
854 ## Private constructor.
855 # @param mesh parent mesh object algorithm is assigned to
856 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
857 # if it is @c 0 (default), the algorithm is assigned to the main shape
858 def __init__(self, mesh, geom=0):
859 Mesh_Algorithm.__init__(self)
864 from geompy import SubShapeAll, ShapeType
865 nbSolids = len( SubShapeAll( shape, ShapeType["SOLID"] ))
866 nbShells = len( SubShapeAll( shape, ShapeType["SHELL"] ))
867 if nbSolids == 0 or nbSolids == nbShells:
868 self.Create(mesh, geom, "Prism_3D")
871 self.algoType = "RadialPrism_3D"
872 self.Create(mesh, geom, "RadialPrism_3D")
873 self.distribHyp = None #self.Hypothesis("LayerDistribution", UseExisting=0)
878 ## Return 3D hypothesis holding the 1D one
879 def Get3DHypothesis(self):
880 if self.algoType != "RadialPrism_3D":
881 print "Prism_3D algorith doesn't support any hyposesis"
883 return self.distribHyp
885 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
886 # hypothesis. Returns the created hypothesis
887 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
888 if self.algoType != "RadialPrism_3D":
889 print "Prism_3D algorith doesn't support any hyposesis"
891 if not self.nbLayers is None:
892 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
893 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
894 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
895 self.mesh.smeshpyD.SetCurrentStudy( None )
896 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
897 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
898 if not self.distribHyp:
899 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
900 self.distribHyp.SetLayerDistribution( hyp )
903 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
904 # prisms to build between the inner and outer shells
905 # @param n number of layers
906 # @param UseExisting if ==true - searches for the existing hypothesis created with
907 # the same parameters, else (default) - creates a new one
908 def NumberOfLayers(self, n, UseExisting=0):
909 if self.algoType != "RadialPrism_3D":
910 print "Prism_3D algorith doesn't support any hyposesis"
912 self.mesh.RemoveHypothesis( self.distribHyp, self.geom )
913 compFun = lambda hyp, args: IsEqual(hyp.GetNumberOfLayers(), args[0])
914 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
915 CompareMethod=compFun)
916 self.nbLayers.SetNumberOfLayers( n )
919 ## Defines "LocalLength" hypothesis, specifying the segment length
920 # to build between the inner and the outer shells
921 # @param l the length of segments
922 # @param p the precision of rounding
923 def LocalLength(self, l, p=1e-07):
924 if self.algoType != "RadialPrism_3D":
925 print "Prism_3D algorith doesn't support any hyposesis"
927 hyp = self.OwnHypothesis("LocalLength", [l,p])
932 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
933 # prisms to build between the inner and the outer shells.
934 # @param n the number of layers
935 # @param s the scale factor (optional)
936 def NumberOfSegments(self, n, s=[]):
937 if self.algoType != "RadialPrism_3D":
938 print "Prism_3D algorith doesn't support any hyposesis"
941 hyp = self.OwnHypothesis("NumberOfSegments", [n])
943 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
944 hyp.SetDistrType( 1 )
945 hyp.SetScaleFactor(s)
946 hyp.SetNumberOfSegments(n)
949 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
950 # to build between the inner and the outer shells with a length that changes in arithmetic progression
951 # @param start the length of the first segment
952 # @param end the length of the last segment
953 def Arithmetic1D(self, start, end ):
954 if self.algoType != "RadialPrism_3D":
955 print "Prism_3D algorith doesn't support any hyposesis"
957 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
958 hyp.SetLength(start, 1)
959 hyp.SetLength(end , 0)
962 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
963 # to build between the inner and the outer shells as geometric length increasing
964 # @param start for the length of the first segment
965 # @param end for the length of the last segment
966 def StartEndLength(self, start, end):
967 if self.algoType != "RadialPrism_3D":
968 print "Prism_3D algorith doesn't support any hyposesis"
970 hyp = self.OwnHypothesis("StartEndLength", [start, end])
971 hyp.SetLength(start, 1)
972 hyp.SetLength(end , 0)
975 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
976 # to build between the inner and outer shells
977 # @param fineness defines the quality of the mesh within the range [0-1]
978 def AutomaticLength(self, fineness=0):
979 if self.algoType != "RadialPrism_3D":
980 print "Prism_3D algorith doesn't support any hyposesis"
982 hyp = self.OwnHypothesis("AutomaticLength")
983 hyp.SetFineness( fineness )
986 pass # end of StdMeshersDC_Prism3D class
988 ## Defines a Prism 3D algorithm, which is either "Extrusion 3D" or "Radial Prism"
989 # depending on geometry
991 # It is created by calling smesh.Mesh.Prism(geom=0)
993 # @ingroup l3_algos_3dextr
994 class StdMeshersDC_RadialPrism3D(StdMeshersDC_Prism3D):
996 ## name of the dynamic method in smesh.Mesh class
999 ## type of algorithm used with helper function in smesh.Mesh class
1001 algoType = "RadialPrism_3D"
1002 ## doc string of the method
1004 docHelper = "Creates prism 3D algorithm for volumes"
1006 ## Private constructor.
1007 # @param mesh parent mesh object algorithm is assigned to
1008 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
1009 # if it is @c 0 (default), the algorithm is assigned to the main shape
1010 def __init__(self, mesh, geom=0):
1011 Mesh_Algorithm.__init__(self)
1016 self.Create(mesh, geom, "RadialPrism_3D")
1017 self.distribHyp = None
1018 self.nbLayers = None
1021 ## Defines a Radial Quadrangle 1D-2D algorithm
1023 # It is created by calling smesh.Mesh.Quadrangle(smesh.RADIAL_QUAD,geom=0)
1025 # @ingroup l2_algos_radialq
1026 class StdMeshersDC_RadialQuadrangle1D2D(Mesh_Algorithm):
1028 ## name of the dynamic method in smesh.Mesh class
1030 meshMethod = "Quadrangle"
1031 ## type of algorithm used with helper function in smesh.Mesh class
1033 algoType = RADIAL_QUAD
1034 ## doc string of the method
1036 docHelper = "Creates quadrangle 1D-2D algorithm for triangular faces"
1038 ## Private constructor.
1039 # @param mesh parent mesh object algorithm is assigned to
1040 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
1041 # if it is @c 0 (default), the algorithm is assigned to the main shape
1042 def __init__(self, mesh, geom=0):
1043 Mesh_Algorithm.__init__(self)
1044 self.Create(mesh, geom, self.algoType)
1046 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
1047 self.nbLayers = None
1050 ## Return 2D hypothesis holding the 1D one
1051 def Get2DHypothesis(self):
1052 if not self.distribHyp:
1053 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
1054 return self.distribHyp
1056 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
1057 # hypothesis. Returns the created hypothesis
1058 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
1060 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
1061 if self.distribHyp is None:
1062 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
1064 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
1065 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
1066 self.mesh.smeshpyD.SetCurrentStudy( None )
1067 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
1068 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
1069 self.distribHyp.SetLayerDistribution( hyp )
1072 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
1073 # @param n number of layers
1074 # @param UseExisting if ==true - searches for the existing hypothesis created with
1075 # the same parameters, else (default) - creates a new one
1076 def NumberOfLayers(self, n, UseExisting=0):
1078 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
1079 compFun = lambda hyp, args: IsEqual(hyp.GetNumberOfLayers(), args[0])
1080 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
1081 CompareMethod=compFun)
1082 self.nbLayers.SetNumberOfLayers( n )
1083 return self.nbLayers
1085 ## Defines "LocalLength" hypothesis, specifying the segment length
1086 # @param l the length of segments
1087 # @param p the precision of rounding
1088 def LocalLength(self, l, p=1e-07):
1089 hyp = self.OwnHypothesis("LocalLength", [l,p])
1094 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
1095 # @param n the number of layers
1096 # @param s the scale factor (optional)
1097 def NumberOfSegments(self, n, s=[]):
1099 hyp = self.OwnHypothesis("NumberOfSegments", [n])
1101 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
1102 hyp.SetDistrType( 1 )
1103 hyp.SetScaleFactor(s)
1104 hyp.SetNumberOfSegments(n)
1107 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
1108 # with a length that changes in arithmetic progression
1109 # @param start the length of the first segment
1110 # @param end the length of the last segment
1111 def Arithmetic1D(self, start, end ):
1112 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
1113 hyp.SetLength(start, 1)
1114 hyp.SetLength(end , 0)
1117 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
1118 # as geometric length increasing
1119 # @param start for the length of the first segment
1120 # @param end for the length of the last segment
1121 def StartEndLength(self, start, end):
1122 hyp = self.OwnHypothesis("StartEndLength", [start, end])
1123 hyp.SetLength(start, 1)
1124 hyp.SetLength(end , 0)
1127 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
1128 # @param fineness defines the quality of the mesh within the range [0-1]
1129 def AutomaticLength(self, fineness=0):
1130 hyp = self.OwnHypothesis("AutomaticLength")
1131 hyp.SetFineness( fineness )
1134 pass # end of StdMeshersDC_RadialQuadrangle1D2D class
1136 ## Defines a Use Existing Elements 1D algorithm
1138 # It is created by calling smesh.Mesh.UseExisting1DElements(geom=0)
1140 # @ingroup l3_algos_basic
1141 class StdMeshersDC_UseExistingElements_1D(Mesh_Algorithm):
1143 ## name of the dynamic method in smesh.Mesh class
1145 meshMethod = "UseExisting1DElements"
1146 ## type of algorithm used with helper function in smesh.Mesh class
1148 algoType = "Import_1D"
1149 ## flag pointing either this algorithm should be used by default in dynamic method
1150 # of smesh.Mesh class
1153 ## doc string of the method
1155 docHelper = "Creates 1D algorithm for edges with reusing of existing mesh elements"
1157 ## Private constructor.
1158 # @param mesh parent mesh object algorithm is assigned to
1159 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
1160 # if it is @c 0 (default), the algorithm is assigned to the main shape
1161 def __init__(self, mesh, geom=0):
1162 Mesh_Algorithm.__init__(self)
1163 self.Create(mesh, geom, self.algoType)
1166 ## Defines "Source edges" hypothesis, specifying groups of edges to import
1167 # @param groups list of groups of edges
1168 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
1169 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
1170 # @param UseExisting if ==true - searches for the existing hypothesis created with
1171 # the same parameters, else (default) - creates a new one
1172 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
1173 for group in groups:
1174 AssureGeomPublished( self.mesh, group )
1175 compFun = lambda hyp, args: ( hyp.GetSourceEdges() == args[0] and \
1176 hyp.GetCopySourceMesh() == args[1], args[2] )
1177 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
1178 UseExisting=UseExisting, CompareMethod=compFun)
1179 hyp.SetSourceEdges(groups)
1180 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
1183 pass # end of StdMeshersDC_UseExistingElements_1D class
1185 ## Defines a Use Existing Elements 1D-2D algorithm
1187 # It is created by calling smesh.Mesh.UseExisting2DElements(geom=0)
1189 # @ingroup l3_algos_basic
1190 class StdMeshersDC_UseExistingElements_1D2D(Mesh_Algorithm):
1192 ## name of the dynamic method in smesh.Mesh class
1194 meshMethod = "UseExisting2DElements"
1195 ## type of algorithm used with helper function in smesh.Mesh class
1197 algoType = "Import_1D2D"
1198 ## flag pointing either this algorithm should be used by default in dynamic method
1199 # of smesh.Mesh class
1202 ## doc string of the method
1204 docHelper = "Creates 1D-2D algorithm for edges/faces with reusing of existing mesh elements"
1206 ## Private constructor.
1207 # @param mesh parent mesh object algorithm is assigned to
1208 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
1209 # if it is @c 0 (default), the algorithm is assigned to the main shape
1210 def __init__(self, mesh, geom=0):
1211 Mesh_Algorithm.__init__(self)
1212 self.Create(mesh, geom, self.algoType)
1215 ## Defines "Source faces" hypothesis, specifying groups of faces to import
1216 # @param groups list of groups of faces
1217 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
1218 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
1219 # @param UseExisting if ==true - searches for the existing hypothesis created with
1220 # the same parameters, else (default) - creates a new one
1221 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
1222 for group in groups:
1223 AssureGeomPublished( self.mesh, group )
1224 compFun = lambda hyp, args: ( hyp.GetSourceFaces() == args[0] and \
1225 hyp.GetCopySourceMesh() == args[1], args[2] )
1226 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
1227 UseExisting=UseExisting, CompareMethod=compFun)
1228 hyp.SetSourceFaces(groups)
1229 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
1232 pass # end of StdMeshersDC_UseExistingElements_1D2D class
1234 ## Defines a Body Fitting 3D algorithm
1236 # It is created by calling smesh.Mesh.BodyFitted(geom=0)
1238 # @ingroup l3_algos_basic
1239 class StdMeshersDC_Cartesian_3D(Mesh_Algorithm):
1241 ## name of the dynamic method in smesh.Mesh class
1243 meshMethod = "BodyFitted"
1244 ## type of algorithm used with helper function in smesh.Mesh class
1246 algoType = "Cartesian_3D"
1247 ## flag pointing either this algorithm should be used by default in dynamic method
1248 # of smesh.Mesh class
1251 ## doc string of the method
1253 docHelper = "Creates body fitting 3D algorithm for volumes"
1255 ## Private constructor.
1256 # @param mesh parent mesh object algorithm is assigned to
1257 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
1258 # if it is @c 0 (default), the algorithm is assigned to the main shape
1259 def __init__(self, mesh, geom=0):
1260 self.Create(mesh, geom, self.algoType)
1264 ## Defines "Body Fitting parameters" hypothesis
1265 # @param xGridDef is definition of the grid along the X asix.
1266 # It can be in either of two following forms:
1267 # - Explicit coordinates of nodes, e.g. [-1.5, 0.0, 3.1] or range( -100,200,10)
1268 # - Functions f(t) defining grid spacing at each point on grid axis. If there are
1269 # several functions, they must be accompanied by relative coordinates of
1270 # points dividing the whole shape into ranges where the functions apply; points
1271 # coodrinates should vary within (0.0, 1.0) range. Parameter \a t of the spacing
1272 # function f(t) varies from 0.0 to 1.0 witin a shape range.
1274 # - "10.5" - defines a grid with a constant spacing
1275 # - [["1", "1+10*t", "11"] [0.1, 0.6]] - defines different spacing in 3 ranges.
1276 # @param yGridDef defines the grid along the Y asix the same way as \a xGridDef does
1277 # @param zGridDef defines the grid along the Z asix the same way as \a xGridDef does
1278 # @param sizeThreshold (> 1.0) defines a minimal size of a polyhedron so that
1279 # a polyhedron of size less than hexSize/sizeThreshold is not created
1280 # @param UseExisting if ==true - searches for the existing hypothesis created with
1281 # the same parameters, else (default) - creates a new one
1282 def SetGrid(self, xGridDef, yGridDef, zGridDef, sizeThreshold=4.0, UseExisting=False):
1284 compFun = lambda hyp, args: False
1285 self.hyp = self.Hypothesis("CartesianParameters3D",
1286 [xGridDef, yGridDef, zGridDef, sizeThreshold],
1287 UseExisting=UseExisting, CompareMethod=compFun)
1288 if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
1289 self.mesh.AddHypothesis( self.hyp, self.geom )
1291 for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef]):
1292 if not gridDef: raise ValueError, "Empty grid definition"
1293 if isinstance( gridDef, str ):
1294 self.hyp.SetGridSpacing( [gridDef], [], axis )
1295 elif isinstance( gridDef[0], str ):
1296 self.hyp.SetGridSpacing( gridDef, [], axis )
1297 elif isinstance( gridDef[0], int ) or \
1298 isinstance( gridDef[0], float ):
1299 self.hyp.SetGrid(gridDef, axis )
1301 self.hyp.SetGridSpacing( gridDef[0], gridDef[1], axis )
1302 self.hyp.SetSizeThreshold( sizeThreshold )
1305 pass # end of StdMeshersDC_Cartesian_3D class
1307 ## Defines a stub 1D algorithm, which enables "manual" creation of nodes and
1308 # segments usable by 2D algoritms
1310 # It is created by calling smesh.Mesh.UseExistingSegments(geom=0)
1312 # @ingroup l3_algos_basic
1313 class StdMeshersDC_UseExisting_1D(Mesh_Algorithm):
1315 ## name of the dynamic method in smesh.Mesh class
1317 meshMethod = "UseExistingSegments"
1318 ## type of algorithm used with helper function in smesh.Mesh class
1320 algoType = "UseExisting_1D"
1321 ## doc string of the method
1323 docHelper = "Creates 1D algorithm for edges with reusing of existing mesh elements"
1325 ## Private constructor.
1326 # @param mesh parent mesh object algorithm is assigned to
1327 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
1328 # if it is @c 0 (default), the algorithm is assigned to the main shape
1329 def __init__(self, mesh, geom=0):
1330 self.Create(mesh, geom, self.algoType)
1333 pass # end of StdMeshersDC_UseExisting_1D class
1335 ## Defines a stub 2D algorithm, which enables "manual" creation of nodes and
1336 # faces usable by 3D algoritms
1338 # It is created by calling smesh.Mesh.UseExistingFaces(geom=0)
1340 # @ingroup l3_algos_basic
1341 class StdMeshersDC_UseExisting_2D(Mesh_Algorithm):
1343 ## name of the dynamic method in smesh.Mesh class
1345 meshMethod = "UseExistingFaces"
1346 ## type of algorithm used with helper function in smesh.Mesh class
1348 algoType = "UseExisting_2D"
1349 ## doc string of the method
1351 docHelper = "Creates 2D algorithm for faces with reusing of existing mesh elements"
1353 ## Private constructor.
1354 # @param mesh parent mesh object algorithm is assigned to
1355 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
1356 # if it is @c 0 (default), the algorithm is assigned to the main shape
1357 def __init__(self, mesh, geom=0):
1358 self.Create(mesh, geom, self.algoType)
1361 pass # end of StdMeshersDC_UseExisting_2D class