1 # Copyright (C) 2007-2013 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.
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 BLSURF meshing plug-in module.
24 from salome.smesh.smesh_algorithm import Mesh_Algorithm
26 # Topology treatment way of BLSURF
27 FromCAD, PreProcess, PreProcessPlus, PreCAD = 0,1,2,3
29 # Element size flag of BLSURF
30 DefaultSize, DefaultGeom, BLSURF_GlobalSize, BLSURF_LocalSize = 0,0,1,2
32 BLSURF_Custom, SizeMap = BLSURF_GlobalSize, BLSURF_LocalSize
35 # import BLSURFPlugin module if possible
43 #----------------------------
44 # Mesh algo type identifiers
45 #----------------------------
47 ## Algorithm type: BLSurf triangle 2D algorithm, see BLSURF_Algorithm
50 #----------------------
52 #----------------------
54 ## BLSurf 2D algorithm.
56 # It can be created by calling smeshBuilder.Mesh.Triangle(smeshBuilder.BLSURF,geom=0)
58 class BLSURF_Algorithm(Mesh_Algorithm):
60 ## name of the dynamic method in smeshBuilder.Mesh class
62 meshMethod = "Triangle"
63 ## type of algorithm used with helper function in smeshBuilder.Mesh class
66 ## doc string of the method
68 docHelper = "Creates triangle 2D algorithm for faces"
70 _anisotropic_ratio = 0
71 _bad_surface_element_aspect_ratio = 1000
72 _geometric_approximation = 22
75 _remove_tiny_edges = 0
77 ## Private constructor.
78 # @param mesh parent mesh object algorithm is assigned to
79 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
80 # if it is @c 0 (default), the algorithm is assigned to the main shape
81 def __init__(self, mesh, geom=0):
82 Mesh_Algorithm.__init__(self)
84 print "Warning: BLSURFPlugin module unavailable"
85 self.Create(mesh, geom, BLSURF, "libBLSURFEngine.so")
87 self.geompyD = mesh.geompyD
88 #self.SetPhysicalMesh() - PAL19680
91 ## Sets a way to define size of mesh elements to generate.
92 # @param thePhysicalMesh is: DefaultSize, BLSURF_Custom or SizeMap.
93 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
94 physical_size_mode = thePhysicalMesh
95 if self.Parameters().GetGeometricMesh() == DefaultGeom:
96 if physical_size_mode == DefaultSize:
97 physical_size_mode = BLSURF_GlobalSize
98 self.Parameters().SetPhysicalMesh(physical_size_mode)
101 ## Sets a way to define maximum angular deflection of mesh from CAD model.
102 # @param theGeometricMesh is: DefaultGeom (0)) or BLSURF_GlobalSize (1))
103 def SetGeometricMesh(self, theGeometricMesh=DefaultGeom):
104 geometric_size_mode = theGeometricMesh
105 if self.Parameters().GetPhysicalMesh() == DefaultSize:
106 if geometric_size_mode == DefaultGeom:
107 geometric_size_mode = BLSURF_GlobalSize
108 self.Parameters().SetGeometricMesh(geometric_size_mode)
111 ## Sets size of mesh elements to generate.
112 # @param theVal : constant global size when using a global physical size.
113 # @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
114 def SetPhySize(self, theVal, isRelative = False):
115 if self.Parameters().GetPhysicalMesh() == DefaultSize:
116 self.SetPhysicalMesh(BLSURF_GlobalSize)
118 self.Parameters().SetPhySizeRel(theVal)
120 self.Parameters().SetPhySize(theVal)
123 ## Sets lower boundary of mesh element size.
124 # @param theVal : global minimal cell size desired.
125 # @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
126 def SetMinSize(self, theVal=-1, isRelative = False):
128 self.Parameters().SetMinSizeRel(theVal)
130 self.Parameters().SetMinSize(theVal)
133 ## Sets upper boundary of mesh element size.
134 # @param theVal : global maximal cell size desired.
135 # @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
136 def SetMaxSize(self, theVal=-1):
138 self.Parameters().SetMaxSizeRel(theVal)
140 self.Parameters().SetMaxSize(theVal)
143 ## Sets angular deflection (in degrees) from CAD surface.
144 # @param theVal value of angular deflection
145 def SetAngleMesh(self, theVal=_geometric_approximation):
146 if self.Parameters().GetGeometricMesh() == DefaultGeom:
147 self.SetGeometricMesh(BLSURF_GlobalSize)
148 self.Parameters().SetAngleMesh(theVal)
151 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
152 # @param theVal value of maximal length ratio
153 def SetGradation(self, theVal=_gradation):
154 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
155 self.Parameters().SetGradation(theVal)
158 ## Sets topology usage way.
159 # @param way defines how mesh conformity is assured <ul>
160 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
161 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model (OBSOLETE: FromCAD will be used)</li>
162 # <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
163 def SetTopology(self, way):
165 print "Warning: topology mode %d is no longer supported. Mode FromCAD is used."%way
167 self.Parameters().SetTopology(way)
170 ## To respect geometrical edges or not.
171 # @param toIgnoreEdges "ignore edges" flag value
172 def SetDecimesh(self, toIgnoreEdges=False):
174 self.SetOptionValue("respect_geometry","0")
176 self.SetOptionValue("respect_geometry","1")
179 ## Sets verbosity level in the range 0 to 100.
180 # @param level verbosity level
181 def SetVerbosity(self, level):
182 self.Parameters().SetVerbosity(level)
185 ## To optimize merges edges.
186 # @param toMergeEdges "merge edges" flag value
187 def SetPreCADMergeEdges(self, toMergeEdges=False):
188 if self.Parameters().GetTopology() != PreCAD:
189 self.SetTopology(PreCAD)
190 self.Parameters().SetPreCADMergeEdges(toMergeEdges)
193 ## To process 3D topology.
194 # @param toProcess "PreCAD process 3D" flag value
195 def SetPreCADProcess3DTopology(self, toProcess=False):
196 if self.Parameters().GetTopology() != PreCAD:
197 self.SetTopology(PreCAD)
198 self.Parameters().SetPreCADProcess3DTopology(toProcess)
201 ## To remove nano edges.
202 # @param toRemoveNanoEdges "remove nano edges" flag value
203 def SetPreCADRemoveNanoEdges(self, toRemoveNanoEdges=False):
204 if toRemoveNanoEdges:
205 self.SetPreCADOptionValue("remove_tiny_edges","1")
207 self.SetPreCADOptionValue("remove_tiny_edges","0")
210 ## To compute topology from scratch
211 # @param toDiscardInput "discard input" flag value
212 def SetPreCADDiscardInput(self, toDiscardInput=False):
213 if self.Parameters().GetTopology() != PreCAD:
214 self.SetTopology(PreCAD)
215 self.Parameters().SetPreCADDiscardInput(toDiscardInput)
218 ## Sets the length below which an edge is considered as nano
219 # for the topology processing.
220 # @param epsNano nano edge length threshold value
221 def SetPreCADEpsNano(self, epsNano):
222 self.SetPreCADOptionValue("tiny_edge_length","%f"%epsNano)
225 ## Sets advanced option value.
226 # @param optionName advanced option name
227 # @param level advanced option value
228 def SetOptionValue(self, optionName, level):
229 self.Parameters().SetOptionValue(optionName,level)
232 ## Sets advanced PreCAD option value.
233 # @param optionName name of the option
234 # @param optionValue value of the option
235 def SetPreCADOptionValue(self, optionName, optionValue):
236 if self.Parameters().GetTopology() != PreCAD:
237 self.SetTopology(PreCAD)
238 self.Parameters().SetPreCADOptionValue(optionName,optionValue)
241 ## Sets GMF file for export at computation
242 # @param fileName GMF file name
243 def SetGMFFile(self, fileName):
244 self.Parameters().SetGMFFile(fileName)
247 #-----------------------------------------
248 # Enforced vertices (BLSURF)
249 #-----------------------------------------
251 ## To get all the enforced vertices
252 def GetAllEnforcedVertices(self):
253 return self.Parameters().GetAllEnforcedVertices()
255 ## To get all the enforced vertices sorted by face (or group, compound)
256 def GetAllEnforcedVerticesByFace(self):
257 return self.Parameters().GetAllEnforcedVerticesByFace()
259 ## To get all the enforced vertices sorted by coords of input vertices
260 def GetAllEnforcedVerticesByCoords(self):
261 return self.Parameters().GetAllEnforcedVerticesByCoords()
263 ## To get all the coords of input vertices sorted by face (or group, compound)
264 def GetAllCoordsByFace(self):
265 return self.Parameters().GetAllCoordsByFace()
267 ## To get all the enforced vertices on a face (or group, compound)
268 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
269 def GetEnforcedVertices(self, theFace):
270 from salome.smesh.smeshBuilder import AssureGeomPublished
271 AssureGeomPublished( self.mesh, theFace )
272 return self.Parameters().GetEnforcedVertices(theFace)
274 ## To clear all the enforced vertices
275 def ClearAllEnforcedVertices(self):
276 return self.Parameters().ClearAllEnforcedVertices()
278 ## 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.
279 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
280 # @param x : x coordinate
281 # @param y : y coordinate
282 # @param z : z coordinate
283 # @param vertexName : name of the enforced vertex
284 # @param groupName : name of the group
285 def SetEnforcedVertex(self, theFace, x, y, z, vertexName = "", groupName = ""):
286 from salome.smesh.smeshBuilder import AssureGeomPublished
287 AssureGeomPublished( self.mesh, theFace )
290 return self.Parameters().SetEnforcedVertex(theFace, x, y, z)
292 return self.Parameters().SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
296 return self.Parameters().SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
298 return self.Parameters().SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
302 ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
303 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
304 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
305 # @param groupName : name of the group
306 def SetEnforcedVertexGeom(self, theFace, theVertex, groupName = ""):
307 from salome.smesh.smeshBuilder import AssureGeomPublished
308 AssureGeomPublished( self.mesh, theFace )
309 AssureGeomPublished( self.mesh, theVertex )
311 return self.Parameters().SetEnforcedVertexGeom(theFace, theVertex)
313 return self.Parameters().SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
316 ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
317 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
318 # @param x : x coordinate
319 # @param y : y coordinate
320 # @param z : z coordinate
321 def UnsetEnforcedVertex(self, theFace, x, y, z):
322 from salome.smesh.smeshBuilder import AssureGeomPublished
323 AssureGeomPublished( self.mesh, theFace )
324 return self.Parameters().UnsetEnforcedVertex(theFace, x, y, z)
326 ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
327 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
328 # @param theVertex : GEOM vertex (or group, compound) to remove.
329 def UnsetEnforcedVertexGeom(self, theFace, theVertex):
330 from salome.smesh.smeshBuilder import AssureGeomPublished
331 AssureGeomPublished( self.mesh, theFace )
332 AssureGeomPublished( self.mesh, theVertex )
333 return self.Parameters().UnsetEnforcedVertexGeom(theFace, theVertex)
335 ## To remove all enforced vertices on a given face.
336 # @param theFace : face (or group/compound of faces) on which to remove all enforced vertices
337 def UnsetEnforcedVertices(self, theFace):
338 from salome.smesh.smeshBuilder import AssureGeomPublished
339 AssureGeomPublished( self.mesh, theFace )
340 return self.Parameters().UnsetEnforcedVertices(theFace)
342 ## To tell BLSURF to add a node on internal vertices
343 # @param toEnforceInternalVertices : boolean; if True the internal vertices are added as enforced vertices
344 def SetInternalEnforcedVertexAllFaces(self, toEnforceInternalVertices):
345 return self.Parameters().SetInternalEnforcedVertexAllFaces(toEnforceInternalVertices)
347 ## To know if BLSURF will add a node on internal vertices
348 def GetInternalEnforcedVertexAllFaces(self):
349 return self.Parameters().GetInternalEnforcedVertexAllFaces()
351 ## To define a group for the nodes of internal vertices
352 # @param groupName : string; name of the group
353 def SetInternalEnforcedVertexAllFacesGroup(self, groupName):
354 return self.Parameters().SetInternalEnforcedVertexAllFacesGroup(groupName)
356 ## To get the group name of the nodes of internal vertices
357 def GetInternalEnforcedVertexAllFacesGroup(self):
358 return self.Parameters().GetInternalEnforcedVertexAllFacesGroup()
360 #-----------------------------------------
362 #-----------------------------------------
364 ## 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 ]
365 # @param theFace : face on which the attractor will be defined
366 # @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
367 # @param theStartSize : mesh size on theAttractor
368 # @param theEndSize : maximum size that will be reached on theFace
369 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
370 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
371 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
372 from salome.smesh.smeshBuilder import AssureGeomPublished
373 AssureGeomPublished( self.mesh, theFace )
374 AssureGeomPublished( self.mesh, theAttractor )
375 self.Parameters().SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
378 ## Unsets an attractor on the chosen face.
379 # @param theFace : face on which the attractor has to be removed
380 def UnsetAttractorGeom(self, theFace):
381 from salome.smesh.smeshBuilder import AssureGeomPublished
382 AssureGeomPublished( self.mesh, theFace )
383 self.Parameters().SetAttractorGeom(theFace)
386 #-----------------------------------------
388 #-----------------------------------------
390 ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
391 # If theObject is a face, the function can be: def f(u,v): return u+v
392 # If theObject is an edge, the function can be: def f(t): return t/2
393 # If theObject is a vertex, the function can be: def f(): return 10
394 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
395 # @param theSizeMap : Size map defined as a string
396 def SetSizeMap(self, theObject, theSizeMap):
397 from salome.smesh.smeshBuilder import AssureGeomPublished
398 AssureGeomPublished( self.mesh, theObject )
399 self.Parameters().SetSizeMap(theObject, theSizeMap)
402 ## To set a constant size map on a face, edge or vertex (or group, compound).
403 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
404 # @param theSizeMap : Size map defined as a double
405 def SetConstantSizeMap(self, theObject, theSizeMap):
406 from salome.smesh.smeshBuilder import AssureGeomPublished
407 AssureGeomPublished( self.mesh, theObject )
408 self.Parameters().SetConstantSizeMap(theObject, theSizeMap)
410 ## To remove a size map defined on a face, edge or vertex (or group, compound)
411 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
412 def UnsetSizeMap(self, theObject):
413 from salome.smesh.smeshBuilder import AssureGeomPublished
414 AssureGeomPublished( self.mesh, theObject )
415 self.Parameters().UnsetSizeMap(theObject)
418 ## To remove all the size maps
419 def ClearSizeMaps(self):
420 self.Parameters().ClearSizeMaps()
423 ## Sets QuadAllowed flag.
424 # @param toAllow "allow quadrangles" flag value
425 def SetQuadAllowed(self, toAllow=True):
426 self.Parameters().SetQuadAllowed(toAllow)
429 ## Defines hypothesis having several parameters
430 # @return hypothesis object
431 def Parameters(self):
433 self.params = self.Hypothesis("BLSURF_Parameters", [],
434 "libBLSURFEngine.so", UseExisting=0)
438 #-----------------------------------------
439 # Periodicity (BLSURF with PreCAD)
440 #-----------------------------------------
442 ## Defines periodicity between two groups of faces, using PreCAD
443 # @param theFace1 : GEOM face (or group, compound) to associate with theFace2
444 # @param theFace2 : GEOM face (or group, compound) associated with theFace1
445 # @param theSourceVertices (optionnal): list of GEOM vertices on theFace1 defining the transformation from theFace1 to theFace2.
446 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
447 # @param theTargetVertices (optionnal): list of GEOM vertices on theFace2 defining the transformation from theFace1 to theFace2.
448 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
449 def AddPreCadFacesPeriodicity(self, theFace1, theFace2, theSourceVertices=[], theTargetVertices=[]):
450 """calls preCad function:
451 status_t cad_add_face_multiple_periodicity_with_transformation_function(cad t *cad,
452 integer *fid1, integer size1, integer *fid2, integer size2,
453 periodicity_transformation_t transf, void *user data);
455 if theSourceVertices and theTargetVertices:
456 self.Parameters().AddPreCadFacesPeriodicityWithVertices(theFace1, theFace2, theSourceVertices, theTargetVertices)
458 self.Parameters().AddPreCadFacesPeriodicity(theFace1, theFace2)
461 ## Defines periodicity between two groups of edges, using PreCAD
462 # @param theEdge1 : GEOM edge (or group, compound) to associate with theEdge2
463 # @param theEdge2 : GEOM edge (or group, compound) associated with theEdge1
464 # @param theSourceVertices (optionnal): list of GEOM vertices on theEdge1 defining the transformation from theEdge1 to theEdge2.
465 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
466 # @param theTargetVertices (optionnal): list of GEOM vertices on theEdge2 defining the transformation from theEdge1 to theEdge2.
467 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
468 def AddPreCadEdgesPeriodicity(self, theEdge1, theEdge2, theSourceVertices=[], theTargetVertices=[]):
469 """calls preCad function:
470 status_t cad_add_edge_multiple_periodicity_with_transformation_function(cad t *cad,
471 integer *eid1, integer size1, integer *eid2, integer size2,
472 periodicity_transformation_t transf, void *user data);
474 if theSourceVertices and theTargetVertices:
475 self.Parameters().AddPreCadEdgesPeriodicityWithVertices(theEdge1, theEdge2, theSourceVertices, theTargetVertices)
477 self.Parameters().AddPreCadEdgesPeriodicity(theEdge1, theEdge2)
481 #-----------------------------------------
482 # Periodicity (BLSURF without PreCAD)
483 #-----------------------------------------
486 ## Defines periodicity between two faces, without using PreCAD.
487 # User has to call AddEdgePeriodicity with the edges of the face,
488 # and AddVertexPeriodicity with the vertices of each edge.
489 # @param theFace1 : GEOM face to associate with theFace2
490 # @param theFace2 : GEOM face associated with theFace1
491 def AddFacePeriodicity(self, theFace1, theFace2):
492 self.Parameters().AddFacePeriodicity(theFace1, theFace2)
495 ## Defines periodicity between two edges belonging to two periodic faces, without using PreCAD.
496 # To be used with AddFacePeriodicity.
497 # User has to call AddVertexPeriodicity with the vertices of each edge
498 # @param theFace1 : GEOM face to associate with theFace2
499 # @param theEdge1 : GEOM edge to associate with theEdge2
500 # @param theFace2 : GEOM face associated with theFace1
501 # @param theEdge2 : GEOM edge associated with theEdge1
502 # @param theEdgeOrientation : -1 (reversed), 0 (unknown) or 1 (forward)
503 def AddEdgePeriodicity(self, theFace1, theEdge1, theFace2, theEdge2, theEdgeOrientation=0):
504 self.Parameters().AddEdgePeriodicity(theFace1, theEdge1, theFace2, theEdge2, theEdgeOrientation)
507 ## Defines periodicity between two edges without face periodicity, without using PreCAD.
508 # User has to call AddVertexPeriodicity with the vertices of each edge.
509 # @param theEdge1 : GEOM edge to associate with theEdge2
510 # @param theEdge2 : GEOM edge associated with theEdge1
511 # @param theEdgeOrientation : -1 (reversed), 0 (unknown) or 1 (forward)
512 def AddEdgePeriodicityWithoutFaces(self, theEdge1, theEdge2, theEdgeOrientation=0):
513 self.Parameters().AddEdgePeriodicityWithoutFaces(theEdge1, theEdge2, theEdgeOrientation)
516 ## Defines periodicity between two vertices.
517 # To be used with AddFacePeriodicity and AddEdgePeriodicity.
518 # @param theEdge1 : GEOM edge to associate with theEdge2
519 # @param theVertex1 : GEOM face to associate with theVertex2
520 # @param theEdge2 : GEOM edge associated with theEdge1
521 # @param theVertex2 : GEOM face associated with theVertex1
522 def AddVertexPeriodicity(self, theEdge1, theVertex1, theEdge2, theVertex2):
523 self.Parameters().AddVertexPeriodicity(theEdge1, theVertex1, theEdge2, theVertex2)
526 ## Define periodicity between two groups of faces, given a transformation function.
527 # This uses the basic BLSURF API for each face, each edge, and each vertex.
528 # @param theFace1 : GEOM face (or group, compound) to associate with theFace2
529 # @param theFace2 : GEOM face (or group, compound) associated with theFace1
530 # @param f_transf : python function defining the transformation between an object of theFace1
531 # into an object of theFace2
532 def AddAdvancedFacesPeriodicity(self, theFace1, theFace2, f_transf):
533 source_faces = self.geompyD.SubShapeAll(theFace1, self.geompyD.ShapeType["FACE"])
537 for source_face in source_faces:
538 self.geompyD.addToStudyInFather(theFace1, source_face, "source_face_%i"%i)
539 p_source = self.geompyD.MakeVertexInsideFace(source_face)
540 p_target = f_transf(p_source)
541 target_face = self.geompyD.GetFaceNearPoint(theFace2, p_target)
542 self.geompyD.addToStudyInFather(theFace2, target_face, "target_face_%i"%i)
543 self.AddFacePeriodicity(source_face, target_face)
546 source_edges = self.geompyD.SubShapeAll(source_face, self.geompyD.ShapeType["EDGE"])
547 for source_edge in source_edges:
548 self.geompyD.addToStudyInFather(theFace1, source_edge, "source_edge_%i"%(j))
549 p_source = self.geompyD.MakeVertexOnCurve(source_edge, 0.5)
550 p_target = f_transf(p_source)
551 target_edge = self.geompyD.GetEdgeNearPoint(theFace2, p_target)
552 self.geompyD.addToStudyInFather(theFace2, target_edge, "target_edge_%i"%(j))
553 self.AddEdgePeriodicity(source_face, source_edge, target_face, target_edge, 1)
556 source_vertices = self.geompyD.SubShapeAll(source_edge, self.geompyD.ShapeType["VERTEX"])
557 for source_vertex in source_vertices:
558 self.geompyD.addToStudyInFather(theFace1, source_vertex, "source_vertex_%i"%(k))
559 target_vertex_tmp = f_transf(source_vertex)
560 target_vertex = self.geompyD.GetSame(theFace2, target_vertex_tmp)
561 self.geompyD.addToStudyInFather(theFace2, target_vertex, "target_vertex_%i"%(k))
562 self.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
566 ## Define periodicity between two groups of edges, without faces, given a transformation function.
567 # This uses the basic BLSURF API for each edge and each vertex.
568 # @param theFace1 : GEOM edge (or group, compound) to associate with theEdge2
569 # @param theFace2 : GEOM edge (or group, compound) associated with theEdge1
570 # @param f_transf : python function defining the transformation between an object of theEdge1
571 # into an object of theFace2
572 def AddAdvancedEdgesPeriodicity(self, theEdge1, theEdge2, f_transf):
573 source_edges = self.geompyD.SubShapeAll(theEdge1, self.geompyD.ShapeType["EDGE"])
576 for source_edge in source_edges:
577 self.geompyD.addToStudyInFather(theEdge1, source_edge, "source_edge_%i"%j)
578 p_source = self.geompyD.MakeVertexOnCurve(source_edge, 0.5)
579 p_target = f_transf(p_source)
580 target_edge = self.geompyD.GetEdgeNearPoint(theEdge2, p_target)
581 self.geompyD.addToStudyInFather(theEdge2, target_edge, "target_edge_%i"%j)
582 self.AddEdgePeriodicityWithoutFaces(source_edge, target_edge)
586 source_vertices = self.geompyD.SubShapeAll(source_edge, self.geompyD.ShapeType["VERTEX"])
587 for source_vertex in source_vertices:
588 self.geompyD.addToStudyInFather(theEdge1, source_vertex, "source_vertex_%i"%k)
589 target_vertex_tmp = f_transf(source_vertex)
590 target_vertex = self.geompyD.GetSame(theEdge2, target_vertex_tmp)
591 self.geompyD.addToStudyInFather(theEdge2, target_vertex, "target_vertex_%i"%k)
592 self.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
597 #=====================
599 #=====================
604 ## Sets lower boundary of mesh element size (PhySize).
605 def SetPhyMin(self, theVal=-1):
607 Obsolete function. Use SetMinSize.
609 print "Warning: SetPhyMin is obsolete. Please use SetMinSize"
610 self.SetMinSize(theVal)
613 ## Sets upper boundary of mesh element size (PhySize).
614 def SetPhyMax(self, theVal=-1):
616 Obsolete function. Use SetMaxSize.
618 print "Warning: SetPhyMax is obsolete. Please use SetMaxSize"
619 self.SetMaxSize(theVal)
622 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
623 def SetAngleMeshS(self, theVal=_geometric_approximation):
625 Obsolete function. Use SetAngleMesh.
627 print "Warning: SetAngleMeshS is obsolete. Please use SetAngleMesh"
628 self.SetAngleMesh(theVal)
631 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
632 def SetAngleMeshC(self, theVal=_geometric_approximation):
634 Obsolete function. Use SetAngleMesh.
636 print "Warning: SetAngleMeshC is obsolete. Please use SetAngleMesh"
637 self.SetAngleMesh(theVal)
640 ## Sets lower boundary of mesh element size computed to respect angular deflection.
641 def SetGeoMin(self, theVal=-1):
643 Obsolete function. Use SetMinSize.
645 print "Warning: SetGeoMin is obsolete. Please use SetMinSize"
646 self.SetMinSize(theVal)
649 ## Sets upper boundary of mesh element size computed to respect angular deflection.
650 def SetGeoMax(self, theVal=-1):
652 Obsolete function. Use SetMaxSize.
654 print "Warning: SetGeoMax is obsolete. Please use SetMaxSize"
655 self.SetMaxSize(theVal)
659 pass # end of BLSURF_Algorithm class