Salome HOME
Merge remote branch 'origin/eap/23307'
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPluginBuilder.py
1 # Copyright (C) 2007-2016  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   _volume_gradation  = 2
78   _metric = "isotropic"
79   _remove_tiny_edges = 0
80
81   ## Private constructor.
82   #  @param mesh parent mesh object algorithm is assigned to
83   #  @param geom geometry (shape/sub-shape) algorithm is assigned to;
84   #              if it is @c 0 (default), the algorithm is assigned to the main shape
85   def __init__(self, mesh, geom=0):
86     Mesh_Algorithm.__init__(self)
87     if noBLSURFPlugin:
88       print "Warning: BLSURFPlugin module unavailable"
89     self.Create(mesh, geom, BLSURF, LIBRARY)
90     self.params=None
91     self.geompyD = mesh.geompyD
92     #self.SetPhysicalMesh() - PAL19680
93     pass
94
95   ## Sets a way to define size of mesh elements to generate.
96   #  @param thePhysicalMesh is: DefaultSize, MG_CADSURF_Custom or SizeMap.
97   def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
98     physical_size_mode = thePhysicalMesh
99     if self.Parameters().GetGeometricMesh() == DefaultGeom:
100       if physical_size_mode == DefaultSize:
101         physical_size_mode = MG_CADSURF_GlobalSize
102     self.Parameters().SetPhysicalMesh(physical_size_mode)
103     pass
104
105   ## Sets a way to define maximum angular deflection of mesh from CAD model.
106   #  @param theGeometricMesh is: DefaultGeom (0)) or MG_CADSURF_GlobalSize (1))
107   def SetGeometricMesh(self, theGeometricMesh=DefaultGeom):
108     geometric_size_mode = theGeometricMesh
109     if self.Parameters().GetPhysicalMesh() == DefaultSize:
110       if geometric_size_mode == DefaultGeom:
111         geometric_size_mode = MG_CADSURF_GlobalSize
112     self.Parameters().SetGeometricMesh(geometric_size_mode)
113     pass
114
115   ## Sets size of mesh elements to generate.
116   #  @param theVal : constant global size when using a global physical size.
117   #  @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
118   def SetPhySize(self, theVal, isRelative = False):
119     if self.Parameters().GetPhysicalMesh() == DefaultSize:
120       self.SetPhysicalMesh(MG_CADSURF_GlobalSize)
121     if isRelative:
122       self.Parameters().SetPhySizeRel(theVal)
123     else:
124       self.Parameters().SetPhySize(theVal)
125     pass
126
127   ## Sets lower boundary of mesh element size.
128   #  @param theVal : global minimal cell size desired.
129   #  @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
130   def SetMinSize(self, theVal=-1, isRelative = False):
131     if isRelative:
132       self.Parameters().SetMinSizeRel(theVal)
133     else:
134       self.Parameters().SetMinSize(theVal)
135     pass
136
137   ## Sets upper boundary of mesh element size.
138   #  @param theVal : global maximal cell size desired.
139   #  @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
140   def SetMaxSize(self, theVal=-1, isRelative = False):
141     if isRelative:
142       self.Parameters().SetMaxSizeRel(theVal)
143     else:
144       self.Parameters().SetMaxSize(theVal)
145     pass
146
147   ## Sets angular deflection (in degrees) from CAD surface.
148   #  @param theVal value of angular deflection
149   def SetAngleMesh(self, theVal=_geometric_approximation):
150     if self.Parameters().GetGeometricMesh() == DefaultGeom:
151       self.SetGeometricMesh(MG_CADSURF_GlobalSize)
152     self.Parameters().SetAngleMesh(theVal)
153     pass
154
155   ## Sets the maximum desired distance between a triangle and its supporting CAD surface
156   #  @param distance the distance between a triangle and a surface
157   def SetChordalError(self, distance):
158     self.Parameters().SetChordalError(distance)
159     pass
160
161   ## Sets maximal allowed ratio between the lengths of two adjacent edges.
162   #  @param theVal value of maximal length ratio
163   def SetGradation(self, toUseGradation=True, theVal=_gradation):
164     if isinstance( toUseGradation, float ): ## backward compatibility
165       toUseGradation, theVal = True, toUseGradation
166     if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
167     self.Parameters().SetUseGradation(toUseGradation)
168     self.Parameters().SetGradation(theVal)
169     pass
170
171   ## Sets maximal allowed ratio between the lengths of two adjacent edges in 3D mesh.
172   #  @param theVal value of maximal length ratio
173   def SetVolumeGradation(self, toUseGradation=True, theVal=_gradation):
174     if self.Parameters().GetGeometricMesh() == 0: theVal = self._volume_gradation
175     self.Parameters().SetUseVolumeGradation(toUseGradation)
176     self.Parameters().SetVolumeGradation(theVal)
177     pass
178
179   ## Sets topology usage way.
180   # @param way defines how mesh conformity is assured <ul>
181   # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
182   # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model (OBSOLETE: FromCAD will be used)</li>
183   # <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
184   def SetTopology(self, way):
185     if way != PreCAD and way != FromCAD:
186       print "Warning: topology mode %d is no longer supported. Mode FromCAD is used."%way
187       way = FromCAD
188     self.Parameters().SetTopology(way)
189     pass
190
191   ## To respect geometrical edges or not.
192   #  @param toIgnoreEdges "ignore edges" flag value
193   def SetDecimesh(self, toIgnoreEdges=False):
194     if toIgnoreEdges:
195       self.SetOptionValue("respect_geometry","0")
196     else:
197       self.SetOptionValue("respect_geometry","1")
198     pass
199
200   ## Sets verbosity level in the range 0 to 100.
201   #  @param level verbosity level
202   def SetVerbosity(self, level):
203     self.Parameters().SetVerbosity(level)
204     pass
205
206   ## Set enforce_cad_edge_sizes parameter
207   #  
208   #  Relaxes the given sizemap constraint around CAD edges to allow a better
209   #  element quality and a better geometric approximation. It is only useful in 
210   #  combination with the gradation option.
211   #  
212   def SetEnforceCadEdgesSize( self, toEnforce ):
213     self.Parameters().SetEnforceCadEdgesSize( toEnforce )
214
215   ## Set jacobian_rectification_respect_geometry parameter
216   #  
217   #  While making the mesh quadratic, allows to lose the CAD-mesh associativity in order
218   #  to correct elements with nagative Jacobian
219   #  
220   def SetJacobianRectificationRespectGeometry( self, allowRectification ):
221     self.Parameters().SetJacobianRectificationRespectGeometry( allowRectification )
222     
223   ## Set rectify_jacobian parameter
224   #  
225   #  While making the mesh quadratic, allow to fix nagative Jacobian surface elements
226   #  
227   def SetJacobianRectification( self, allowRectification ):
228     self.Parameters().SetJacobianRectification( allowRectification )
229
230   ## Set respect_geometry parameter
231   #  
232   #  This patch independent option can be deactivated to allow MeshGems-CADSurf
233   #  to lower the geometry accuracy in its patch independent process.
234   #  
235   def SetRespectGeometry( self, toRespect ):
236     self.Parameters().SetRespectGeometry( toRespect )
237
238   ## Set max_number_of_points_per_patch parameter
239   #  
240   #  This parameter controls the maximum amount of points MeshGems-CADSurf is allowed
241   #  to generate on a single CAD patch. For an automatic gestion of the memory, one
242   #  can set this parameter to 0
243   #  
244   def SetMaxNumberOfPointsPerPatch( self, nb ):
245     self.Parameters().SetMaxNumberOfPointsPerPatch( nb )
246
247   ## Set respect_geometry parameter
248   #  
249   #  This patch independent option can be deactivated to allow MeshGems-CADSurf
250   #  to lower the geometry accuracy in its patch independent process.
251   #  
252   def SetRespectGeometry( self, toRespect ):
253     self.Parameters().SetRespectGeometry( toRespect )
254
255   ## Set tiny_edges_avoid_surface_intersections parameter
256   #  
257   #  This option defines the priority between the tiny feature
258   #  suppression and the surface intersection prevention. 
259   #  
260   def SetTinyEdgesAvoidSurfaceIntersections( self, toAvoidIntersection ):
261     self.Parameters().SetTinyEdgesAvoidSurfaceIntersections( toAvoidIntersection )
262
263   ## Set closed_geometry parameter parameter
264   #  
265   #  Describes whether the geometry is expected to be closed or not. 
266   #  When activated, this option helps MeshGems-PreCAD to treat the dirtiest geometries.
267   #  
268   def SetClosedGeometry( self, isClosed ):
269     self.Parameters().SetClosedGeometry( isClosed )
270
271   ## Set debug parameter
272   #  
273   #  Make MeshGems-CADSurf will be very verbose and will output some intermediate
274   #  files in the working directory. This option is mainly meant for Distene support issues.
275   #  
276   def SetDebug( self, isDebug ):
277     self.Parameters().SetDebug( isDebug )
278
279   ## Set periodic_tolerance parameter
280   #  
281   #  This parameter defines the maximum size difference between two periodic edges
282   #  and also the maximum distance error between two periodic entities.
283   #  
284   def SetPeriodicTolerance( self, tol ):
285     self.Parameters().SetPeriodicTolerance( tol )
286
287   ## Set required_entities parameter
288   #  
289   #  The required entities control the correction operations. 
290   #  Accepted values for this parameter are :
291   #  - "respect" : MeshGems-CADSurf is not allowed to alter any required entity, 
292   #                even for correction purposes,
293   #  - "ignore" : MeshGems-CADSurf will ignore the required entities in its processing,
294   #  - "clear" : MeshGems-CADSurf will clear any required status for the entities. 
295   #              There will not be any entity marked as required in the generated mesh.
296   #  
297   def SetRequiredEntities( self, howToTreat ):
298     self.Parameters().SetRequiredEntities( howToTreat )
299
300   ## Set sewing_tolerance parameter
301   #  
302   #  This parameter is the tolerance of the assembly.
303   #  
304   def SetSewingTolerance( self, tol ):
305     self.Parameters().SetSewingTolerance( tol )
306
307   ## Set tags parameter
308   #  
309   #  The tag (attribute) system controls the optimisation process. 
310   #  Accepted values for this parameter are :
311   #  - "respect"  : the CAD tags will be preserved and unaltered by the optimisation operations,
312   #  - "ignore" : the CAD tags will be ignored by the optimisation operations 
313   #               but they will still be present in the output mesh,
314   #  - "clear" : MeshGems-CADSurf will clear any tag on any entity and optimise accordingly. 
315   #              There will not be any tag in the generated mesh.
316   #  
317   def SetTags( self, howToTreat ):
318     self.Parameters().SetTags( howToTreat )
319
320   ## Activate removal of the tiny edges from the generated
321   # mesh when it improves the local mesh quality, without taking into account the
322   # tags (attributes) specifications.
323   #  @param toOptimise "to optimize" flag value
324   #  @param length minimal length under which an edge is considered to be a tiny
325   def SetOptimiseTinyEdges(self, toOptimise, length=-1):
326     self.Parameters().SetOptimiseTinyEdges( toOptimise )
327     if toOptimise:
328       self.Parameters().SetTinyEdgeOptimisationLength( length )
329
330   ## Activate correction of all surface intersections
331   #  @param toCorrect "to correct" flag value
332   #  @param maxCost  the time the user is ready to spend in the intersection prevention process
333   #         For example, maxCost = 3 means that MeshGems-CADSurf will not spend more time
334   #         in the intersection removal process than 3 times the time required to mesh
335   #         without processing the intersections.
336   def SetCorrectSurfaceIntersection(self, toCorrect, maxCost ):
337     self.Parameters().SetCorrectSurfaceIntersection( toCorrect )
338     if toCorrect:
339       self.Parameters().SetCorrectSurfaceIntersectionMaxCost( maxCost )
340
341   ## To optimize merges edges.
342   #  @param toMergeEdges "merge edges" flag value
343   def SetPreCADMergeEdges(self, toMergeEdges=False):
344     self.Parameters().SetPreCADMergeEdges(toMergeEdges)
345     pass
346
347   ## To remove tiny UV edges.
348   #  @param toRemoveTinyUVEdges "remove_tiny_uv_edges" flag value
349   def SetPreCADRemoveTinyUVEdges(self, toRemoveTinyUVEdges=False):
350     self.Parameters().SetPreCADRemoveTinyUVEdges(toRemoveTinyUVEdges)
351     pass
352
353   ## To remove duplicate CAD Faces
354   #  @param toRemoveDuplicateCADFaces "remove_duplicate_cad_faces" flag value
355   def SetPreCADRemoveDuplicateCADFaces(self, toRemoveDuplicateCADFaces=False):
356     self.Parameters().SetPreCADRemoveDuplicateCADFaces(toRemoveDuplicateCADFaces)
357     pass
358
359   ## To process 3D topology.
360   #  @param toProcess "PreCAD process 3D" flag value
361   def SetPreCADProcess3DTopology(self, toProcess=False):
362     self.Parameters().SetPreCADProcess3DTopology(toProcess)
363     pass
364
365   ## To remove nano edges.
366   #  @param toRemoveNanoEdges "remove nano edges" flag value
367   def SetPreCADRemoveNanoEdges(self, toRemoveNanoEdges=False):
368     if toRemoveNanoEdges:
369       self.SetPreCADOptionValue("remove_tiny_edges","1")
370     else:
371       self.SetPreCADOptionValue("remove_tiny_edges","0")
372     pass
373
374   ## To compute topology from scratch
375   #  @param toDiscardInput "discard input" flag value
376   def SetPreCADDiscardInput(self, toDiscardInput=False):
377     self.Parameters().SetPreCADDiscardInput(toDiscardInput)
378     pass
379
380   ## Sets the length below which an edge is considered as nano
381   #  for the topology processing.
382   #  @param epsNano nano edge length threshold value
383   def SetPreCADEpsNano(self, epsNano):
384     self.SetPreCADOptionValue("tiny_edge_length","%f"%epsNano)
385     pass
386
387   ## Sets advanced option value.
388   #  @param optionName advanced option name
389   #  @param level advanced option value
390   def SetOptionValue(self, optionName, level):
391     self.Parameters().SetOptionValue(optionName,level)
392     pass
393
394   ## Sets advanced PreCAD option value.
395   #  @param optionName name of the option
396   #  @param optionValue value of the option
397   def SetPreCADOptionValue(self, optionName, optionValue):
398     self.Parameters().SetPreCADOptionValue(optionName,optionValue)
399     pass
400   
401   ## Adds custom advanced option values
402   #  @param optionsAndValues options and values in a form "option_1 v1 option_2 v2'"
403   def SetAdvancedOption(self, optionsAndValues):
404     self.Parameters().SetAdvancedOption(optionsAndValues)
405     pass
406
407   ## Adds custom advanced option value.
408   #  @param optionName custom advanced option name
409   #  @param level custom advanced option value
410   def AddOption(self, optionName, level):
411     self.Parameters().AddOption(optionName,level)
412     pass
413
414   ## Adds custom advanced PreCAD option value.
415   #  @param optionName custom name of the option
416   #  @param optionValue value of the option
417   def AddPreCADOption(self, optionName, optionValue):
418     self.Parameters().AddPreCADOption(optionName,optionValue)
419     pass
420
421   ## Sets GMF file for export at computation
422   #  @param fileName GMF file name
423   def SetGMFFile(self, fileName):
424     self.Parameters().SetGMFFile(fileName)
425     pass
426
427   #-----------------------------------------
428   # Enforced vertices (BLSURF)
429   #-----------------------------------------
430
431   ## To get all the enforced vertices
432   def GetAllEnforcedVertices(self):
433     return self.Parameters().GetAllEnforcedVertices()
434
435   ## To get all the enforced vertices sorted by face (or group, compound)
436   def GetAllEnforcedVerticesByFace(self):
437     return self.Parameters().GetAllEnforcedVerticesByFace()
438
439   ## To get all the enforced vertices sorted by coords of input vertices
440   def GetAllEnforcedVerticesByCoords(self):
441     return self.Parameters().GetAllEnforcedVerticesByCoords()
442
443   ## To get all the coords of input vertices sorted by face (or group, compound)
444   def GetAllCoordsByFace(self):
445     return self.Parameters().GetAllCoordsByFace()
446
447   ## To get all the enforced vertices on a face (or group, compound)
448   #  @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
449   def GetEnforcedVertices(self, theFace):
450     from salome.smesh.smeshBuilder import AssureGeomPublished
451     AssureGeomPublished( self.mesh, theFace )
452     return self.Parameters().GetEnforcedVertices(theFace)
453
454   ## To clear all the enforced vertices
455   def ClearAllEnforcedVertices(self):
456     return self.Parameters().ClearAllEnforcedVertices()
457
458   ## 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.
459   #  @param theFace      : GEOM face (or group, compound) on which to define an enforced vertex
460   #  @param x            : x coordinate
461   #  @param y            : y coordinate
462   #  @param z            : z coordinate
463   #  @param vertexName   : name of the enforced vertex
464   #  @param groupName    : name of the group
465   def SetEnforcedVertex(self, theFace, x, y, z, vertexName = "", groupName = ""):
466     from salome.smesh.smeshBuilder import AssureGeomPublished
467     AssureGeomPublished( self.mesh, theFace )
468     if vertexName == "":
469       if groupName == "":
470         return self.Parameters().SetEnforcedVertex(theFace, x, y, z)
471       else:
472         return self.Parameters().SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
473       pass
474     else:
475       if groupName == "":
476         return self.Parameters().SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
477       else:
478         return self.Parameters().SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
479       pass
480     pass
481
482   ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
483   #  @param theFace      : GEOM face (or group, compound) on which to define an enforced vertex
484   #  @param theVertex    : GEOM vertex (or group, compound) to be projected on theFace.
485   #  @param groupName    : name of the group
486   def SetEnforcedVertexGeom(self, theFace, theVertex, groupName = ""):
487     from salome.smesh.smeshBuilder import AssureGeomPublished
488     AssureGeomPublished( self.mesh, theFace )
489     AssureGeomPublished( self.mesh, theVertex )
490     if groupName == "":
491       return self.Parameters().SetEnforcedVertexGeom(theFace, theVertex)
492     else:
493       return self.Parameters().SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
494     pass
495
496   ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
497   #  @param theFace      : GEOM face (or group, compound) on which to remove the enforced vertex
498   #  @param x            : x coordinate
499   #  @param y            : y coordinate
500   #  @param z            : z coordinate
501   def UnsetEnforcedVertex(self, theFace, x, y, z):
502     from salome.smesh.smeshBuilder import AssureGeomPublished
503     AssureGeomPublished( self.mesh, theFace )
504     return self.Parameters().UnsetEnforcedVertex(theFace, x, y, z)
505
506   ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
507   #  @param theFace      : GEOM face (or group, compound) on which to remove the enforced vertex
508   #  @param theVertex    : GEOM vertex (or group, compound) to remove.
509   def UnsetEnforcedVertexGeom(self, theFace, theVertex):
510     from salome.smesh.smeshBuilder import AssureGeomPublished
511     AssureGeomPublished( self.mesh, theFace )
512     AssureGeomPublished( self.mesh, theVertex )
513     return self.Parameters().UnsetEnforcedVertexGeom(theFace, theVertex)
514
515   ## To remove all enforced vertices on a given face.
516   #  @param theFace      : face (or group/compound of faces) on which to remove all enforced vertices
517   def UnsetEnforcedVertices(self, theFace):
518     from salome.smesh.smeshBuilder import AssureGeomPublished
519     AssureGeomPublished( self.mesh, theFace )
520     return self.Parameters().UnsetEnforcedVertices(theFace)
521
522   ## To tell BLSURF to add a node on internal vertices
523   #  @param toEnforceInternalVertices : boolean; if True the internal vertices are added as enforced vertices
524   def SetInternalEnforcedVertexAllFaces(self, toEnforceInternalVertices):
525     return self.Parameters().SetInternalEnforcedVertexAllFaces(toEnforceInternalVertices)
526
527   ## To know if BLSURF will add a node on internal vertices
528   def GetInternalEnforcedVertexAllFaces(self):
529     return self.Parameters().GetInternalEnforcedVertexAllFaces()
530
531   ## To define a group for the nodes of internal vertices
532   #  @param groupName : string; name of the group
533   def SetInternalEnforcedVertexAllFacesGroup(self, groupName):
534     return self.Parameters().SetInternalEnforcedVertexAllFacesGroup(groupName)
535
536   ## To get the group name of the nodes of internal vertices
537   def GetInternalEnforcedVertexAllFacesGroup(self):
538     return self.Parameters().GetInternalEnforcedVertexAllFacesGroup()
539
540   #-----------------------------------------
541   #  Attractors
542   #-----------------------------------------
543
544   ## 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 ]
545   #  @param theFace      : face on which the attractor will be defined
546   #  @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
547   #  @param theStartSize : mesh size on theAttractor
548   #  @param theEndSize   : maximum size that will be reached on theFace
549   #  @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
550   #  @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
551   def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
552     from salome.smesh.smeshBuilder import AssureGeomPublished
553     AssureGeomPublished( self.mesh, theFace )
554     AssureGeomPublished( self.mesh, theAttractor )
555     self.Parameters().SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
556     pass
557
558   ## Unsets an attractor on the chosen face.
559   #  @param theFace      : face on which the attractor has to be removed
560   def UnsetAttractorGeom(self, theFace):
561     from salome.smesh.smeshBuilder import AssureGeomPublished
562     AssureGeomPublished( self.mesh, theFace )
563     self.Parameters().SetAttractorGeom(theFace)
564     pass
565
566   #-----------------------------------------
567   # Size maps (BLSURF)
568   #-----------------------------------------
569
570   ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
571   #  If theObject is a face, the function can be: def f(u,v): return u+v
572   #  If theObject is an edge, the function can be: def f(t): return t/2
573   #  If theObject is a vertex, the function can be: def f(): return 10
574   #  @param theObject   : GEOM face, edge or vertex (or group, compound) on which to define a size map
575   #  @param theSizeMap  : Size map defined as a string
576   def SetSizeMap(self, theObject, theSizeMap):
577     from salome.smesh.smeshBuilder import AssureGeomPublished
578     AssureGeomPublished( self.mesh, theObject )
579     self.Parameters().SetSizeMap(theObject, theSizeMap)
580     pass
581
582   ## To set a constant size map on a face, edge or vertex (or group, compound).
583   #  @param theObject   : GEOM face, edge or vertex (or group, compound) on which to define a size map
584   #  @param theSizeMap  : Size map defined as a double
585   def SetConstantSizeMap(self, theObject, theSizeMap):
586     from salome.smesh.smeshBuilder import AssureGeomPublished
587     AssureGeomPublished( self.mesh, theObject )
588     self.Parameters().SetConstantSizeMap(theObject, theSizeMap)
589
590   ## To remove a size map defined on a face, edge or vertex (or group, compound)
591   #  @param theObject   : GEOM face, edge or vertex (or group, compound) on which to define a size map
592   def UnsetSizeMap(self, theObject):
593     from salome.smesh.smeshBuilder import AssureGeomPublished
594     AssureGeomPublished( self.mesh, theObject )
595     self.Parameters().UnsetSizeMap(theObject)
596     pass
597
598   ## To remove all the size maps
599   def ClearSizeMaps(self):
600     self.Parameters().ClearSizeMaps()
601     pass
602
603   ## Sets QuadAllowed flag.
604   #  @param toAllow "allow quadrangles" flag value
605   def SetQuadAllowed(self, toAllow=True):
606     self.Parameters().SetQuadAllowed(toAllow)
607     pass
608
609   ## Defines hypothesis having several parameters
610   #  @return hypothesis object
611   def Parameters(self):
612     if not self.params:
613       self.params = self.Hypothesis("MG-CADSurf Parameters", [],
614                                     LIBRARY, UseExisting=0)
615       pass
616     return self.params
617
618   #-----------------------------------------
619   # Periodicity (BLSURF with PreCAD)
620   #-----------------------------------------
621   
622   ## Defines periodicity between two groups of faces, using PreCAD
623   #  @param theFace1 : GEOM face (or group, compound) to associate with theFace2
624   #  @param theFace2 : GEOM face (or group, compound) associated with theFace1
625   #  @param theSourceVertices (optionnal): list of GEOM vertices on theFace1 defining the transformation from theFace1 to theFace2.
626   #    If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
627   #  @param theTargetVertices (optionnal): list of GEOM vertices on theFace2 defining the transformation from theFace1 to theFace2.
628   #    If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
629   def AddPreCadFacesPeriodicity(self, theFace1, theFace2, theSourceVertices=[], theTargetVertices=[]):
630     """calls preCad function:
631     status_t cad_add_face_multiple_periodicity_with_transformation_function(cad t *cad,
632           integer *fid1, integer size1, integer *fid2, integer size2,
633           periodicity_transformation_t transf, void *user data);
634     """
635     if theSourceVertices and theTargetVertices:
636       self.Parameters().AddPreCadFacesPeriodicityWithVertices(theFace1, theFace2, theSourceVertices, theTargetVertices)
637     else:
638       self.Parameters().AddPreCadFacesPeriodicity(theFace1, theFace2)
639     pass
640
641   ## Defines periodicity between two groups of edges, using PreCAD
642   #  @param theEdge1 : GEOM edge (or group, compound) to associate with theEdge2
643   #  @param theEdge2 : GEOM edge (or group, compound) associated with theEdge1
644   #  @param theSourceVertices (optionnal): list of GEOM vertices on theEdge1 defining the transformation from theEdge1 to theEdge2.
645   #    If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
646   #  @param  theTargetVertices (optionnal): list of GEOM vertices on theEdge2 defining the transformation from theEdge1 to theEdge2.
647   #    If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
648   def AddPreCadEdgesPeriodicity(self, theEdge1, theEdge2, theSourceVertices=[], theTargetVertices=[]):
649     """calls preCad function:
650     status_t cad_add_edge_multiple_periodicity_with_transformation_function(cad t *cad,
651           integer *eid1, integer size1, integer *eid2, integer size2,
652           periodicity_transformation_t transf, void *user data);
653     """
654     if theSourceVertices and theTargetVertices:
655         self.Parameters().AddPreCadEdgesPeriodicityWithVertices(theEdge1, theEdge2, theSourceVertices, theTargetVertices)
656     else:
657         self.Parameters().AddPreCadEdgesPeriodicity(theEdge1, theEdge2)
658     pass
659
660   #=====================
661   # Obsolete methods
662   #=====================
663   #
664   # SALOME 6.6.0
665   #
666
667   ## Sets lower boundary of mesh element size (PhySize).
668   def SetPhyMin(self, theVal=-1):
669     """
670     Obsolete function. Use SetMinSize.
671     """
672     print "Warning: SetPhyMin is obsolete. Please use SetMinSize"
673     self.SetMinSize(theVal)
674     pass
675
676   ## Sets upper boundary of mesh element size (PhySize).
677   def SetPhyMax(self, theVal=-1):
678     """
679     Obsolete function. Use SetMaxSize.
680     """
681     print "Warning: SetPhyMax is obsolete. Please use SetMaxSize"
682     self.SetMaxSize(theVal)
683     pass
684
685   ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
686   def SetAngleMeshS(self, theVal=_geometric_approximation):
687     """
688     Obsolete function. Use SetAngleMesh.
689     """
690     print "Warning: SetAngleMeshS is obsolete. Please use SetAngleMesh"
691     self.SetAngleMesh(theVal)
692     pass
693
694   ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
695   def SetAngleMeshC(self, theVal=_geometric_approximation):
696     """
697     Obsolete function. Use SetAngleMesh.
698     """
699     print "Warning: SetAngleMeshC is obsolete. Please use SetAngleMesh"
700     self.SetAngleMesh(theVal)
701     pass
702
703   ## Sets lower boundary of mesh element size computed to respect angular deflection.
704   def SetGeoMin(self, theVal=-1):
705     """
706     Obsolete function. Use SetMinSize.
707     """
708     print "Warning: SetGeoMin is obsolete. Please use SetMinSize"
709     self.SetMinSize(theVal)
710     pass
711
712   ## Sets upper boundary of mesh element size computed to respect angular deflection.
713   def SetGeoMax(self, theVal=-1):
714     """
715     Obsolete function. Use SetMaxSize.
716     """
717     print "Warning: SetGeoMax is obsolete. Please use SetMaxSize"
718     self.SetMaxSize(theVal)
719     pass
720
721
722   pass # end of BLSURF_Algorithm class