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