1 # Copyright (C) 2007-2012 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 = 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 self.distribHyp.SetLayerDistribution( hyp )
901 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
902 # prisms to build between the inner and outer shells
903 # @param n number of layers
904 # @param UseExisting if ==true - searches for the existing hypothesis created with
905 # the same parameters, else (default) - creates a new one
906 def NumberOfLayers(self, n, UseExisting=0):
907 if self.algoType != "RadialPrism_3D":
908 print "Prism_3D algorith doesn't support any hyposesis"
910 self.mesh.RemoveHypothesis( self.distribHyp, self.geom )
911 compFun = lambda hyp, args: IsEqual(hyp.GetNumberOfLayers(), args[0])
912 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
913 CompareMethod=compFun)
914 self.nbLayers.SetNumberOfLayers( n )
917 ## Defines "LocalLength" hypothesis, specifying the segment length
918 # to build between the inner and the outer shells
919 # @param l the length of segments
920 # @param p the precision of rounding
921 def LocalLength(self, l, p=1e-07):
922 if self.algoType != "RadialPrism_3D":
923 print "Prism_3D algorith doesn't support any hyposesis"
925 hyp = self.OwnHypothesis("LocalLength", [l,p])
930 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
931 # prisms to build between the inner and the outer shells.
932 # @param n the number of layers
933 # @param s the scale factor (optional)
934 def NumberOfSegments(self, n, s=[]):
935 if self.algoType != "RadialPrism_3D":
936 print "Prism_3D algorith doesn't support any hyposesis"
939 hyp = self.OwnHypothesis("NumberOfSegments", [n])
941 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
942 hyp.SetDistrType( 1 )
943 hyp.SetScaleFactor(s)
944 hyp.SetNumberOfSegments(n)
947 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
948 # to build between the inner and the outer shells with a length that changes in arithmetic progression
949 # @param start the length of the first segment
950 # @param end the length of the last segment
951 def Arithmetic1D(self, start, end ):
952 if self.algoType != "RadialPrism_3D":
953 print "Prism_3D algorith doesn't support any hyposesis"
955 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
956 hyp.SetLength(start, 1)
957 hyp.SetLength(end , 0)
960 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
961 # to build between the inner and the outer shells as geometric length increasing
962 # @param start for the length of the first segment
963 # @param end for the length of the last segment
964 def StartEndLength(self, start, end):
965 if self.algoType != "RadialPrism_3D":
966 print "Prism_3D algorith doesn't support any hyposesis"
968 hyp = self.OwnHypothesis("StartEndLength", [start, end])
969 hyp.SetLength(start, 1)
970 hyp.SetLength(end , 0)
973 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
974 # to build between the inner and outer shells
975 # @param fineness defines the quality of the mesh within the range [0-1]
976 def AutomaticLength(self, fineness=0):
977 if self.algoType != "RadialPrism_3D":
978 print "Prism_3D algorith doesn't support any hyposesis"
980 hyp = self.OwnHypothesis("AutomaticLength")
981 hyp.SetFineness( fineness )
984 pass # end of StdMeshersDC_Prism3D class
986 ## Defines a Radial Quadrangle 1D-2D algorithm
988 # It is created by calling smesh.Mesh.Quadrangle(smesh.RADIAL_QUAD,geom=0)
990 # @ingroup l2_algos_radialq
991 class StdMeshersDC_RadialQuadrangle1D2D(Mesh_Algorithm):
993 ## name of the dynamic method in smesh.Mesh class
995 meshMethod = "Quadrangle"
996 ## type of algorithm used with helper function in smesh.Mesh class
998 algoType = RADIAL_QUAD
999 ## doc string of the method
1001 docHelper = "Creates quadrangle 1D-2D algorithm for triangular faces"
1003 ## Private constructor.
1004 # @param mesh parent mesh object algorithm is assigned to
1005 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
1006 # if it is @c 0 (default), the algorithm is assigned to the main shape
1007 def __init__(self, mesh, geom=0):
1008 Mesh_Algorithm.__init__(self)
1009 self.Create(mesh, geom, self.algoType)
1011 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
1012 self.nbLayers = None
1015 ## Return 2D hypothesis holding the 1D one
1016 def Get2DHypothesis(self):
1017 if not self.distribHyp:
1018 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
1019 return self.distribHyp
1021 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
1022 # hypothesis. Returns the created hypothesis
1023 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
1025 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
1026 if self.distribHyp is None:
1027 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
1029 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
1030 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
1031 self.mesh.smeshpyD.SetCurrentStudy( None )
1032 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
1033 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
1034 self.distribHyp.SetLayerDistribution( hyp )
1037 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
1038 # @param n number of layers
1039 # @param UseExisting if ==true - searches for the existing hypothesis created with
1040 # the same parameters, else (default) - creates a new one
1041 def NumberOfLayers(self, n, UseExisting=0):
1043 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
1044 compFun = lambda hyp, args: IsEqual(hyp.GetNumberOfLayers(), args[0])
1045 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
1046 CompareMethod=compFun)
1047 self.nbLayers.SetNumberOfLayers( n )
1048 return self.nbLayers
1050 ## Defines "LocalLength" hypothesis, specifying the segment length
1051 # @param l the length of segments
1052 # @param p the precision of rounding
1053 def LocalLength(self, l, p=1e-07):
1054 hyp = self.OwnHypothesis("LocalLength", [l,p])
1059 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
1060 # @param n the number of layers
1061 # @param s the scale factor (optional)
1062 def NumberOfSegments(self, n, s=[]):
1064 hyp = self.OwnHypothesis("NumberOfSegments", [n])
1066 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
1067 hyp.SetDistrType( 1 )
1068 hyp.SetScaleFactor(s)
1069 hyp.SetNumberOfSegments(n)
1072 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
1073 # with a length that changes in arithmetic progression
1074 # @param start the length of the first segment
1075 # @param end the length of the last segment
1076 def Arithmetic1D(self, start, end ):
1077 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
1078 hyp.SetLength(start, 1)
1079 hyp.SetLength(end , 0)
1082 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
1083 # as geometric length increasing
1084 # @param start for the length of the first segment
1085 # @param end for the length of the last segment
1086 def StartEndLength(self, start, end):
1087 hyp = self.OwnHypothesis("StartEndLength", [start, end])
1088 hyp.SetLength(start, 1)
1089 hyp.SetLength(end , 0)
1092 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
1093 # @param fineness defines the quality of the mesh within the range [0-1]
1094 def AutomaticLength(self, fineness=0):
1095 hyp = self.OwnHypothesis("AutomaticLength")
1096 hyp.SetFineness( fineness )
1099 pass # end of StdMeshersDC_RadialQuadrangle1D2D class
1101 ## Defines a Use Existing Elements 1D algorithm
1103 # It is created by calling smesh.Mesh.UseExisting1DElements(geom=0)
1105 # @ingroup l3_algos_basic
1106 class StdMeshersDC_UseExistingElements_1D(Mesh_Algorithm):
1108 ## name of the dynamic method in smesh.Mesh class
1110 meshMethod = "UseExisting1DElements"
1111 ## type of algorithm used with helper function in smesh.Mesh class
1113 algoType = "Import_1D"
1114 ## flag pointing either this algorithm should be used by default in dynamic method
1115 # of smesh.Mesh class
1118 ## doc string of the method
1120 docHelper = "Creates 1D algorithm for edges with reusing of existing mesh elements"
1122 ## Private constructor.
1123 # @param mesh parent mesh object algorithm is assigned to
1124 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
1125 # if it is @c 0 (default), the algorithm is assigned to the main shape
1126 def __init__(self, mesh, geom=0):
1127 Mesh_Algorithm.__init__(self)
1128 self.Create(mesh, geom, self.algoType)
1131 ## Defines "Source edges" hypothesis, specifying groups of edges to import
1132 # @param groups list of groups of edges
1133 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
1134 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
1135 # @param UseExisting if ==true - searches for the existing hypothesis created with
1136 # the same parameters, else (default) - creates a new one
1137 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
1138 for group in groups:
1139 AssureGeomPublished( self.mesh, group )
1140 compFun = lambda hyp, args: ( hyp.GetSourceEdges() == args[0] and \
1141 hyp.GetCopySourceMesh() == args[1], args[2] )
1142 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
1143 UseExisting=UseExisting, CompareMethod=compFun)
1144 hyp.SetSourceEdges(groups)
1145 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
1148 pass # end of StdMeshersDC_UseExistingElements_1D class
1150 ## Defines a Use Existing Elements 1D-2D algorithm
1152 # It is created by calling smesh.Mesh.UseExisting2DElements(geom=0)
1154 # @ingroup l3_algos_basic
1155 class StdMeshersDC_UseExistingElements_1D2D(Mesh_Algorithm):
1157 ## name of the dynamic method in smesh.Mesh class
1159 meshMethod = "UseExisting2DElements"
1160 ## type of algorithm used with helper function in smesh.Mesh class
1162 algoType = "Import_1D2D"
1163 ## flag pointing either this algorithm should be used by default in dynamic method
1164 # of smesh.Mesh class
1167 ## doc string of the method
1169 docHelper = "Creates 1D-2D algorithm for edges/faces with reusing of existing mesh elements"
1171 ## Private constructor.
1172 # @param mesh parent mesh object algorithm is assigned to
1173 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
1174 # if it is @c 0 (default), the algorithm is assigned to the main shape
1175 def __init__(self, mesh, geom=0):
1176 Mesh_Algorithm.__init__(self)
1177 self.Create(mesh, geom, self.algoType)
1180 ## Defines "Source faces" hypothesis, specifying groups of faces to import
1181 # @param groups list of groups of faces
1182 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
1183 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
1184 # @param UseExisting if ==true - searches for the existing hypothesis created with
1185 # the same parameters, else (default) - creates a new one
1186 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
1187 for group in groups:
1188 AssureGeomPublished( self.mesh, group )
1189 compFun = lambda hyp, args: ( hyp.GetSourceFaces() == args[0] and \
1190 hyp.GetCopySourceMesh() == args[1], args[2] )
1191 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
1192 UseExisting=UseExisting, CompareMethod=compFun)
1193 hyp.SetSourceFaces(groups)
1194 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
1197 pass # end of StdMeshersDC_UseExistingElements_1D2D class
1199 ## Defines a Body Fitting 3D algorithm
1201 # It is created by calling smesh.Mesh.BodyFitted(geom=0)
1203 # @ingroup l3_algos_basic
1204 class StdMeshersDC_Cartesian_3D(Mesh_Algorithm):
1206 ## name of the dynamic method in smesh.Mesh class
1208 meshMethod = "BodyFitted"
1209 ## type of algorithm used with helper function in smesh.Mesh class
1211 algoType = "Cartesian_3D"
1212 ## flag pointing either this algorithm should be used by default in dynamic method
1213 # of smesh.Mesh class
1216 ## doc string of the method
1218 docHelper = "Creates body fitting 3D algorithm for volumes"
1220 ## Private constructor.
1221 # @param mesh parent mesh object algorithm is assigned to
1222 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
1223 # if it is @c 0 (default), the algorithm is assigned to the main shape
1224 def __init__(self, mesh, geom=0):
1225 self.Create(mesh, geom, self.algoType)
1229 ## Defines "Body Fitting parameters" hypothesis
1230 # @param xGridDef is definition of the grid along the X asix.
1231 # It can be in either of two following forms:
1232 # - Explicit coordinates of nodes, e.g. [-1.5, 0.0, 3.1] or range( -100,200,10)
1233 # - Functions f(t) defining grid spacing at each point on grid axis. If there are
1234 # several functions, they must be accompanied by relative coordinates of
1235 # points dividing the whole shape into ranges where the functions apply; points
1236 # coodrinates should vary within (0.0, 1.0) range. Parameter \a t of the spacing
1237 # function f(t) varies from 0.0 to 1.0 witin a shape range.
1239 # - "10.5" - defines a grid with a constant spacing
1240 # - [["1", "1+10*t", "11"] [0.1, 0.6]] - defines different spacing in 3 ranges.
1241 # @param yGridDef defines the grid along the Y asix the same way as \a xGridDef does
1242 # @param zGridDef defines the grid along the Z asix the same way as \a xGridDef does
1243 # @param sizeThreshold (> 1.0) defines a minimal size of a polyhedron so that
1244 # a polyhedron of size less than hexSize/sizeThreshold is not created
1245 # @param UseExisting if ==true - searches for the existing hypothesis created with
1246 # the same parameters, else (default) - creates a new one
1247 def SetGrid(self, xGridDef, yGridDef, zGridDef, sizeThreshold=4.0, UseExisting=False):
1249 compFun = lambda hyp, args: False
1250 self.hyp = self.Hypothesis("CartesianParameters3D",
1251 [xGridDef, yGridDef, zGridDef, sizeThreshold],
1252 UseExisting=UseExisting, CompareMethod=compFun)
1253 if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
1254 self.mesh.AddHypothesis( self.hyp, self.geom )
1256 for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef]):
1257 if not gridDef: raise ValueError, "Empty grid definition"
1258 if isinstance( gridDef, str ):
1259 self.hyp.SetGridSpacing( [gridDef], [], axis )
1260 elif isinstance( gridDef[0], str ):
1261 self.hyp.SetGridSpacing( gridDef, [], axis )
1262 elif isinstance( gridDef[0], int ) or \
1263 isinstance( gridDef[0], float ):
1264 self.hyp.SetGrid(gridDef, axis )
1266 self.hyp.SetGridSpacing( gridDef[0], gridDef[1], axis )
1267 self.hyp.SetSizeThreshold( sizeThreshold )
1270 pass # end of StdMeshersDC_Cartesian_3D class
1272 ## Defines a stub 1D algorithm, which enables "manual" creation of nodes and
1273 # segments usable by 2D algoritms
1275 # It is created by calling smesh.Mesh.UseExistingSegments(geom=0)
1277 # @ingroup l3_algos_basic
1278 class StdMeshersDC_UseExisting_1D(Mesh_Algorithm):
1280 ## name of the dynamic method in smesh.Mesh class
1282 meshMethod = "UseExistingSegments"
1283 ## type of algorithm used with helper function in smesh.Mesh class
1285 algoType = "UseExisting_1D"
1286 ## doc string of the method
1288 docHelper = "Creates 1D algorithm for edges with reusing of existing mesh elements"
1290 ## Private constructor.
1291 # @param mesh parent mesh object algorithm is assigned to
1292 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
1293 # if it is @c 0 (default), the algorithm is assigned to the main shape
1294 def __init__(self, mesh, geom=0):
1295 self.Create(mesh, geom, self.algoType)
1298 pass # end of StdMeshersDC_UseExisting_1D class
1300 ## Defines a stub 2D algorithm, which enables "manual" creation of nodes and
1301 # faces usable by 3D algoritms
1303 # It is created by calling smesh.Mesh.UseExistingFaces(geom=0)
1305 # @ingroup l3_algos_basic
1306 class StdMeshersDC_UseExisting_2D(Mesh_Algorithm):
1308 ## name of the dynamic method in smesh.Mesh class
1310 meshMethod = "UseExistingFaces"
1311 ## type of algorithm used with helper function in smesh.Mesh class
1313 algoType = "UseExisting_2D"
1314 ## doc string of the method
1316 docHelper = "Creates 2D algorithm for faces with reusing of existing mesh elements"
1318 ## Private constructor.
1319 # @param mesh parent mesh object algorithm is assigned to
1320 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
1321 # if it is @c 0 (default), the algorithm is assigned to the main shape
1322 def __init__(self, mesh, geom=0):
1323 self.Create(mesh, geom, self.algoType)
1326 pass # end of StdMeshersDC_UseExisting_2D class