Salome HOME
Enable C++0x/C++11 support
[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 maximal allowed ratio between the lengths of two adjacent edges.
155   #  @param theVal value of maximal length ratio
156   def SetGradation(self, theVal=_gradation):
157     if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
158     self.Parameters().SetGradation(theVal)
159     pass
160
161   ## Sets topology usage way.
162   # @param way defines how mesh conformity is assured <ul>
163   # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
164   # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model (OBSOLETE: FromCAD will be used)</li>
165   # <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
166   def SetTopology(self, way):
167     if way != PreCAD and way != FromCAD:
168       print "Warning: topology mode %d is no longer supported. Mode FromCAD is used."%way
169       way = FromCAD
170     self.Parameters().SetTopology(way)
171     pass
172
173   ## To respect geometrical edges or not.
174   #  @param toIgnoreEdges "ignore edges" flag value
175   def SetDecimesh(self, toIgnoreEdges=False):
176     if toIgnoreEdges:
177       self.SetOptionValue("respect_geometry","0")
178     else:
179       self.SetOptionValue("respect_geometry","1")
180     pass
181
182   ## Sets verbosity level in the range 0 to 100.
183   #  @param level verbosity level
184   def SetVerbosity(self, level):
185     self.Parameters().SetVerbosity(level)
186     pass
187
188   ## To optimize merges edges.
189   #  @param toMergeEdges "merge edges" flag value
190   def SetPreCADMergeEdges(self, toMergeEdges=False):
191     if self.Parameters().GetTopology() != PreCAD:
192       self.SetTopology(PreCAD)
193     self.Parameters().SetPreCADMergeEdges(toMergeEdges)
194     pass
195
196   ## To process 3D topology.
197   #  @param toProcess "PreCAD process 3D" flag value
198   def SetPreCADProcess3DTopology(self, toProcess=False):
199     if self.Parameters().GetTopology() != PreCAD:
200       self.SetTopology(PreCAD)
201     self.Parameters().SetPreCADProcess3DTopology(toProcess)
202     pass
203
204   ## To remove nano edges.
205   #  @param toRemoveNanoEdges "remove nano edges" flag value
206   def SetPreCADRemoveNanoEdges(self, toRemoveNanoEdges=False):
207     if toRemoveNanoEdges:
208       self.SetPreCADOptionValue("remove_tiny_edges","1")
209     else:
210       self.SetPreCADOptionValue("remove_tiny_edges","0")
211     pass
212
213   ## To compute topology from scratch
214   #  @param toDiscardInput "discard input" flag value
215   def SetPreCADDiscardInput(self, toDiscardInput=False):
216     if self.Parameters().GetTopology() != PreCAD:
217       self.SetTopology(PreCAD)
218     self.Parameters().SetPreCADDiscardInput(toDiscardInput)
219     pass
220
221   ## Sets the length below which an edge is considered as nano
222   #  for the topology processing.
223   #  @param epsNano nano edge length threshold value
224   def SetPreCADEpsNano(self, epsNano):
225     self.SetPreCADOptionValue("tiny_edge_length","%f"%epsNano)
226     pass
227
228   ## Sets advanced option value.
229   #  @param optionName advanced option name
230   #  @param level advanced option value
231   def SetOptionValue(self, optionName, level):
232     self.Parameters().SetOptionValue(optionName,level)
233     pass
234
235   ## Sets advanced PreCAD option value.
236   #  @param optionName name of the option
237   #  @param optionValue value of the option
238   def SetPreCADOptionValue(self, optionName, optionValue):
239     if self.Parameters().GetTopology() != PreCAD:
240       self.SetTopology(PreCAD)
241     self.Parameters().SetPreCADOptionValue(optionName,optionValue)
242     pass
243   
244   ## Adds custom advanced option value.
245   #  @param optionName custom advanced option name
246   #  @param level custom advanced option value
247   def AddOption(self, optionName, level):
248     self.Parameters().AddOption(optionName,level)
249     pass
250
251   ## Adds custom advanced PreCAD option value.
252   #  @param optionName custom name of the option
253   #  @param optionValue value of the option
254   def AddPreCADOption(self, optionName, optionValue):
255     if self.Parameters().GetTopology() != PreCAD:
256       self.SetTopology(PreCAD)
257     self.Parameters().AddPreCADOption(optionName,optionValue)
258     pass
259
260   ## Sets GMF file for export at computation
261   #  @param fileName GMF file name
262   def SetGMFFile(self, fileName):
263     self.Parameters().SetGMFFile(fileName)
264     pass
265
266   #-----------------------------------------
267   # Enforced vertices (BLSURF)
268   #-----------------------------------------
269
270   ## To get all the enforced vertices
271   def GetAllEnforcedVertices(self):
272     return self.Parameters().GetAllEnforcedVertices()
273
274   ## To get all the enforced vertices sorted by face (or group, compound)
275   def GetAllEnforcedVerticesByFace(self):
276     return self.Parameters().GetAllEnforcedVerticesByFace()
277
278   ## To get all the enforced vertices sorted by coords of input vertices
279   def GetAllEnforcedVerticesByCoords(self):
280     return self.Parameters().GetAllEnforcedVerticesByCoords()
281
282   ## To get all the coords of input vertices sorted by face (or group, compound)
283   def GetAllCoordsByFace(self):
284     return self.Parameters().GetAllCoordsByFace()
285
286   ## To get all the enforced vertices on a face (or group, compound)
287   #  @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
288   def GetEnforcedVertices(self, theFace):
289     from salome.smesh.smeshBuilder import AssureGeomPublished
290     AssureGeomPublished( self.mesh, theFace )
291     return self.Parameters().GetEnforcedVertices(theFace)
292
293   ## To clear all the enforced vertices
294   def ClearAllEnforcedVertices(self):
295     return self.Parameters().ClearAllEnforcedVertices()
296
297   ## 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.
298   #  @param theFace      : GEOM face (or group, compound) on which to define an enforced vertex
299   #  @param x            : x coordinate
300   #  @param y            : y coordinate
301   #  @param z            : z coordinate
302   #  @param vertexName   : name of the enforced vertex
303   #  @param groupName    : name of the group
304   def SetEnforcedVertex(self, theFace, x, y, z, vertexName = "", groupName = ""):
305     from salome.smesh.smeshBuilder import AssureGeomPublished
306     AssureGeomPublished( self.mesh, theFace )
307     if vertexName == "":
308       if groupName == "":
309         return self.Parameters().SetEnforcedVertex(theFace, x, y, z)
310       else:
311         return self.Parameters().SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
312       pass
313     else:
314       if groupName == "":
315         return self.Parameters().SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
316       else:
317         return self.Parameters().SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
318       pass
319     pass
320
321   ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
322   #  @param theFace      : GEOM face (or group, compound) on which to define an enforced vertex
323   #  @param theVertex    : GEOM vertex (or group, compound) to be projected on theFace.
324   #  @param groupName    : name of the group
325   def SetEnforcedVertexGeom(self, theFace, theVertex, groupName = ""):
326     from salome.smesh.smeshBuilder import AssureGeomPublished
327     AssureGeomPublished( self.mesh, theFace )
328     AssureGeomPublished( self.mesh, theVertex )
329     if groupName == "":
330       return self.Parameters().SetEnforcedVertexGeom(theFace, theVertex)
331     else:
332       return self.Parameters().SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
333     pass
334
335   ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
336   #  @param theFace      : GEOM face (or group, compound) on which to remove the enforced vertex
337   #  @param x            : x coordinate
338   #  @param y            : y coordinate
339   #  @param z            : z coordinate
340   def UnsetEnforcedVertex(self, theFace, x, y, z):
341     from salome.smesh.smeshBuilder import AssureGeomPublished
342     AssureGeomPublished( self.mesh, theFace )
343     return self.Parameters().UnsetEnforcedVertex(theFace, x, y, z)
344
345   ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
346   #  @param theFace      : GEOM face (or group, compound) on which to remove the enforced vertex
347   #  @param theVertex    : GEOM vertex (or group, compound) to remove.
348   def UnsetEnforcedVertexGeom(self, theFace, theVertex):
349     from salome.smesh.smeshBuilder import AssureGeomPublished
350     AssureGeomPublished( self.mesh, theFace )
351     AssureGeomPublished( self.mesh, theVertex )
352     return self.Parameters().UnsetEnforcedVertexGeom(theFace, theVertex)
353
354   ## To remove all enforced vertices on a given face.
355   #  @param theFace      : face (or group/compound of faces) on which to remove all enforced vertices
356   def UnsetEnforcedVertices(self, theFace):
357     from salome.smesh.smeshBuilder import AssureGeomPublished
358     AssureGeomPublished( self.mesh, theFace )
359     return self.Parameters().UnsetEnforcedVertices(theFace)
360
361   ## To tell BLSURF to add a node on internal vertices
362   #  @param toEnforceInternalVertices : boolean; if True the internal vertices are added as enforced vertices
363   def SetInternalEnforcedVertexAllFaces(self, toEnforceInternalVertices):
364     return self.Parameters().SetInternalEnforcedVertexAllFaces(toEnforceInternalVertices)
365
366   ## To know if BLSURF will add a node on internal vertices
367   def GetInternalEnforcedVertexAllFaces(self):
368     return self.Parameters().GetInternalEnforcedVertexAllFaces()
369
370   ## To define a group for the nodes of internal vertices
371   #  @param groupName : string; name of the group
372   def SetInternalEnforcedVertexAllFacesGroup(self, groupName):
373     return self.Parameters().SetInternalEnforcedVertexAllFacesGroup(groupName)
374
375   ## To get the group name of the nodes of internal vertices
376   def GetInternalEnforcedVertexAllFacesGroup(self):
377     return self.Parameters().GetInternalEnforcedVertexAllFacesGroup()
378
379   #-----------------------------------------
380   #  Attractors
381   #-----------------------------------------
382
383   ## 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 ]
384   #  @param theFace      : face on which the attractor will be defined
385   #  @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
386   #  @param theStartSize : mesh size on theAttractor
387   #  @param theEndSize   : maximum size that will be reached on theFace
388   #  @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
389   #  @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
390   def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
391     from salome.smesh.smeshBuilder import AssureGeomPublished
392     AssureGeomPublished( self.mesh, theFace )
393     AssureGeomPublished( self.mesh, theAttractor )
394     self.Parameters().SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
395     pass
396
397   ## Unsets an attractor on the chosen face.
398   #  @param theFace      : face on which the attractor has to be removed
399   def UnsetAttractorGeom(self, theFace):
400     from salome.smesh.smeshBuilder import AssureGeomPublished
401     AssureGeomPublished( self.mesh, theFace )
402     self.Parameters().SetAttractorGeom(theFace)
403     pass
404
405   #-----------------------------------------
406   # Size maps (BLSURF)
407   #-----------------------------------------
408
409   ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
410   #  If theObject is a face, the function can be: def f(u,v): return u+v
411   #  If theObject is an edge, the function can be: def f(t): return t/2
412   #  If theObject is a vertex, the function can be: def f(): return 10
413   #  @param theObject   : GEOM face, edge or vertex (or group, compound) on which to define a size map
414   #  @param theSizeMap  : Size map defined as a string
415   def SetSizeMap(self, theObject, theSizeMap):
416     from salome.smesh.smeshBuilder import AssureGeomPublished
417     AssureGeomPublished( self.mesh, theObject )
418     self.Parameters().SetSizeMap(theObject, theSizeMap)
419     pass
420
421   ## To set a constant size map on a face, edge or vertex (or group, compound).
422   #  @param theObject   : GEOM face, edge or vertex (or group, compound) on which to define a size map
423   #  @param theSizeMap  : Size map defined as a double
424   def SetConstantSizeMap(self, theObject, theSizeMap):
425     from salome.smesh.smeshBuilder import AssureGeomPublished
426     AssureGeomPublished( self.mesh, theObject )
427     self.Parameters().SetConstantSizeMap(theObject, theSizeMap)
428
429   ## To remove a size map defined on a face, edge or vertex (or group, compound)
430   #  @param theObject   : GEOM face, edge or vertex (or group, compound) on which to define a size map
431   def UnsetSizeMap(self, theObject):
432     from salome.smesh.smeshBuilder import AssureGeomPublished
433     AssureGeomPublished( self.mesh, theObject )
434     self.Parameters().UnsetSizeMap(theObject)
435     pass
436
437   ## To remove all the size maps
438   def ClearSizeMaps(self):
439     self.Parameters().ClearSizeMaps()
440     pass
441
442   ## Sets QuadAllowed flag.
443   #  @param toAllow "allow quadrangles" flag value
444   def SetQuadAllowed(self, toAllow=True):
445     self.Parameters().SetQuadAllowed(toAllow)
446     pass
447
448   ## Defines hypothesis having several parameters
449   #  @return hypothesis object
450   def Parameters(self):
451     if not self.params:
452       self.params = self.Hypothesis("MG-CADSurf Parameters", [],
453                                     LIBRARY, UseExisting=0)
454       pass
455     return self.params
456
457   #-----------------------------------------
458   # Periodicity (BLSURF with PreCAD)
459   #-----------------------------------------
460   
461   ## Defines periodicity between two groups of faces, using PreCAD
462   #  @param theFace1 : GEOM face (or group, compound) to associate with theFace2
463   #  @param theFace2 : GEOM face (or group, compound) associated with theFace1
464   #  @param theSourceVertices (optionnal): list of GEOM vertices on theFace1 defining the transformation from theFace1 to theFace2.
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 theFace2 defining the transformation from theFace1 to theFace2.
467   #    If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
468   def AddPreCadFacesPeriodicity(self, theFace1, theFace2, theSourceVertices=[], theTargetVertices=[]):
469     """calls preCad function:
470     status_t cad_add_face_multiple_periodicity_with_transformation_function(cad t *cad,
471           integer *fid1, integer size1, integer *fid2, integer size2,
472           periodicity_transformation_t transf, void *user data);
473     """
474     if theSourceVertices and theTargetVertices:
475       self.Parameters().AddPreCadFacesPeriodicityWithVertices(theFace1, theFace2, theSourceVertices, theTargetVertices)
476     else:
477       self.Parameters().AddPreCadFacesPeriodicity(theFace1, theFace2)
478     pass
479
480   ## Defines periodicity between two groups of edges, using PreCAD
481   #  @param theEdge1 : GEOM edge (or group, compound) to associate with theEdge2
482   #  @param theEdge2 : GEOM edge (or group, compound) associated with theEdge1
483   #  @param theSourceVertices (optionnal): list of GEOM vertices on theEdge1 defining the transformation from theEdge1 to theEdge2.
484   #    If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
485   #  @param  theTargetVertices (optionnal): list of GEOM vertices on theEdge2 defining the transformation from theEdge1 to theEdge2.
486   #    If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
487   def AddPreCadEdgesPeriodicity(self, theEdge1, theEdge2, theSourceVertices=[], theTargetVertices=[]):
488     """calls preCad function:
489     status_t cad_add_edge_multiple_periodicity_with_transformation_function(cad t *cad,
490           integer *eid1, integer size1, integer *eid2, integer size2,
491           periodicity_transformation_t transf, void *user data);
492     """
493     if theSourceVertices and theTargetVertices:
494         self.Parameters().AddPreCadEdgesPeriodicityWithVertices(theEdge1, theEdge2, theSourceVertices, theTargetVertices)
495     else:
496         self.Parameters().AddPreCadEdgesPeriodicity(theEdge1, theEdge2)
497     pass
498
499
500   #-----------------------------------------
501   # Periodicity (BLSURF without PreCAD)
502   #-----------------------------------------
503
504
505   ## Defines periodicity between two faces, without using PreCAD.
506   #  User has to call AddEdgePeriodicity with the edges of the face,
507   #  and AddVertexPeriodicity with the vertices of each edge.
508   #  @param theFace1 : GEOM face to associate with theFace2
509   #  @param theFace2 : GEOM face associated with theFace1
510   def AddFacePeriodicity(self, theFace1, theFace2):
511     self.Parameters().AddFacePeriodicity(theFace1, theFace2)
512     pass
513       
514   ## Defines periodicity between two edges belonging to two periodic faces, without using PreCAD.
515   #  To be used with AddFacePeriodicity.
516   #  User has to call AddVertexPeriodicity with the vertices of each edge
517   #  @param theFace1 : GEOM face to associate with theFace2
518   #  @param theEdge1 : GEOM edge to associate with theEdge2
519   #  @param theFace2 : GEOM face associated with theFace1
520   #  @param theEdge2 : GEOM edge associated with theEdge1
521   #  @param theEdgeOrientation : -1 (reversed), 0 (unknown) or 1 (forward)
522   def AddEdgePeriodicity(self, theFace1, theEdge1, theFace2, theEdge2, theEdgeOrientation=0):
523     self.Parameters().AddEdgePeriodicity(theFace1, theEdge1, theFace2, theEdge2, theEdgeOrientation)
524     pass
525
526   ## Defines periodicity between two edges without face periodicity, without using PreCAD.
527   #  User has to call AddVertexPeriodicity with the vertices of each edge.
528   #  @param theEdge1 : GEOM edge to associate with theEdge2
529   #  @param theEdge2 : GEOM edge associated with theEdge1
530   #  @param theEdgeOrientation : -1 (reversed), 0 (unknown) or 1 (forward)
531   def AddEdgePeriodicityWithoutFaces(self, theEdge1, theEdge2, theEdgeOrientation=0):
532     self.Parameters().AddEdgePeriodicityWithoutFaces(theEdge1, theEdge2, theEdgeOrientation)
533     pass
534       
535   ## Defines periodicity between two vertices.
536   #  To be used with AddFacePeriodicity and AddEdgePeriodicity.
537   #  @param theEdge1 : GEOM edge to associate with theEdge2
538   #  @param theVertex1 : GEOM face to associate with theVertex2
539   #  @param theEdge2 : GEOM edge associated with theEdge1
540   #  @param theVertex2 : GEOM face associated with theVertex1
541   def AddVertexPeriodicity(self, theEdge1, theVertex1, theEdge2, theVertex2):
542     self.Parameters().AddVertexPeriodicity(theEdge1, theVertex1, theEdge2, theVertex2)
543     pass
544
545   ## Define periodicity between two groups of faces, given a transformation function.
546   #  This uses the basic BLSURF API for each face, each edge, and each vertex.
547   #  @param theFace1 : GEOM face (or group, compound) to associate with theFace2
548   #  @param theFace2 : GEOM face (or group, compound) associated with theFace1
549   #  @param f_transf : python function defining the transformation between an object of theFace1
550   # into an object of theFace2
551   def AddAdvancedFacesPeriodicity(self, theFace1, theFace2, f_transf):
552     source_faces = self.geompyD.SubShapeAll(theFace1, self.geompyD.ShapeType["FACE"])
553     i = 0
554     j = 0
555     k = 0
556     for source_face in source_faces:
557       self.geompyD.addToStudyInFather(theFace1, source_face, "source_face_%i"%i)
558       p_source = self.geompyD.MakeVertexInsideFace(source_face)
559       p_target = f_transf(p_source)
560       target_face = self.geompyD.GetFaceNearPoint(theFace2, p_target)
561       self.geompyD.addToStudyInFather(theFace2, target_face, "target_face_%i"%i)
562       self.AddFacePeriodicity(source_face, target_face)
563       i += 1
564       
565       source_edges = self.geompyD.SubShapeAll(source_face, self.geompyD.ShapeType["EDGE"])
566       for source_edge in source_edges:
567         self.geompyD.addToStudyInFather(theFace1, source_edge, "source_edge_%i"%(j))
568         p_source = self.geompyD.MakeVertexOnCurve(source_edge, 0.5)
569         p_target = f_transf(p_source)
570         target_edge = self.geompyD.GetEdgeNearPoint(theFace2, p_target)
571         self.geompyD.addToStudyInFather(theFace2, target_edge, "target_edge_%i"%(j))
572         self.AddEdgePeriodicity(source_face, source_edge, target_face, target_edge, 1)
573         j += 1
574         
575         source_vertices = self.geompyD.SubShapeAll(source_edge, self.geompyD.ShapeType["VERTEX"])
576         for source_vertex in source_vertices:
577           self.geompyD.addToStudyInFather(theFace1, source_vertex, "source_vertex_%i"%(k))
578           target_vertex_tmp = f_transf(source_vertex)
579           target_vertex = self.geompyD.GetSame(theFace2, target_vertex_tmp)
580           self.geompyD.addToStudyInFather(theFace2, target_vertex, "target_vertex_%i"%(k))
581           self.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
582           k += 1
583       pass
584
585   ## Define periodicity between two groups of edges, without faces, given a transformation function.
586   #  This uses the basic BLSURF API for each edge and each vertex.
587   #  @param theEdge1 : GEOM edge (or group, compound) to associate with theEdge2
588   #  @param theEdge2 : GEOM edge (or group, compound) associated with theEdge1
589   #  @param f_transf : python function defining the transformation between an object of theEdge1
590   # into an object of theFace2
591   def AddAdvancedEdgesPeriodicity(self, theEdge1, theEdge2, f_transf):
592     source_edges = self.geompyD.SubShapeAll(theEdge1, self.geompyD.ShapeType["EDGE"])
593     j = 0
594     k = 0
595     for source_edge in source_edges:
596       self.geompyD.addToStudyInFather(theEdge1, source_edge, "source_edge_%i"%j)
597       p_source = self.geompyD.MakeVertexOnCurve(source_edge, 0.5)
598       p_target = f_transf(p_source)
599       target_edge = self.geompyD.GetEdgeNearPoint(theEdge2, p_target)
600       self.geompyD.addToStudyInFather(theEdge2, target_edge, "target_edge_%i"%j)
601       self.AddEdgePeriodicityWithoutFaces(source_edge, target_edge)
602       
603       j += 1
604       
605       source_vertices = self.geompyD.SubShapeAll(source_edge, self.geompyD.ShapeType["VERTEX"])
606       for source_vertex in source_vertices:
607         self.geompyD.addToStudyInFather(theEdge1, source_vertex, "source_vertex_%i"%k)
608         target_vertex_tmp = f_transf(source_vertex)
609         target_vertex = self.geompyD.GetSame(theEdge2, target_vertex_tmp)
610         self.geompyD.addToStudyInFather(theEdge2, target_vertex, "target_vertex_%i"%k)
611         self.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
612         
613         k += 1
614     pass
615
616   #=====================
617   # Obsolete methods
618   #=====================
619   #
620   # SALOME 6.6.0
621   #
622
623   ## Sets lower boundary of mesh element size (PhySize).
624   def SetPhyMin(self, theVal=-1):
625     """
626     Obsolete function. Use SetMinSize.
627     """
628     print "Warning: SetPhyMin is obsolete. Please use SetMinSize"
629     self.SetMinSize(theVal)
630     pass
631
632   ## Sets upper boundary of mesh element size (PhySize).
633   def SetPhyMax(self, theVal=-1):
634     """
635     Obsolete function. Use SetMaxSize.
636     """
637     print "Warning: SetPhyMax is obsolete. Please use SetMaxSize"
638     self.SetMaxSize(theVal)
639     pass
640
641   ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
642   def SetAngleMeshS(self, theVal=_geometric_approximation):
643     """
644     Obsolete function. Use SetAngleMesh.
645     """
646     print "Warning: SetAngleMeshS is obsolete. Please use SetAngleMesh"
647     self.SetAngleMesh(theVal)
648     pass
649
650   ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
651   def SetAngleMeshC(self, theVal=_geometric_approximation):
652     """
653     Obsolete function. Use SetAngleMesh.
654     """
655     print "Warning: SetAngleMeshC is obsolete. Please use SetAngleMesh"
656     self.SetAngleMesh(theVal)
657     pass
658
659   ## Sets lower boundary of mesh element size computed to respect angular deflection.
660   def SetGeoMin(self, theVal=-1):
661     """
662     Obsolete function. Use SetMinSize.
663     """
664     print "Warning: SetGeoMin is obsolete. Please use SetMinSize"
665     self.SetMinSize(theVal)
666     pass
667
668   ## Sets upper boundary of mesh element size computed to respect angular deflection.
669   def SetGeoMax(self, theVal=-1):
670     """
671     Obsolete function. Use SetMaxSize.
672     """
673     print "Warning: SetGeoMax is obsolete. Please use SetMaxSize"
674     self.SetMaxSize(theVal)
675     pass
676
677
678   pass # end of BLSURF_Algorithm class