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