Salome HOME
Copyrights update 2015.
[modules/smesh.git] / src / SMESH_SWIG / StdMeshersBuilder.py
1 # Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 ##
21 # @package StdMeshersBuilder
22 # Python API for the standard meshing plug-in module.
23
24 from salome.smesh.smesh_algorithm import Mesh_Algorithm
25 import StdMeshers
26
27 #----------------------------
28 # Mesh algo type identifiers
29 #----------------------------
30
31 ## Algorithm type: Regular 1D algorithm, see StdMeshersBuilder_Segment
32 REGULAR     = "Regular_1D"
33 ## Algorithm type: Python 1D algorithm, see StdMeshersBuilder_Segment_Python
34 PYTHON      = "Python_1D"
35 ## Algorithm type: Composite segment 1D algorithm, see StdMeshersBuilder_CompositeSegment
36 COMPOSITE   = "CompositeSegment_1D"
37 ## Algorithm type: Triangle MEFISTO 2D algorithm, see StdMeshersBuilder_Triangle_MEFISTO
38 MEFISTO     = "MEFISTO_2D"
39 ## Algorithm type: Hexahedron 3D (i-j-k) algorithm, see StdMeshersBuilder_Hexahedron
40 Hexa        = "Hexa_3D"
41 ## Algorithm type: Quadrangle 2D algorithm, see StdMeshersBuilder_Quadrangle
42 QUADRANGLE  = "Quadrangle_2D"
43 ## Algorithm type: Radial Quadrangle 1D-2D algorithm, see StdMeshersBuilder_RadialQuadrangle1D2D
44 RADIAL_QUAD = "RadialQuadrangle_1D2D"
45
46 # import items of enums
47 for e in StdMeshers.QuadType._items: exec('%s = StdMeshers.%s'%(e,e))
48 for e in StdMeshers.VLExtrusionMethod._items: exec('%s = StdMeshers.%s'%(e,e))
49
50 #----------------------
51 # Algorithms
52 #----------------------
53
54 ## Defines segment 1D algorithm for edges discretization.
55 #
56 #  It can be created by calling smeshBuilder.Mesh.Segment(geom=0)
57 #
58 #  @ingroup l3_algos_basic
59 class StdMeshersBuilder_Segment(Mesh_Algorithm):
60
61     ## name of the dynamic method in smeshBuilder.Mesh class
62     #  @internal
63     meshMethod = "Segment"
64     ## type of algorithm used with helper function in smeshBuilder.Mesh class
65     #  @internal
66     algoType   = REGULAR
67     ## flag pointing either this algorithm should be used by default in dynamic method
68     #  of smeshBuilder.Mesh class
69     #  @internal
70     isDefault  = True
71     ## doc string of the method
72     #  @internal
73     docHelper  = "Creates segment 1D algorithm for edges"
74
75     ## Private constructor.
76     #  @param mesh parent mesh object algorithm is assigned to
77     #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
78     #              if it is @c 0 (default), the algorithm is assigned to the main shape
79     def __init__(self, mesh, geom=0):
80         Mesh_Algorithm.__init__(self)
81         self.Create(mesh, geom, self.algoType)
82         pass
83
84     ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
85     #  @param l for the length of segments that cut an edge
86     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
87     #                    the same parameters, else (default) - creates a new one
88     #  @param p precision, used for calculation of the number of segments.
89     #           The precision should be a positive, meaningful value within the range [0,1].
90     #           In general, the number of segments is calculated with the formula:
91     #           nb = ceil((edge_length / l) - p)
92     #           Function ceil rounds its argument to the higher integer.
93     #           So, p=0 means rounding of (edge_length / l) to the higher integer,
94     #               p=0.5 means rounding of (edge_length / l) to the nearest integer,
95     #               p=1 means rounding of (edge_length / l) to the lower integer.
96     #           Default value is 1e-07.
97     #  @return an instance of StdMeshers_LocalLength hypothesis
98     #  @ingroup l3_hypos_1dhyps
99     def LocalLength(self, l, UseExisting=0, p=1e-07):
100         from salome.smesh.smeshBuilder import IsEqual
101         comFun=lambda hyp, args: IsEqual(hyp.GetLength(), args[0]) and IsEqual(hyp.GetPrecision(), args[1])
102         hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting, CompareMethod=comFun)
103         hyp.SetLength(l)
104         hyp.SetPrecision(p)
105         return hyp
106
107     ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
108     #  @param length is optional maximal allowed length of segment, if it is omitted
109     #                the preestimated length is used that depends on geometry size
110     #  @param UseExisting if ==true - searches for an existing hypothesis created with
111     #                     the same parameters, else (default) - creates a new one
112     #  @return an instance of StdMeshers_MaxLength hypothesis
113     #  @ingroup l3_hypos_1dhyps
114     def MaxSize(self, length=0.0, UseExisting=0):
115         hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
116         if length > 0.0:
117             # set given length
118             hyp.SetLength(length)
119         if not UseExisting:
120             # set preestimated length
121             gen = self.mesh.smeshpyD
122             initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
123                                                        self.mesh.GetMesh(), self.mesh.GetShape(),
124                                                        False) # <- byMesh
125             preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
126             if preHyp:
127                 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
128                 pass
129             pass
130         hyp.SetUsePreestimatedLength( length == 0.0 )
131         return hyp
132
133     ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
134     #  @param n for the number of segments that cut an edge
135     #  @param s for the scale factor (optional)
136     #  @param reversedEdges is a list of edges to mesh using reversed orientation.
137     #                       A list item can also be a tuple (edge, 1st_vertex_of_edge)
138     #  @param UseExisting if ==true - searches for an existing hypothesis created with
139     #                     the same parameters, else (default) - create a new one
140     #  @return an instance of StdMeshers_NumberOfSegments hypothesis
141     #  @ingroup l3_hypos_1dhyps
142     def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
143         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
144             reversedEdges, UseExisting = [], reversedEdges
145         entry = self.MainShapeEntry()
146         reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
147         if s == []:
148             hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdgeInd, entry],
149                                   UseExisting=UseExisting,
150                                   CompareMethod=self._compareNumberOfSegments)
151         else:
152             hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdgeInd, entry],
153                                   UseExisting=UseExisting,
154                                   CompareMethod=self._compareNumberOfSegments)
155             hyp.SetDistrType( 1 )
156             hyp.SetScaleFactor(s)
157         hyp.SetNumberOfSegments(n)
158         hyp.SetReversedEdges( reversedEdgeInd )
159         hyp.SetObjectEntry( entry )
160         return hyp
161
162     ## Private method
163     #  
164     #  Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
165     def _compareNumberOfSegments(self, hyp, args):
166         if hyp.GetNumberOfSegments() == args[0]:
167             if len(args) == 3:
168                 if hyp.GetReversedEdges() == args[1]:
169                     if not args[1] or hyp.GetObjectEntry() == args[2]:
170                         return True
171             else:
172                 from salome.smesh.smeshBuilder import IsEqual
173                 if hyp.GetReversedEdges() == args[2]:
174                     if not args[2] or hyp.GetObjectEntry() == args[3]:
175                         if hyp.GetDistrType() == 1:
176                             if IsEqual(hyp.GetScaleFactor(), args[1]):
177                                 return True
178         return False
179
180     ## Defines "Adaptive" hypothesis to cut an edge into segments keeping segment size
181     #  within the given range and considering (1) deflection of segments from the edge
182     #  and (2) distance from segments to closest edges and faces to have segment length
183     #  not longer than two times shortest distances to edges and faces.
184     #  @param minSize defines the minimal allowed segment length
185     #  @param maxSize defines the maximal allowed segment length
186     #  @param deflection defines the maximal allowed distance from a segment to an edge
187     #  @param UseExisting if ==true - searches for an existing hypothesis created with
188     #                     the same parameters, else (default) - creates a new one
189     #  @return an instance of StdMeshers_Adaptive1D hypothesis
190     #  @ingroup l3_hypos_1dhyps
191     def Adaptive(self, minSize, maxSize, deflection, UseExisting=False):
192         from salome.smesh.smeshBuilder import IsEqual
193         compFun = lambda hyp, args: ( IsEqual(hyp.GetMinSize(), args[0]) and \
194                                       IsEqual(hyp.GetMaxSize(), args[1]) and \
195                                       IsEqual(hyp.GetDeflection(), args[2]))
196         hyp = self.Hypothesis("Adaptive1D", [minSize, maxSize, deflection],
197                               UseExisting=UseExisting, CompareMethod=compFun)
198         hyp.SetMinSize(minSize)
199         hyp.SetMaxSize(maxSize)
200         hyp.SetDeflection(deflection)
201         return hyp
202
203     ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with a length
204     #  that changes in arithmetic progression
205     #  @param start defines the length of the first segment
206     #  @param end   defines the length of the last  segment
207     #  @param reversedEdges is a list of edges to mesh using reversed orientation.
208     #                       A list item can also be a tuple (edge, 1st_vertex_of_edge)
209     #  @param UseExisting if ==true - searches for an existing hypothesis created with
210     #                     the same parameters, else (default) - creates a new one
211     #  @return an instance of StdMeshers_Arithmetic1D hypothesis
212     #  @ingroup l3_hypos_1dhyps
213     def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
214         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
215             reversedEdges, UseExisting = [], reversedEdges
216         reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
217         entry = self.MainShapeEntry()
218         from salome.smesh.smeshBuilder import IsEqual
219         compFun = lambda hyp, args: ( IsEqual(hyp.GetLength(1), args[0]) and \
220                                       IsEqual(hyp.GetLength(0), args[1]) and \
221                                       hyp.GetReversedEdges() == args[2]  and \
222                                       (not args[2] or hyp.GetObjectEntry() == args[3]))
223         hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdgeInd, entry],
224                               UseExisting=UseExisting, CompareMethod=compFun)
225         hyp.SetStartLength(start)
226         hyp.SetEndLength(end)
227         hyp.SetReversedEdges( reversedEdgeInd )
228         hyp.SetObjectEntry( entry )
229         return hyp
230
231     ## Defines "GeometricProgression" hypothesis to cut an edge in several
232     #  segments with a length that changes in Geometric progression
233     #  @param start defines the length of the first segment
234     #  @param ratio defines the common ratio of the geometric progression
235     #  @param reversedEdges is a list of edges to mesh using reversed orientation.
236     #                       A list item can also be a tuple (edge, 1st_vertex_of_edge)
237     #  @param UseExisting if ==true - searches for an existing hypothesis created with
238     #                     the same parameters, else (default) - creates a new one
239     #  @return an instance of StdMeshers_Geometric1D hypothesis
240     #  @ingroup l3_hypos_1dhyps
241     def GeometricProgression(self, start, ratio, reversedEdges=[], UseExisting=0):
242         reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
243         entry = self.MainShapeEntry()
244         from salome.smesh.smeshBuilder import IsEqual
245         compFun = lambda hyp, args: ( IsEqual(hyp.GetLength(1), args[0]) and \
246                                       IsEqual(hyp.GetLength(0), args[1]) and \
247                                       hyp.GetReversedEdges() == args[2]  and \
248                                       (not args[2] or hyp.GetObjectEntry() == args[3]))
249         hyp = self.Hypothesis("GeometricProgression", [start, ratio, reversedEdgeInd, entry],
250                               UseExisting=UseExisting, CompareMethod=compFun)
251         hyp.SetStartLength( start )
252         hyp.SetCommonRatio( ratio )
253         hyp.SetReversedEdges( reversedEdgeInd )
254         hyp.SetObjectEntry( entry )
255         return hyp
256
257     ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
258     # on curve from 0 to 1 (additionally it is neecessary to check
259     # orientation of edges and create list of reversed edges if it is
260     # needed) and sets numbers of segments between given points (default
261     # values are equals 1
262     #  @param points defines the list of parameters on curve
263     #  @param nbSegs defines the list of numbers of segments
264     #  @param reversedEdges is a list of edges to mesh using reversed orientation.
265     #                       A list item can also be a tuple (edge, 1st_vertex_of_edge)
266     #  @param UseExisting if ==true - searches for an existing hypothesis created with
267     #                     the same parameters, else (default) - creates a new one
268     #  @return an instance of StdMeshers_FixedPoints1D hypothesis
269     #  @ingroup l3_hypos_1dhyps
270     def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
271         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
272             reversedEdges, UseExisting = [], reversedEdges
273         reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
274         entry = self.MainShapeEntry()
275         compFun = lambda hyp, args: ( hyp.GetPoints() == args[0] and \
276                                       hyp.GetNbSegments() == args[1] and \
277                                       hyp.GetReversedEdges() == args[2] and \
278                                       (not args[2] or hyp.GetObjectEntry() == args[3]))
279         hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdgeInd, entry],
280                               UseExisting=UseExisting, CompareMethod=compFun)
281         hyp.SetPoints(points)
282         hyp.SetNbSegments(nbSegs)
283         hyp.SetReversedEdges(reversedEdgeInd)
284         hyp.SetObjectEntry(entry)
285         return hyp
286
287     ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
288     #  @param start defines the length of the first segment
289     #  @param end   defines the length of the last  segment
290     #  @param reversedEdges is a list of edges to mesh using reversed orientation.
291     #                       A list item can also be a tuple (edge, 1st_vertex_of_edge)
292     #  @param UseExisting if ==true - searches for an existing hypothesis created with
293     #                     the same parameters, else (default) - creates a new one
294     #  @return an instance of StdMeshers_StartEndLength hypothesis
295     #  @ingroup l3_hypos_1dhyps
296     def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
297         if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
298             reversedEdges, UseExisting = [], reversedEdges
299         reversedEdgeInd = self.ReversedEdgeIndices(reversedEdges)
300         entry = self.MainShapeEntry()
301         from salome.smesh.smeshBuilder import IsEqual
302         compFun = lambda hyp, args: ( IsEqual(hyp.GetLength(1), args[0]) and \
303                                       IsEqual(hyp.GetLength(0), args[1]) and \
304                                       hyp.GetReversedEdges() == args[2]  and \
305                                       (not args[2] or hyp.GetObjectEntry() == args[3]))
306         hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdgeInd, entry],
307                               UseExisting=UseExisting, CompareMethod=compFun)
308         hyp.SetStartLength(start)
309         hyp.SetEndLength(end)
310         hyp.SetReversedEdges( reversedEdgeInd )
311         hyp.SetObjectEntry( entry )
312         return hyp
313
314     ## Defines "Deflection1D" hypothesis
315     #  @param d for the deflection
316     #  @param UseExisting if ==true - searches for an existing hypothesis created with
317     #                     the same parameters, else (default) - create a new one
318     #  @ingroup l3_hypos_1dhyps
319     def Deflection1D(self, d, UseExisting=0):
320         from salome.smesh.smeshBuilder import IsEqual
321         compFun = lambda hyp, args: IsEqual(hyp.GetDeflection(), args[0])
322         hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting, CompareMethod=compFun)
323         hyp.SetDeflection(d)
324         return hyp
325
326     ## Defines "Propagation" hypothesis that propagates 1D hypotheses
327     #  from an edge where this hypothesis is assigned to
328     #  on all other edges that are at the opposite side in case of quadrangular faces
329     #  This hypothesis should be assigned to an edge to propagate a hypothesis from.
330     #  @ingroup l3_hypos_additi
331     def Propagation(self):
332         return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
333
334     ## Defines "Propagation of Node Distribution" hypothesis that propagates
335     #  distribution of nodes from an edge where this hypothesis is assigned to,
336     #  to opposite edges of quadrangular faces, so that number of segments on all these
337     #  edges will be the same, as well as relations between segment lengths. 
338     #  @ingroup l3_hypos_additi
339     def PropagationOfDistribution(self):
340         return self.Hypothesis("PropagOfDistribution", UseExisting=1,
341                                CompareMethod=self.CompareEqualHyp)
342
343     ## Defines "AutomaticLength" hypothesis
344     #  @param fineness for the fineness [0-1]
345     #  @param UseExisting if ==true - searches for an existing hypothesis created with the
346     #                     same parameters, else (default) - create a new one
347     #  @ingroup l3_hypos_1dhyps
348     def AutomaticLength(self, fineness=0, UseExisting=0):
349         from salome.smesh.smeshBuilder import IsEqual
350         compFun = lambda hyp, args: IsEqual(hyp.GetFineness(), args[0])
351         hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
352                               CompareMethod=compFun)
353         hyp.SetFineness( fineness )
354         return hyp
355
356     ## Defines "SegmentLengthAroundVertex" hypothesis
357     #  @param length for the segment length
358     #  @param vertex for the length localization: the vertex index [0,1] | vertex object.
359     #         Any other integer value means that the hypothesis will be set on the
360     #         whole 1D shape, where Mesh_Segment algorithm is assigned.
361     #  @param UseExisting if ==true - searches for an  existing hypothesis created with
362     #                   the same parameters, else (default) - creates a new one
363     #  @ingroup l3_algos_segmarv
364     def LengthNearVertex(self, length, vertex=0, UseExisting=0):
365         import types
366         store_geom = self.geom
367         if type(vertex) is types.IntType:
368             if vertex == 0 or vertex == 1:
369                 from salome.geom import geomBuilder
370                 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geomBuilder.geomBuilder.ShapeType["VERTEX"],True)[vertex]
371                 self.geom = vertex
372                 pass
373             pass
374         else:
375             self.geom = vertex
376             pass
377         # 0D algorithm
378         if self.geom is None:
379             raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
380         from salome.smesh.smeshBuilder import AssureGeomPublished, GetName, TreatHypoStatus
381         AssureGeomPublished( self.mesh, self.geom )
382         name = GetName(self.geom)
383
384         algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
385         if algo is None:
386             algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
387             pass
388         status = self.mesh.mesh.AddHypothesis(self.geom, algo)
389         TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True, self.mesh)
390         #
391         from salome.smesh.smeshBuilder import IsEqual
392         comFun = lambda hyp, args: IsEqual(hyp.GetLength(), args[0])
393         hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
394                               CompareMethod=comFun)
395         self.geom = store_geom
396         hyp.SetLength( length )
397         return hyp
398
399     ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
400     #  If the 2D mesher sees that all boundary edges are quadratic,
401     #  it generates quadratic faces, else it generates linear faces using
402     #  medium nodes as if they are vertices.
403     #  The 3D mesher generates quadratic volumes only if all boundary faces
404     #  are quadratic, else it fails.
405     #
406     #  @ingroup l3_hypos_additi
407     def QuadraticMesh(self):
408         hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
409         return hyp
410
411     pass # end of StdMeshersBuilder_Segment class
412
413 ## Segment 1D algorithm for discretization of a set of adjacent edges as one edge.
414 #
415 #  It is created by calling smeshBuilder.Mesh.Segment(smeshBuilder.COMPOSITE,geom=0)
416 #
417 #  @ingroup l3_algos_basic
418 class StdMeshersBuilder_CompositeSegment(StdMeshersBuilder_Segment):
419
420     ## name of the dynamic method in smeshBuilder.Mesh class
421     #  @internal
422     meshMethod = "Segment"
423     ## type of algorithm used with helper function in smeshBuilder.Mesh class
424     #  @internal
425     algoType   = COMPOSITE
426     ## flag pointing either this algorithm should be used by default in dynamic method
427     #  of smeshBuilder.Mesh class
428     #  @internal
429     isDefault  = False
430     ## doc string of the method
431     #  @internal
432     docHelper  = "Creates segment 1D algorithm for edges"
433
434     ## Private constructor.
435     #  @param mesh parent mesh object algorithm is assigned to
436     #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
437     #              if it is @c 0 (default), the algorithm is assigned to the main shape
438     def __init__(self, mesh, geom=0):
439         self.Create(mesh, geom, self.algoType)
440         pass
441
442     pass # end of StdMeshersBuilder_CompositeSegment class
443
444 ## Defines a segment 1D algorithm for discretization of edges with Python function
445 #
446 #  It is created by calling smeshBuilder.Mesh.Segment(smeshBuilder.PYTHON,geom=0)
447 #
448 #  @ingroup l3_algos_basic
449 class StdMeshersBuilder_Segment_Python(Mesh_Algorithm):
450
451     ## name of the dynamic method in smeshBuilder.Mesh class
452     #  @internal
453     meshMethod = "Segment"
454     ## type of algorithm used with helper function in smeshBuilder.Mesh class
455     #  @internal
456     algoType   = PYTHON
457     ## doc string of the method
458     #  @internal
459     docHelper  = "Creates tetrahedron 3D algorithm for solids"
460     ## doc string of the method
461     #  @internal
462     docHelper  = "Creates segment 1D algorithm for edges"
463
464     ## Private constructor.
465     #  @param mesh parent mesh object algorithm is assigned to
466     #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
467     #              if it is @c 0 (default), the algorithm is assigned to the main shape
468     def __init__(self, mesh, geom=0):
469         import Python1dPlugin
470         self.Create(mesh, geom, self.algoType, "libPython1dEngine.so")
471         pass
472
473     ## Defines "PythonSplit1D" hypothesis
474     #  @param n for the number of segments that cut an edge
475     #  @param func for the python function that calculates the length of all segments
476     #  @param UseExisting if ==true - searches for the existing hypothesis created with
477     #                     the same parameters, else (default) - creates a new one
478     #  @ingroup l3_hypos_1dhyps
479     def PythonSplit1D(self, n, func, UseExisting=0):
480         compFun = lambda hyp, args: False
481         hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
482                               UseExisting=UseExisting, CompareMethod=compFun)
483         hyp.SetNumberOfSegments(n)
484         hyp.SetPythonLog10RatioFunction(func)
485         return hyp
486
487     pass # end of StdMeshersBuilder_Segment_Python class
488
489 ## Triangle MEFISTO 2D algorithm
490 #
491 #  It is created by calling smeshBuilder.Mesh.Triangle(smeshBuilder.MEFISTO,geom=0)
492 #
493 #  @ingroup l3_algos_basic
494 class StdMeshersBuilder_Triangle_MEFISTO(Mesh_Algorithm):
495
496     ## name of the dynamic method in smeshBuilder.Mesh class
497     #  @internal
498     meshMethod = "Triangle"
499     ## type of algorithm used with helper function in smeshBuilder.Mesh class
500     #  @internal
501     algoType   = MEFISTO
502     ## flag pointing either this algorithm should be used by default in dynamic method
503     #  of smeshBuilder.Mesh class
504     #  @internal
505     isDefault  = True
506     ## doc string of the method
507     #  @internal
508     docHelper  = "Creates triangle 2D algorithm for faces"
509
510     ## Private constructor.
511     #  @param mesh parent mesh object algorithm is assigned to
512     #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
513     #              if it is @c 0 (default), the algorithm is assigned to the main shape
514     def __init__(self, mesh, geom=0):
515         Mesh_Algorithm.__init__(self)
516         self.Create(mesh, geom, self.algoType)
517         pass
518
519     ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
520     #  @param area for the maximum area of each triangle
521     #  @param UseExisting if ==true - searches for an  existing hypothesis created with the
522     #                     same parameters, else (default) - creates a new one
523     #
524     #  @ingroup l3_hypos_2dhyps
525     def MaxElementArea(self, area, UseExisting=0):
526         from salome.smesh.smeshBuilder import IsEqual
527         comparator = lambda hyp, args: IsEqual(hyp.GetMaxElementArea(), args[0])
528         hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
529                               CompareMethod=comparator)
530         hyp.SetMaxElementArea(area)
531         return hyp
532
533     ## Defines "LengthFromEdges" hypothesis to build triangles
534     #  based on the length of the edges taken from the wire
535     #
536     #  @ingroup l3_hypos_2dhyps
537     def LengthFromEdges(self):
538         hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
539         return hyp
540
541     pass # end of StdMeshersBuilder_Triangle_MEFISTO class
542
543 ## Defines a quadrangle 2D algorithm
544
545 #  It is created by calling smeshBuilder.Mesh.Quadrangle(geom=0)
546 #
547 #  @ingroup l3_algos_basic
548 class StdMeshersBuilder_Quadrangle(Mesh_Algorithm):
549
550     ## name of the dynamic method in smeshBuilder.Mesh class
551     #  @internal
552     meshMethod = "Quadrangle"
553     ## type of algorithm used with helper function in smeshBuilder.Mesh class
554     #  @internal
555     algoType   = QUADRANGLE
556     ## flag pointing either this algorithm should be used by default in dynamic method
557     #  of smeshBuilder.Mesh class
558     #  @internal
559     isDefault  = True
560     ## doc string of the method
561     #  @internal
562     docHelper  = "Creates quadrangle 2D algorithm for faces"
563     ## hypothesis associated with algorithm
564     #  @internal
565     params     = 0
566
567     ## Private constructor.
568     #  @param mesh parent mesh object algorithm is assigned to
569     #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
570     #              if it is @c 0 (default), the algorithm is assigned to the main shape
571     def __init__(self, mesh, geom=0):
572         Mesh_Algorithm.__init__(self)
573         self.Create(mesh, geom, self.algoType)
574         pass
575
576     ## Defines "QuadrangleParameters" hypothesis
577     #  @param quadType defines the algorithm of transition between differently descretized
578     #                  sides of a geometrical face:
579     #  - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
580     #                    area along the finer meshed sides.
581     #  - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
582     #                    finer meshed sides.
583     #  - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
584     #                    the finer meshed sides, iff the total quantity of segments on
585     #                    all four sides of the face is even (divisible by 2).
586     #  - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
587     #                    area is located along the coarser meshed sides.
588     #  - QUAD_REDUCED - only quadrangles are built and the transition between the sides
589     #                    is made gradually, layer by layer. This type has a limitation on
590     #                    the number of segments: one pair of opposite sides must have the
591     #                    same number of segments, the other pair must have an even difference
592     #                    between the numbers of segments on the sides.
593     #  @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
594     #                    will be created while other elements will be quadrangles.
595     #                    Vertex can be either a GEOM_Object or a vertex ID within the
596     #                    shape to mesh
597     #  @param enfVertices: list of shapes defining positions where nodes (enforced nodes)
598     #                    must be created by the mesher. Shapes can be of any type,
599     #                    vertices of given shapes define positions of enforced nodes.
600     #                    Only vertices successfully projected to the face are used.
601     #  @param enfPoints: list of points giving positions of enforced nodes.
602     #                    Point can be defined either as SMESH.PointStruct's
603     #                    ([SMESH.PointStruct(x1,y1,z1), SMESH.PointStruct(x2,y2,z2),...])
604     #                    or triples of values ([[x1,y1,z1], [x2,y2,z2], ...]).
605     #                    In the case if the defined QuadrangleParameters() refer to a sole face,
606     #                    all given points must lie on this face, else the mesher fails.
607     #  @param UseExisting: if \c True - searches for the existing hypothesis created with
608     #                    the same parameters, else (default) - creates a new one
609     #  @ingroup l3_hypos_quad
610     def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0,
611                              enfVertices=[],enfPoints=[],UseExisting=0):
612         import GEOM, SMESH
613         vertexID = triangleVertex
614         if isinstance( triangleVertex, GEOM._objref_GEOM_Object ):
615             vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
616         if isinstance( enfVertices, int ) and not enfPoints and not UseExisting:
617             # a call of old syntax, before inserting enfVertices and enfPoints before UseExisting
618             UseExisting, enfVertices = enfVertices, []
619         pStructs, xyz = [], []
620         for p in enfPoints:
621             if isinstance( p, SMESH.PointStruct ):
622                 xyz.append(( p.x, p.y, p.z ))
623                 pStructs.append( p )
624             else:
625                 xyz.append(( p[0], p[1], p[2] ))
626                 pStructs.append( SMESH.PointStruct( p[0], p[1], p[2] ))
627         if not self.params:
628             compFun = lambda hyp,args: \
629                       hyp.GetQuadType() == args[0] and \
630                       (hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1)) and \
631                       ((hyp.GetEnforcedNodes()) == (args[2],args[3])) # True w/o enfVertices only
632             entries = [ shape.GetStudyEntry() for shape in enfVertices ]
633             self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID,entries,xyz],
634                                           UseExisting = UseExisting, CompareMethod=compFun)
635             pass
636         if self.params.GetQuadType() != quadType:
637             self.params.SetQuadType(quadType)
638         if vertexID > 0:
639             self.params.SetTriaVertex( vertexID )
640         from salome.smesh.smeshBuilder import AssureGeomPublished
641         for v in enfVertices:
642             AssureGeomPublished( self.mesh, v )
643         self.params.SetEnforcedNodes( enfVertices, pStructs )
644         return self.params
645
646     ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
647     #   quadrangles are built in the transition area along the finer meshed sides,
648     #   iff the total quantity of segments on all four sides of the face is even.
649     #  @param reversed if True, transition area is located along the coarser meshed sides.
650     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
651     #                  the same parameters, else (default) - creates a new one
652     #  @ingroup l3_hypos_quad
653     def QuadranglePreference(self, reversed=False, UseExisting=0):
654         if reversed:
655             return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
656         return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
657
658     ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
659     #   triangles are built in the transition area along the finer meshed sides.
660     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
661     #                  the same parameters, else (default) - creates a new one
662     #  @ingroup l3_hypos_quad
663     def TrianglePreference(self, UseExisting=0):
664         return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
665
666     ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
667     #   quadrangles are built and the transition between the sides is made gradually,
668     #   layer by layer. This type has a limitation on the number of segments: one pair
669     #   of opposite sides must have the same number of segments, the other pair must
670     #   have an even difference between the numbers of segments on the sides.
671     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
672     #                  the same parameters, else (default) - creates a new one
673     #  @ingroup l3_hypos_quad
674     def Reduced(self, UseExisting=0):
675         return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
676
677     ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
678     #  @param vertex: vertex of a trilateral geometrical face, around which triangles
679     #                 will be created while other elements will be quadrangles.
680     #                 Vertex can be either a GEOM_Object or a vertex ID within the
681     #                 shape to mesh
682     #  @param UseExisting: if ==true - searches for the existing hypothesis created with
683     #                   the same parameters, else (default) - creates a new one
684     #  @ingroup l3_hypos_quad
685     def TriangleVertex(self, vertex, UseExisting=0):
686         return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
687
688     pass # end of StdMeshersBuilder_Quadrangle class
689
690 ## Defines a hexahedron 3D algorithm
691
692 #  It is created by calling smeshBuilder.Mesh.Hexahedron(geom=0)
693 #
694 #  @ingroup l3_algos_basic
695 class StdMeshersBuilder_Hexahedron(Mesh_Algorithm):
696
697     ## name of the dynamic method in smeshBuilder.Mesh class
698     #  @internal
699     meshMethod = "Hexahedron"
700     ## type of algorithm used with helper function in smeshBuilder.Mesh class
701     #  @internal
702     algoType   = Hexa
703     ## flag pointing either this algorithm should be used by default in dynamic method
704     #  of smeshBuilder.Mesh class
705     #  @internal
706     isDefault  = True
707     ## doc string of the method
708     #  @internal
709     docHelper  = "Creates hexahedron 3D algorithm for volumes"
710
711     ## Private constructor.
712     #  @param mesh parent mesh object algorithm is assigned to
713     #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
714     #              if it is @c 0 (default), the algorithm is assigned to the main shape
715     def __init__(self, mesh, geom=0):
716         Mesh_Algorithm.__init__(self)
717         self.Create(mesh, geom, Hexa)
718         pass
719
720     pass # end of StdMeshersBuilder_Hexahedron class
721
722 ## Defines a projection 1D algorithm
723 #  
724 #  It is created by calling smeshBuilder.Mesh.Projection1D(geom=0)
725 #
726 #  @ingroup l3_algos_proj
727 class StdMeshersBuilder_Projection1D(Mesh_Algorithm):
728
729     ## name of the dynamic method in smeshBuilder.Mesh class
730     #  @internal
731     meshMethod = "Projection1D"
732     ## type of algorithm used with helper function in smeshBuilder.Mesh class
733     #  @internal
734     algoType   = "Projection_1D"
735     ## flag pointing either this algorithm should be used by default in dynamic method
736     #  of smeshBuilder.Mesh class
737     #  @internal
738     isDefault  = True
739     ## doc string of the method
740     #  @internal
741     docHelper  = "Creates projection 1D algorithm for edges"
742
743     ## Private constructor.
744     #  @param mesh parent mesh object algorithm is assigned to
745     #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
746     #              if it is @c 0 (default), the algorithm is assigned to the main shape
747     def __init__(self, mesh, geom=0):
748         Mesh_Algorithm.__init__(self)
749         self.Create(mesh, geom, self.algoType)
750         pass
751
752     ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
753     #  a mesh pattern is taken, and, optionally, the association of vertices
754     #  between the source edge and a target edge (to which a hypothesis is assigned)
755     #  @param edge from which nodes distribution is taken
756     #  @param mesh from which nodes distribution is taken (optional)
757     #  @param srcV a vertex of \a edge to associate with \a tgtV (optional)
758     #  @param tgtV a vertex of \a the edge to which the algorithm is assigned,
759     #  to associate with \a srcV (optional)
760     #  @param UseExisting if ==true - searches for the existing hypothesis created with
761     #                     the same parameters, else (default) - creates a new one
762     def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
763         from salome.smesh.smeshBuilder import AssureGeomPublished, Mesh
764         AssureGeomPublished( self.mesh, edge )
765         AssureGeomPublished( self.mesh, srcV )
766         AssureGeomPublished( self.mesh, tgtV )
767         hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
768                               UseExisting=0)
769         # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
770                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
771         hyp.SetSourceEdge( edge )
772         if not mesh is None and isinstance(mesh, Mesh):
773             mesh = mesh.GetMesh()
774         hyp.SetSourceMesh( mesh )
775         hyp.SetVertexAssociation( srcV, tgtV )
776         return hyp
777
778     pass # end of StdMeshersBuilder_Projection1D class
779
780 ## Defines a projection 2D algorithm
781 #  
782 #  It is created by calling smeshBuilder.Mesh.Projection2D(geom=0)
783 #
784 #  @ingroup l3_algos_proj
785 class StdMeshersBuilder_Projection2D(Mesh_Algorithm):
786
787     ## name of the dynamic method in smeshBuilder.Mesh class
788     #  @internal
789     meshMethod = "Projection2D"
790     ## type of algorithm used with helper function in smeshBuilder.Mesh class
791     #  @internal
792     algoType   = "Projection_2D"
793     ## flag pointing either this algorithm should be used by default in dynamic method
794     #  of smeshBuilder.Mesh class
795     #  @internal
796     isDefault  = True
797     ## doc string of the method
798     #  @internal
799     docHelper  = "Creates projection 2D algorithm for faces"
800
801     ## Private constructor.
802     #  @param mesh parent mesh object algorithm is assigned to
803     #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
804     #              if it is @c 0 (default), the algorithm is assigned to the main shape
805     def __init__(self, mesh, geom=0):
806         Mesh_Algorithm.__init__(self)
807         self.Create(mesh, geom, self.algoType)
808         pass
809
810     ## Defines "Source Face" hypothesis, specifying a meshed face, from where
811     #  a mesh pattern is taken, and, optionally, the association of vertices
812     #  between the source face and the target face (to which a hypothesis is assigned)
813     #  @param face from which the mesh pattern is taken
814     #  @param mesh from which the mesh pattern is taken (optional)
815     #  @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
816     #  @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
817     #               to associate with \a srcV1 (optional)
818     #  @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
819     #  @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
820     #               to associate with \a srcV2 (optional)
821     #  @param UseExisting if ==true - forces the search for the existing hypothesis created with
822     #                     the same parameters, else (default) - forces the creation a new one
823     #
824     #  Note: all association vertices must belong to one edge of a face
825     def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
826                    srcV2=None, tgtV2=None, UseExisting=0):
827         from salome.smesh.smeshBuilder import Mesh
828         if isinstance(mesh, Mesh):
829             mesh = mesh.GetMesh()
830         for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
831             from salome.smesh.smeshBuilder import AssureGeomPublished
832             AssureGeomPublished( self.mesh, geom )
833         hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
834                               UseExisting=0, toAdd=False)
835         # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
836                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
837         hyp.SetSourceFace( face )
838         hyp.SetSourceMesh( mesh )
839         hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
840         self.mesh.AddHypothesis(hyp, self.geom)
841         return hyp
842
843     pass # end of StdMeshersBuilder_Projection2D class
844
845 ## Defines a projection 1D-2D algorithm
846 #  
847 #  It is created by calling smeshBuilder.Mesh.Projection1D2D(geom=0)
848 #
849 #  @ingroup l3_algos_proj
850 class StdMeshersBuilder_Projection1D2D(StdMeshersBuilder_Projection2D):
851
852     ## name of the dynamic method in smeshBuilder.Mesh class
853     #  @internal
854     meshMethod = "Projection1D2D"
855     ## type of algorithm used with helper function in smeshBuilder.Mesh class
856     #  @internal
857     algoType   = "Projection_1D2D"
858     ## doc string of the method
859     #  @internal
860     docHelper  = "Creates projection 1D-2D algorithm for edges and faces"
861
862     ## Private constructor.
863     #  @param mesh parent mesh object algorithm is assigned to
864     #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
865     #              if it is @c 0 (default), the algorithm is assigned to the main shape
866     def __init__(self, mesh, geom=0):
867         StdMeshersBuilder_Projection2D.__init__(self, mesh, geom)
868         pass
869
870     pass # end of StdMeshersBuilder_Projection1D2D class
871
872 ## Defines a projection 3D algorithm
873
874 #  It is created by calling smeshBuilder.Mesh.Projection3D(geom=0)
875 #
876 #  @ingroup l3_algos_proj
877 class StdMeshersBuilder_Projection3D(Mesh_Algorithm):
878
879     ## name of the dynamic method in smeshBuilder.Mesh class
880     #  @internal
881     meshMethod = "Projection3D"
882     ## type of algorithm used with helper function in smeshBuilder.Mesh class
883     #  @internal
884     algoType   = "Projection_3D"
885     ## doc string of the method
886     #  @internal
887     docHelper  = "Creates projection 3D algorithm for volumes"
888
889     ## Private constructor.
890     #  @param mesh parent mesh object algorithm is assigned to
891     #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
892     #              if it is @c 0 (default), the algorithm is assigned to the main shape
893     def __init__(self, mesh, geom=0):
894         Mesh_Algorithm.__init__(self)
895         self.Create(mesh, geom, self.algoType)
896         pass
897
898     ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
899     #  the mesh pattern is taken, and, optionally, the  association of vertices
900     #  between the source and the target solid  (to which a hipothesis is assigned)
901     #  @param solid from where the mesh pattern is taken
902     #  @param mesh from where the mesh pattern is taken (optional)
903     #  @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
904     #  @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
905     #  to associate with \a srcV1 (optional)
906     #  @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
907     #  @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
908     #  to associate with \a srcV2 (optional)
909     #  @param UseExisting - if ==true - searches for the existing hypothesis created with
910     #                     the same parameters, else (default) - creates a new one
911     #
912     #  Note: association vertices must belong to one edge of a solid
913     def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
914                       srcV2=0, tgtV2=0, UseExisting=0):
915         for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
916             from salome.smesh.smeshBuilder import AssureGeomPublished
917             AssureGeomPublished( self.mesh, geom )
918         hyp = self.Hypothesis("ProjectionSource3D",
919                               [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
920                               UseExisting=0)
921         # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
922                               #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
923         hyp.SetSource3DShape( solid )
924         from salome.smesh.smeshBuilder import Mesh
925         if isinstance(mesh, Mesh):
926             mesh = mesh.GetMesh()
927         if mesh:
928             hyp.SetSourceMesh( mesh )
929         if srcV1 and srcV2 and tgtV1 and tgtV2:
930             hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
931         #elif srcV1 or srcV2 or tgtV1 or tgtV2:
932         return hyp
933
934     pass # end of StdMeshersBuilder_Projection3D class
935
936 ## Defines a Prism 3D algorithm, which is either "Extrusion 3D" or "Radial Prism"
937 #  depending on geometry
938
939 #  It is created by calling smeshBuilder.Mesh.Prism(geom=0)
940 #
941 #  @ingroup l3_algos_3dextr
942 class StdMeshersBuilder_Prism3D(Mesh_Algorithm):
943
944     ## name of the dynamic method in smeshBuilder.Mesh class
945     #  @internal
946     meshMethod = "Prism"
947     ## type of algorithm used with helper function in smeshBuilder.Mesh class
948     #  @internal
949     algoType   = "Prism_3D"
950     ## doc string of the method
951     #  @internal
952     docHelper  = "Creates prism 3D algorithm for volumes"
953
954     ## Private constructor.
955     #  @param mesh parent mesh object algorithm is assigned to
956     #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
957     #              if it is @c 0 (default), the algorithm is assigned to the main shape
958     def __init__(self, mesh, geom=0):
959         Mesh_Algorithm.__init__(self)
960         
961         shape = geom
962         if not shape:
963             shape = mesh.geom
964         from salome.geom import geomBuilder
965         nbSolids = len( geomBuilder.geom.SubShapeAll( shape, geomBuilder.geomBuilder.ShapeType["SOLID"] ))
966         nbShells = len( geomBuilder.geom.SubShapeAll( shape, geomBuilder.geomBuilder.ShapeType["SHELL"] ))
967         if nbSolids == 0 or nbSolids == nbShells:
968             self.Create(mesh, geom, "Prism_3D")
969             pass
970         else:
971             self.algoType = "RadialPrism_3D"
972             self.Create(mesh, geom, "RadialPrism_3D")
973             self.distribHyp = None #self.Hypothesis("LayerDistribution", UseExisting=0)
974             self.nbLayers = None
975             pass
976         pass
977
978     ## Return 3D hypothesis holding the 1D one
979     def Get3DHypothesis(self):
980         if self.algoType != "RadialPrism_3D":
981             print "Prism_3D algorith doesn't support any hyposesis"
982             return None
983         return self.distribHyp
984
985     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
986     #  hypothesis. Returns the created hypothesis
987     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
988         if self.algoType != "RadialPrism_3D":
989             print "Prism_3D algorith doesn't support any hyposesis"
990             return None
991         if not self.nbLayers is None:
992             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
993             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
994         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
995         self.mesh.smeshpyD.SetCurrentStudy( None )
996         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
997         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
998         if not self.distribHyp:
999             self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
1000         self.distribHyp.SetLayerDistribution( hyp )
1001         return hyp
1002
1003     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
1004     #  prisms to build between the inner and outer shells
1005     #  @param n number of layers
1006     #  @param UseExisting if ==true - searches for the existing hypothesis created with
1007     #                     the same parameters, else (default) - creates a new one
1008     def NumberOfLayers(self, n, UseExisting=0):
1009         if self.algoType != "RadialPrism_3D":
1010             print "Prism_3D algorith doesn't support any hyposesis"
1011             return None
1012         self.mesh.RemoveHypothesis( self.distribHyp, self.geom )
1013         from salome.smesh.smeshBuilder import IsEqual
1014         compFun = lambda hyp, args: IsEqual(hyp.GetNumberOfLayers(), args[0])
1015         self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
1016                                         CompareMethod=compFun)
1017         self.nbLayers.SetNumberOfLayers( n )
1018         return self.nbLayers
1019
1020     ## Defines "LocalLength" hypothesis, specifying the segment length
1021     #  to build between the inner and the outer shells
1022     #  @param l the length of segments
1023     #  @param p the precision of rounding
1024     def LocalLength(self, l, p=1e-07):
1025         if self.algoType != "RadialPrism_3D":
1026             print "Prism_3D algorith doesn't support any hyposesis"
1027             return None
1028         hyp = self.OwnHypothesis("LocalLength", [l,p])
1029         hyp.SetLength(l)
1030         hyp.SetPrecision(p)
1031         return hyp
1032
1033     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
1034     #  prisms to build between the inner and the outer shells.
1035     #  @param n the number of layers
1036     #  @param s the scale factor (optional)
1037     def NumberOfSegments(self, n, s=[]):
1038         if self.algoType != "RadialPrism_3D":
1039             print "Prism_3D algorith doesn't support any hyposesis"
1040             return None
1041         if s == []:
1042             hyp = self.OwnHypothesis("NumberOfSegments", [n])
1043         else:
1044             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
1045             hyp.SetDistrType( 1 )
1046             hyp.SetScaleFactor(s)
1047         hyp.SetNumberOfSegments(n)
1048         return hyp
1049
1050     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
1051     #  to build between the inner and the outer shells with a length that changes
1052     #  in arithmetic progression
1053     #  @param start  the length of the first segment
1054     #  @param end    the length of the last  segment
1055     def Arithmetic1D(self, start, end ):
1056         if self.algoType != "RadialPrism_3D":
1057             print "Prism_3D algorith doesn't support any hyposesis"
1058             return None
1059         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
1060         hyp.SetLength(start, 1)
1061         hyp.SetLength(end  , 0)
1062         return hyp
1063
1064     ## Defines "GeometricProgression" hypothesis, specifying the distribution of segments
1065     #  to build between the inner and the outer shells with a length that changes
1066     #  in Geometric progression
1067     #  @param start  the length of the first segment
1068     #  @param ratio  the common ratio of the geometric progression
1069     def GeometricProgression(self, start, ratio ):
1070         if self.algoType != "RadialPrism_3D":
1071             print "Prism_3D algorith doesn't support any hyposesis"
1072             return None
1073         hyp = self.OwnHypothesis("GeometricProgression", [start, ratio])
1074         hyp.SetStartLength( start )
1075         hyp.SetCommonRatio( ratio )
1076         return hyp
1077
1078     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
1079     #  to build between the inner and the outer shells as geometric length increasing
1080     #  @param start for the length of the first segment
1081     #  @param end   for the length of the last  segment
1082     def StartEndLength(self, start, end):
1083         if self.algoType != "RadialPrism_3D":
1084             print "Prism_3D algorith doesn't support any hyposesis"
1085             return None
1086         hyp = self.OwnHypothesis("StartEndLength", [start, end])
1087         hyp.SetLength(start, 1)
1088         hyp.SetLength(end  , 0)
1089         return hyp
1090
1091     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
1092     #  to build between the inner and outer shells
1093     #  @param fineness defines the quality of the mesh within the range [0-1]
1094     def AutomaticLength(self, fineness=0):
1095         if self.algoType != "RadialPrism_3D":
1096             print "Prism_3D algorith doesn't support any hyposesis"
1097             return None
1098         hyp = self.OwnHypothesis("AutomaticLength")
1099         hyp.SetFineness( fineness )
1100         return hyp
1101
1102     pass # end of StdMeshersBuilder_Prism3D class
1103
1104 ## Defines a Prism 3D algorithm, which is either "Extrusion 3D" or "Radial Prism"
1105 #  depending on geometry
1106
1107 #  It is created by calling smeshBuilder.Mesh.Prism(geom=0)
1108 #
1109 #  @ingroup l3_algos_3dextr
1110 class StdMeshersBuilder_RadialPrism3D(StdMeshersBuilder_Prism3D):
1111
1112     ## name of the dynamic method in smeshBuilder.Mesh class
1113     #  @internal
1114     meshMethod = "Prism"
1115     ## type of algorithm used with helper function in smeshBuilder.Mesh class
1116     #  @internal
1117     algoType   = "RadialPrism_3D"
1118     ## doc string of the method
1119     #  @internal
1120     docHelper  = "Creates prism 3D algorithm for volumes"
1121
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         
1129         shape = geom
1130         if not shape:
1131             shape = mesh.geom
1132         self.Create(mesh, geom, "RadialPrism_3D")
1133         self.distribHyp = None
1134         self.nbLayers = None
1135         return
1136
1137 ## Defines a Radial Quadrangle 1D-2D algorithm
1138
1139 #  It is created by calling smeshBuilder.Mesh.Quadrangle(smeshBuilder.RADIAL_QUAD,geom=0)
1140 #
1141 #  @ingroup l2_algos_radialq
1142 class StdMeshersBuilder_RadialQuadrangle1D2D(Mesh_Algorithm):
1143
1144     ## name of the dynamic method in smeshBuilder.Mesh class
1145     #  @internal
1146     meshMethod = "Quadrangle"
1147     ## type of algorithm used with helper function in smeshBuilder.Mesh class
1148     #  @internal
1149     algoType   = RADIAL_QUAD
1150     ## doc string of the method
1151     #  @internal
1152     docHelper  = "Creates quadrangle 1D-2D algorithm for triangular faces"
1153
1154     ## Private constructor.
1155     #  @param mesh parent mesh object algorithm is assigned to
1156     #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
1157     #              if it is @c 0 (default), the algorithm is assigned to the main shape
1158     def __init__(self, mesh, geom=0):
1159         Mesh_Algorithm.__init__(self)
1160         self.Create(mesh, geom, self.algoType)
1161
1162         self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
1163         self.nbLayers = None
1164         pass
1165
1166     ## Return 2D hypothesis holding the 1D one
1167     def Get2DHypothesis(self):
1168         if not self.distribHyp:
1169             self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
1170         return self.distribHyp
1171
1172     ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
1173     #  hypothesis. Returns the created hypothesis
1174     def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
1175         if self.nbLayers:
1176             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
1177         if self.distribHyp is None:
1178             self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
1179         else:
1180             self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
1181         study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
1182         self.mesh.smeshpyD.SetCurrentStudy( None )
1183         hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
1184         self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
1185         self.distribHyp.SetLayerDistribution( hyp )
1186         return hyp
1187
1188     ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
1189     #  @param n number of layers
1190     #  @param UseExisting if ==true - searches for the existing hypothesis created with
1191     #                     the same parameters, else (default) - creates a new one
1192     def NumberOfLayers(self, n, UseExisting=0):
1193         if self.distribHyp:
1194             self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
1195         from salome.smesh.smeshBuilder import IsEqual
1196         compFun = lambda hyp, args: IsEqual(hyp.GetNumberOfLayers(), args[0])
1197         self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
1198                                         CompareMethod=compFun)
1199         self.nbLayers.SetNumberOfLayers( n )
1200         return self.nbLayers
1201
1202     ## Defines "LocalLength" hypothesis, specifying the segment length
1203     #  @param l the length of segments
1204     #  @param p the precision of rounding
1205     def LocalLength(self, l, p=1e-07):
1206         hyp = self.OwnHypothesis("LocalLength", [l,p])
1207         hyp.SetLength(l)
1208         hyp.SetPrecision(p)
1209         return hyp
1210
1211     ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
1212     #  @param n the number of layers
1213     #  @param s the scale factor (optional)
1214     def NumberOfSegments(self, n, s=[]):
1215         if s == []:
1216             hyp = self.OwnHypothesis("NumberOfSegments", [n])
1217         else:
1218             hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
1219             hyp.SetDistrType( 1 )
1220             hyp.SetScaleFactor(s)
1221         hyp.SetNumberOfSegments(n)
1222         return hyp
1223
1224     ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
1225     #  with a length that changes in arithmetic progression
1226     #  @param start  the length of the first segment
1227     #  @param end    the length of the last  segment
1228     def Arithmetic1D(self, start, end ):
1229         hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
1230         hyp.SetLength(start, 1)
1231         hyp.SetLength(end  , 0)
1232         return hyp
1233
1234     ## Defines "GeometricProgression" hypothesis, specifying the distribution of segments
1235     #  with a length that changes in Geometric progression
1236     #  @param start  the length of the first segment
1237     #  @param ratio  the common ratio of the geometric progression
1238     def GeometricProgression(self, start, ratio ):
1239         hyp = self.OwnHypothesis("GeometricProgression", [start, ratio])
1240         hyp.SetStartLength( start )
1241         hyp.SetCommonRatio( ratio )
1242         return hyp
1243
1244     ## Defines "StartEndLength" hypothesis, specifying distribution of segments
1245     #  as geometric length increasing
1246     #  @param start for the length of the first segment
1247     #  @param end   for the length of the last  segment
1248     def StartEndLength(self, start, end):
1249         hyp = self.OwnHypothesis("StartEndLength", [start, end])
1250         hyp.SetLength(start, 1)
1251         hyp.SetLength(end  , 0)
1252         return hyp
1253
1254     ## Defines "AutomaticLength" hypothesis, specifying the number of segments
1255     #  @param fineness defines the quality of the mesh within the range [0-1]
1256     def AutomaticLength(self, fineness=0):
1257         hyp = self.OwnHypothesis("AutomaticLength")
1258         hyp.SetFineness( fineness )
1259         return hyp
1260
1261     pass # end of StdMeshersBuilder_RadialQuadrangle1D2D class
1262
1263 ## Defines a Use Existing Elements 1D algorithm
1264 #
1265 #  It is created by calling smeshBuilder.Mesh.UseExisting1DElements(geom=0)
1266 #
1267 #  @ingroup l3_algos_basic
1268 class StdMeshersBuilder_UseExistingElements_1D(Mesh_Algorithm):
1269
1270     ## name of the dynamic method in smeshBuilder.Mesh class
1271     #  @internal
1272     meshMethod = "UseExisting1DElements"
1273     ## type of algorithm used with helper function in smeshBuilder.Mesh class
1274     #  @internal
1275     algoType   = "Import_1D"
1276     ## flag pointing either this algorithm should be used by default in dynamic method
1277     #  of smeshBuilder.Mesh class
1278     #  @internal
1279     isDefault  = True
1280     ## doc string of the method
1281     #  @internal
1282     docHelper  = "Creates 1D algorithm for edges with reusing of existing mesh elements"
1283
1284     ## Private constructor.
1285     #  @param mesh parent mesh object algorithm is assigned to
1286     #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
1287     #              if it is @c 0 (default), the algorithm is assigned to the main shape
1288     def __init__(self, mesh, geom=0):
1289         Mesh_Algorithm.__init__(self)
1290         self.Create(mesh, geom, self.algoType)
1291         pass
1292
1293     ## Defines "Source edges" hypothesis, specifying groups of edges to import
1294     #  @param groups list of groups of edges
1295     #  @param toCopyMesh if True, the whole mesh \a groups belong to is imported
1296     #  @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
1297     #  @param UseExisting if ==true - searches for the existing hypothesis created with
1298     #                     the same parameters, else (default) - creates a new one
1299     def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
1300         for group in groups:
1301             from salome.smesh.smeshBuilder import AssureGeomPublished
1302             AssureGeomPublished( self.mesh, group )
1303         compFun = lambda hyp, args: ( hyp.GetSourceEdges() == args[0] and \
1304                                       hyp.GetCopySourceMesh() == args[1], args[2] )
1305         hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
1306                               UseExisting=UseExisting, CompareMethod=compFun)
1307         hyp.SetSourceEdges(groups)
1308         hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
1309         return hyp
1310
1311     pass # end of StdMeshersBuilder_UseExistingElements_1D class
1312
1313 ## Defines a Use Existing Elements 1D-2D algorithm
1314 #
1315 #  It is created by calling smeshBuilder.Mesh.UseExisting2DElements(geom=0)
1316 #
1317 #  @ingroup l3_algos_basic
1318 class StdMeshersBuilder_UseExistingElements_1D2D(Mesh_Algorithm):
1319
1320     ## name of the dynamic method in smeshBuilder.Mesh class
1321     #  @internal
1322     meshMethod = "UseExisting2DElements"
1323     ## type of algorithm used with helper function in smeshBuilder.Mesh class
1324     #  @internal
1325     algoType   = "Import_1D2D"
1326     ## flag pointing either this algorithm should be used by default in dynamic method
1327     #  of smeshBuilder.Mesh class
1328     #  @internal
1329     isDefault  = True
1330     ## doc string of the method
1331     #  @internal
1332     docHelper  = "Creates 1D-2D algorithm for edges/faces with reusing of existing mesh elements"
1333
1334     ## Private constructor.
1335     #  @param mesh parent mesh object algorithm is assigned to
1336     #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
1337     #              if it is @c 0 (default), the algorithm is assigned to the main shape
1338     def __init__(self, mesh, geom=0):
1339         Mesh_Algorithm.__init__(self)
1340         self.Create(mesh, geom, self.algoType)
1341         pass
1342
1343     ## Defines "Source faces" hypothesis, specifying groups of faces to import
1344     #  @param groups list of groups of faces
1345     #  @param toCopyMesh if True, the whole mesh \a groups belong to is imported
1346     #  @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
1347     #  @param UseExisting if ==true - searches for the existing hypothesis created with
1348     #                     the same parameters, else (default) - creates a new one
1349     def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
1350         for group in groups:
1351             from salome.smesh.smeshBuilder import AssureGeomPublished
1352             AssureGeomPublished( self.mesh, group )
1353         compFun = lambda hyp, args: ( hyp.GetSourceFaces() == args[0] and \
1354                                       hyp.GetCopySourceMesh() == args[1], args[2] )
1355         hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
1356                               UseExisting=UseExisting, CompareMethod=compFun)
1357         hyp.SetSourceFaces(groups)
1358         hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
1359         return hyp
1360
1361     pass # end of StdMeshersBuilder_UseExistingElements_1D2D class
1362
1363 ## Defines a Body Fitting 3D algorithm
1364 #
1365 #  It is created by calling smeshBuilder.Mesh.BodyFitted(geom=0)
1366 #
1367 #  @ingroup l3_algos_basic
1368 class StdMeshersBuilder_Cartesian_3D(Mesh_Algorithm):
1369
1370     ## name of the dynamic method in smeshBuilder.Mesh class
1371     #  @internal
1372     meshMethod = "BodyFitted"
1373     ## type of algorithm used with helper function in smeshBuilder.Mesh class
1374     #  @internal
1375     algoType   = "Cartesian_3D"
1376     ## flag pointing either this algorithm should be used by default in dynamic method
1377     #  of smeshBuilder.Mesh class
1378     #  @internal
1379     isDefault  = True
1380     ## doc string of the method
1381     #  @internal
1382     docHelper  = "Creates body fitting 3D algorithm for volumes"
1383
1384     ## Private constructor.
1385     #  @param mesh parent mesh object algorithm is assigned to
1386     #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
1387     #              if it is @c 0 (default), the algorithm is assigned to the main shape
1388     def __init__(self, mesh, geom=0):
1389         self.Create(mesh, geom, self.algoType)
1390         self.hyp = None
1391         pass
1392
1393     ## Defines "Body Fitting parameters" hypothesis
1394     #  @param xGridDef is definition of the grid along the X asix.
1395     #  It can be in either of two following forms:
1396     #  - Explicit coordinates of nodes, e.g. [-1.5, 0.0, 3.1] or range( -100,200,10)
1397     #  - Functions f(t) defining grid spacing at each point on grid axis. If there are
1398     #    several functions, they must be accompanied by relative coordinates of
1399     #    points dividing the whole shape into ranges where the functions apply; points
1400     #    coodrinates should vary within (0.0, 1.0) range. Parameter \a t of the spacing
1401     #    function f(t) varies from 0.0 to 1.0 witin a shape range. 
1402     #    Examples:
1403     #    - "10.5" - defines a grid with a constant spacing
1404     #    - [["1", "1+10*t", "11"] [0.1, 0.6]] - defines different spacing in 3 ranges.
1405     #  @param yGridDef defines the grid along the Y asix the same way as \a xGridDef does.
1406     #  @param zGridDef defines the grid along the Z asix the same way as \a xGridDef does.
1407     #  @param sizeThreshold (> 1.0) defines a minimal size of a polyhedron so that
1408     #         a polyhedron of size less than hexSize/sizeThreshold is not created.
1409     #  @param implEdges enables implementation of geometrical edges into the mesh.
1410     def SetGrid(self, xGridDef, yGridDef, zGridDef, sizeThreshold=4.0, implEdges=False):
1411         if not self.hyp:
1412             compFun = lambda hyp, args: False
1413             self.hyp = self.Hypothesis("CartesianParameters3D",
1414                                        [xGridDef, yGridDef, zGridDef, sizeThreshold],
1415                                        UseExisting=False, CompareMethod=compFun)
1416         if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
1417             self.mesh.AddHypothesis( self.hyp, self.geom )
1418
1419         for axis, gridDef in enumerate( [xGridDef, yGridDef, zGridDef] ):
1420             if not gridDef: raise ValueError, "Empty grid definition"
1421             if isinstance( gridDef, str ):
1422                 self.hyp.SetGridSpacing( [gridDef], [], axis )
1423             elif isinstance( gridDef[0], str ):
1424                 self.hyp.SetGridSpacing( gridDef, [], axis )
1425             elif isinstance( gridDef[0], int ) or \
1426                  isinstance( gridDef[0], float ):
1427                 self.hyp.SetGrid(gridDef, axis )
1428             else:
1429                 self.hyp.SetGridSpacing( gridDef[0], gridDef[1], axis )
1430         self.hyp.SetSizeThreshold( sizeThreshold )
1431         self.hyp.SetToAddEdges( implEdges )
1432         return self.hyp
1433
1434     ## Defines custom directions of axes of the grid
1435     #  @param xAxis either SMESH.DirStruct or a vector, or 3 vector components
1436     #  @param yAxis either SMESH.DirStruct or a vector, or 3 vector components
1437     #  @param zAxis either SMESH.DirStruct or a vector, or 3 vector components
1438     def SetAxesDirs( self, xAxis, yAxis, zAxis ):
1439         import GEOM
1440         if hasattr( xAxis, "__getitem__" ):
1441             xAxis = self.mesh.smeshpyD.MakeDirStruct( xAxis[0],xAxis[1],xAxis[2] )
1442         elif isinstance( xAxis, GEOM._objref_GEOM_Object ):
1443             xAxis = self.mesh.smeshpyD.GetDirStruct( xAxis )
1444         if hasattr( yAxis, "__getitem__" ):
1445             yAxis = self.mesh.smeshpyD.MakeDirStruct( yAxis[0],yAxis[1],yAxis[2] )
1446         elif isinstance( yAxis, GEOM._objref_GEOM_Object ):
1447             yAxis = self.mesh.smeshpyD.GetDirStruct( yAxis )
1448         if hasattr( zAxis, "__getitem__" ):
1449             zAxis = self.mesh.smeshpyD.MakeDirStruct( zAxis[0],zAxis[1],zAxis[2] )
1450         elif isinstance( zAxis, GEOM._objref_GEOM_Object ):
1451             zAxis = self.mesh.smeshpyD.GetDirStruct( zAxis )
1452         if not self.hyp:
1453             self.hyp = self.Hypothesis("CartesianParameters3D")
1454         if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
1455             self.mesh.AddHypothesis( self.hyp, self.geom )
1456         self.hyp.SetAxesDirs( xAxis, yAxis, zAxis )
1457         return self.hyp
1458
1459     ## Automatically defines directions of axes of the grid at which
1460     #  a number of generated hexahedra is maximal
1461     #  @param isOrthogonal defines whether the axes mush be orthogonal
1462     def SetOptimalAxesDirs(self, isOrthogonal=True):
1463         if not self.hyp:
1464             self.hyp = self.Hypothesis("CartesianParameters3D")
1465         if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
1466             self.mesh.AddHypothesis( self.hyp, self.geom )
1467         x,y,z = self.hyp.ComputeOptimalAxesDirs( self.geom, isOrthogonal )
1468         self.hyp.SetAxesDirs( x,y,z )
1469         return self.hyp
1470
1471     ## Sets/unsets a fixed point. The algorithm makes a plane of the grid pass
1472     #  through the fixed point in each direction at which the grid is defined
1473     #  by spacing
1474     #  @param p coordinates of the fixed point. Either SMESH.PointStruct or
1475     #         a vertex or 3 components of coordinates.
1476     #  @param toUnset defines whether the fixed point is defined or removed.
1477     def SetFixedPoint( self, p, toUnset=False ):
1478         import SMESH, GEOM
1479         if toUnset:
1480             if not self.hyp: return
1481             p = SMESH.PointStruct(0,0,0)
1482         elif hasattr( p, "__getitem__" ):
1483             p = SMESH.PointStruct( p[0],p[1],p[2] )
1484         elif isinstance( p, GEOM._objref_GEOM_Object ):
1485             p = self.mesh.smeshpyD.GetPointStruct( p )
1486         if not self.hyp:
1487             self.hyp = self.Hypothesis("CartesianParameters3D")
1488         if not self.mesh.IsUsedHypothesis( self.hyp, self.geom ):
1489             self.mesh.AddHypothesis( self.hyp, self.geom )
1490         self.hyp.SetFixedPoint( p, toUnset )
1491         return self.hyp
1492         
1493
1494     pass # end of StdMeshersBuilder_Cartesian_3D class
1495
1496 ## Defines a stub 1D algorithm, which enables "manual" creation of nodes and
1497 #  segments usable by 2D algoritms
1498 #
1499 #  It is created by calling smeshBuilder.Mesh.UseExistingSegments(geom=0)
1500 #
1501 #  @ingroup l3_algos_basic
1502 class StdMeshersBuilder_UseExisting_1D(Mesh_Algorithm):
1503
1504     ## name of the dynamic method in smeshBuilder.Mesh class
1505     #  @internal
1506     meshMethod = "UseExistingSegments"
1507     ## type of algorithm used with helper function in smeshBuilder.Mesh class
1508     #  @internal
1509     algoType   = "UseExisting_1D"
1510     ## doc string of the method
1511     #  @internal
1512     docHelper  = "Creates 1D algorithm for edges with reusing of existing mesh elements"
1513
1514     ## Private constructor.
1515     #  @param mesh parent mesh object algorithm is assigned to
1516     #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
1517     #              if it is @c 0 (default), the algorithm is assigned to the main shape
1518     def __init__(self, mesh, geom=0):
1519         self.Create(mesh, geom, self.algoType)
1520         pass
1521
1522     pass # end of StdMeshersBuilder_UseExisting_1D class
1523
1524 ## Defines a stub 2D algorithm, which enables "manual" creation of nodes and
1525 #  faces usable by 3D algoritms
1526 #
1527 #  It is created by calling smeshBuilder.Mesh.UseExistingFaces(geom=0)
1528 #
1529 #  @ingroup l3_algos_basic
1530 class StdMeshersBuilder_UseExisting_2D(Mesh_Algorithm):
1531
1532     ## name of the dynamic method in smeshBuilder.Mesh class
1533     #  @internal
1534     meshMethod = "UseExistingFaces"
1535     ## type of algorithm used with helper function in smeshBuilder.Mesh class
1536     #  @internal
1537     algoType   = "UseExisting_2D"
1538     ## doc string of the method
1539     #  @internal
1540     docHelper  = "Creates 2D algorithm for faces with reusing of existing mesh elements"
1541
1542     ## Private constructor.
1543     #  @param mesh parent mesh object algorithm is assigned to
1544     #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
1545     #              if it is @c 0 (default), the algorithm is assigned to the main shape
1546     def __init__(self, mesh, geom=0):
1547         self.Create(mesh, geom, self.algoType)
1548         pass
1549
1550     pass # end of StdMeshersBuilder_UseExisting_2D class