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
26 LIBRARY = "libBLSURFEngine.so"
28 # Topology treatment way of MG-CADSurf
29 FromCAD, PreProcess, PreProcessPlus, PreCAD = 0,1,2,3
31 # Element size flag of MG-CADSurf
32 DefaultSize, DefaultGeom, MG_CADSURF_GlobalSize, MG_CADSURF_LocalSize = 0,0,1,2
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
37 # import BLSURFPlugin module if possible
45 #----------------------------
46 # Mesh algo type identifiers
47 #----------------------------
49 ## Algorithm type: MG-CADSurf triangle algorithm, see BLSURF_Algorithm
50 MG_CADSurf = "MG-CADSurf"
53 #----------------------
55 #----------------------
57 ## MG-CADSurf 2D algorithm.
59 # It can be created by calling smeshBuilder.Mesh.Triangle(smeshBuilder.MG-CADSurf,geom=0)
61 class BLSURF_Algorithm(Mesh_Algorithm):
63 ## name of the dynamic method in smeshBuilder.Mesh class
65 meshMethod = "Triangle"
66 ## type of algorithm used with helper function in smeshBuilder.Mesh class
69 ## doc string of the method
71 docHelper = "Creates triangle algorithm for faces"
73 _anisotropic_ratio = 0
74 _bad_surface_element_aspect_ratio = 1000
75 _geometric_approximation = 22
78 _remove_tiny_edges = 0
80 ## Private constructor.
81 # @param mesh parent mesh object algorithm is assigned to
82 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
83 # if it is @c 0 (default), the algorithm is assigned to the main shape
84 def __init__(self, mesh, geom=0):
85 Mesh_Algorithm.__init__(self)
87 print "Warning: BLSURFPlugin module unavailable"
88 self.Create(mesh, geom, BLSURF, LIBRARY)
90 self.geompyD = mesh.geompyD
91 #self.SetPhysicalMesh() - PAL19680
94 ## Sets a way to define size of mesh elements to generate.
95 # @param thePhysicalMesh is: DefaultSize, MG_CADSURF_Custom or SizeMap.
96 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
97 physical_size_mode = thePhysicalMesh
98 if self.Parameters().GetGeometricMesh() == DefaultGeom:
99 if physical_size_mode == DefaultSize:
100 physical_size_mode = MG_CADSURF_GlobalSize
101 self.Parameters().SetPhysicalMesh(physical_size_mode)
104 ## Sets a way to define maximum angular deflection of mesh from CAD model.
105 # @param theGeometricMesh is: DefaultGeom (0)) or MG_CADSURF_GlobalSize (1))
106 def SetGeometricMesh(self, theGeometricMesh=DefaultGeom):
107 geometric_size_mode = theGeometricMesh
108 if self.Parameters().GetPhysicalMesh() == DefaultSize:
109 if geometric_size_mode == DefaultGeom:
110 geometric_size_mode = MG_CADSURF_GlobalSize
111 self.Parameters().SetGeometricMesh(geometric_size_mode)
114 ## Sets size of mesh elements to generate.
115 # @param theVal : constant global size when using a global physical size.
116 # @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
117 def SetPhySize(self, theVal, isRelative = False):
118 if self.Parameters().GetPhysicalMesh() == DefaultSize:
119 self.SetPhysicalMesh(MG_CADSURF_GlobalSize)
121 self.Parameters().SetPhySizeRel(theVal)
123 self.Parameters().SetPhySize(theVal)
126 ## Sets lower boundary of mesh element size.
127 # @param theVal : global minimal cell size desired.
128 # @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
129 def SetMinSize(self, theVal=-1, isRelative = False):
131 self.Parameters().SetMinSizeRel(theVal)
133 self.Parameters().SetMinSize(theVal)
136 ## Sets upper boundary of mesh element size.
137 # @param theVal : global maximal cell size desired.
138 # @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
139 def SetMaxSize(self, theVal=-1, isRelative = False):
141 self.Parameters().SetMaxSizeRel(theVal)
143 self.Parameters().SetMaxSize(theVal)
146 ## Sets angular deflection (in degrees) from CAD surface.
147 # @param theVal value of angular deflection
148 def SetAngleMesh(self, theVal=_geometric_approximation):
149 if self.Parameters().GetGeometricMesh() == DefaultGeom:
150 self.SetGeometricMesh(MG_CADSURF_GlobalSize)
151 self.Parameters().SetAngleMesh(theVal)
154 ## Sets the maximum desired distance between a triangle and its supporting CAD surface
155 # @param distance the distance between a triangle and a surface
156 def SetChordalError(self, distance):
157 self.Parameters().SetChordalError(distance)
160 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
161 # @param theVal value of maximal length ratio
162 def SetGradation(self, theVal=_gradation):
163 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
164 self.Parameters().SetGradation(theVal)
167 ## Sets topology usage way.
168 # @param way defines how mesh conformity is assured <ul>
169 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
170 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model (OBSOLETE: FromCAD will be used)</li>
171 # <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
172 def SetTopology(self, way):
173 if way != PreCAD and way != FromCAD:
174 print "Warning: topology mode %d is no longer supported. Mode FromCAD is used."%way
176 self.Parameters().SetTopology(way)
179 ## To respect geometrical edges or not.
180 # @param toIgnoreEdges "ignore edges" flag value
181 def SetDecimesh(self, toIgnoreEdges=False):
183 self.SetOptionValue("respect_geometry","0")
185 self.SetOptionValue("respect_geometry","1")
188 ## Sets verbosity level in the range 0 to 100.
189 # @param level verbosity level
190 def SetVerbosity(self, level):
191 self.Parameters().SetVerbosity(level)
194 ## To optimize merges edges.
195 # @param toMergeEdges "merge edges" flag value
196 def SetPreCADMergeEdges(self, toMergeEdges=False):
197 if self.Parameters().GetTopology() != PreCAD:
198 self.SetTopology(PreCAD)
199 self.Parameters().SetPreCADMergeEdges(toMergeEdges)
202 ## To process 3D topology.
203 # @param toProcess "PreCAD process 3D" flag value
204 def SetPreCADProcess3DTopology(self, toProcess=False):
205 if self.Parameters().GetTopology() != PreCAD:
206 self.SetTopology(PreCAD)
207 self.Parameters().SetPreCADProcess3DTopology(toProcess)
210 ## To remove nano edges.
211 # @param toRemoveNanoEdges "remove nano edges" flag value
212 def SetPreCADRemoveNanoEdges(self, toRemoveNanoEdges=False):
213 if toRemoveNanoEdges:
214 self.SetPreCADOptionValue("remove_tiny_edges","1")
216 self.SetPreCADOptionValue("remove_tiny_edges","0")
219 ## To compute topology from scratch
220 # @param toDiscardInput "discard input" flag value
221 def SetPreCADDiscardInput(self, toDiscardInput=False):
222 if self.Parameters().GetTopology() != PreCAD:
223 self.SetTopology(PreCAD)
224 self.Parameters().SetPreCADDiscardInput(toDiscardInput)
227 ## Sets the length below which an edge is considered as nano
228 # for the topology processing.
229 # @param epsNano nano edge length threshold value
230 def SetPreCADEpsNano(self, epsNano):
231 self.SetPreCADOptionValue("tiny_edge_length","%f"%epsNano)
234 ## Sets advanced option value.
235 # @param optionName advanced option name
236 # @param level advanced option value
237 def SetOptionValue(self, optionName, level):
238 self.Parameters().SetOptionValue(optionName,level)
241 ## Sets advanced PreCAD option value.
242 # @param optionName name of the option
243 # @param optionValue value of the option
244 def SetPreCADOptionValue(self, optionName, optionValue):
245 if self.Parameters().GetTopology() != PreCAD:
246 self.SetTopology(PreCAD)
247 self.Parameters().SetPreCADOptionValue(optionName,optionValue)
250 ## Adds custom advanced option value.
251 # @param optionName custom advanced option name
252 # @param level custom advanced option value
253 def AddOption(self, optionName, level):
254 self.Parameters().AddOption(optionName,level)
257 ## Adds custom advanced PreCAD option value.
258 # @param optionName custom name of the option
259 # @param optionValue value of the option
260 def AddPreCADOption(self, optionName, optionValue):
261 if self.Parameters().GetTopology() != PreCAD:
262 self.SetTopology(PreCAD)
263 self.Parameters().AddPreCADOption(optionName,optionValue)
266 ## Sets GMF file for export at computation
267 # @param fileName GMF file name
268 def SetGMFFile(self, fileName):
269 self.Parameters().SetGMFFile(fileName)
272 #-----------------------------------------
273 # Enforced vertices (BLSURF)
274 #-----------------------------------------
276 ## To get all the enforced vertices
277 def GetAllEnforcedVertices(self):
278 return self.Parameters().GetAllEnforcedVertices()
280 ## To get all the enforced vertices sorted by face (or group, compound)
281 def GetAllEnforcedVerticesByFace(self):
282 return self.Parameters().GetAllEnforcedVerticesByFace()
284 ## To get all the enforced vertices sorted by coords of input vertices
285 def GetAllEnforcedVerticesByCoords(self):
286 return self.Parameters().GetAllEnforcedVerticesByCoords()
288 ## To get all the coords of input vertices sorted by face (or group, compound)
289 def GetAllCoordsByFace(self):
290 return self.Parameters().GetAllCoordsByFace()
292 ## To get all the enforced vertices on a face (or group, compound)
293 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
294 def GetEnforcedVertices(self, theFace):
295 from salome.smesh.smeshBuilder import AssureGeomPublished
296 AssureGeomPublished( self.mesh, theFace )
297 return self.Parameters().GetEnforcedVertices(theFace)
299 ## To clear all the enforced vertices
300 def ClearAllEnforcedVertices(self):
301 return self.Parameters().ClearAllEnforcedVertices()
303 ## 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.
304 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
305 # @param x : x coordinate
306 # @param y : y coordinate
307 # @param z : z coordinate
308 # @param vertexName : name of the enforced vertex
309 # @param groupName : name of the group
310 def SetEnforcedVertex(self, theFace, x, y, z, vertexName = "", groupName = ""):
311 from salome.smesh.smeshBuilder import AssureGeomPublished
312 AssureGeomPublished( self.mesh, theFace )
315 return self.Parameters().SetEnforcedVertex(theFace, x, y, z)
317 return self.Parameters().SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
321 return self.Parameters().SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
323 return self.Parameters().SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
327 ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
328 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
329 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
330 # @param groupName : name of the group
331 def SetEnforcedVertexGeom(self, theFace, theVertex, groupName = ""):
332 from salome.smesh.smeshBuilder import AssureGeomPublished
333 AssureGeomPublished( self.mesh, theFace )
334 AssureGeomPublished( self.mesh, theVertex )
336 return self.Parameters().SetEnforcedVertexGeom(theFace, theVertex)
338 return self.Parameters().SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
341 ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
342 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
343 # @param x : x coordinate
344 # @param y : y coordinate
345 # @param z : z coordinate
346 def UnsetEnforcedVertex(self, theFace, x, y, z):
347 from salome.smesh.smeshBuilder import AssureGeomPublished
348 AssureGeomPublished( self.mesh, theFace )
349 return self.Parameters().UnsetEnforcedVertex(theFace, x, y, z)
351 ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
352 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
353 # @param theVertex : GEOM vertex (or group, compound) to remove.
354 def UnsetEnforcedVertexGeom(self, theFace, theVertex):
355 from salome.smesh.smeshBuilder import AssureGeomPublished
356 AssureGeomPublished( self.mesh, theFace )
357 AssureGeomPublished( self.mesh, theVertex )
358 return self.Parameters().UnsetEnforcedVertexGeom(theFace, theVertex)
360 ## To remove all enforced vertices on a given face.
361 # @param theFace : face (or group/compound of faces) on which to remove all enforced vertices
362 def UnsetEnforcedVertices(self, theFace):
363 from salome.smesh.smeshBuilder import AssureGeomPublished
364 AssureGeomPublished( self.mesh, theFace )
365 return self.Parameters().UnsetEnforcedVertices(theFace)
367 ## To tell BLSURF to add a node on internal vertices
368 # @param toEnforceInternalVertices : boolean; if True the internal vertices are added as enforced vertices
369 def SetInternalEnforcedVertexAllFaces(self, toEnforceInternalVertices):
370 return self.Parameters().SetInternalEnforcedVertexAllFaces(toEnforceInternalVertices)
372 ## To know if BLSURF will add a node on internal vertices
373 def GetInternalEnforcedVertexAllFaces(self):
374 return self.Parameters().GetInternalEnforcedVertexAllFaces()
376 ## To define a group for the nodes of internal vertices
377 # @param groupName : string; name of the group
378 def SetInternalEnforcedVertexAllFacesGroup(self, groupName):
379 return self.Parameters().SetInternalEnforcedVertexAllFacesGroup(groupName)
381 ## To get the group name of the nodes of internal vertices
382 def GetInternalEnforcedVertexAllFacesGroup(self):
383 return self.Parameters().GetInternalEnforcedVertexAllFacesGroup()
385 #-----------------------------------------
387 #-----------------------------------------
389 ## 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 ]
390 # @param theFace : face on which the attractor will be defined
391 # @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
392 # @param theStartSize : mesh size on theAttractor
393 # @param theEndSize : maximum size that will be reached on theFace
394 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
395 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
396 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
397 from salome.smesh.smeshBuilder import AssureGeomPublished
398 AssureGeomPublished( self.mesh, theFace )
399 AssureGeomPublished( self.mesh, theAttractor )
400 self.Parameters().SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
403 ## Unsets an attractor on the chosen face.
404 # @param theFace : face on which the attractor has to be removed
405 def UnsetAttractorGeom(self, theFace):
406 from salome.smesh.smeshBuilder import AssureGeomPublished
407 AssureGeomPublished( self.mesh, theFace )
408 self.Parameters().SetAttractorGeom(theFace)
411 #-----------------------------------------
413 #-----------------------------------------
415 ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
416 # If theObject is a face, the function can be: def f(u,v): return u+v
417 # If theObject is an edge, the function can be: def f(t): return t/2
418 # If theObject is a vertex, the function can be: def f(): return 10
419 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
420 # @param theSizeMap : Size map defined as a string
421 def SetSizeMap(self, theObject, theSizeMap):
422 from salome.smesh.smeshBuilder import AssureGeomPublished
423 AssureGeomPublished( self.mesh, theObject )
424 self.Parameters().SetSizeMap(theObject, theSizeMap)
427 ## To set a constant size map on a face, edge or vertex (or group, compound).
428 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
429 # @param theSizeMap : Size map defined as a double
430 def SetConstantSizeMap(self, theObject, theSizeMap):
431 from salome.smesh.smeshBuilder import AssureGeomPublished
432 AssureGeomPublished( self.mesh, theObject )
433 self.Parameters().SetConstantSizeMap(theObject, theSizeMap)
435 ## To remove a size map defined on a face, edge or vertex (or group, compound)
436 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
437 def UnsetSizeMap(self, theObject):
438 from salome.smesh.smeshBuilder import AssureGeomPublished
439 AssureGeomPublished( self.mesh, theObject )
440 self.Parameters().UnsetSizeMap(theObject)
443 ## To remove all the size maps
444 def ClearSizeMaps(self):
445 self.Parameters().ClearSizeMaps()
448 ## Sets QuadAllowed flag.
449 # @param toAllow "allow quadrangles" flag value
450 def SetQuadAllowed(self, toAllow=True):
451 self.Parameters().SetQuadAllowed(toAllow)
454 ## Defines hypothesis having several parameters
455 # @return hypothesis object
456 def Parameters(self):
458 self.params = self.Hypothesis("MG-CADSurf Parameters", [],
459 LIBRARY, UseExisting=0)
463 #-----------------------------------------
464 # Periodicity (BLSURF with PreCAD)
465 #-----------------------------------------
467 ## Defines periodicity between two groups of faces, using PreCAD
468 # @param theFace1 : GEOM face (or group, compound) to associate with theFace2
469 # @param theFace2 : GEOM face (or group, compound) associated with theFace1
470 # @param theSourceVertices (optionnal): list of GEOM vertices on theFace1 defining the transformation from theFace1 to theFace2.
471 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
472 # @param theTargetVertices (optionnal): list of GEOM vertices on theFace2 defining the transformation from theFace1 to theFace2.
473 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
474 def AddPreCadFacesPeriodicity(self, theFace1, theFace2, theSourceVertices=[], theTargetVertices=[]):
475 """calls preCad function:
476 status_t cad_add_face_multiple_periodicity_with_transformation_function(cad t *cad,
477 integer *fid1, integer size1, integer *fid2, integer size2,
478 periodicity_transformation_t transf, void *user data);
480 if theSourceVertices and theTargetVertices:
481 self.Parameters().AddPreCadFacesPeriodicityWithVertices(theFace1, theFace2, theSourceVertices, theTargetVertices)
483 self.Parameters().AddPreCadFacesPeriodicity(theFace1, theFace2)
486 ## Defines periodicity between two groups of edges, using PreCAD
487 # @param theEdge1 : GEOM edge (or group, compound) to associate with theEdge2
488 # @param theEdge2 : GEOM edge (or group, compound) associated with theEdge1
489 # @param theSourceVertices (optionnal): list of GEOM vertices on theEdge1 defining the transformation from theEdge1 to theEdge2.
490 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
491 # @param theTargetVertices (optionnal): list of GEOM vertices on theEdge2 defining the transformation from theEdge1 to theEdge2.
492 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
493 def AddPreCadEdgesPeriodicity(self, theEdge1, theEdge2, theSourceVertices=[], theTargetVertices=[]):
494 """calls preCad function:
495 status_t cad_add_edge_multiple_periodicity_with_transformation_function(cad t *cad,
496 integer *eid1, integer size1, integer *eid2, integer size2,
497 periodicity_transformation_t transf, void *user data);
499 if theSourceVertices and theTargetVertices:
500 self.Parameters().AddPreCadEdgesPeriodicityWithVertices(theEdge1, theEdge2, theSourceVertices, theTargetVertices)
502 self.Parameters().AddPreCadEdgesPeriodicity(theEdge1, theEdge2)
506 #-----------------------------------------
507 # Periodicity (BLSURF without PreCAD)
508 #-----------------------------------------
511 ## Defines periodicity between two faces, without using PreCAD.
512 # User has to call AddEdgePeriodicity with the edges of the face,
513 # and AddVertexPeriodicity with the vertices of each edge.
514 # @param theFace1 : GEOM face to associate with theFace2
515 # @param theFace2 : GEOM face associated with theFace1
516 def AddFacePeriodicity(self, theFace1, theFace2):
517 self.Parameters().AddFacePeriodicity(theFace1, theFace2)
520 ## Defines periodicity between two edges belonging to two periodic faces, without using PreCAD.
521 # To be used with AddFacePeriodicity.
522 # User has to call AddVertexPeriodicity with the vertices of each edge
523 # @param theFace1 : GEOM face to associate with theFace2
524 # @param theEdge1 : GEOM edge to associate with theEdge2
525 # @param theFace2 : GEOM face associated with theFace1
526 # @param theEdge2 : GEOM edge associated with theEdge1
527 # @param theEdgeOrientation : -1 (reversed), 0 (unknown) or 1 (forward)
528 def AddEdgePeriodicity(self, theFace1, theEdge1, theFace2, theEdge2, theEdgeOrientation=0):
529 self.Parameters().AddEdgePeriodicity(theFace1, theEdge1, theFace2, theEdge2, theEdgeOrientation)
532 ## Defines periodicity between two edges without face periodicity, without using PreCAD.
533 # User has to call AddVertexPeriodicity with the vertices of each edge.
534 # @param theEdge1 : GEOM edge to associate with theEdge2
535 # @param theEdge2 : GEOM edge associated with theEdge1
536 # @param theEdgeOrientation : -1 (reversed), 0 (unknown) or 1 (forward)
537 def AddEdgePeriodicityWithoutFaces(self, theEdge1, theEdge2, theEdgeOrientation=0):
538 self.Parameters().AddEdgePeriodicityWithoutFaces(theEdge1, theEdge2, theEdgeOrientation)
541 ## Defines periodicity between two vertices.
542 # To be used with AddFacePeriodicity and AddEdgePeriodicity.
543 # @param theEdge1 : GEOM edge to associate with theEdge2
544 # @param theVertex1 : GEOM face to associate with theVertex2
545 # @param theEdge2 : GEOM edge associated with theEdge1
546 # @param theVertex2 : GEOM face associated with theVertex1
547 def AddVertexPeriodicity(self, theEdge1, theVertex1, theEdge2, theVertex2):
548 self.Parameters().AddVertexPeriodicity(theEdge1, theVertex1, theEdge2, theVertex2)
551 ## Define periodicity between two groups of faces, given a transformation function.
552 # This uses the basic BLSURF API for each face, each edge, and each vertex.
553 # @param theFace1 : GEOM face (or group, compound) to associate with theFace2
554 # @param theFace2 : GEOM face (or group, compound) associated with theFace1
555 # @param f_transf : python function defining the transformation between an object of theFace1
556 # into an object of theFace2
557 def AddAdvancedFacesPeriodicity(self, theFace1, theFace2, f_transf):
558 source_faces = self.geompyD.SubShapeAll(theFace1, self.geompyD.ShapeType["FACE"])
562 for source_face in source_faces:
563 self.geompyD.addToStudyInFather(theFace1, source_face, "source_face_%i"%i)
564 p_source = self.geompyD.MakeVertexInsideFace(source_face)
565 p_target = f_transf(p_source)
566 target_face = self.geompyD.GetFaceNearPoint(theFace2, p_target)
567 self.geompyD.addToStudyInFather(theFace2, target_face, "target_face_%i"%i)
568 self.AddFacePeriodicity(source_face, target_face)
571 source_edges = self.geompyD.SubShapeAll(source_face, self.geompyD.ShapeType["EDGE"])
572 for source_edge in source_edges:
573 self.geompyD.addToStudyInFather(theFace1, source_edge, "source_edge_%i"%(j))
574 p_source = self.geompyD.MakeVertexOnCurve(source_edge, 0.5)
575 p_target = f_transf(p_source)
576 target_edge = self.geompyD.GetEdgeNearPoint(theFace2, p_target)
577 self.geompyD.addToStudyInFather(theFace2, target_edge, "target_edge_%i"%(j))
578 self.AddEdgePeriodicity(source_face, source_edge, target_face, target_edge, 1)
581 source_vertices = self.geompyD.SubShapeAll(source_edge, self.geompyD.ShapeType["VERTEX"])
582 for source_vertex in source_vertices:
583 self.geompyD.addToStudyInFather(theFace1, source_vertex, "source_vertex_%i"%(k))
584 target_vertex_tmp = f_transf(source_vertex)
585 target_vertex = self.geompyD.GetSame(theFace2, target_vertex_tmp)
586 self.geompyD.addToStudyInFather(theFace2, target_vertex, "target_vertex_%i"%(k))
587 self.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
591 ## Define periodicity between two groups of edges, without faces, given a transformation function.
592 # This uses the basic BLSURF API for each edge and each vertex.
593 # @param theEdge1 : GEOM edge (or group, compound) to associate with theEdge2
594 # @param theEdge2 : GEOM edge (or group, compound) associated with theEdge1
595 # @param f_transf : python function defining the transformation between an object of theEdge1
596 # into an object of theFace2
597 def AddAdvancedEdgesPeriodicity(self, theEdge1, theEdge2, f_transf):
598 source_edges = self.geompyD.SubShapeAll(theEdge1, self.geompyD.ShapeType["EDGE"])
601 for source_edge in source_edges:
602 self.geompyD.addToStudyInFather(theEdge1, source_edge, "source_edge_%i"%j)
603 p_source = self.geompyD.MakeVertexOnCurve(source_edge, 0.5)
604 p_target = f_transf(p_source)
605 target_edge = self.geompyD.GetEdgeNearPoint(theEdge2, p_target)
606 self.geompyD.addToStudyInFather(theEdge2, target_edge, "target_edge_%i"%j)
607 self.AddEdgePeriodicityWithoutFaces(source_edge, target_edge)
611 source_vertices = self.geompyD.SubShapeAll(source_edge, self.geompyD.ShapeType["VERTEX"])
612 for source_vertex in source_vertices:
613 self.geompyD.addToStudyInFather(theEdge1, source_vertex, "source_vertex_%i"%k)
614 target_vertex_tmp = f_transf(source_vertex)
615 target_vertex = self.geompyD.GetSame(theEdge2, target_vertex_tmp)
616 self.geompyD.addToStudyInFather(theEdge2, target_vertex, "target_vertex_%i"%k)
617 self.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
622 #=====================
624 #=====================
629 ## Sets lower boundary of mesh element size (PhySize).
630 def SetPhyMin(self, theVal=-1):
632 Obsolete function. Use SetMinSize.
634 print "Warning: SetPhyMin is obsolete. Please use SetMinSize"
635 self.SetMinSize(theVal)
638 ## Sets upper boundary of mesh element size (PhySize).
639 def SetPhyMax(self, theVal=-1):
641 Obsolete function. Use SetMaxSize.
643 print "Warning: SetPhyMax is obsolete. Please use SetMaxSize"
644 self.SetMaxSize(theVal)
647 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
648 def SetAngleMeshS(self, theVal=_geometric_approximation):
650 Obsolete function. Use SetAngleMesh.
652 print "Warning: SetAngleMeshS is obsolete. Please use SetAngleMesh"
653 self.SetAngleMesh(theVal)
656 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
657 def SetAngleMeshC(self, theVal=_geometric_approximation):
659 Obsolete function. Use SetAngleMesh.
661 print "Warning: SetAngleMeshC is obsolete. Please use SetAngleMesh"
662 self.SetAngleMesh(theVal)
665 ## Sets lower boundary of mesh element size computed to respect angular deflection.
666 def SetGeoMin(self, theVal=-1):
668 Obsolete function. Use SetMinSize.
670 print "Warning: SetGeoMin is obsolete. Please use SetMinSize"
671 self.SetMinSize(theVal)
674 ## Sets upper boundary of mesh element size computed to respect angular deflection.
675 def SetGeoMax(self, theVal=-1):
677 Obsolete function. Use SetMaxSize.
679 print "Warning: SetGeoMax is obsolete. Please use SetMaxSize"
680 self.SetMaxSize(theVal)
684 pass # end of BLSURF_Algorithm class