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 self.Create(mesh, geom, BLSURF, LIBRARY)
92 self.geompyD = mesh.geompyD
93 #self.SetPhysicalMesh() - PAL19680
96 ## Sets a way to define size of mesh elements to generate.
97 # @param thePhysicalMesh is: DefaultSize, MG_CADSURF_Custom or SizeMap.
98 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
99 physical_size_mode = thePhysicalMesh
100 if self.Parameters().GetGeometricMesh() == DefaultGeom:
101 if physical_size_mode == DefaultSize:
102 physical_size_mode = MG_CADSURF_GlobalSize
103 self.Parameters().SetPhysicalMesh(physical_size_mode)
106 ## Sets a way to define maximum angular deflection of mesh from CAD model.
107 # @param theGeometricMesh is: DefaultGeom (0)) or MG_CADSURF_GlobalSize (1))
108 def SetGeometricMesh(self, theGeometricMesh=DefaultGeom):
109 geometric_size_mode = theGeometricMesh
110 if self.Parameters().GetPhysicalMesh() == DefaultSize:
111 if geometric_size_mode == DefaultGeom:
112 geometric_size_mode = MG_CADSURF_GlobalSize
113 self.Parameters().SetGeometricMesh(geometric_size_mode)
116 ## Sets size of mesh elements to generate.
117 # @param theVal : constant global size when using a global physical size.
118 # @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
119 def SetPhySize(self, theVal, isRelative = False):
120 if self.Parameters().GetPhysicalMesh() == DefaultSize:
121 self.SetPhysicalMesh(MG_CADSURF_GlobalSize)
123 self.Parameters().SetPhySizeRel(theVal)
125 self.Parameters().SetPhySize(theVal)
128 ## Sets lower boundary of mesh element size.
129 # @param theVal : global minimal cell size desired.
130 # @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
131 def SetMinSize(self, theVal=-1, isRelative = False):
133 self.Parameters().SetMinSizeRel(theVal)
135 self.Parameters().SetMinSize(theVal)
138 ## Sets upper boundary of mesh element size.
139 # @param theVal : global maximal cell size desired.
140 # @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
141 def SetMaxSize(self, theVal=-1, isRelative = False):
143 self.Parameters().SetMaxSizeRel(theVal)
145 self.Parameters().SetMaxSize(theVal)
148 ## Sets angular deflection (in degrees) from CAD surface.
149 # @param theVal value of angular deflection
150 def SetAngleMesh(self, theVal=_geometric_approximation):
151 if self.Parameters().GetGeometricMesh() == DefaultGeom:
152 self.SetGeometricMesh(MG_CADSURF_GlobalSize)
153 self.Parameters().SetAngleMesh(theVal)
156 ## Sets the maximum desired distance between a triangle and its supporting CAD surface
157 # @param distance the distance between a triangle and a surface
158 def SetChordalError(self, distance):
159 self.Parameters().SetChordalError(distance)
162 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
163 # @param toUseGradation to use gradation
164 # @param theVal value of maximal length ratio
165 def SetGradation(self, toUseGradation=True, theVal=_gradation):
166 if isinstance( toUseGradation, float ): ## backward compatibility
167 toUseGradation, theVal = True, toUseGradation
168 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
169 self.Parameters().SetUseGradation(toUseGradation)
170 self.Parameters().SetGradation(theVal)
173 ## Sets maximal allowed ratio between the lengths of two adjacent edges in 3D mesh.
174 # @param toUseGradation to use gradation
175 # @param theVal value of maximal length ratio
176 def SetVolumeGradation(self, toUseGradation=True, theVal=_gradation):
177 if self.Parameters().GetGeometricMesh() == 0: theVal = self._volume_gradation
178 self.Parameters().SetUseVolumeGradation(toUseGradation)
179 self.Parameters().SetVolumeGradation(theVal)
182 ## Sets topology usage way.
183 # @param way defines how mesh conformity is assured <ul>
184 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
185 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model (OBSOLETE: FromCAD will be used)</li>
186 # <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
187 def SetTopology(self, way):
188 if way != PreCAD and way != FromCAD:
189 print "Warning: topology mode %d is no longer supported. Mode FromCAD is used."%way
191 self.Parameters().SetTopology(way)
194 ## To respect geometrical edges or not.
195 # @param toIgnoreEdges "ignore edges" flag value
196 def SetDecimesh(self, toIgnoreEdges=False):
198 self.SetOptionValue("respect_geometry","0")
200 self.SetOptionValue("respect_geometry","1")
203 ## Sets verbosity level in the range 0 to 100.
204 # @param level verbosity level
205 def SetVerbosity(self, level):
206 self.Parameters().SetVerbosity(level)
209 ## Set enforce_cad_edge_sizes parameter
211 # Relaxes the given sizemap constraint around CAD edges to allow a better
212 # element quality and a better geometric approximation. It is only useful in
213 # combination with the gradation option.
215 def SetEnforceCadEdgesSize( self, toEnforce ):
216 self.Parameters().SetEnforceCadEdgesSize( toEnforce )
218 ## Set jacobian_rectification_respect_geometry parameter
220 # While making the mesh quadratic, allows to lose the CAD-mesh associativity in order
221 # to correct elements with nagative Jacobian
223 def SetJacobianRectificationRespectGeometry( self, allowRectification ):
224 self.Parameters().SetJacobianRectificationRespectGeometry( allowRectification )
226 ## Set rectify_jacobian parameter
228 # While making the mesh quadratic, allow to fix nagative Jacobian surface elements
230 def SetJacobianRectification( self, allowRectification ):
231 self.Parameters().SetJacobianRectification( allowRectification )
233 ## Set respect_geometry parameter
235 # This patch independent option can be deactivated to allow MeshGems-CADSurf
236 # to lower the geometry accuracy in its patch independent process.
238 def SetRespectGeometry( self, toRespect ):
239 self.Parameters().SetRespectGeometry( toRespect )
241 ## Set max_number_of_points_per_patch parameter
243 # This parameter controls the maximum amount of points MeshGems-CADSurf is allowed
244 # to generate on a single CAD patch. For an automatic gestion of the memory, one
245 # can set this parameter to 0
247 def SetMaxNumberOfPointsPerPatch( self, nb ):
248 self.Parameters().SetMaxNumberOfPointsPerPatch( nb )
250 ## Set respect_geometry parameter
252 # This patch independent option can be deactivated to allow MeshGems-CADSurf
253 # to lower the geometry accuracy in its patch independent process.
255 def SetRespectGeometry( self, toRespect ):
256 self.Parameters().SetRespectGeometry( toRespect )
258 ## Set tiny_edges_avoid_surface_intersections parameter
260 # This option defines the priority between the tiny feature
261 # suppression and the surface intersection prevention.
263 def SetTinyEdgesAvoidSurfaceIntersections( self, toAvoidIntersection ):
264 self.Parameters().SetTinyEdgesAvoidSurfaceIntersections( toAvoidIntersection )
266 ## Set closed_geometry parameter parameter
268 # Describes whether the geometry is expected to be closed or not.
269 # When activated, this option helps MeshGems-PreCAD to treat the dirtiest geometries.
271 def SetClosedGeometry( self, isClosed ):
272 self.Parameters().SetClosedGeometry( isClosed )
274 ## Set debug parameter
276 # Make MeshGems-CADSurf will be very verbose and will output some intermediate
277 # files in the working directory. This option is mainly meant for Distene support issues.
279 def SetDebug( self, isDebug ):
280 self.Parameters().SetDebug( isDebug )
282 ## Set periodic_tolerance parameter
284 # This parameter defines the maximum size difference between two periodic edges
285 # and also the maximum distance error between two periodic entities.
287 def SetPeriodicTolerance( self, tol ):
288 self.Parameters().SetPeriodicTolerance( tol )
290 ## Set required_entities parameter
292 # The required entities control the correction operations.
293 # Accepted values for this parameter are :
294 # - "respect" : MeshGems-CADSurf is not allowed to alter any required entity,
295 # even for correction purposes,
296 # - "ignore" : MeshGems-CADSurf will ignore the required entities in its processing,
297 # - "clear" : MeshGems-CADSurf will clear any required status for the entities.
298 # There will not be any entity marked as required in the generated mesh.
300 def SetRequiredEntities( self, howToTreat ):
301 self.Parameters().SetRequiredEntities( howToTreat )
303 ## Set sewing_tolerance parameter
305 # This parameter is the tolerance of the assembly.
307 def SetSewingTolerance( self, tol ):
308 self.Parameters().SetSewingTolerance( tol )
310 ## Set tags parameter
312 # The tag (attribute) system controls the optimisation process.
313 # Accepted values for this parameter are :
314 # - "respect" : the CAD tags will be preserved and unaltered by the optimisation operations,
315 # - "ignore" : the CAD tags will be ignored by the optimisation operations
316 # but they will still be present in the output mesh,
317 # - "clear" : MeshGems-CADSurf will clear any tag on any entity and optimise accordingly.
318 # There will not be any tag in the generated mesh.
320 def SetTags( self, howToTreat ):
321 self.Parameters().SetTags( howToTreat )
323 ## Activate removal of the tiny edges from the generated
324 # mesh when it improves the local mesh quality, without taking into account the
325 # tags (attributes) specifications.
326 # @param toOptimise "to optimize" flag value
327 # @param length minimal length under which an edge is considered to be a tiny
328 def SetOptimiseTinyEdges(self, toOptimise, length=-1):
329 self.Parameters().SetOptimiseTinyEdges( toOptimise )
331 self.Parameters().SetTinyEdgeOptimisationLength( length )
333 ## Activate correction of all surface intersections
334 # @param toCorrect "to correct" flag value
335 # @param maxCost the time the user is ready to spend in the intersection prevention process
336 # For example, maxCost = 3 means that MeshGems-CADSurf will not spend more time
337 # in the intersection removal process than 3 times the time required to mesh
338 # without processing the intersections.
339 def SetCorrectSurfaceIntersection(self, toCorrect, maxCost ):
340 self.Parameters().SetCorrectSurfaceIntersection( toCorrect )
342 self.Parameters().SetCorrectSurfaceIntersectionMaxCost( maxCost )
344 ## To optimize merges edges.
345 # @param toMergeEdges "merge edges" flag value
346 def SetPreCADMergeEdges(self, toMergeEdges=False):
347 self.Parameters().SetPreCADMergeEdges(toMergeEdges)
350 ## To remove tiny UV edges.
351 # @param toRemoveTinyUVEdges "remove_tiny_uv_edges" flag value
352 def SetPreCADRemoveTinyUVEdges(self, toRemoveTinyUVEdges=False):
353 self.Parameters().SetPreCADRemoveTinyUVEdges(toRemoveTinyUVEdges)
356 ## To remove duplicate CAD Faces
357 # @param toRemoveDuplicateCADFaces "remove_duplicate_cad_faces" flag value
358 def SetPreCADRemoveDuplicateCADFaces(self, toRemoveDuplicateCADFaces=False):
359 self.Parameters().SetPreCADRemoveDuplicateCADFaces(toRemoveDuplicateCADFaces)
362 ## To process 3D topology.
363 # @param toProcess "PreCAD process 3D" flag value
364 def SetPreCADProcess3DTopology(self, toProcess=False):
365 self.Parameters().SetPreCADProcess3DTopology(toProcess)
368 ## To remove nano edges.
369 # @param toRemoveNanoEdges "remove nano edges" flag value
370 def SetPreCADRemoveNanoEdges(self, toRemoveNanoEdges=False):
371 if toRemoveNanoEdges:
372 self.SetPreCADOptionValue("remove_tiny_edges","1")
374 self.SetPreCADOptionValue("remove_tiny_edges","0")
377 ## To compute topology from scratch
378 # @param toDiscardInput "discard input" flag value
379 def SetPreCADDiscardInput(self, toDiscardInput=False):
380 self.Parameters().SetPreCADDiscardInput(toDiscardInput)
383 ## Sets the length below which an edge is considered as nano
384 # for the topology processing.
385 # @param epsNano nano edge length threshold value
386 def SetPreCADEpsNano(self, epsNano):
387 self.SetPreCADOptionValue("tiny_edge_length","%f"%epsNano)
390 ## Sets advanced option value.
391 # @param optionName advanced option name
392 # @param level advanced option value
393 def SetOptionValue(self, optionName, level):
394 self.Parameters().SetOptionValue(optionName,level)
397 ## Sets advanced PreCAD option value.
398 # @param optionName name of the option
399 # @param optionValue value of the option
400 def SetPreCADOptionValue(self, optionName, optionValue):
401 self.Parameters().SetPreCADOptionValue(optionName,optionValue)
404 ## Adds custom advanced option values
405 # @param optionsAndValues options and values in a form "option_1 v1 option_2 v2'"
406 def SetAdvancedOption(self, optionsAndValues):
407 self.Parameters().SetAdvancedOption(optionsAndValues)
410 ## Adds custom advanced option value.
411 # @param optionName custom advanced option name
412 # @param level custom advanced option value
413 def AddOption(self, optionName, level):
414 self.Parameters().AddOption(optionName,level)
417 ## Adds custom advanced PreCAD option value.
418 # @param optionName custom name of the option
419 # @param optionValue value of the option
420 def AddPreCADOption(self, optionName, optionValue):
421 self.Parameters().AddPreCADOption(optionName,optionValue)
424 ## Sets GMF file for export at computation
425 # @param fileName GMF file name
426 def SetGMFFile(self, fileName):
427 self.Parameters().SetGMFFile(fileName)
430 #-----------------------------------------
431 # Enforced vertices (BLSURF)
432 #-----------------------------------------
434 ## To get all the enforced vertices
435 def GetAllEnforcedVertices(self):
436 return self.Parameters().GetAllEnforcedVertices()
438 ## To get all the enforced vertices sorted by face (or group, compound)
439 def GetAllEnforcedVerticesByFace(self):
440 return self.Parameters().GetAllEnforcedVerticesByFace()
442 ## To get all the enforced vertices sorted by coords of input vertices
443 def GetAllEnforcedVerticesByCoords(self):
444 return self.Parameters().GetAllEnforcedVerticesByCoords()
446 ## To get all the coords of input vertices sorted by face (or group, compound)
447 def GetAllCoordsByFace(self):
448 return self.Parameters().GetAllCoordsByFace()
450 ## To get all the enforced vertices on a face (or group, compound)
451 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
452 def GetEnforcedVertices(self, theFace):
453 from salome.smesh.smeshBuilder import AssureGeomPublished
454 AssureGeomPublished( self.mesh, theFace )
455 return self.Parameters().GetEnforcedVertices(theFace)
457 ## To clear all the enforced vertices
458 def ClearAllEnforcedVertices(self):
459 return self.Parameters().ClearAllEnforcedVertices()
461 ## 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.
462 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
463 # @param x : x coordinate
464 # @param y : y coordinate
465 # @param z : z coordinate
466 # @param vertexName : name of the enforced vertex
467 # @param groupName : name of the group
468 def SetEnforcedVertex(self, theFace, x, y, z, vertexName = "", groupName = ""):
469 from salome.smesh.smeshBuilder import AssureGeomPublished
470 AssureGeomPublished( self.mesh, theFace )
473 return self.Parameters().SetEnforcedVertex(theFace, x, y, z)
475 return self.Parameters().SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
479 return self.Parameters().SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
481 return self.Parameters().SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
485 ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
486 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
487 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
488 # @param groupName : name of the group
489 def SetEnforcedVertexGeom(self, theFace, theVertex, groupName = ""):
490 from salome.smesh.smeshBuilder import AssureGeomPublished
491 AssureGeomPublished( self.mesh, theFace )
492 AssureGeomPublished( self.mesh, theVertex )
494 return self.Parameters().SetEnforcedVertexGeom(theFace, theVertex)
496 return self.Parameters().SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
499 ## Set an enforced vertex on a face given the coordinates of a point.
500 # The face if found by the application.
501 # @param x : x coordinate
502 # @param y : y coordinate
503 # @param z : z coordinate
504 # @param vertexName : name of the enforced vertex
505 # @param groupName : name of the group
506 def AddEnforcedVertex(self, x, y, z, vertexName = "", groupName = ""):
507 from salome.smesh.smeshBuilder import AssureGeomPublished
510 return self.Parameters().AddEnforcedVertex(x, y, z)
512 return self.Parameters().AddEnforcedVertexWithGroup(x, y, z, groupName)
516 return self.Parameters().AddEnforcedVertexNamed(x, y, z, vertexName)
518 return self.Parameters().AddEnforcedVertexNamedWithGroup( x, y, z, vertexName, groupName)
522 ## To set an enforced vertex on a face given a GEOM vertex, group or compound.
523 # The face if found by the application.
524 # @param theVertex : GEOM vertex (or group, compound).
525 # @param groupName : name of the group
526 def AddEnforcedVertexGeom(self, theVertex, groupName = ""):
527 from salome.smesh.smeshBuilder import AssureGeomPublished
528 AssureGeomPublished( self.mesh, theVertex )
530 return self.Parameters().AddEnforcedVertexGeom(theVertex)
532 return self.Parameters().AddEnforcedVertexGeomWithGroup(theVertex,groupName)
535 ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
536 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
537 # @param x : x coordinate
538 # @param y : y coordinate
539 # @param z : z coordinate
540 def UnsetEnforcedVertex(self, theFace, x, y, z):
541 from salome.smesh.smeshBuilder import AssureGeomPublished
542 AssureGeomPublished( self.mesh, theFace )
543 return self.Parameters().UnsetEnforcedVertex(theFace, x, y, z)
545 ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
546 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
547 # @param theVertex : GEOM vertex (or group, compound) to remove.
548 def UnsetEnforcedVertexGeom(self, theFace, theVertex):
549 from salome.smesh.smeshBuilder import AssureGeomPublished
550 AssureGeomPublished( self.mesh, theFace )
551 AssureGeomPublished( self.mesh, theVertex )
552 return self.Parameters().UnsetEnforcedVertexGeom(theFace, theVertex)
554 ## To remove all enforced vertices on a given face.
555 # @param theFace : face (or group/compound of faces) on which to remove all enforced vertices
556 def UnsetEnforcedVertices(self, theFace):
557 from salome.smesh.smeshBuilder import AssureGeomPublished
558 AssureGeomPublished( self.mesh, theFace )
559 return self.Parameters().UnsetEnforcedVertices(theFace)
561 ## To tell BLSURF to add a node on internal vertices
562 # @param toEnforceInternalVertices : boolean; if True the internal vertices are added as enforced vertices
563 def SetInternalEnforcedVertexAllFaces(self, toEnforceInternalVertices):
564 return self.Parameters().SetInternalEnforcedVertexAllFaces(toEnforceInternalVertices)
566 ## To know if BLSURF will add a node on internal vertices
567 def GetInternalEnforcedVertexAllFaces(self):
568 return self.Parameters().GetInternalEnforcedVertexAllFaces()
570 ## To define a group for the nodes of internal vertices
571 # @param groupName : string; name of the group
572 def SetInternalEnforcedVertexAllFacesGroup(self, groupName):
573 return self.Parameters().SetInternalEnforcedVertexAllFacesGroup(groupName)
575 ## To get the group name of the nodes of internal vertices
576 def GetInternalEnforcedVertexAllFacesGroup(self):
577 return self.Parameters().GetInternalEnforcedVertexAllFacesGroup()
579 #-----------------------------------------
581 #-----------------------------------------
583 ## 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 ]
584 # @param theFace : face on which the attractor will be defined
585 # @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
586 # @param theStartSize : mesh size on theAttractor
587 # @param theEndSize : maximum size that will be reached on theFace
588 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
589 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
590 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
591 from salome.smesh.smeshBuilder import AssureGeomPublished
592 AssureGeomPublished( self.mesh, theFace )
593 AssureGeomPublished( self.mesh, theAttractor )
594 self.Parameters().SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
597 ## Unsets an attractor on the chosen face.
598 # @param theFace : face on which the attractor has to be removed
599 def UnsetAttractorGeom(self, theFace):
600 from salome.smesh.smeshBuilder import AssureGeomPublished
601 AssureGeomPublished( self.mesh, theFace )
602 self.Parameters().SetAttractorGeom(theFace)
605 #-----------------------------------------
607 #-----------------------------------------
609 ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
610 # If theObject is a face, the function can be: def f(u,v): return u+v
611 # If theObject is an edge, the function can be: def f(t): return t/2
612 # If theObject is a vertex, the function can be: def f(): return 10
613 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
614 # @param theSizeMap : Size map defined as a string
615 def SetSizeMap(self, theObject, theSizeMap):
616 from salome.smesh.smeshBuilder import AssureGeomPublished
617 AssureGeomPublished( self.mesh, theObject )
618 self.Parameters().SetSizeMap(theObject, theSizeMap)
621 ## To set a constant size map on a face, edge or vertex (or group, compound).
622 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
623 # @param theSizeMap : Size map defined as a double
624 def SetConstantSizeMap(self, theObject, theSizeMap):
625 from salome.smesh.smeshBuilder import AssureGeomPublished
626 AssureGeomPublished( self.mesh, theObject )
627 self.Parameters().SetConstantSizeMap(theObject, theSizeMap)
629 ## To remove a size map defined on a face, edge or vertex (or group, compound)
630 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
631 def UnsetSizeMap(self, theObject):
632 from salome.smesh.smeshBuilder import AssureGeomPublished
633 AssureGeomPublished( self.mesh, theObject )
634 self.Parameters().UnsetSizeMap(theObject)
637 ## To remove all the size maps
638 def ClearSizeMaps(self):
639 self.Parameters().ClearSizeMaps()
642 ## Sets QuadAllowed flag.
643 # @param toAllow "allow quadrangles" flag value
644 def SetQuadAllowed(self, toAllow=True):
645 self.Parameters().SetQuadAllowed(toAllow)
648 ## Defines hypothesis having several parameters
649 # @return hypothesis object
650 def Parameters(self):
652 self.params = self.Hypothesis("MG-CADSurf Parameters", [],
653 LIBRARY, UseExisting=0)
657 #-----------------------------------------
658 # Periodicity (BLSURF with PreCAD)
659 #-----------------------------------------
661 ## Defines periodicity between two groups of faces, using PreCAD
662 # @param theFace1 : GEOM face (or group, compound) to associate with theFace2
663 # @param theFace2 : GEOM face (or group, compound) associated with theFace1
664 # @param theSourceVertices (optionnal): list of GEOM vertices on theFace1 defining the transformation from theFace1 to theFace2.
665 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
666 # @param theTargetVertices (optionnal): list of GEOM vertices on theFace2 defining the transformation from theFace1 to theFace2.
667 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
668 def AddPreCadFacesPeriodicity(self, theFace1, theFace2, theSourceVertices=[], theTargetVertices=[]):
669 """calls preCad function:
670 status_t cad_add_face_multiple_periodicity_with_transformation_function(cad t *cad,
671 integer *fid1, integer size1, integer *fid2, integer size2,
672 periodicity_transformation_t transf, void *user data);
674 if theSourceVertices and theTargetVertices:
675 self.Parameters().AddPreCadFacesPeriodicityWithVertices(theFace1, theFace2, theSourceVertices, theTargetVertices)
677 self.Parameters().AddPreCadFacesPeriodicity(theFace1, theFace2)
680 ## Defines periodicity between two groups of edges, using PreCAD
681 # @param theEdge1 : GEOM edge (or group, compound) to associate with theEdge2
682 # @param theEdge2 : GEOM edge (or group, compound) associated with theEdge1
683 # @param theSourceVertices (optionnal): list of GEOM vertices on theEdge1 defining the transformation from theEdge1 to theEdge2.
684 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
685 # @param theTargetVertices (optionnal): list of GEOM vertices on theEdge2 defining the transformation from theEdge1 to theEdge2.
686 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
687 def AddPreCadEdgesPeriodicity(self, theEdge1, theEdge2, theSourceVertices=[], theTargetVertices=[]):
688 """calls preCad function:
689 status_t cad_add_edge_multiple_periodicity_with_transformation_function(cad t *cad,
690 integer *eid1, integer size1, integer *eid2, integer size2,
691 periodicity_transformation_t transf, void *user data);
693 if theSourceVertices and theTargetVertices:
694 self.Parameters().AddPreCadEdgesPeriodicityWithVertices(theEdge1, theEdge2, theSourceVertices, theTargetVertices)
696 self.Parameters().AddPreCadEdgesPeriodicity(theEdge1, theEdge2)
699 #-----------------------------------------
701 #-----------------------------------------
703 ## Defines hyper-patches. A hyper-patch is a set of adjacent faces meshed as a whole,
704 # ignoring edges between them
705 # @param hyperPatchList : list of hyper-patches. A hyper-patch is defined as a list of
706 # faces or groups of faces. A face can be identified either as a GEOM object or
707 # a face ID (returned e.g. by geompy.GetSubShapeID( mainShape, subShape )).
709 # Example: cadsurf.SetHyperPatches([[ Face_1, Group_2 ],[ 13, 23 ]])
710 def SetHyperPatches(self, hyperPatchList):
712 for patch in hyperPatchList:
715 if isinstance( face, int ):
717 elif isinstance( face, GEOM._objref_GEOM_Object):
718 faces = self.mesh.geompyD.SubShapeAll( face, self.mesh.geompyD.ShapeType["FACE"] )
720 ids.append( self.mesh.geompyD.GetSubShapeID( self.mesh.geom, f ))
723 "Face of hyper-patch should be either ID or GEOM_Object, not %s" % type(face)
727 self.Parameters().SetHyperPatches( hpl )
730 #=====================
732 #=====================
737 ## Sets lower boundary of mesh element size (PhySize).
738 def SetPhyMin(self, theVal=-1):
740 Obsolete function. Use SetMinSize.
742 print "Warning: SetPhyMin is obsolete. Please use SetMinSize"
743 self.SetMinSize(theVal)
746 ## Sets upper boundary of mesh element size (PhySize).
747 def SetPhyMax(self, theVal=-1):
749 Obsolete function. Use SetMaxSize.
751 print "Warning: SetPhyMax is obsolete. Please use SetMaxSize"
752 self.SetMaxSize(theVal)
755 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
756 def SetAngleMeshS(self, theVal=_geometric_approximation):
758 Obsolete function. Use SetAngleMesh.
760 print "Warning: SetAngleMeshS is obsolete. Please use SetAngleMesh"
761 self.SetAngleMesh(theVal)
764 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
765 def SetAngleMeshC(self, theVal=_geometric_approximation):
767 Obsolete function. Use SetAngleMesh.
769 print "Warning: SetAngleMeshC is obsolete. Please use SetAngleMesh"
770 self.SetAngleMesh(theVal)
773 ## Sets lower boundary of mesh element size computed to respect angular deflection.
774 def SetGeoMin(self, theVal=-1):
776 Obsolete function. Use SetMinSize.
778 print "Warning: SetGeoMin is obsolete. Please use SetMinSize"
779 self.SetMinSize(theVal)
782 ## Sets upper boundary of mesh element size computed to respect angular deflection.
783 def SetGeoMax(self, theVal=-1):
785 Obsolete function. Use SetMaxSize.
787 print "Warning: SetGeoMax is obsolete. Please use SetMaxSize"
788 self.SetMaxSize(theVal)
792 pass # end of BLSURF_Algorithm class