Salome HOME
- Disable PreCAD when using basic periodicity API
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPluginBuilder.py
1 # Copyright (C) 2007-2014  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 # Topology treatment way of MG-CADSurf
27 FromCAD, PreProcess, PreProcessPlus, PreCAD = 0,1,2,3
28
29 # Element size flag of MG-CADSurf
30 DefaultSize, DefaultGeom, MG_CADSURF_GlobalSize, MG_CADSURF_LocalSize = 0,0,1,2
31 # Retrocompatibility
32 MG_CADSURF_Custom, SizeMap = MG_CADSURF_GlobalSize, MG_CADSURF_LocalSize
33 BLSURF_Custom, BLSURF_GlobalSize, BLSURF_LocalSize = MG_CADSURF_Custom, MG_CADSURF_GlobalSize, MG_CADSURF_LocalSize
34
35 # import BLSURFPlugin module if possible
36 noBLSURFPlugin = 0
37 try:
38   import BLSURFPlugin
39 except ImportError:
40   noBLSURFPlugin = 1
41   pass
42
43 #----------------------------
44 # Mesh algo type identifiers
45 #----------------------------
46
47 ## Algorithm type: MG-CADSurf triangle algorithm, see BLSURF_Algorithm
48 MG_CADSurf = "MG-CADSurf"
49 BLSURF = MG_CADSurf
50
51 #----------------------
52 # Algorithms
53 #----------------------
54
55 ## MG-CADSurf 2D algorithm.
56 #
57 #  It can be created by calling smeshBuilder.Mesh.Triangle(smeshBuilder.MG-CADSurf,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   = MG_CADSurf
67   ## doc string of the method
68   #  @internal
69   docHelper  = "Creates triangle 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, MG_CADSURF_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 = MG_CADSURF_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 MG_CADSURF_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 = MG_CADSURF_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(MG_CADSURF_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, isRelative = False):
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(MG_CADSURF_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 and way != FromCAD:
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     from salome.smesh.smeshBuilder import AssureGeomPublished
272     AssureGeomPublished( self.mesh, theFace )
273     return self.Parameters().GetEnforcedVertices(theFace)
274
275   ## To clear all the enforced vertices
276   def ClearAllEnforcedVertices(self):
277     return self.Parameters().ClearAllEnforcedVertices()
278
279   ## 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.
280   #  @param theFace      : GEOM face (or group, compound) on which to define an enforced vertex
281   #  @param x            : x coordinate
282   #  @param y            : y coordinate
283   #  @param z            : z coordinate
284   #  @param vertexName   : name of the enforced vertex
285   #  @param groupName    : name of the group
286   def SetEnforcedVertex(self, theFace, x, y, z, vertexName = "", groupName = ""):
287     from salome.smesh.smeshBuilder import AssureGeomPublished
288     AssureGeomPublished( self.mesh, theFace )
289     if vertexName == "":
290       if groupName == "":
291         return self.Parameters().SetEnforcedVertex(theFace, x, y, z)
292       else:
293         return self.Parameters().SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
294       pass
295     else:
296       if groupName == "":
297         return self.Parameters().SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
298       else:
299         return self.Parameters().SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
300       pass
301     pass
302
303   ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
304   #  @param theFace      : GEOM face (or group, compound) on which to define an enforced vertex
305   #  @param theVertex    : GEOM vertex (or group, compound) to be projected on theFace.
306   #  @param groupName    : name of the group
307   def SetEnforcedVertexGeom(self, theFace, theVertex, groupName = ""):
308     from salome.smesh.smeshBuilder import AssureGeomPublished
309     AssureGeomPublished( self.mesh, theFace )
310     AssureGeomPublished( self.mesh, theVertex )
311     if groupName == "":
312       return self.Parameters().SetEnforcedVertexGeom(theFace, theVertex)
313     else:
314       return self.Parameters().SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
315     pass
316
317   ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
318   #  @param theFace      : GEOM face (or group, compound) on which to remove the enforced vertex
319   #  @param x            : x coordinate
320   #  @param y            : y coordinate
321   #  @param z            : z coordinate
322   def UnsetEnforcedVertex(self, theFace, x, y, z):
323     from salome.smesh.smeshBuilder import AssureGeomPublished
324     AssureGeomPublished( self.mesh, theFace )
325     return self.Parameters().UnsetEnforcedVertex(theFace, x, y, z)
326
327   ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
328   #  @param theFace      : GEOM face (or group, compound) on which to remove the enforced vertex
329   #  @param theVertex    : GEOM vertex (or group, compound) to remove.
330   def UnsetEnforcedVertexGeom(self, theFace, theVertex):
331     from salome.smesh.smeshBuilder import AssureGeomPublished
332     AssureGeomPublished( self.mesh, theFace )
333     AssureGeomPublished( self.mesh, theVertex )
334     return self.Parameters().UnsetEnforcedVertexGeom(theFace, theVertex)
335
336   ## To remove all enforced vertices on a given face.
337   #  @param theFace      : face (or group/compound of faces) on which to remove all enforced vertices
338   def UnsetEnforcedVertices(self, theFace):
339     from salome.smesh.smeshBuilder import AssureGeomPublished
340     AssureGeomPublished( self.mesh, theFace )
341     return self.Parameters().UnsetEnforcedVertices(theFace)
342
343   ## To tell BLSURF to add a node on internal vertices
344   #  @param toEnforceInternalVertices : boolean; if True the internal vertices are added as enforced vertices
345   def SetInternalEnforcedVertexAllFaces(self, toEnforceInternalVertices):
346     return self.Parameters().SetInternalEnforcedVertexAllFaces(toEnforceInternalVertices)
347
348   ## To know if BLSURF will add a node on internal vertices
349   def GetInternalEnforcedVertexAllFaces(self):
350     return self.Parameters().GetInternalEnforcedVertexAllFaces()
351
352   ## To define a group for the nodes of internal vertices
353   #  @param groupName : string; name of the group
354   def SetInternalEnforcedVertexAllFacesGroup(self, groupName):
355     return self.Parameters().SetInternalEnforcedVertexAllFacesGroup(groupName)
356
357   ## To get the group name of the nodes of internal vertices
358   def GetInternalEnforcedVertexAllFacesGroup(self):
359     return self.Parameters().GetInternalEnforcedVertexAllFacesGroup()
360
361   #-----------------------------------------
362   #  Attractors
363   #-----------------------------------------
364
365   ## 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 ]
366   #  @param theFace      : face on which the attractor will be defined
367   #  @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
368   #  @param theStartSize : mesh size on theAttractor
369   #  @param theEndSize   : maximum size that will be reached on theFace
370   #  @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
371   #  @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
372   def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
373     from salome.smesh.smeshBuilder import AssureGeomPublished
374     AssureGeomPublished( self.mesh, theFace )
375     AssureGeomPublished( self.mesh, theAttractor )
376     self.Parameters().SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
377     pass
378
379   ## Unsets an attractor on the chosen face.
380   #  @param theFace      : face on which the attractor has to be removed
381   def UnsetAttractorGeom(self, theFace):
382     from salome.smesh.smeshBuilder import AssureGeomPublished
383     AssureGeomPublished( self.mesh, theFace )
384     self.Parameters().SetAttractorGeom(theFace)
385     pass
386
387   #-----------------------------------------
388   # Size maps (BLSURF)
389   #-----------------------------------------
390
391   ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
392   #  If theObject is a face, the function can be: def f(u,v): return u+v
393   #  If theObject is an edge, the function can be: def f(t): return t/2
394   #  If theObject is a vertex, the function can be: def f(): return 10
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 string
397   def SetSizeMap(self, theObject, theSizeMap):
398     from salome.smesh.smeshBuilder import AssureGeomPublished
399     AssureGeomPublished( self.mesh, theObject )
400     self.Parameters().SetSizeMap(theObject, theSizeMap)
401     pass
402
403   ## To set a constant size map on a face, edge or vertex (or group, compound).
404   #  @param theObject   : GEOM face, edge or vertex (or group, compound) on which to define a size map
405   #  @param theSizeMap  : Size map defined as a double
406   def SetConstantSizeMap(self, theObject, theSizeMap):
407     from salome.smesh.smeshBuilder import AssureGeomPublished
408     AssureGeomPublished( self.mesh, theObject )
409     self.Parameters().SetConstantSizeMap(theObject, theSizeMap)
410
411   ## To remove a size map defined on a face, edge or vertex (or group, compound)
412   #  @param theObject   : GEOM face, edge or vertex (or group, compound) on which to define a size map
413   def UnsetSizeMap(self, theObject):
414     from salome.smesh.smeshBuilder import AssureGeomPublished
415     AssureGeomPublished( self.mesh, theObject )
416     self.Parameters().UnsetSizeMap(theObject)
417     pass
418
419   ## To remove all the size maps
420   def ClearSizeMaps(self):
421     self.Parameters().ClearSizeMaps()
422     pass
423
424   ## Sets QuadAllowed flag.
425   #  @param toAllow "allow quadrangles" flag value
426   def SetQuadAllowed(self, toAllow=True):
427     self.Parameters().SetQuadAllowed(toAllow)
428     pass
429
430   ## Defines hypothesis having several parameters
431   #  @return hypothesis object
432   def Parameters(self):
433     if not self.params:
434       self.params = self.Hypothesis("MG-CADSurf Parameters", [],
435                                     "libBLSURFEngine.so", UseExisting=0)
436       pass
437     return self.params
438
439   #-----------------------------------------
440   # Periodicity (BLSURF with PreCAD)
441   #-----------------------------------------
442   
443   ## Defines periodicity between two groups of faces, using PreCAD
444   #  @param theFace1 : GEOM face (or group, compound) to associate with theFace2
445   #  @param theFace2 : GEOM face (or group, compound) associated with theFace1
446   #  @param theSourceVertices (optionnal): list of GEOM vertices on theFace1 defining the transformation from theFace1 to theFace2.
447   #    If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
448   #  @param theTargetVertices (optionnal): list of GEOM vertices on theFace2 defining the transformation from theFace1 to theFace2.
449   #    If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
450   def AddPreCadFacesPeriodicity(self, theFace1, theFace2, theSourceVertices=[], theTargetVertices=[]):
451     """calls preCad function:
452     status_t cad_add_face_multiple_periodicity_with_transformation_function(cad t *cad,
453           integer *fid1, integer size1, integer *fid2, integer size2,
454           periodicity_transformation_t transf, void *user data);
455     """
456     if theSourceVertices and theTargetVertices:
457       self.Parameters().AddPreCadFacesPeriodicityWithVertices(theFace1, theFace2, theSourceVertices, theTargetVertices)
458     else:
459       self.Parameters().AddPreCadFacesPeriodicity(theFace1, theFace2)
460     pass
461
462   ## Defines periodicity between two groups of edges, using PreCAD
463   #  @param theEdge1 : GEOM edge (or group, compound) to associate with theEdge2
464   #  @param theEdge2 : GEOM edge (or group, compound) associated with theEdge1
465   #  @param theSourceVertices (optionnal): list of GEOM vertices on theEdge1 defining the transformation from theEdge1 to theEdge2.
466   #    If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
467   #  @param  theTargetVertices (optionnal): list of GEOM vertices on theEdge2 defining the transformation from theEdge1 to theEdge2.
468   #    If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
469   def AddPreCadEdgesPeriodicity(self, theEdge1, theEdge2, theSourceVertices=[], theTargetVertices=[]):
470     """calls preCad function:
471     status_t cad_add_edge_multiple_periodicity_with_transformation_function(cad t *cad,
472           integer *eid1, integer size1, integer *eid2, integer size2,
473           periodicity_transformation_t transf, void *user data);
474     """
475     if theSourceVertices and theTargetVertices:
476         self.Parameters().AddPreCadEdgesPeriodicityWithVertices(theEdge1, theEdge2, theSourceVertices, theTargetVertices)
477     else:
478         self.Parameters().AddPreCadEdgesPeriodicity(theEdge1, theEdge2)
479     pass
480
481
482   #-----------------------------------------
483   # Periodicity (BLSURF without PreCAD)
484   #-----------------------------------------
485
486
487   ## Defines periodicity between two faces, without using PreCAD.
488   #  User has to call AddEdgePeriodicity with the edges of the face,
489   #  and AddVertexPeriodicity with the vertices of each edge.
490   #  @param theFace1 : GEOM face to associate with theFace2
491   #  @param theFace2 : GEOM face associated with theFace1
492   def AddFacePeriodicity(self, theFace1, theFace2):
493     self.Parameters().AddFacePeriodicity(theFace1, theFace2)
494     pass
495       
496   ## Defines periodicity between two edges belonging to two periodic faces, without using PreCAD.
497   #  To be used with AddFacePeriodicity.
498   #  User has to call AddVertexPeriodicity with the vertices of each edge
499   #  @param theFace1 : GEOM face to associate with theFace2
500   #  @param theEdge1 : GEOM edge to associate with theEdge2
501   #  @param theFace2 : GEOM face associated with theFace1
502   #  @param theEdge2 : GEOM edge associated with theEdge1
503   #  @param theEdgeOrientation : -1 (reversed), 0 (unknown) or 1 (forward)
504   def AddEdgePeriodicity(self, theFace1, theEdge1, theFace2, theEdge2, theEdgeOrientation=0):
505     self.Parameters().AddEdgePeriodicity(theFace1, theEdge1, theFace2, theEdge2, theEdgeOrientation)
506     pass
507
508   ## Defines periodicity between two edges without face periodicity, without using PreCAD.
509   #  User has to call AddVertexPeriodicity with the vertices of each edge.
510   #  @param theEdge1 : GEOM edge to associate with theEdge2
511   #  @param theEdge2 : GEOM edge associated with theEdge1
512   #  @param theEdgeOrientation : -1 (reversed), 0 (unknown) or 1 (forward)
513   def AddEdgePeriodicityWithoutFaces(self, theEdge1, theEdge2, theEdgeOrientation=0):
514     self.Parameters().AddEdgePeriodicityWithoutFaces(theEdge1, theEdge2, theEdgeOrientation)
515     pass
516       
517   ## Defines periodicity between two vertices.
518   #  To be used with AddFacePeriodicity and AddEdgePeriodicity.
519   #  @param theEdge1 : GEOM edge to associate with theEdge2
520   #  @param theVertex1 : GEOM face to associate with theVertex2
521   #  @param theEdge2 : GEOM edge associated with theEdge1
522   #  @param theVertex2 : GEOM face associated with theVertex1
523   def AddVertexPeriodicity(self, theEdge1, theVertex1, theEdge2, theVertex2):
524     self.Parameters().AddVertexPeriodicity(theEdge1, theVertex1, theEdge2, theVertex2)
525     pass
526
527   ## Define periodicity between two groups of faces, given a transformation function.
528   #  This uses the basic BLSURF API for each face, each edge, and each vertex.
529   #  @param theFace1 : GEOM face (or group, compound) to associate with theFace2
530   #  @param theFace2 : GEOM face (or group, compound) associated with theFace1
531   #  @param f_transf : python function defining the transformation between an object of theFace1
532   # into an object of theFace2
533   def AddAdvancedFacesPeriodicity(self, theFace1, theFace2, f_transf):
534     source_faces = self.geompyD.SubShapeAll(theFace1, self.geompyD.ShapeType["FACE"])
535     i = 0
536     j = 0
537     k = 0
538     for source_face in source_faces:
539       self.geompyD.addToStudyInFather(theFace1, source_face, "source_face_%i"%i)
540       p_source = self.geompyD.MakeVertexInsideFace(source_face)
541       p_target = f_transf(p_source)
542       target_face = self.geompyD.GetFaceNearPoint(theFace2, p_target)
543       self.geompyD.addToStudyInFather(theFace2, target_face, "target_face_%i"%i)
544       self.AddFacePeriodicity(source_face, target_face)
545       i += 1
546       
547       source_edges = self.geompyD.SubShapeAll(source_face, self.geompyD.ShapeType["EDGE"])
548       for source_edge in source_edges:
549         self.geompyD.addToStudyInFather(theFace1, source_edge, "source_edge_%i"%(j))
550         p_source = self.geompyD.MakeVertexOnCurve(source_edge, 0.5)
551         p_target = f_transf(p_source)
552         target_edge = self.geompyD.GetEdgeNearPoint(theFace2, p_target)
553         self.geompyD.addToStudyInFather(theFace2, target_edge, "target_edge_%i"%(j))
554         self.AddEdgePeriodicity(source_face, source_edge, target_face, target_edge, 1)
555         j += 1
556         
557         source_vertices = self.geompyD.SubShapeAll(source_edge, self.geompyD.ShapeType["VERTEX"])
558         for source_vertex in source_vertices:
559           self.geompyD.addToStudyInFather(theFace1, source_vertex, "source_vertex_%i"%(k))
560           target_vertex_tmp = f_transf(source_vertex)
561           target_vertex = self.geompyD.GetSame(theFace2, target_vertex_tmp)
562           self.geompyD.addToStudyInFather(theFace2, target_vertex, "target_vertex_%i"%(k))
563           self.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
564           k += 1
565       pass
566
567   ## Define periodicity between two groups of edges, without faces, given a transformation function.
568   #  This uses the basic BLSURF API for each edge and each vertex.
569   #  @param theEdge1 : GEOM edge (or group, compound) to associate with theEdge2
570   #  @param theEdge2 : GEOM edge (or group, compound) associated with theEdge1
571   #  @param f_transf : python function defining the transformation between an object of theEdge1
572   # into an object of theFace2
573   def AddAdvancedEdgesPeriodicity(self, theEdge1, theEdge2, f_transf):
574     source_edges = self.geompyD.SubShapeAll(theEdge1, self.geompyD.ShapeType["EDGE"])
575     j = 0
576     k = 0
577     for source_edge in source_edges:
578       self.geompyD.addToStudyInFather(theEdge1, source_edge, "source_edge_%i"%j)
579       p_source = self.geompyD.MakeVertexOnCurve(source_edge, 0.5)
580       p_target = f_transf(p_source)
581       target_edge = self.geompyD.GetEdgeNearPoint(theEdge2, p_target)
582       self.geompyD.addToStudyInFather(theEdge2, target_edge, "target_edge_%i"%j)
583       self.AddEdgePeriodicityWithoutFaces(source_edge, target_edge)
584       
585       j += 1
586       
587       source_vertices = self.geompyD.SubShapeAll(source_edge, self.geompyD.ShapeType["VERTEX"])
588       for source_vertex in source_vertices:
589         self.geompyD.addToStudyInFather(theEdge1, source_vertex, "source_vertex_%i"%k)
590         target_vertex_tmp = f_transf(source_vertex)
591         target_vertex = self.geompyD.GetSame(theEdge2, target_vertex_tmp)
592         self.geompyD.addToStudyInFather(theEdge2, target_vertex, "target_vertex_%i"%k)
593         self.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
594         
595         k += 1
596     pass
597
598   #=====================
599   # Obsolete methods
600   #=====================
601   #
602   # SALOME 6.6.0
603   #
604
605   ## Sets lower boundary of mesh element size (PhySize).
606   def SetPhyMin(self, theVal=-1):
607     """
608     Obsolete function. Use SetMinSize.
609     """
610     print "Warning: SetPhyMin is obsolete. Please use SetMinSize"
611     self.SetMinSize(theVal)
612     pass
613
614   ## Sets upper boundary of mesh element size (PhySize).
615   def SetPhyMax(self, theVal=-1):
616     """
617     Obsolete function. Use SetMaxSize.
618     """
619     print "Warning: SetPhyMax is obsolete. Please use SetMaxSize"
620     self.SetMaxSize(theVal)
621     pass
622
623   ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
624   def SetAngleMeshS(self, theVal=_geometric_approximation):
625     """
626     Obsolete function. Use SetAngleMesh.
627     """
628     print "Warning: SetAngleMeshS is obsolete. Please use SetAngleMesh"
629     self.SetAngleMesh(theVal)
630     pass
631
632   ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
633   def SetAngleMeshC(self, theVal=_geometric_approximation):
634     """
635     Obsolete function. Use SetAngleMesh.
636     """
637     print "Warning: SetAngleMeshC is obsolete. Please use SetAngleMesh"
638     self.SetAngleMesh(theVal)
639     pass
640
641   ## Sets lower boundary of mesh element size computed to respect angular deflection.
642   def SetGeoMin(self, theVal=-1):
643     """
644     Obsolete function. Use SetMinSize.
645     """
646     print "Warning: SetGeoMin is obsolete. Please use SetMinSize"
647     self.SetMinSize(theVal)
648     pass
649
650   ## Sets upper boundary of mesh element size computed to respect angular deflection.
651   def SetGeoMax(self, theVal=-1):
652     """
653     Obsolete function. Use SetMaxSize.
654     """
655     print "Warning: SetGeoMax is obsolete. Please use SetMaxSize"
656     self.SetMaxSize(theVal)
657     pass
658
659
660   pass # end of BLSURF_Algorithm class