1 # Copyright (C) 2007-2016 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # @package BLSURFPluginBuilder
22 # Python API for the MG-CADSurf meshing plug-in module.
24 from salome.smesh.smesh_algorithm import Mesh_Algorithm
27 LIBRARY = "libBLSURFEngine.so"
29 # Topology treatment way of MG-CADSurf
30 FromCAD, PreProcess, PreProcessPlus, PreCAD = 0,1,2,3
32 # Element size flag of MG-CADSurf
33 DefaultSize, DefaultGeom, MG_CADSURF_GlobalSize, MG_CADSURF_LocalSize = 0,0,1,2
35 MG_CADSURF_Custom, SizeMap = MG_CADSURF_GlobalSize, MG_CADSURF_LocalSize
36 BLSURF_Custom, BLSURF_GlobalSize, BLSURF_LocalSize = MG_CADSURF_Custom, MG_CADSURF_GlobalSize, MG_CADSURF_LocalSize
38 # import BLSURFPlugin module if possible
46 #----------------------------
47 # Mesh algo type identifiers
48 #----------------------------
50 ## Algorithm type: MG-CADSurf triangle algorithm, see BLSURF_Algorithm
51 MG_CADSurf = "MG-CADSurf"
54 #----------------------
56 #----------------------
58 ## MG-CADSurf 2D algorithm.
60 # It can be created by calling smeshBuilder.Mesh.Triangle(smeshBuilder.MG-CADSurf,geom=0)
62 class BLSURF_Algorithm(Mesh_Algorithm):
64 ## name of the dynamic method in smeshBuilder.Mesh class
66 meshMethod = "Triangle"
67 ## type of algorithm used with helper function in smeshBuilder.Mesh class
70 ## doc string of the method
72 docHelper = "Creates triangle algorithm for faces"
74 _anisotropic_ratio = 0
75 _bad_surface_element_aspect_ratio = 1000
76 _geometric_approximation = 22
80 _remove_tiny_edges = 0
82 ## Private constructor.
83 # @param mesh parent mesh object algorithm is assigned to
84 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
85 # if it is @c 0 (default), the algorithm is assigned to the main shape
86 def __init__(self, mesh, geom=0):
87 Mesh_Algorithm.__init__(self)
89 print "Warning: BLSURFPlugin module unavailable"
90 if mesh.GetMesh().HasShapeToMesh():
91 self.Create(mesh, geom, self.algoType, LIBRARY)
93 self.Create(mesh, geom, self.algoType+"_NOGEOM", LIBRARY)
94 mesh.smeshpyD.SetName( self.algo, self.algoType )
96 self.geompyD = mesh.geompyD
97 #self.SetPhysicalMesh() - PAL19680
100 ## Sets a way to define size of mesh elements to generate.
101 # @param thePhysicalMesh is: DefaultSize, MG_CADSURF_Custom or SizeMap.
102 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
103 physical_size_mode = thePhysicalMesh
104 if self.Parameters().GetGeometricMesh() == DefaultGeom:
105 if physical_size_mode == DefaultSize:
106 physical_size_mode = MG_CADSURF_GlobalSize
107 self.Parameters().SetPhysicalMesh(physical_size_mode)
110 ## Sets a way to define maximum angular deflection of mesh from CAD model.
111 # @param theGeometricMesh is: DefaultGeom (0)) or MG_CADSURF_GlobalSize (1))
112 def SetGeometricMesh(self, theGeometricMesh=DefaultGeom):
113 geometric_size_mode = theGeometricMesh
114 if self.Parameters().GetPhysicalMesh() == DefaultSize:
115 if geometric_size_mode == DefaultGeom:
116 geometric_size_mode = MG_CADSURF_GlobalSize
117 self.Parameters().SetGeometricMesh(geometric_size_mode)
120 ## Sets size of mesh elements to generate.
121 # @param theVal : constant global size when using a global physical size.
122 # @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
123 def SetPhySize(self, theVal, isRelative = False):
124 if self.Parameters().GetPhysicalMesh() == DefaultSize:
125 self.SetPhysicalMesh(MG_CADSURF_GlobalSize)
127 self.Parameters().SetPhySizeRel(theVal)
129 self.Parameters().SetPhySize(theVal)
132 ## Sets lower boundary of mesh element size.
133 # @param theVal : global minimal cell size desired.
134 # @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
135 def SetMinSize(self, theVal=-1, isRelative = False):
137 self.Parameters().SetMinSizeRel(theVal)
139 self.Parameters().SetMinSize(theVal)
142 ## Sets upper boundary of mesh element size.
143 # @param theVal : global maximal cell size desired.
144 # @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
145 def SetMaxSize(self, theVal=-1, isRelative = False):
147 self.Parameters().SetMaxSizeRel(theVal)
149 self.Parameters().SetMaxSize(theVal)
152 ## Sets angular deflection (in degrees) from CAD surface.
153 # @param theVal value of angular deflection
154 def SetAngleMesh(self, theVal=_geometric_approximation):
155 if self.Parameters().GetGeometricMesh() == DefaultGeom:
156 self.SetGeometricMesh(MG_CADSURF_GlobalSize)
157 self.Parameters().SetAngleMesh(theVal)
160 ## Sets the maximum desired distance between a triangle and its supporting CAD surface
161 # @param distance the distance between a triangle and a surface
162 def SetChordalError(self, distance):
163 self.Parameters().SetChordalError(distance)
166 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
167 # @param toUseGradation to use gradation
168 # @param theVal value of maximal length ratio
169 def SetGradation(self, toUseGradation=True, theVal=_gradation):
170 if isinstance( toUseGradation, float ): ## backward compatibility
171 toUseGradation, theVal = True, toUseGradation
172 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
173 self.Parameters().SetUseGradation(toUseGradation)
174 self.Parameters().SetGradation(theVal)
177 ## Sets maximal allowed ratio between the lengths of two adjacent edges in 3D mesh.
178 # @param toUseGradation to use gradation
179 # @param theVal value of maximal length ratio
180 def SetVolumeGradation(self, toUseGradation=True, theVal=_gradation):
181 if self.Parameters().GetGeometricMesh() == 0: theVal = self._volume_gradation
182 self.Parameters().SetUseVolumeGradation(toUseGradation)
183 self.Parameters().SetVolumeGradation(theVal)
186 ## Sets topology usage way.
187 # @param way defines how mesh conformity is assured <ul>
188 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
189 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model (OBSOLETE: FromCAD will be used)</li>
190 # <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
191 def SetTopology(self, way):
192 if way != PreCAD and way != FromCAD:
193 print "Warning: topology mode %d is no longer supported. Mode FromCAD is used."%way
195 self.Parameters().SetTopology(way)
198 ## To respect geometrical edges or not.
199 # @param toIgnoreEdges "ignore edges" flag value
200 def SetDecimesh(self, toIgnoreEdges=False):
202 self.SetOptionValue("respect_geometry","0")
204 self.SetOptionValue("respect_geometry","1")
207 ## Sets verbosity level in the range 0 to 100.
208 # @param level verbosity level
209 def SetVerbosity(self, level):
210 self.Parameters().SetVerbosity(level)
213 ## Set enforce_cad_edge_sizes parameter
215 # Relaxes the given sizemap constraint around CAD edges to allow a better
216 # element quality and a better geometric approximation. It is only useful in
217 # combination with the gradation option.
219 def SetEnforceCadEdgesSize( self, toEnforce ):
220 self.Parameters().SetEnforceCadEdgesSize( toEnforce )
222 ## Set jacobian_rectification_respect_geometry parameter
224 # While making the mesh quadratic, allows to lose the CAD-mesh associativity in order
225 # to correct elements with nagative Jacobian
227 def SetJacobianRectificationRespectGeometry( self, allowRectification ):
228 self.Parameters().SetJacobianRectificationRespectGeometry( allowRectification )
230 ## Set rectify_jacobian parameter
232 # While making the mesh quadratic, allow to fix nagative Jacobian surface elements
234 def SetJacobianRectification( self, allowRectification ):
235 self.Parameters().SetJacobianRectification( allowRectification )
237 ## Set respect_geometry parameter
239 # This patch independent option can be deactivated to allow MeshGems-CADSurf
240 # to lower the geometry accuracy in its patch independent process.
242 def SetRespectGeometry( self, toRespect ):
243 self.Parameters().SetRespectGeometry( toRespect )
245 ## Set max_number_of_points_per_patch parameter
247 # This parameter controls the maximum amount of points MeshGems-CADSurf is allowed
248 # to generate on a single CAD patch. For an automatic gestion of the memory, one
249 # can set this parameter to 0
251 def SetMaxNumberOfPointsPerPatch( self, nb ):
252 self.Parameters().SetMaxNumberOfPointsPerPatch( nb )
254 ## Set respect_geometry parameter
256 # This patch independent option can be deactivated to allow MeshGems-CADSurf
257 # to lower the geometry accuracy in its patch independent process.
259 def SetRespectGeometry( self, toRespect ):
260 self.Parameters().SetRespectGeometry( toRespect )
262 ## Set tiny_edges_avoid_surface_intersections parameter
264 # This option defines the priority between the tiny feature
265 # suppression and the surface intersection prevention.
267 def SetTinyEdgesAvoidSurfaceIntersections( self, toAvoidIntersection ):
268 self.Parameters().SetTinyEdgesAvoidSurfaceIntersections( toAvoidIntersection )
270 ## Set closed_geometry parameter parameter
272 # Describes whether the geometry is expected to be closed or not.
273 # When activated, this option helps MeshGems-PreCAD to treat the dirtiest geometries.
275 def SetClosedGeometry( self, isClosed ):
276 self.Parameters().SetClosedGeometry( isClosed )
278 ## Set debug parameter
280 # Make MeshGems-CADSurf will be very verbose and will output some intermediate
281 # files in the working directory. This option is mainly meant for Distene support issues.
283 def SetDebug( self, isDebug ):
284 self.Parameters().SetDebug( isDebug )
286 ## Set periodic_tolerance parameter
288 # This parameter defines the maximum size difference between two periodic edges
289 # and also the maximum distance error between two periodic entities.
291 def SetPeriodicTolerance( self, tol ):
292 self.Parameters().SetPeriodicTolerance( tol )
294 ## Set required_entities parameter
296 # The required entities control the correction operations.
297 # Accepted values for this parameter are :
298 # - "respect" : MeshGems-CADSurf is not allowed to alter any required entity,
299 # even for correction purposes,
300 # - "ignore" : MeshGems-CADSurf will ignore the required entities in its processing,
301 # - "clear" : MeshGems-CADSurf will clear any required status for the entities.
302 # There will not be any entity marked as required in the generated mesh.
304 def SetRequiredEntities( self, howToTreat ):
305 self.Parameters().SetRequiredEntities( howToTreat )
307 ## Set sewing_tolerance parameter
309 # This parameter is the tolerance of the assembly.
311 def SetSewingTolerance( self, tol ):
312 self.Parameters().SetSewingTolerance( tol )
314 ## Set tags parameter
316 # The tag (attribute) system controls the optimisation process.
317 # Accepted values for this parameter are :
318 # - "respect" : the CAD tags will be preserved and unaltered by the optimisation operations,
319 # - "ignore" : the CAD tags will be ignored by the optimisation operations
320 # but they will still be present in the output mesh,
321 # - "clear" : MeshGems-CADSurf will clear any tag on any entity and optimise accordingly.
322 # There will not be any tag in the generated mesh.
324 def SetTags( self, howToTreat ):
325 self.Parameters().SetTags( howToTreat )
327 ## Activate removal of the tiny edges from the generated
328 # mesh when it improves the local mesh quality, without taking into account the
329 # tags (attributes) specifications.
330 # @param toOptimise "to optimize" flag value
331 # @param length minimal length under which an edge is considered to be a tiny
332 def SetOptimiseTinyEdges(self, toOptimise, length=-1):
333 self.Parameters().SetOptimiseTinyEdges( toOptimise )
335 self.Parameters().SetTinyEdgeOptimisationLength( length )
337 ## Activate correction of all surface intersections
338 # @param toCorrect "to correct" flag value
339 # @param maxCost the time the user is ready to spend in the intersection prevention process
340 # For example, maxCost = 3 means that MeshGems-CADSurf will not spend more time
341 # in the intersection removal process than 3 times the time required to mesh
342 # without processing the intersections.
343 def SetCorrectSurfaceIntersection(self, toCorrect, maxCost ):
344 self.Parameters().SetCorrectSurfaceIntersection( toCorrect )
346 self.Parameters().SetCorrectSurfaceIntersectionMaxCost( maxCost )
348 ## To optimize merges edges.
349 # @param toMergeEdges "merge edges" flag value
350 def SetPreCADMergeEdges(self, toMergeEdges=False):
351 self.Parameters().SetPreCADMergeEdges(toMergeEdges)
354 ## To remove duplicate CAD Faces
355 # @param toRemoveDuplicateCADFaces "remove_duplicate_cad_faces" flag value
356 def SetPreCADRemoveDuplicateCADFaces(self, toRemoveDuplicateCADFaces=False):
357 self.Parameters().SetPreCADRemoveDuplicateCADFaces(toRemoveDuplicateCADFaces)
360 ## To process 3D topology.
361 # @param toProcess "PreCAD process 3D" flag value
362 def SetPreCADProcess3DTopology(self, toProcess=False):
363 self.Parameters().SetPreCADProcess3DTopology(toProcess)
366 ## To remove nano edges.
367 # @param toRemoveNanoEdges "remove nano edges" flag value
368 def SetPreCADRemoveNanoEdges(self, toRemoveNanoEdges=False):
369 if toRemoveNanoEdges:
370 self.SetPreCADOptionValue("remove_tiny_edges","1")
372 self.SetPreCADOptionValue("remove_tiny_edges","0")
375 ## To compute topology from scratch
376 # @param toDiscardInput "discard input" flag value
377 def SetPreCADDiscardInput(self, toDiscardInput=False):
378 self.Parameters().SetPreCADDiscardInput(toDiscardInput)
381 ## Sets the length below which an edge is considered as nano
382 # for the topology processing.
383 # @param epsNano nano edge length threshold value
384 def SetPreCADEpsNano(self, epsNano):
385 self.SetPreCADOptionValue("tiny_edge_length","%f"%epsNano)
388 ## Sets advanced option value.
389 # @param optionName advanced option name
390 # @param level advanced option value
391 def SetOptionValue(self, optionName, level):
392 self.Parameters().SetOptionValue(optionName,level)
395 ## Sets advanced PreCAD option value.
396 # @param optionName name of the option
397 # @param optionValue value of the option
398 def SetPreCADOptionValue(self, optionName, optionValue):
399 self.Parameters().SetPreCADOptionValue(optionName,optionValue)
402 ## Adds custom advanced option values
403 # @param optionsAndValues options and values in a form "option_1 v1 option_2 v2'"
404 def SetAdvancedOption(self, optionsAndValues):
405 self.Parameters().SetAdvancedOption(optionsAndValues)
408 ## Adds custom advanced option value.
409 # @param optionName custom advanced option name
410 # @param level custom advanced option value
411 def AddOption(self, optionName, level):
412 self.Parameters().AddOption(optionName,level)
415 ## Adds custom advanced PreCAD option value.
416 # @param optionName custom name of the option
417 # @param optionValue value of the option
418 def AddPreCADOption(self, optionName, optionValue):
419 self.Parameters().AddPreCADOption(optionName,optionValue)
422 ## Sets GMF file for export at computation
423 # @param fileName GMF file name
424 def SetGMFFile(self, fileName):
425 self.Parameters().SetGMFFile(fileName)
428 #-----------------------------------------
429 # Enforced vertices (BLSURF)
430 #-----------------------------------------
432 ## To get all the enforced vertices
433 def GetAllEnforcedVertices(self):
434 return self.Parameters().GetAllEnforcedVertices()
436 ## To get all the enforced vertices sorted by face (or group, compound)
437 def GetAllEnforcedVerticesByFace(self):
438 return self.Parameters().GetAllEnforcedVerticesByFace()
440 ## To get all the enforced vertices sorted by coords of input vertices
441 def GetAllEnforcedVerticesByCoords(self):
442 return self.Parameters().GetAllEnforcedVerticesByCoords()
444 ## To get all the coords of input vertices sorted by face (or group, compound)
445 def GetAllCoordsByFace(self):
446 return self.Parameters().GetAllCoordsByFace()
448 ## To get all the enforced vertices on a face (or group, compound)
449 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
450 def GetEnforcedVertices(self, theFace):
451 from salome.smesh.smeshBuilder import AssureGeomPublished
452 AssureGeomPublished( self.mesh, theFace )
453 return self.Parameters().GetEnforcedVertices(theFace)
455 ## To clear all the enforced vertices
456 def ClearAllEnforcedVertices(self):
457 return self.Parameters().ClearAllEnforcedVertices()
459 ## 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.
460 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
461 # @param x : x coordinate
462 # @param y : y coordinate
463 # @param z : z coordinate
464 # @param vertexName : name of the enforced vertex
465 # @param groupName : name of the group
466 def SetEnforcedVertex(self, theFace, x, y, z, vertexName = "", groupName = ""):
467 from salome.smesh.smeshBuilder import AssureGeomPublished
468 AssureGeomPublished( self.mesh, theFace )
471 return self.Parameters().SetEnforcedVertex(theFace, x, y, z)
473 return self.Parameters().SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
477 return self.Parameters().SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
479 return self.Parameters().SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
483 ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
484 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
485 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
486 # @param groupName : name of the group
487 def SetEnforcedVertexGeom(self, theFace, theVertex, groupName = ""):
488 from salome.smesh.smeshBuilder import AssureGeomPublished
489 AssureGeomPublished( self.mesh, theFace )
490 AssureGeomPublished( self.mesh, theVertex )
492 return self.Parameters().SetEnforcedVertexGeom(theFace, theVertex)
494 return self.Parameters().SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
497 ## Set an enforced vertex on a face given the coordinates of a point.
498 # The face if found by the application.
499 # @param x : x coordinate
500 # @param y : y coordinate
501 # @param z : z coordinate
502 # @param vertexName : name of the enforced vertex
503 # @param groupName : name of the group
504 def AddEnforcedVertex(self, x, y, z, vertexName = "", groupName = ""):
505 from salome.smesh.smeshBuilder import AssureGeomPublished
508 return self.Parameters().AddEnforcedVertex(x, y, z)
510 return self.Parameters().AddEnforcedVertexWithGroup(x, y, z, groupName)
514 return self.Parameters().AddEnforcedVertexNamed(x, y, z, vertexName)
516 return self.Parameters().AddEnforcedVertexNamedWithGroup( x, y, z, vertexName, groupName)
520 ## To set an enforced vertex on a face given a GEOM vertex, group or compound.
521 # The face if found by the application.
522 # @param theVertex : GEOM vertex (or group, compound).
523 # @param groupName : name of the group
524 def AddEnforcedVertexGeom(self, theVertex, groupName = ""):
525 from salome.smesh.smeshBuilder import AssureGeomPublished
526 AssureGeomPublished( self.mesh, theVertex )
528 return self.Parameters().AddEnforcedVertexGeom(theVertex)
530 return self.Parameters().AddEnforcedVertexGeomWithGroup(theVertex,groupName)
533 ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
534 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
535 # @param x : x coordinate
536 # @param y : y coordinate
537 # @param z : z coordinate
538 def UnsetEnforcedVertex(self, theFace, x, y, z):
539 from salome.smesh.smeshBuilder import AssureGeomPublished
540 AssureGeomPublished( self.mesh, theFace )
541 return self.Parameters().UnsetEnforcedVertex(theFace, x, y, z)
543 ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
544 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
545 # @param theVertex : GEOM vertex (or group, compound) to remove.
546 def UnsetEnforcedVertexGeom(self, theFace, theVertex):
547 from salome.smesh.smeshBuilder import AssureGeomPublished
548 AssureGeomPublished( self.mesh, theFace )
549 AssureGeomPublished( self.mesh, theVertex )
550 return self.Parameters().UnsetEnforcedVertexGeom(theFace, theVertex)
552 ## To remove all enforced vertices on a given face.
553 # @param theFace : face (or group/compound of faces) on which to remove all enforced vertices
554 def UnsetEnforcedVertices(self, theFace):
555 from salome.smesh.smeshBuilder import AssureGeomPublished
556 AssureGeomPublished( self.mesh, theFace )
557 return self.Parameters().UnsetEnforcedVertices(theFace)
559 ## To tell BLSURF to add a node on internal vertices
560 # @param toEnforceInternalVertices : boolean; if True the internal vertices are added as enforced vertices
561 def SetInternalEnforcedVertexAllFaces(self, toEnforceInternalVertices):
562 return self.Parameters().SetInternalEnforcedVertexAllFaces(toEnforceInternalVertices)
564 ## To know if BLSURF will add a node on internal vertices
565 def GetInternalEnforcedVertexAllFaces(self):
566 return self.Parameters().GetInternalEnforcedVertexAllFaces()
568 ## To define a group for the nodes of internal vertices
569 # @param groupName : string; name of the group
570 def SetInternalEnforcedVertexAllFacesGroup(self, groupName):
571 return self.Parameters().SetInternalEnforcedVertexAllFacesGroup(groupName)
573 ## To get the group name of the nodes of internal vertices
574 def GetInternalEnforcedVertexAllFacesGroup(self):
575 return self.Parameters().GetInternalEnforcedVertexAllFacesGroup()
577 #-----------------------------------------
579 #-----------------------------------------
581 ## 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 ]
582 # @param theFace : face on which the attractor will be defined
583 # @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
584 # @param theStartSize : mesh size on theAttractor
585 # @param theEndSize : maximum size that will be reached on theFace
586 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
587 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
588 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
589 from salome.smesh.smeshBuilder import AssureGeomPublished
590 AssureGeomPublished( self.mesh, theFace )
591 AssureGeomPublished( self.mesh, theAttractor )
592 self.Parameters().SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
595 ## Unsets an attractor on the chosen face.
596 # @param theFace : face on which the attractor has to be removed
597 def UnsetAttractorGeom(self, theFace):
598 from salome.smesh.smeshBuilder import AssureGeomPublished
599 AssureGeomPublished( self.mesh, theFace )
600 self.Parameters().SetAttractorGeom(theFace)
603 #-----------------------------------------
605 #-----------------------------------------
607 ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
608 # If theObject is a face, the function can be: def f(u,v): return u+v
609 # If theObject is an edge, the function can be: def f(t): return t/2
610 # If theObject is a vertex, the function can be: def f(): return 10
611 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
612 # @param theSizeMap : Size map defined as a string
613 def SetSizeMap(self, theObject, theSizeMap):
614 from salome.smesh.smeshBuilder import AssureGeomPublished
615 AssureGeomPublished( self.mesh, theObject )
616 self.Parameters().SetSizeMap(theObject, theSizeMap)
619 ## To set a constant size map on a face, edge or vertex (or group, compound).
620 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
621 # @param theSizeMap : Size map defined as a double
622 def SetConstantSizeMap(self, theObject, theSizeMap):
623 from salome.smesh.smeshBuilder import AssureGeomPublished
624 AssureGeomPublished( self.mesh, theObject )
625 self.Parameters().SetConstantSizeMap(theObject, theSizeMap)
627 ## To remove a size map defined on a face, edge or vertex (or group, compound)
628 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
629 def UnsetSizeMap(self, theObject):
630 from salome.smesh.smeshBuilder import AssureGeomPublished
631 AssureGeomPublished( self.mesh, theObject )
632 self.Parameters().UnsetSizeMap(theObject)
635 ## To remove all the size maps
636 def ClearSizeMaps(self):
637 self.Parameters().ClearSizeMaps()
640 ## Sets QuadAllowed flag.
641 # @param toAllow "allow quadrangles" flag value
642 def SetQuadAllowed(self, toAllow=True):
643 self.Parameters().SetQuadAllowed(toAllow)
646 ## Defines hypothesis having several parameters
647 # @return hypothesis object
648 def Parameters(self):
650 hypType = "MG-CADSurf Parameters"
651 hasGeom = self.mesh.GetMesh().HasShapeToMesh()
653 self.params = self.Hypothesis(hypType, [], LIBRARY, UseExisting=0)
655 self.params = self.Hypothesis(hypType + "_NOGEOM", [], LIBRARY, UseExisting=0)
656 self.mesh.smeshpyD.SetName( self.params, hypType )
660 #-----------------------------------------
661 # Periodicity (BLSURF with PreCAD)
662 #-----------------------------------------
664 ## Defines periodicity between two groups of faces, using PreCAD
665 # @param theFace1 : GEOM face (or group, compound) to associate with theFace2
666 # @param theFace2 : GEOM face (or group, compound) associated with theFace1
667 # @param theSourceVertices (optionnal): list of GEOM vertices on theFace1 defining the transformation from theFace1 to theFace2.
668 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
669 # @param theTargetVertices (optionnal): list of GEOM vertices on theFace2 defining the transformation from theFace1 to theFace2.
670 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
671 def AddPreCadFacesPeriodicity(self, theFace1, theFace2, theSourceVertices=[], theTargetVertices=[]):
672 """calls preCad function:
673 status_t cad_add_face_multiple_periodicity_with_transformation_function(cad t *cad,
674 integer *fid1, integer size1, integer *fid2, integer size2,
675 periodicity_transformation_t transf, void *user data);
677 if theSourceVertices and theTargetVertices:
678 self.Parameters().AddPreCadFacesPeriodicityWithVertices(theFace1, theFace2, theSourceVertices, theTargetVertices)
680 self.Parameters().AddPreCadFacesPeriodicity(theFace1, theFace2)
683 ## Defines periodicity between two groups of edges, using PreCAD
684 # @param theEdge1 : GEOM edge (or group, compound) to associate with theEdge2
685 # @param theEdge2 : GEOM edge (or group, compound) associated with theEdge1
686 # @param theSourceVertices (optionnal): list of GEOM vertices on theEdge1 defining the transformation from theEdge1 to theEdge2.
687 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
688 # @param theTargetVertices (optionnal): list of GEOM vertices on theEdge2 defining the transformation from theEdge1 to theEdge2.
689 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
690 def AddPreCadEdgesPeriodicity(self, theEdge1, theEdge2, theSourceVertices=[], theTargetVertices=[]):
691 """calls preCad function:
692 status_t cad_add_edge_multiple_periodicity_with_transformation_function(cad t *cad,
693 integer *eid1, integer size1, integer *eid2, integer size2,
694 periodicity_transformation_t transf, void *user data);
696 if theSourceVertices and theTargetVertices:
697 self.Parameters().AddPreCadEdgesPeriodicityWithVertices(theEdge1, theEdge2, theSourceVertices, theTargetVertices)
699 self.Parameters().AddPreCadEdgesPeriodicity(theEdge1, theEdge2)
702 #-----------------------------------------
704 #-----------------------------------------
706 ## Defines hyper-patches. A hyper-patch is a set of adjacent faces meshed as a whole,
707 # ignoring edges between them
708 # @param hyperPatchList : list of hyper-patches. A hyper-patch is defined as a list of
709 # faces or groups of faces. A face can be identified either as a GEOM object or
710 # a face ID (returned e.g. by geompy.GetSubShapeID( mainShape, subShape )).
712 # Example: cadsurf.SetHyperPatches([[ Face_1, Group_2 ],[ 13, 23 ]])
713 def SetHyperPatches(self, hyperPatchList):
715 for patch in hyperPatchList:
718 if isinstance( face, int ):
720 elif isinstance( face, GEOM._objref_GEOM_Object):
721 faces = self.mesh.geompyD.SubShapeAll( face, self.mesh.geompyD.ShapeType["FACE"] )
723 ids.append( self.mesh.geompyD.GetSubShapeID( self.mesh.geom, f ))
726 "Face of hyper-patch should be either ID or GEOM_Object, not %s" % type(face)
730 self.Parameters().SetHyperPatches( hpl )
733 #=====================
735 #=====================
740 ## Sets lower boundary of mesh element size (PhySize).
741 def SetPhyMin(self, theVal=-1):
743 Obsolete function. Use SetMinSize.
745 print "Warning: SetPhyMin is obsolete. Please use SetMinSize"
746 self.SetMinSize(theVal)
749 ## Sets upper boundary of mesh element size (PhySize).
750 def SetPhyMax(self, theVal=-1):
752 Obsolete function. Use SetMaxSize.
754 print "Warning: SetPhyMax is obsolete. Please use SetMaxSize"
755 self.SetMaxSize(theVal)
758 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
759 def SetAngleMeshS(self, theVal=_geometric_approximation):
761 Obsolete function. Use SetAngleMesh.
763 print "Warning: SetAngleMeshS is obsolete. Please use SetAngleMesh"
764 self.SetAngleMesh(theVal)
767 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
768 def SetAngleMeshC(self, theVal=_geometric_approximation):
770 Obsolete function. Use SetAngleMesh.
772 print "Warning: SetAngleMeshC is obsolete. Please use SetAngleMesh"
773 self.SetAngleMesh(theVal)
776 ## Sets lower boundary of mesh element size computed to respect angular deflection.
777 def SetGeoMin(self, theVal=-1):
779 Obsolete function. Use SetMinSize.
781 print "Warning: SetGeoMin is obsolete. Please use SetMinSize"
782 self.SetMinSize(theVal)
785 ## Sets upper boundary of mesh element size computed to respect angular deflection.
786 def SetGeoMax(self, theVal=-1):
788 Obsolete function. Use SetMaxSize.
790 print "Warning: SetGeoMax is obsolete. Please use SetMaxSize"
791 self.SetMaxSize(theVal)
795 pass # end of BLSURF_Algorithm class