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