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
25 from salome.smesh.smeshBuilder import AssureGeomPublished
27 # Topology treatment way of BLSURF
28 FromCAD, PreProcess, PreProcessPlus, PreCAD = 0,1,2,3
30 # Element size flag of BLSURF
31 DefaultSize, DefaultGeom, BLSURF_GlobalSize, BLSURF_LocalSize = 0,0,1,2
33 BLSURF_Custom, SizeMap = BLSURF_GlobalSize, BLSURF_LocalSize
36 # import BLSURFPlugin module if possible
44 #----------------------------
45 # Mesh algo type identifiers
46 #----------------------------
48 ## Algorithm type: BLSurf triangle 2D algorithm, see BLSURF_Algorithm
51 #----------------------
53 #----------------------
55 ## BLSurf 2D algorithm.
57 # It can be created by calling smeshBuilder.Mesh.Triangle(smeshBuilder.BLSURF,geom=0)
59 class BLSURF_Algorithm(Mesh_Algorithm):
61 ## name of the dynamic method in smeshBuilder.Mesh class
63 meshMethod = "Triangle"
64 ## type of algorithm used with helper function in smeshBuilder.Mesh class
67 ## doc string of the method
69 docHelper = "Creates triangle 2D algorithm for faces"
71 _anisotropic_ratio = 0
72 _bad_surface_element_aspect_ratio = 1000
73 _geometric_approximation = 22
76 _remove_tiny_edges = 0
78 ## Private constructor.
79 # @param mesh parent mesh object algorithm is assigned to
80 # @param geom geometry (shape/sub-shape) algorithm is assigned to;
81 # if it is @c 0 (default), the algorithm is assigned to the main shape
82 def __init__(self, mesh, geom=0):
83 Mesh_Algorithm.__init__(self)
85 print "Warning: BLSURFPlugin module unavailable"
86 self.Create(mesh, geom, BLSURF, "libBLSURFEngine.so")
88 self.geompyD = mesh.geompyD
89 #self.SetPhysicalMesh() - PAL19680
92 ## Sets a way to define size of mesh elements to generate.
93 # @param thePhysicalMesh is: DefaultSize, BLSURF_Custom or SizeMap.
94 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
95 physical_size_mode = thePhysicalMesh
96 if self.Parameters().GetGeometricMesh() == DefaultGeom:
97 if physical_size_mode == DefaultSize:
98 physical_size_mode = BLSURF_GlobalSize
99 self.Parameters().SetPhysicalMesh(physical_size_mode)
102 ## Sets a way to define maximum angular deflection of mesh from CAD model.
103 # @param theGeometricMesh is: DefaultGeom (0)) or BLSURF_GlobalSize (1))
104 def SetGeometricMesh(self, theGeometricMesh=DefaultGeom):
105 geometric_size_mode = theGeometricMesh
106 if self.Parameters().GetPhysicalMesh() == DefaultSize:
107 if geometric_size_mode == DefaultGeom:
108 geometric_size_mode = BLSURF_GlobalSize
109 self.Parameters().SetGeometricMesh(geometric_size_mode)
112 ## Sets size of mesh elements to generate.
113 # @param theVal : constant global size when using a global physical size.
114 # @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
115 def SetPhySize(self, theVal, isRelative = False):
116 if self.Parameters().GetPhysicalMesh() == DefaultSize:
117 self.SetPhysicalMesh(BLSURF_GlobalSize)
119 self.Parameters().SetPhySizeRel(theVal)
121 self.Parameters().SetPhySize(theVal)
124 ## Sets lower boundary of mesh element size.
125 # @param theVal : global minimal cell size desired.
126 # @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
127 def SetMinSize(self, theVal=-1, isRelative = False):
129 self.Parameters().SetMinSizeRel(theVal)
131 self.Parameters().SetMinSize(theVal)
134 ## Sets upper boundary of mesh element size.
135 # @param theVal : global maximal cell size desired.
136 # @param isRelative : if True, the value is relative to the length of the diagonal of the bounding box
137 def SetMaxSize(self, theVal=-1):
139 self.Parameters().SetMaxSizeRel(theVal)
141 self.Parameters().SetMaxSize(theVal)
144 ## Sets angular deflection (in degrees) from CAD surface.
145 # @param theVal value of angular deflection
146 def SetAngleMesh(self, theVal=_geometric_approximation):
147 if self.Parameters().GetGeometricMesh() == DefaultGeom:
148 self.SetGeometricMesh(BLSURF_GlobalSize)
149 self.Parameters().SetAngleMesh(theVal)
152 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
153 # @param theVal value of maximal length ratio
154 def SetGradation(self, theVal=_gradation):
155 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
156 self.Parameters().SetGradation(theVal)
159 ## Sets topology usage way.
160 # @param way defines how mesh conformity is assured <ul>
161 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
162 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model (OBSOLETE: FromCAD will be used)</li>
163 # <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
164 def SetTopology(self, way):
166 print "Warning: topology mode %d is no longer supported. Mode FromCAD is used."%way
168 self.Parameters().SetTopology(way)
171 ## To respect geometrical edges or not.
172 # @param toIgnoreEdges "ignore edges" flag value
173 def SetDecimesh(self, toIgnoreEdges=False):
175 self.SetOptionValue("respect_geometry","0")
177 self.SetOptionValue("respect_geometry","1")
180 ## Sets verbosity level in the range 0 to 100.
181 # @param level verbosity level
182 def SetVerbosity(self, level):
183 self.Parameters().SetVerbosity(level)
186 ## To optimize merges edges.
187 # @param toMergeEdges "merge edges" flag value
188 def SetPreCADMergeEdges(self, toMergeEdges=False):
189 if self.Parameters().GetTopology() != PreCAD:
190 self.SetTopology(PreCAD)
191 self.Parameters().SetPreCADMergeEdges(toMergeEdges)
194 ## To process 3D topology.
195 # @param toProcess "PreCAD process 3D" flag value
196 def SetPreCADProcess3DTopology(self, toProcess=False):
197 if self.Parameters().GetTopology() != PreCAD:
198 self.SetTopology(PreCAD)
199 self.Parameters().SetPreCADProcess3DTopology(toProcess)
202 ## To remove nano edges.
203 # @param toRemoveNanoEdges "remove nano edges" flag value
204 def SetPreCADRemoveNanoEdges(self, toRemoveNanoEdges=False):
205 if toRemoveNanoEdges:
206 self.SetPreCADOptionValue("remove_tiny_edges","1")
208 self.SetPreCADOptionValue("remove_tiny_edges","0")
211 ## To compute topology from scratch
212 # @param toDiscardInput "discard input" flag value
213 def SetPreCADDiscardInput(self, toDiscardInput=False):
214 if self.Parameters().GetTopology() != PreCAD:
215 self.SetTopology(PreCAD)
216 self.Parameters().SetPreCADDiscardInput(toDiscardInput)
219 ## Sets the length below which an edge is considered as nano
220 # for the topology processing.
221 # @param epsNano nano edge length threshold value
222 def SetPreCADEpsNano(self, epsNano):
223 self.SetPreCADOptionValue("tiny_edge_length","%f"%epsNano)
226 ## Sets advanced option value.
227 # @param optionName advanced option name
228 # @param level advanced option value
229 def SetOptionValue(self, optionName, level):
230 self.Parameters().SetOptionValue(optionName,level)
233 ## Sets advanced PreCAD option value.
234 # @param optionName name of the option
235 # @param optionValue value of the option
236 def SetPreCADOptionValue(self, optionName, optionValue):
237 if self.Parameters().GetTopology() != PreCAD:
238 self.SetTopology(PreCAD)
239 self.Parameters().SetPreCADOptionValue(optionName,optionValue)
242 ## Sets GMF file for export at computation
243 # @param fileName GMF file name
244 def SetGMFFile(self, fileName):
245 self.Parameters().SetGMFFile(fileName)
248 #-----------------------------------------
249 # Enforced vertices (BLSURF)
250 #-----------------------------------------
252 ## To get all the enforced vertices
253 def GetAllEnforcedVertices(self):
254 return self.Parameters().GetAllEnforcedVertices()
256 ## To get all the enforced vertices sorted by face (or group, compound)
257 def GetAllEnforcedVerticesByFace(self):
258 return self.Parameters().GetAllEnforcedVerticesByFace()
260 ## To get all the enforced vertices sorted by coords of input vertices
261 def GetAllEnforcedVerticesByCoords(self):
262 return self.Parameters().GetAllEnforcedVerticesByCoords()
264 ## To get all the coords of input vertices sorted by face (or group, compound)
265 def GetAllCoordsByFace(self):
266 return self.Parameters().GetAllCoordsByFace()
268 ## To get all the enforced vertices on a face (or group, compound)
269 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
270 def GetEnforcedVertices(self, theFace):
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 AssureGeomPublished( self.mesh, theFace )
289 return self.Parameters().SetEnforcedVertex(theFace, x, y, z)
291 return self.Parameters().SetEnforcedVertexWithGroup(theFace, x, y, z, groupName)
295 return self.Parameters().SetEnforcedVertexNamed(theFace, x, y, z, vertexName)
297 return self.Parameters().SetEnforcedVertexNamedWithGroup(theFace, x, y, z, vertexName, groupName)
301 ## To set an enforced vertex on a face (or group, compound) given a GEOM vertex, group or compound.
302 # @param theFace : GEOM face (or group, compound) on which to define an enforced vertex
303 # @param theVertex : GEOM vertex (or group, compound) to be projected on theFace.
304 # @param groupName : name of the group
305 def SetEnforcedVertexGeom(self, theFace, theVertex, groupName = ""):
306 AssureGeomPublished( self.mesh, theFace )
307 AssureGeomPublished( self.mesh, theVertex )
309 return self.Parameters().SetEnforcedVertexGeom(theFace, theVertex)
311 return self.Parameters().SetEnforcedVertexGeomWithGroup(theFace, theVertex,groupName)
314 ## To remove an enforced vertex on a given GEOM face (or group, compound) given the coordinates.
315 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
316 # @param x : x coordinate
317 # @param y : y coordinate
318 # @param z : z coordinate
319 def UnsetEnforcedVertex(self, theFace, x, y, z):
320 AssureGeomPublished( self.mesh, theFace )
321 return self.Parameters().UnsetEnforcedVertex(theFace, x, y, z)
323 ## To remove an enforced vertex on a given GEOM face (or group, compound) given a GEOM vertex, group or compound.
324 # @param theFace : GEOM face (or group, compound) on which to remove the enforced vertex
325 # @param theVertex : GEOM vertex (or group, compound) to remove.
326 def UnsetEnforcedVertexGeom(self, theFace, theVertex):
327 AssureGeomPublished( self.mesh, theFace )
328 AssureGeomPublished( self.mesh, theVertex )
329 return self.Parameters().UnsetEnforcedVertexGeom(theFace, theVertex)
331 ## To remove all enforced vertices on a given face.
332 # @param theFace : face (or group/compound of faces) on which to remove all enforced vertices
333 def UnsetEnforcedVertices(self, theFace):
334 AssureGeomPublished( self.mesh, theFace )
335 return self.Parameters().UnsetEnforcedVertices(theFace)
337 ## To tell BLSURF to add a node on internal vertices
338 # @param toEnforceInternalVertices : boolean; if True the internal vertices are added as enforced vertices
339 def SetInternalEnforcedVertexAllFaces(self, toEnforceInternalVertices):
340 return self.Parameters().SetInternalEnforcedVertexAllFaces(toEnforceInternalVertices)
342 ## To know if BLSURF will add a node on internal vertices
343 def GetInternalEnforcedVertexAllFaces(self):
344 return self.Parameters().GetInternalEnforcedVertexAllFaces()
346 ## To define a group for the nodes of internal vertices
347 # @param groupName : string; name of the group
348 def SetInternalEnforcedVertexAllFacesGroup(self, groupName):
349 return self.Parameters().SetInternalEnforcedVertexAllFacesGroup(groupName)
351 ## To get the group name of the nodes of internal vertices
352 def GetInternalEnforcedVertexAllFacesGroup(self):
353 return self.Parameters().GetInternalEnforcedVertexAllFacesGroup()
355 #-----------------------------------------
357 #-----------------------------------------
359 ## 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 ]
360 # @param theFace : face on which the attractor will be defined
361 # @param theAttractor : geometrical object from which the mesh size "h" decreases exponentially
362 # @param theStartSize : mesh size on theAttractor
363 # @param theEndSize : maximum size that will be reached on theFace
364 # @param theInfluenceDistance : influence of the attractor ( the size grow slower on theFace if it's high)
365 # @param theConstantSizeDistance : distance until which the mesh size will be kept constant on theFace
366 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
367 AssureGeomPublished( self.mesh, theFace )
368 AssureGeomPublished( self.mesh, theAttractor )
369 self.Parameters().SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
372 ## Unsets an attractor on the chosen face.
373 # @param theFace : face on which the attractor has to be removed
374 def UnsetAttractorGeom(self, theFace):
375 AssureGeomPublished( self.mesh, theFace )
376 self.Parameters().SetAttractorGeom(theFace)
379 #-----------------------------------------
381 #-----------------------------------------
383 ## To set a size map on a face, edge or vertex (or group, compound) given Python function.
384 # If theObject is a face, the function can be: def f(u,v): return u+v
385 # If theObject is an edge, the function can be: def f(t): return t/2
386 # If theObject is a vertex, the function can be: def f(): return 10
387 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
388 # @param theSizeMap : Size map defined as a string
389 def SetSizeMap(self, theObject, theSizeMap):
390 AssureGeomPublished( self.mesh, theObject )
391 self.Parameters().SetSizeMap(theObject, theSizeMap)
394 ## To set a constant size map on a face, edge or vertex (or group, compound).
395 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
396 # @param theSizeMap : Size map defined as a double
397 def SetConstantSizeMap(self, theObject, theSizeMap):
398 AssureGeomPublished( self.mesh, theObject )
399 self.Parameters().SetConstantSizeMap(theObject, theSizeMap)
401 ## To remove a size map defined on a face, edge or vertex (or group, compound)
402 # @param theObject : GEOM face, edge or vertex (or group, compound) on which to define a size map
403 def UnsetSizeMap(self, theObject):
404 AssureGeomPublished( self.mesh, theObject )
405 self.Parameters().UnsetSizeMap(theObject)
408 ## To remove all the size maps
409 def ClearSizeMaps(self):
410 self.Parameters().ClearSizeMaps()
413 ## Sets QuadAllowed flag.
414 # @param toAllow "allow quadrangles" flag value
415 def SetQuadAllowed(self, toAllow=True):
416 self.Parameters().SetQuadAllowed(toAllow)
419 ## Defines hypothesis having several parameters
420 # @return hypothesis object
421 def Parameters(self):
423 self.params = self.Hypothesis("BLSURF_Parameters", [],
424 "libBLSURFEngine.so", UseExisting=0)
428 #-----------------------------------------
429 # Periodicity (BLSURF with PreCAD)
430 #-----------------------------------------
432 ## Defines periodicity between two groups of faces, using PreCAD
433 # @param theFace1 : GEOM face (or group, compound) to associate with theFace2
434 # @param theFace2 : GEOM face (or group, compound) associated with theFace1
435 # @param theSourceVertices (optionnal): list of GEOM vertices on theFace1 defining the transformation from theFace1 to theFace2.
436 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
437 # @param theTargetVertices (optionnal): list of GEOM vertices on theFace2 defining the transformation from theFace1 to theFace2.
438 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
439 def AddPreCadFacesPeriodicity(self, theFace1, theFace2, theSourceVertices=[], theTargetVertices=[]):
440 """calls preCad function:
441 status_t cad_add_face_multiple_periodicity_with_transformation_function(cad t *cad,
442 integer *fid1, integer size1, integer *fid2, integer size2,
443 periodicity_transformation_t transf, void *user data);
445 if theSourceVertices and theTargetVertices:
446 self.Parameters().AddPreCadFacesPeriodicityWithVertices(theFace1, theFace2, theSourceVertices, theTargetVertices)
448 self.Parameters().AddPreCadFacesPeriodicity(theFace1, theFace2)
451 ## Defines periodicity between two groups of edges, using PreCAD
452 # @param theEdge1 : GEOM edge (or group, compound) to associate with theEdge2
453 # @param theEdge2 : GEOM edge (or group, compound) associated with theEdge1
454 # @param theSourceVertices (optionnal): list of GEOM vertices on theEdge1 defining the transformation from theEdge1 to theEdge2.
455 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
456 # @param theTargetVertices (optionnal): list of GEOM vertices on theEdge2 defining the transformation from theEdge1 to theEdge2.
457 # If None, PreCAD tries to find a simple translation. Else, need at least 3 not aligned vertices.
458 def AddPreCadEdgesPeriodicity(self, theEdge1, theEdge2, theSourceVertices=[], theTargetVertices=[]):
459 """calls preCad function:
460 status_t cad_add_edge_multiple_periodicity_with_transformation_function(cad t *cad,
461 integer *eid1, integer size1, integer *eid2, integer size2,
462 periodicity_transformation_t transf, void *user data);
464 if theSourceVertices and theTargetVertices:
465 self.Parameters().AddPreCadEdgesPeriodicityWithVertices(theEdge1, theEdge2, theSourceVertices, theTargetVertices)
467 self.Parameters().AddPreCadEdgesPeriodicity(theEdge1, theEdge2)
471 #-----------------------------------------
472 # Periodicity (BLSURF without PreCAD)
473 #-----------------------------------------
476 ## Defines periodicity between two faces, without using PreCAD.
477 # User has to call AddEdgePeriodicity with the edges of the face,
478 # and AddVertexPeriodicity with the vertices of each edge.
479 # @param theFace1 : GEOM face to associate with theFace2
480 # @param theFace2 : GEOM face associated with theFace1
481 def AddFacePeriodicity(self, theFace1, theFace2):
482 self.Parameters().AddFacePeriodicity(theFace1, theFace2)
485 ## Defines periodicity between two edges belonging to two periodic faces, without using PreCAD.
486 # To be used with AddFacePeriodicity.
487 # User has to call AddVertexPeriodicity with the vertices of each edge
488 # @param theFace1 : GEOM face to associate with theFace2
489 # @param theEdge1 : GEOM edge to associate with theEdge2
490 # @param theFace2 : GEOM face associated with theFace1
491 # @param theEdge2 : GEOM edge associated with theEdge1
492 # @param theEdgeOrientation : -1 (reversed), 0 (unknown) or 1 (forward)
493 def AddEdgePeriodicity(self, theFace1, theEdge1, theFace2, theEdge2, theEdgeOrientation=0):
494 self.Parameters().AddEdgePeriodicity(theFace1, theEdge1, theFace2, theEdge2, theEdgeOrientation)
497 ## Defines periodicity between two edges without face periodicity, without using PreCAD.
498 # User has to call AddVertexPeriodicity with the vertices of each edge.
499 # @param theEdge1 : GEOM edge to associate with theEdge2
500 # @param theEdge2 : GEOM edge associated with theEdge1
501 # @param theEdgeOrientation : -1 (reversed), 0 (unknown) or 1 (forward)
502 def AddEdgePeriodicityWithoutFaces(self, theEdge1, theEdge2, theEdgeOrientation=0):
503 self.Parameters().AddEdgePeriodicityWithoutFaces(theEdge1, theEdge2, theEdgeOrientation)
506 ## Defines periodicity between two vertices.
507 # To be used with AddFacePeriodicity and AddEdgePeriodicity.
508 # @param theEdge1 : GEOM edge to associate with theEdge2
509 # @param theVertex1 : GEOM face to associate with theVertex2
510 # @param theEdge2 : GEOM edge associated with theEdge1
511 # @param theVertex2 : GEOM face associated with theVertex1
512 def AddVertexPeriodicity(self, theEdge1, theVertex1, theEdge2, theVertex2):
513 self.Parameters().AddVertexPeriodicity(theEdge1, theVertex1, theEdge2, theVertex2)
516 ## Define periodicity between two groups of faces, given a transformation function.
517 # This uses the basic BLSURF API for each face, each edge, and each vertex.
518 # @param theFace1 : GEOM face (or group, compound) to associate with theFace2
519 # @param theFace2 : GEOM face (or group, compound) associated with theFace1
520 # @param f_transf : python function defining the transformation between an object of theFace1
521 # into an object of theFace2
522 def AddAdvancedFacesPeriodicity(self, theFace1, theFace2, f_transf):
523 source_faces = self.geompyD.SubShapeAll(theFace1, self.geompyD.ShapeType["FACE"])
527 for source_face in source_faces:
528 self.geompyD.addToStudyInFather(theFace1, source_face, "source_face_%i"%i)
529 p_source = self.geompyD.MakeVertexInsideFace(source_face)
530 p_target = f_transf(p_source)
531 target_face = self.geompyD.GetFaceNearPoint(theFace2, p_target)
532 self.geompyD.addToStudyInFather(theFace2, target_face, "target_face_%i"%i)
533 self.AddFacePeriodicity(source_face, target_face)
536 source_edges = self.geompyD.SubShapeAll(source_face, self.geompyD.ShapeType["EDGE"])
537 for source_edge in source_edges:
538 self.geompyD.addToStudyInFather(theFace1, source_edge, "source_edge_%i"%(j))
539 p_source = self.geompyD.MakeVertexOnCurve(source_edge, 0.5)
540 p_target = f_transf(p_source)
541 target_edge = self.geompyD.GetEdgeNearPoint(theFace2, p_target)
542 self.geompyD.addToStudyInFather(theFace2, target_edge, "target_edge_%i"%(j))
543 self.AddEdgePeriodicity(source_face, source_edge, target_face, target_edge, 1)
546 source_vertices = self.geompyD.SubShapeAll(source_edge, self.geompyD.ShapeType["VERTEX"])
547 for source_vertex in source_vertices:
548 self.geompyD.addToStudyInFather(theFace1, source_vertex, "source_vertex_%i"%(k))
549 target_vertex_tmp = f_transf(source_vertex)
550 target_vertex = self.geompyD.GetSame(theFace2, target_vertex_tmp)
551 self.geompyD.addToStudyInFather(theFace2, target_vertex, "target_vertex_%i"%(k))
552 self.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
556 ## Define periodicity between two groups of edges, without faces, given a transformation function.
557 # This uses the basic BLSURF API for each edge and each vertex.
558 # @param theFace1 : GEOM edge (or group, compound) to associate with theEdge2
559 # @param theFace2 : GEOM edge (or group, compound) associated with theEdge1
560 # @param f_transf : python function defining the transformation between an object of theEdge1
561 # into an object of theFace2
562 def AddAdvancedEdgesPeriodicity(self, theEdge1, theEdge2, f_transf):
563 source_edges = self.geompyD.SubShapeAll(theEdge1, self.geompyD.ShapeType["EDGE"])
566 for source_edge in source_edges:
567 self.geompyD.addToStudyInFather(theEdge1, source_edge, "source_edge_%i"%j)
568 p_source = self.geompyD.MakeVertexOnCurve(source_edge, 0.5)
569 p_target = f_transf(p_source)
570 target_edge = self.geompyD.GetEdgeNearPoint(theEdge2, p_target)
571 self.geompyD.addToStudyInFather(theEdge2, target_edge, "target_edge_%i"%j)
572 self.AddEdgePeriodicityWithoutFaces(source_edge, target_edge)
576 source_vertices = self.geompyD.SubShapeAll(source_edge, self.geompyD.ShapeType["VERTEX"])
577 for source_vertex in source_vertices:
578 self.geompyD.addToStudyInFather(theEdge1, source_vertex, "source_vertex_%i"%k)
579 target_vertex_tmp = f_transf(source_vertex)
580 target_vertex = self.geompyD.GetSame(theEdge2, target_vertex_tmp)
581 self.geompyD.addToStudyInFather(theEdge2, target_vertex, "target_vertex_%i"%k)
582 self.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex)
587 #=====================
589 #=====================
594 ## Sets lower boundary of mesh element size (PhySize).
595 def SetPhyMin(self, theVal=-1):
597 Obsolete function. Use SetMinSize.
599 print "Warning: SetPhyMin is obsolete. Please use SetMinSize"
600 self.SetMinSize(theVal)
603 ## Sets upper boundary of mesh element size (PhySize).
604 def SetPhyMax(self, theVal=-1):
606 Obsolete function. Use SetMaxSize.
608 print "Warning: SetPhyMax is obsolete. Please use SetMaxSize"
609 self.SetMaxSize(theVal)
612 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
613 def SetAngleMeshS(self, theVal=_geometric_approximation):
615 Obsolete function. Use SetAngleMesh.
617 print "Warning: SetAngleMeshS is obsolete. Please use SetAngleMesh"
618 self.SetAngleMesh(theVal)
621 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
622 def SetAngleMeshC(self, theVal=_geometric_approximation):
624 Obsolete function. Use SetAngleMesh.
626 print "Warning: SetAngleMeshC is obsolete. Please use SetAngleMesh"
627 self.SetAngleMesh(theVal)
630 ## Sets lower boundary of mesh element size computed to respect angular deflection.
631 def SetGeoMin(self, theVal=-1):
633 Obsolete function. Use SetMinSize.
635 print "Warning: SetGeoMin is obsolete. Please use SetMinSize"
636 self.SetMinSize(theVal)
639 ## Sets upper boundary of mesh element size computed to respect angular deflection.
640 def SetGeoMax(self, theVal=-1):
642 Obsolete function. Use SetMaxSize.
644 print "Warning: SetGeoMax is obsolete. Please use SetMaxSize"
645 self.SetMaxSize(theVal)
649 pass # end of BLSURF_Algorithm class