Salome HOME
Do not import smeshBuilder to avoid the error of cyclic import
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPluginBuilder.py
1 # Copyright (C) 2007-2013  CEA/DEN, EDF R&D
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.
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 BLSURFPluginBuilder
22 # Python API for the BLSURF meshing plug-in module.
23
24 from salome.smesh.smesh_algorithm import Mesh_Algorithm
25
26 # Topology treatment way of BLSURF
27 FromCAD, PreProcess, PreProcessPlus, PreCAD = 0,1,2,3
28
29 # Element size flag of BLSURF
30 DefaultSize, DefaultGeom, BLSURF_GlobalSize, BLSURF_LocalSize = 0,0,1,2
31 # Retrocompatibility
32 BLSURF_Custom, SizeMap = BLSURF_GlobalSize, BLSURF_LocalSize
33
34
35 # import BLSURFPlugin module if possible
36 noBLSURFPlugin = 0
37 try:
38   import BLSURFPlugin
39 except ImportError:
40   noBLSURFPlugin = 1
41   pass
42
43 #----------------------------
44 # Mesh algo type identifiers
45 #----------------------------
46
47 ## Algorithm type: BLSurf triangle 2D algorithm, see BLSURF_Algorithm
48 BLSURF = "BLSURF"
49
50 #----------------------
51 # Algorithms
52 #----------------------
53
54 ## BLSurf 2D algorithm.
55 #
56 #  It can be created by calling smeshBuilder.Mesh.Triangle(smeshBuilder.BLSURF,geom=0)
57 #
58 class BLSURF_Algorithm(Mesh_Algorithm):
59
60   ## name of the dynamic method in smeshBuilder.Mesh class
61   #  @internal
62   meshMethod = "Triangle"
63   ## type of algorithm used with helper function in smeshBuilder.Mesh class
64   #  @internal
65   algoType   = BLSURF
66   ## doc string of the method
67   #  @internal
68   docHelper  = "Creates triangle 2D algorithm for faces"
69
70   _anisotropic_ratio = 0
71   _bad_surface_element_aspect_ratio = 1000
72   _geometric_approximation = 22
73   _gradation  = 1.3
74   _metric = "isotropic"
75   _remove_tiny_edges = 0
76
77   ## Private constructor.
78   #  @param mesh parent mesh object algorithm is assigned to
79   #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
80   #              if it is @c 0 (default), the algorithm is assigned to the main shape
81   def __init__(self, mesh, geom=0):
82     Mesh_Algorithm.__init__(self)
83     if noBLSURFPlugin:
84       print "Warning: BLSURFPlugin module unavailable"
85     self.Create(mesh, geom, BLSURF, "libBLSURFEngine.so")
86     self.params=None
87     self.geompyD = mesh.geompyD
88     #self.SetPhysicalMesh() - PAL19680
89     pass
90
91   ## Sets a way to define size of mesh elements to generate.
92   #  @param thePhysicalMesh is: DefaultSize, BLSURF_Custom or SizeMap.
93   def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
94     physical_size_mode = thePhysicalMesh
95     if self.Parameters().GetGeometricMesh() == DefaultGeom:
96       if physical_size_mode == DefaultSize:
97         physical_size_mode = BLSURF_GlobalSize
98     self.Parameters().SetPhysicalMesh(physical_size_mode)
99     pass
100
101   ## Sets a way to define maximum angular deflection of mesh from CAD model.
102   #  @param theGeometricMesh is: DefaultGeom (0)) or BLSURF_GlobalSize (1))
103   def SetGeometricMesh(self, theGeometricMesh=DefaultGeom):
104     geometric_size_mode = theGeometricMesh
105     if self.Parameters().GetPhysicalMesh() == DefaultSize:
106       if geometric_size_mode == DefaultGeom:
107         geometric_size_mode = BLSURF_GlobalSize
108     self.Parameters().SetGeometricMesh(geometric_size_mode)
109     pass
110
111   ## Sets size of mesh elements to generate.
112   #  @param theVal : constant global size when using a global physical size.
113   #  @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
114   def SetPhySize(self, theVal, isRelative = False):
115     if self.Parameters().GetPhysicalMesh() == DefaultSize:
116       self.SetPhysicalMesh(BLSURF_GlobalSize)
117     if isRelative:
118       self.Parameters().SetPhySizeRel(theVal)
119     else:
120       self.Parameters().SetPhySize(theVal)
121     pass
122
123   ## Sets lower boundary of mesh element size.
124   #  @param theVal : global minimal cell size desired.
125   #  @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
126   def SetMinSize(self, theVal=-1, isRelative = False):
127     if isRelative:
128       self.Parameters().SetMinSizeRel(theVal)
129     else:
130       self.Parameters().SetMinSize(theVal)
131     pass
132
133   ## Sets upper boundary of mesh element size.
134   #  @param theVal : global maximal cell size desired.
135   #  @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
136   def SetMaxSize(self, theVal=-1):
137     if isRelative:
138       self.Parameters().SetMaxSizeRel(theVal)
139     else:
140       self.Parameters().SetMaxSize(theVal)
141     pass
142
143   ## Sets angular deflection (in degrees) from CAD surface.
144   #  @param theVal value of angular deflection
145   def SetAngleMesh(self, theVal=_geometric_approximation):
146     if self.Parameters().GetGeometricMesh() == DefaultGeom:
147       self.SetGeometricMesh(BLSURF_GlobalSize)
148     self.Parameters().SetAngleMesh(theVal)
149     pass
150
151   ## Sets maximal allowed ratio between the lengths of two adjacent edges.
152   #  @param theVal value of maximal length ratio
153   def SetGradation(self, theVal=_gradation):
154     if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
155     self.Parameters().SetGradation(theVal)
156     pass
157
158   ## Sets topology usage way.
159   # @param way defines how mesh conformity is assured <ul>
160   # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
161   # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model (OBSOLETE: FromCAD will be used)</li>
162   # <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
163   def SetTopology(self, way):
164     if way != PreCAD:
165       print "Warning: topology mode %d is no longer supported. Mode FromCAD is used."%way
166       way = FromCAD
167     self.Parameters().SetTopology(way)
168     pass
169
170   ## To respect geometrical edges or not.
171   #  @param toIgnoreEdges "ignore edges" flag value
172   def SetDecimesh(self, toIgnoreEdges=False):
173     if toIgnoreEdges:
174       self.SetOptionValue("respect_geometry","0")
175     else:
176       self.SetOptionValue("respect_geometry","1")
177     pass
178
179   ## Sets verbosity level in the range 0 to 100.
180   #  @param level verbosity level
181   def SetVerbosity(self, level):
182     self.Parameters().SetVerbosity(level)
183     pass
184
185   ## To optimize merges edges.
186   #  @param toMergeEdges "merge edges" flag value
187   def SetPreCADMergeEdges(self, toMergeEdges=False):
188     if self.Parameters().GetTopology() != PreCAD:
189       self.SetTopology(PreCAD)
190     self.Parameters().SetPreCADMergeEdges(toMergeEdges)
191     pass
192
193   ## To process 3D topology.
194   #  @param toProcess "PreCAD process 3D" flag value
195   def SetPreCADProcess3DTopology(self, toProcess=False):
196     if self.Parameters().GetTopology() != PreCAD:
197       self.SetTopology(PreCAD)
198     self.Parameters().SetPreCADProcess3DTopology(toProcess)
199     pass
200
201   ## To remove nano edges.
202   #  @param toRemoveNanoEdges "remove nano edges" flag value
203   def SetPreCADRemoveNanoEdges(self, toRemoveNanoEdges=False):
204     if toRemoveNanoEdges:
205       self.SetPreCADOptionValue("remove_tiny_edges","1")
206     else:
207       self.SetPreCADOptionValue("remove_tiny_edges","0")
208     pass
209
210   ## To compute topology from scratch
211   #  @param toDiscardInput "discard input" flag value
212   def SetPreCADDiscardInput(self, toDiscardInput=False):
213     if self.Parameters().GetTopology() != PreCAD:
214       self.SetTopology(PreCAD)
215     self.Parameters().SetPreCADDiscardInput(toDiscardInput)
216     pass
217
218   ## Sets the length below which an edge is considered as nano
219   #  for the topology processing.
220   #  @param epsNano nano edge length threshold value
221   def SetPreCADEpsNano(self, epsNano):
222     self.SetPreCADOptionValue("tiny_edge_length","%f"%epsNano)
223     pass
224
225   ## Sets advanced option value.
226   #  @param optionName advanced option name
227   #  @param level advanced option value
228   def SetOptionValue(self, optionName, level):
229     self.Parameters().SetOptionValue(optionName,level)
230     pass
231
232   ## Sets advanced PreCAD option value.
233   #  @param optionName name of the option
234   #  @param optionValue value of the option
235   def SetPreCADOptionValue(self, optionName, optionValue):
236     if self.Parameters().GetTopology() != PreCAD:
237       self.SetTopology(PreCAD)
238     self.Parameters().SetPreCADOptionValue(optionName,optionValue)
239     pass
240
241   ## Sets GMF file for export at computation
242   #  @param fileName GMF file name
243   def SetGMFFile(self, fileName):
244     self.Parameters().SetGMFFile(fileName)
245     pass
246
247   #-----------------------------------------
248   # Enforced vertices (BLSURF)
249   #-----------------------------------------
250
251   ## To get all the enforced vertices
252   def GetAllEnforcedVertices(self):
253     return self.Parameters().GetAllEnforcedVertices()
254
255   ## To get all the enforced vertices sorted by face (or group, compound)
256   def GetAllEnforcedVerticesByFace(self):
257     return self.Parameters().GetAllEnforcedVerticesByFace()
258
259   ## To get all the enforced vertices sorted by coords of input vertices
260   def GetAllEnforcedVerticesByCoords(self):
261     return self.Parameters().GetAllEnforcedVerticesByCoords()
262
263   ## To get all the coords of input vertices sorted by face (or group, compound)
264   def GetAllCoordsByFace(self):
265     return self.Parameters().GetAllCoordsByFace()
266
267   ## To get all the enforced vertices on a face (or group, compound)
268   #  @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
269   def GetEnforcedVertices(self, theFace):
270     from salome.smesh.smeshBuilder import AssureGeomPublished
271     AssureGeomPublished( self.mesh, theFace )
272     return self.Parameters().GetEnforcedVertices(theFace)
273
274   ## To clear all the enforced vertices
275   def ClearAllEnforcedVertices(self):
276     return self.Parameters().ClearAllEnforcedVertices()
277
278   ## To set an enforced vertex on a face (or group, compound) given the coordinates of a point. If the point is not on the face, it will projected on it. If there is no projection, no enforced vertex is created.
279   #  @param theFace      : GEOM face (or group, compound) on which to define an enforced vertex
280   #  @param x            : x coordinate
281   #  @param y            : y coordinate
282   #  @param z            : z coordinate
283   #  @param vertexName   : name of the enforced vertex
284   #  @param groupName    : name of the group
285   def SetEnforcedVertex(self, theFace, x, y, z, vertexName = "", groupName = ""):
286     from salome.smesh.smeshBuilder import AssureGeomPublished
287     AssureGeomPublished( self.mesh, theFace )
288     if vertexName == "":
289       if groupName == "":
290         return self.Parameters().SetEnforcedVertex(theFace, x, y, z)
291       else:
292         return self.Parameters().SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
293       pass
294     else:
295       if groupName == "":
296         return self.Parameters().SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
297       else:
298         return self.Parameters().SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
299       pass
300     pass
301
302   ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
303   #  @param theFace      : GEOM face (or group, compound) on which to define an enforced vertex
304   #  @param theVertex    : GEOM vertex (or group, compound) to be projected on theFace.
305   #  @param groupName    : name of the group
306   def SetEnforcedVertexGeom(self, theFace, theVertex, groupName = ""):
307     from salome.smesh.smeshBuilder import AssureGeomPublished
308     AssureGeomPublished( self.mesh, theFace )
309     AssureGeomPublished( self.mesh, theVertex )
310     if groupName == "":
311       return self.Parameters().SetEnforcedVertexGeom(theFace, theVertex)
312     else:
313       return self.Parameters().SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
314     pass
315
316   ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
317   #  @param theFace      : GEOM face (or group, compound) on which to remove the enforced vertex
318   #  @param x            : x coordinate
319   #  @param y            : y coordinate
320   #  @param z            : z coordinate
321   def UnsetEnforcedVertex(self, theFace, x, y, z):
322     from salome.smesh.smeshBuilder import AssureGeomPublished
323     AssureGeomPublished( self.mesh, theFace )
324     return self.Parameters().UnsetEnforcedVertex(theFace, x, y, z)
325
326   ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
327   #  @param theFace      : GEOM face (or group, compound) on which to remove the enforced vertex
328   #  @param theVertex    : GEOM vertex (or group, compound) to remove.
329   def UnsetEnforcedVertexGeom(self, theFace, theVertex):
330     from salome.smesh.smeshBuilder import AssureGeomPublished
331     AssureGeomPublished( self.mesh, theFace )
332     AssureGeomPublished( self.mesh, theVertex )
333     return self.Parameters().UnsetEnforcedVertexGeom(theFace, theVertex)
334
335   ## To remove all enforced vertices on a given face.
336   #  @param theFace      : face (or group/compound of faces) on which to remove all enforced vertices
337   def UnsetEnforcedVertices(self, theFace):
338     from salome.smesh.smeshBuilder import AssureGeomPublished
339     AssureGeomPublished( self.mesh, theFace )
340     return self.Parameters().UnsetEnforcedVertices(theFace)
341
342   ## To tell BLSURF to add a node on internal vertices
343   #  @param toEnforceInternalVertices : boolean; if True the internal vertices are added as enforced vertices
344   def SetInternalEnforcedVertexAllFaces(self, toEnforceInternalVertices):
345     return self.Parameters().SetInternalEnforcedVertexAllFaces(toEnforceInternalVertices)
346
347   ## To know if BLSURF will add a node on internal vertices
348   def GetInternalEnforcedVertexAllFaces(self):
349     return self.Parameters().GetInternalEnforcedVertexAllFaces()
350
351   ## To define a group for the nodes of internal vertices
352   #  @param groupName : string; name of the group
353   def SetInternalEnforcedVertexAllFacesGroup(self, groupName):
354     return self.Parameters().SetInternalEnforcedVertexAllFacesGroup(groupName)
355
356   ## To get the group name of the nodes of internal vertices
357   def GetInternalEnforcedVertexAllFacesGroup(self):
358     return self.Parameters().GetInternalEnforcedVertexAllFacesGroup()
359
360   #-----------------------------------------
361   #  Attractors
362   #-----------------------------------------
363
364   ## Sets an attractor on the chosen face. The mesh size will decrease exponentially with the distance from theAttractor, following the rule h(d) = theEndSize - (theEndSize - theStartSize) * exp [ - ( d / theInfluenceDistance ) ^ 2 ]
365   #  @param theFace      : face on which the attractor will be defined
366   #  @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
367   #  @param theStartSize : mesh size on theAttractor
368   #  @param theEndSize   : maximum size that will be reached on theFace
369   #  @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
370   #  @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
371   def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
372     from salome.smesh.smeshBuilder import AssureGeomPublished
373     AssureGeomPublished( self.mesh, theFace )
374     AssureGeomPublished( self.mesh, theAttractor )
375     self.Parameters().SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
376     pass
377
378   ## Unsets an attractor on the chosen face.
379   #  @param theFace      : face on which the attractor has to be removed
380   def UnsetAttractorGeom(self, theFace):
381     from salome.smesh.smeshBuilder import AssureGeomPublished
382     AssureGeomPublished( self.mesh, theFace )
383     self.Parameters().SetAttractorGeom(theFace)
384     pass
385
386   #-----------------------------------------
387   # Size maps (BLSURF)
388   #-----------------------------------------
389
390   ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
391   #  If theObject is a face, the function can be: def f(u,v): return u+v
392   #  If theObject is an edge, the function can be: def f(t): return t/2
393   #  If theObject is a vertex, the function can be: def f(): return 10
394   #  @param theObject   : GEOM face, edge or vertex (or group, compound) on which to define a size map
395   #  @param theSizeMap  : Size map defined as a string
396   def SetSizeMap(self, theObject, theSizeMap):
397     from salome.smesh.smeshBuilder import AssureGeomPublished
398     AssureGeomPublished( self.mesh, theObject )
399     self.Parameters().SetSizeMap(theObject, theSizeMap)
400     pass
401
402   ## To set a constant size map on a face, edge or vertex (or group, compound).
403   #  @param theObject   : GEOM face, edge or vertex (or group, compound) on which to define a size map
404   #  @param theSizeMap  : Size map defined as a double
405   def SetConstantSizeMap(self, theObject, theSizeMap):
406     from salome.smesh.smeshBuilder import AssureGeomPublished
407     AssureGeomPublished( self.mesh, theObject )
408     self.Parameters().SetConstantSizeMap(theObject, theSizeMap)
409
410   ## To remove a size map defined on a face, edge or vertex (or group, compound)
411   #  @param theObject   : GEOM face, edge or vertex (or group, compound) on which to define a size map
412   def UnsetSizeMap(self, theObject):
413     from salome.smesh.smeshBuilder import AssureGeomPublished
414     AssureGeomPublished( self.mesh, theObject )
415     self.Parameters().UnsetSizeMap(theObject)
416     pass
417
418   ## To remove all the size maps
419   def ClearSizeMaps(self):
420     self.Parameters().ClearSizeMaps()
421     pass
422
423   ## Sets QuadAllowed flag.
424   #  @param toAllow "allow quadrangles" flag value
425   def SetQuadAllowed(self, toAllow=True):
426     self.Parameters().SetQuadAllowed(toAllow)
427     pass
428
429   ## Defines hypothesis having several parameters
430   #  @return hypothesis object
431   def Parameters(self):
432     if not self.params:
433       self.params = self.Hypothesis("BLSURF_Parameters", [],
434                                     "libBLSURFEngine.so", UseExisting=0)
435       pass
436     return self.params
437
438   #-----------------------------------------
439   # Periodicity (BLSURF with PreCAD)
440   #-----------------------------------------
441   
442   ## Defines periodicity between two groups of faces, using PreCAD
443   #  @param theFace1 : GEOM face (or group, compound) to associate with theFace2
444   #  @param theFace2 : GEOM face (or group, compound) associated with theFace1
445   #  @param theSourceVertices (optionnal): list of GEOM vertices on theFace1 defining the transformation from theFace1 to theFace2.
446   #    If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
447   #  @param theTargetVertices (optionnal): list of GEOM vertices on theFace2 defining the transformation from theFace1 to theFace2.
448   #    If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
449   def AddPreCadFacesPeriodicity(self, theFace1, theFace2, theSourceVertices=[], theTargetVertices=[]):
450     """calls preCad function:
451     status_t cad_add_face_multiple_periodicity_with_transformation_function(cad t *cad,
452           integer *fid1, integer size1, integer *fid2, integer size2,
453           periodicity_transformation_t transf, void *user data);
454     """
455     if theSourceVertices and theTargetVertices:
456       self.Parameters().AddPreCadFacesPeriodicityWithVertices(theFace1, theFace2, theSourceVertices, theTargetVertices)
457     else:
458       self.Parameters().AddPreCadFacesPeriodicity(theFace1, theFace2)
459     pass
460
461   ## Defines periodicity between two groups of edges, using PreCAD
462   #  @param theEdge1 : GEOM edge (or group, compound) to associate with theEdge2
463   #  @param theEdge2 : GEOM edge (or group, compound) associated with theEdge1
464   #  @param theSourceVertices (optionnal): list of GEOM vertices on theEdge1 defining the transformation from theEdge1 to theEdge2.
465   #    If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
466   #  @param  theTargetVertices (optionnal): list of GEOM vertices on theEdge2 defining the transformation from theEdge1 to theEdge2.
467   #    If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
468   def AddPreCadEdgesPeriodicity(self, theEdge1, theEdge2, theSourceVertices=[], theTargetVertices=[]):
469     """calls preCad function:
470     status_t cad_add_edge_multiple_periodicity_with_transformation_function(cad t *cad,
471           integer *eid1, integer size1, integer *eid2, integer size2,
472           periodicity_transformation_t transf, void *user data);
473     """
474     if theSourceVertices and theTargetVertices:
475         self.Parameters().AddPreCadEdgesPeriodicityWithVertices(theEdge1, theEdge2, theSourceVertices, theTargetVertices)
476     else:
477         self.Parameters().AddPreCadEdgesPeriodicity(theEdge1, theEdge2)
478     pass
479
480
481   #-----------------------------------------
482   # Periodicity (BLSURF without PreCAD)
483   #-----------------------------------------
484
485
486   ## Defines periodicity between two faces, without using PreCAD.
487   #  User has to call AddEdgePeriodicity with the edges of the face,
488   #  and AddVertexPeriodicity with the vertices of each edge.
489   #  @param theFace1 : GEOM face to associate with theFace2
490   #  @param theFace2 : GEOM face associated with theFace1
491   def AddFacePeriodicity(self, theFace1, theFace2):
492     self.Parameters().AddFacePeriodicity(theFace1, theFace2)
493     pass
494       
495   ## Defines periodicity between two edges belonging to two periodic faces, without using PreCAD.
496   #  To be used with AddFacePeriodicity.
497   #  User has to call AddVertexPeriodicity with the vertices of each edge
498   #  @param theFace1 : GEOM face to associate with theFace2
499   #  @param theEdge1 : GEOM edge to associate with theEdge2
500   #  @param theFace2 : GEOM face associated with theFace1
501   #  @param theEdge2 : GEOM edge associated with theEdge1
502   #  @param theEdgeOrientation : -1 (reversed), 0 (unknown) or 1 (forward)
503   def AddEdgePeriodicity(self, theFace1, theEdge1, theFace2, theEdge2, theEdgeOrientation=0):
504     self.Parameters().AddEdgePeriodicity(theFace1, theEdge1, theFace2, theEdge2, theEdgeOrientation)
505     pass
506
507   ## Defines periodicity between two edges without face periodicity, without using PreCAD.
508   #  User has to call AddVertexPeriodicity with the vertices of each edge.
509   #  @param theEdge1 : GEOM edge to associate with theEdge2
510   #  @param theEdge2 : GEOM edge associated with theEdge1
511   #  @param theEdgeOrientation : -1 (reversed), 0 (unknown) or 1 (forward)
512   def AddEdgePeriodicityWithoutFaces(self, theEdge1, theEdge2, theEdgeOrientation=0):
513     self.Parameters().AddEdgePeriodicityWithoutFaces(theEdge1, theEdge2, theEdgeOrientation)
514     pass
515       
516   ## Defines periodicity between two vertices.
517   #  To be used with AddFacePeriodicity and AddEdgePeriodicity.
518   #  @param theEdge1 : GEOM edge to associate with theEdge2
519   #  @param theVertex1 : GEOM face to associate with theVertex2
520   #  @param theEdge2 : GEOM edge associated with theEdge1
521   #  @param theVertex2 : GEOM face associated with theVertex1
522   def AddVertexPeriodicity(self, theEdge1, theVertex1, theEdge2, theVertex2):
523     self.Parameters().AddVertexPeriodicity(theEdge1, theVertex1, theEdge2, theVertex2)
524     pass
525
526   ## Define periodicity between two groups of faces, given a transformation function.
527   #  This uses the basic BLSURF API for each face, each edge, and each vertex.
528   #  @param theFace1 : GEOM face (or group, compound) to associate with theFace2
529   #  @param theFace2 : GEOM face (or group, compound) associated with theFace1
530   #  @param f_transf : python function defining the transformation between an object of theFace1
531   # into an object of theFace2
532   def AddAdvancedFacesPeriodicity(self, theFace1, theFace2, f_transf):
533     source_faces = self.geompyD.SubShapeAll(theFace1, self.geompyD.ShapeType["FACE"])
534     i = 0
535     j = 0
536     k = 0
537     for source_face in source_faces:
538       self.geompyD.addToStudyInFather(theFace1, source_face, "source_face_%i"%i)
539       p_source = self.geompyD.MakeVertexInsideFace(source_face)
540       p_target = f_transf(p_source)
541       target_face = self.geompyD.GetFaceNearPoint(theFace2, p_target)
542       self.geompyD.addToStudyInFather(theFace2, target_face, "target_face_%i"%i)
543       self.AddFacePeriodicity(source_face, target_face)
544       i += 1
545       
546       source_edges = self.geompyD.SubShapeAll(source_face, self.geompyD.ShapeType["EDGE"])
547       for source_edge in source_edges:
548         self.geompyD.addToStudyInFather(theFace1, source_edge, "source_edge_%i"%(j))
549         p_source = self.geompyD.MakeVertexOnCurve(source_edge, 0.5)
550         p_target = f_transf(p_source)
551         target_edge = self.geompyD.GetEdgeNearPoint(theFace2, p_target)
552         self.geompyD.addToStudyInFather(theFace2, target_edge, "target_edge_%i"%(j))
553         self.AddEdgePeriodicity(source_face, source_edge, target_face, target_edge, 1)
554         j += 1
555         
556         source_vertices = self.geompyD.SubShapeAll(source_edge, self.geompyD.ShapeType["VERTEX"])
557         for source_vertex in source_vertices:
558           self.geompyD.addToStudyInFather(theFace1, source_vertex, "source_vertex_%i"%(k))
559           target_vertex_tmp = f_transf(source_vertex)
560           target_vertex = self.geompyD.GetSame(theFace2, target_vertex_tmp)
561           self.geompyD.addToStudyInFather(theFace2, target_vertex, "target_vertex_%i"%(k))
562           self.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
563           k += 1
564       pass
565
566   ## Define periodicity between two groups of edges, without faces, given a transformation function.
567   #  This uses the basic BLSURF API for each edge and each vertex.
568   #  @param theFace1 : GEOM edge (or group, compound) to associate with theEdge2
569   #  @param theFace2 : GEOM edge (or group, compound) associated with theEdge1
570   #  @param f_transf : python function defining the transformation between an object of theEdge1
571   # into an object of theFace2
572   def AddAdvancedEdgesPeriodicity(self, theEdge1, theEdge2, f_transf):
573     source_edges = self.geompyD.SubShapeAll(theEdge1, self.geompyD.ShapeType["EDGE"])
574     j = 0
575     k = 0
576     for source_edge in source_edges:
577       self.geompyD.addToStudyInFather(theEdge1, source_edge, "source_edge_%i"%j)
578       p_source = self.geompyD.MakeVertexOnCurve(source_edge, 0.5)
579       p_target = f_transf(p_source)
580       target_edge = self.geompyD.GetEdgeNearPoint(theEdge2, p_target)
581       self.geompyD.addToStudyInFather(theEdge2, target_edge, "target_edge_%i"%j)
582       self.AddEdgePeriodicityWithoutFaces(source_edge, target_edge)
583       
584       j += 1
585       
586       source_vertices = self.geompyD.SubShapeAll(source_edge, self.geompyD.ShapeType["VERTEX"])
587       for source_vertex in source_vertices:
588         self.geompyD.addToStudyInFather(theEdge1, source_vertex, "source_vertex_%i"%k)
589         target_vertex_tmp = f_transf(source_vertex)
590         target_vertex = self.geompyD.GetSame(theEdge2, target_vertex_tmp)
591         self.geompyD.addToStudyInFather(theEdge2, target_vertex, "target_vertex_%i"%k)
592         self.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
593         
594         k += 1
595     pass
596
597   #=====================
598   # Obsolete methods
599   #=====================
600   #
601   # SALOME 6.6.0
602   #
603
604   ## Sets lower boundary of mesh element size (PhySize).
605   def SetPhyMin(self, theVal=-1):
606     """
607     Obsolete function. Use SetMinSize.
608     """
609     print "Warning: SetPhyMin is obsolete. Please use SetMinSize"
610     self.SetMinSize(theVal)
611     pass
612
613   ## Sets upper boundary of mesh element size (PhySize).
614   def SetPhyMax(self, theVal=-1):
615     """
616     Obsolete function. Use SetMaxSize.
617     """
618     print "Warning: SetPhyMax is obsolete. Please use SetMaxSize"
619     self.SetMaxSize(theVal)
620     pass
621
622   ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
623   def SetAngleMeshS(self, theVal=_geometric_approximation):
624     """
625     Obsolete function. Use SetAngleMesh.
626     """
627     print "Warning: SetAngleMeshS is obsolete. Please use SetAngleMesh"
628     self.SetAngleMesh(theVal)
629     pass
630
631   ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
632   def SetAngleMeshC(self, theVal=_geometric_approximation):
633     """
634     Obsolete function. Use SetAngleMesh.
635     """
636     print "Warning: SetAngleMeshC is obsolete. Please use SetAngleMesh"
637     self.SetAngleMesh(theVal)
638     pass
639
640   ## Sets lower boundary of mesh element size computed to respect angular deflection.
641   def SetGeoMin(self, theVal=-1):
642     """
643     Obsolete function. Use SetMinSize.
644     """
645     print "Warning: SetGeoMin is obsolete. Please use SetMinSize"
646     self.SetMinSize(theVal)
647     pass
648
649   ## Sets upper boundary of mesh element size computed to respect angular deflection.
650   def SetGeoMax(self, theVal=-1):
651     """
652     Obsolete function. Use SetMaxSize.
653     """
654     print "Warning: SetGeoMax is obsolete. Please use SetMaxSize"
655     self.SetMaxSize(theVal)
656     pass
657
658
659   pass # end of BLSURF_Algorithm class