1 # Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author : Francis KLOSS, OCC
29 ## @defgroup l1_auxiliary Auxiliary methods and structures
30 ## @defgroup l1_creating Creating meshes
32 ## @defgroup l2_impexp Importing and exporting meshes
33 ## @defgroup l2_construct Constructing meshes
34 ## @defgroup l2_algorithms Defining Algorithms
36 ## @defgroup l3_algos_basic Basic meshing algorithms
37 ## @defgroup l3_algos_proj Projection Algorithms
38 ## @defgroup l3_algos_radialp Radial Prism
39 ## @defgroup l3_algos_segmarv Segments around Vertex
40 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
43 ## @defgroup l2_hypotheses Defining hypotheses
45 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
46 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
47 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
48 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
49 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
50 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
51 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
52 ## @defgroup l3_hypos_additi Additional Hypotheses
55 ## @defgroup l2_submeshes Constructing submeshes
56 ## @defgroup l2_compounds Building Compounds
57 ## @defgroup l2_editing Editing Meshes
60 ## @defgroup l1_meshinfo Mesh Information
61 ## @defgroup l1_controls Quality controls and Filtering
62 ## @defgroup l1_grouping Grouping elements
64 ## @defgroup l2_grps_create Creating groups
65 ## @defgroup l2_grps_edit Editing groups
66 ## @defgroup l2_grps_operon Using operations on groups
67 ## @defgroup l2_grps_delete Deleting Groups
70 ## @defgroup l1_modifying Modifying meshes
72 ## @defgroup l2_modif_add Adding nodes and elements
73 ## @defgroup l2_modif_del Removing nodes and elements
74 ## @defgroup l2_modif_edit Modifying nodes and elements
75 ## @defgroup l2_modif_renumber Renumbering nodes and elements
76 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
77 ## @defgroup l2_modif_movenode Moving nodes
78 ## @defgroup l2_modif_throughp Mesh through point
79 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
80 ## @defgroup l2_modif_unitetri Uniting triangles
81 ## @defgroup l2_modif_changori Changing orientation of elements
82 ## @defgroup l2_modif_cutquadr Cutting quadrangles
83 ## @defgroup l2_modif_smooth Smoothing
84 ## @defgroup l2_modif_extrurev Extrusion and Revolution
85 ## @defgroup l2_modif_patterns Pattern mapping
86 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
93 import SMESH # This is necessary for back compatibility
100 # import NETGENPlugin module if possible
108 ## @addtogroup l1_auxiliary
111 # Types of algorithms
124 NETGEN_1D2D3D = FULL_NETGEN
125 NETGEN_FULL = FULL_NETGEN
130 # MirrorType enumeration
131 POINT = SMESH_MeshEditor.POINT
132 AXIS = SMESH_MeshEditor.AXIS
133 PLANE = SMESH_MeshEditor.PLANE
135 # Smooth_Method enumeration
136 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
137 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
139 # Fineness enumeration (for NETGEN)
147 # Optimization level of GHS3D
148 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
150 # Topology treatment way of BLSURF
151 FromCAD, PreProcess, PreProcessPlus = 0,1,2
153 # Element size flag of BLSURF
154 DefaultSize, DefaultGeom, Custom = 0,0,1
156 PrecisionConfusion = 1e-07
158 def IsEqual(val1, val2, tol=PrecisionConfusion):
159 if abs(val1 - val2) < tol:
167 ior = salome.orb.object_to_string(obj)
168 sobj = salome.myStudy.FindObjectIOR(ior)
172 attr = sobj.FindAttribute("AttributeName")[1]
175 ## Sets a name to the object
176 def SetName(obj, name):
177 if isinstance( obj, Mesh ):
179 elif isinstance( obj, Mesh_Algorithm ):
180 obj = obj.GetAlgorithm()
181 ior = salome.orb.object_to_string(obj)
182 sobj = salome.myStudy.FindObjectIOR(ior)
184 attr = sobj.FindAttribute("AttributeName")[1]
187 ## Prints error message if a hypothesis was not assigned.
188 def TreatHypoStatus(status, hypName, geomName, isAlgo):
190 hypType = "algorithm"
192 hypType = "hypothesis"
194 if status == HYP_UNKNOWN_FATAL :
195 reason = "for unknown reason"
196 elif status == HYP_INCOMPATIBLE :
197 reason = "this hypothesis mismatches the algorithm"
198 elif status == HYP_NOTCONFORM :
199 reason = "a non-conform mesh would be built"
200 elif status == HYP_ALREADY_EXIST :
201 reason = hypType + " of the same dimension is already assigned to this shape"
202 elif status == HYP_BAD_DIM :
203 reason = hypType + " mismatches the shape"
204 elif status == HYP_CONCURENT :
205 reason = "there are concurrent hypotheses on sub-shapes"
206 elif status == HYP_BAD_SUBSHAPE :
207 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
208 elif status == HYP_BAD_GEOMETRY:
209 reason = "geometry mismatches the expectation of the algorithm"
210 elif status == HYP_HIDDEN_ALGO:
211 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
212 elif status == HYP_HIDING_ALGO:
213 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
214 elif status == HYP_NEED_SHAPE:
215 reason = "Algorithm can't work without shape"
218 hypName = '"' + hypName + '"'
219 geomName= '"' + geomName+ '"'
220 if status < HYP_UNKNOWN_FATAL:
221 print hypName, "was assigned to", geomName,"but", reason
223 print hypName, "was not assigned to",geomName,":", reason
226 ## Converts an angle from degrees to radians
227 def DegreesToRadians(AngleInDegrees):
229 return AngleInDegrees * pi / 180.0
231 # end of l1_auxiliary
234 # All methods of this class are accessible directly from the smesh.py package.
235 class smeshDC(SMESH._objref_SMESH_Gen):
237 ## Sets the current study and Geometry component
238 # @ingroup l1_auxiliary
239 def init_smesh(self,theStudy,geompyD):
240 self.SetCurrentStudy(theStudy,geompyD)
242 ## Creates an empty Mesh. This mesh can have an underlying geometry.
243 # @param obj the Geometrical object on which the mesh is built. If not defined,
244 # the mesh will have no underlying geometry.
245 # @param name the name for the new mesh.
246 # @return an instance of Mesh class.
247 # @ingroup l2_construct
248 def Mesh(self, obj=0, name=0):
249 return Mesh(self,self.geompyD,obj,name)
251 ## Returns a long value from enumeration
252 # Should be used for SMESH.FunctorType enumeration
253 # @ingroup l1_controls
254 def EnumToLong(self,theItem):
257 ## Gets PointStruct from vertex
258 # @param theVertex a GEOM object(vertex)
259 # @return SMESH.PointStruct
260 # @ingroup l1_auxiliary
261 def GetPointStruct(self,theVertex):
262 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
263 return PointStruct(x,y,z)
265 ## Gets DirStruct from vector
266 # @param theVector a GEOM object(vector)
267 # @return SMESH.DirStruct
268 # @ingroup l1_auxiliary
269 def GetDirStruct(self,theVector):
270 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
271 if(len(vertices) != 2):
272 print "Error: vector object is incorrect."
274 p1 = self.geompyD.PointCoordinates(vertices[0])
275 p2 = self.geompyD.PointCoordinates(vertices[1])
276 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
277 dirst = DirStruct(pnt)
280 ## Makes DirStruct from a triplet
281 # @param x,y,z vector components
282 # @return SMESH.DirStruct
283 # @ingroup l1_auxiliary
284 def MakeDirStruct(self,x,y,z):
285 pnt = PointStruct(x,y,z)
286 return DirStruct(pnt)
288 ## Get AxisStruct from object
289 # @param theObj a GEOM object (line or plane)
290 # @return SMESH.AxisStruct
291 # @ingroup l1_auxiliary
292 def GetAxisStruct(self,theObj):
293 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
295 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
296 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
297 vertex1 = self.geompyD.PointCoordinates(vertex1)
298 vertex2 = self.geompyD.PointCoordinates(vertex2)
299 vertex3 = self.geompyD.PointCoordinates(vertex3)
300 vertex4 = self.geompyD.PointCoordinates(vertex4)
301 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
302 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
303 normal = [ v1[1]*v2[2]-v2[1]*v1[2], v1[2]*v2[0]-v2[2]*v1[0], v1[0]*v2[1]-v2[0]*v1[1] ]
304 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
306 elif len(edges) == 1:
307 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
308 p1 = self.geompyD.PointCoordinates( vertex1 )
309 p2 = self.geompyD.PointCoordinates( vertex2 )
310 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
314 # From SMESH_Gen interface:
315 # ------------------------
317 ## Sets the current mode
318 # @ingroup l1_auxiliary
319 def SetEmbeddedMode( self,theMode ):
320 #self.SetEmbeddedMode(theMode)
321 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
323 ## Gets the current mode
324 # @ingroup l1_auxiliary
325 def IsEmbeddedMode(self):
326 #return self.IsEmbeddedMode()
327 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
329 ## Sets the current study
330 # @ingroup l1_auxiliary
331 def SetCurrentStudy( self, theStudy, geompyD = None ):
332 #self.SetCurrentStudy(theStudy)
335 geompyD = geompy.geom
338 self.SetGeomEngine(geompyD)
339 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
341 ## Gets the current study
342 # @ingroup l1_auxiliary
343 def GetCurrentStudy(self):
344 #return self.GetCurrentStudy()
345 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
347 ## Creates a Mesh object importing data from the given UNV file
348 # @return an instance of Mesh class
350 def CreateMeshesFromUNV( self,theFileName ):
351 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
352 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
355 ## Creates a Mesh object(s) importing data from the given MED file
356 # @return a list of Mesh class instances
358 def CreateMeshesFromMED( self,theFileName ):
359 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
361 for iMesh in range(len(aSmeshMeshes)) :
362 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
363 aMeshes.append(aMesh)
364 return aMeshes, aStatus
366 ## Creates a Mesh object importing data from the given STL file
367 # @return an instance of Mesh class
369 def CreateMeshesFromSTL( self, theFileName ):
370 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
371 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
374 ## Concatenate the given meshes into one mesh.
375 # @return an instance of Mesh class
376 # @param meshes the meshes to combine into one mesh
377 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
378 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
379 # @param mergeTolerance tolerance for merging nodes
380 # @param allGroups forces creation of groups of all elements
381 def Concatenate( self, meshes, uniteIdenticalGroups,
382 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
384 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
385 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
387 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
388 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
389 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
392 ## From SMESH_Gen interface
393 # @return the list of integer values
394 # @ingroup l1_auxiliary
395 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
396 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
398 ## From SMESH_Gen interface. Creates a pattern
399 # @return an instance of SMESH_Pattern
401 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
402 # @ingroup l2_modif_patterns
403 def GetPattern(self):
404 return SMESH._objref_SMESH_Gen.GetPattern(self)
407 # Filtering. Auxiliary functions:
408 # ------------------------------
410 ## Creates an empty criterion
411 # @return SMESH.Filter.Criterion
412 # @ingroup l1_controls
413 def GetEmptyCriterion(self):
414 Type = self.EnumToLong(FT_Undefined)
415 Compare = self.EnumToLong(FT_Undefined)
419 UnaryOp = self.EnumToLong(FT_Undefined)
420 BinaryOp = self.EnumToLong(FT_Undefined)
423 Precision = -1 ##@1e-07
424 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
425 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
427 ## Creates a criterion by the given parameters
428 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
429 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
430 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
431 # @param Treshold the threshold value (range of ids as string, shape, numeric)
432 # @param UnaryOp FT_LogicalNOT or FT_Undefined
433 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
434 # FT_Undefined (must be for the last criterion of all criteria)
435 # @return SMESH.Filter.Criterion
436 # @ingroup l1_controls
437 def GetCriterion(self,elementType,
439 Compare = FT_EqualTo,
441 UnaryOp=FT_Undefined,
442 BinaryOp=FT_Undefined):
443 aCriterion = self.GetEmptyCriterion()
444 aCriterion.TypeOfElement = elementType
445 aCriterion.Type = self.EnumToLong(CritType)
449 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
450 aCriterion.Compare = self.EnumToLong(Compare)
451 elif Compare == "=" or Compare == "==":
452 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
454 aCriterion.Compare = self.EnumToLong(FT_LessThan)
456 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
458 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
461 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
462 FT_BelongToCylinder, FT_LyingOnGeom]:
463 # Checks the treshold
464 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
465 aCriterion.ThresholdStr = GetName(aTreshold)
466 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
468 print "Error: The treshold should be a shape."
470 elif CritType == FT_RangeOfIds:
471 # Checks the treshold
472 if isinstance(aTreshold, str):
473 aCriterion.ThresholdStr = aTreshold
475 print "Error: The treshold should be a string."
477 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
478 # At this point the treshold is unnecessary
479 if aTreshold == FT_LogicalNOT:
480 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
481 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
482 aCriterion.BinaryOp = aTreshold
486 aTreshold = float(aTreshold)
487 aCriterion.Threshold = aTreshold
489 print "Error: The treshold should be a number."
492 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
493 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
495 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
496 aCriterion.BinaryOp = self.EnumToLong(Treshold)
498 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
499 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
501 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
502 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
506 ## Creates a filter with the given parameters
507 # @param elementType the type of elements in the group
508 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
509 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
510 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
511 # @param UnaryOp FT_LogicalNOT or FT_Undefined
512 # @return SMESH_Filter
513 # @ingroup l1_controls
514 def GetFilter(self,elementType,
515 CritType=FT_Undefined,
518 UnaryOp=FT_Undefined):
519 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
520 aFilterMgr = self.CreateFilterManager()
521 aFilter = aFilterMgr.CreateFilter()
523 aCriteria.append(aCriterion)
524 aFilter.SetCriteria(aCriteria)
527 ## Creates a numerical functor by its type
528 # @param theCriterion FT_...; functor type
529 # @return SMESH_NumericalFunctor
530 # @ingroup l1_controls
531 def GetFunctor(self,theCriterion):
532 aFilterMgr = self.CreateFilterManager()
533 if theCriterion == FT_AspectRatio:
534 return aFilterMgr.CreateAspectRatio()
535 elif theCriterion == FT_AspectRatio3D:
536 return aFilterMgr.CreateAspectRatio3D()
537 elif theCriterion == FT_Warping:
538 return aFilterMgr.CreateWarping()
539 elif theCriterion == FT_MinimumAngle:
540 return aFilterMgr.CreateMinimumAngle()
541 elif theCriterion == FT_Taper:
542 return aFilterMgr.CreateTaper()
543 elif theCriterion == FT_Skew:
544 return aFilterMgr.CreateSkew()
545 elif theCriterion == FT_Area:
546 return aFilterMgr.CreateArea()
547 elif theCriterion == FT_Volume3D:
548 return aFilterMgr.CreateVolume3D()
549 elif theCriterion == FT_MultiConnection:
550 return aFilterMgr.CreateMultiConnection()
551 elif theCriterion == FT_MultiConnection2D:
552 return aFilterMgr.CreateMultiConnection2D()
553 elif theCriterion == FT_Length:
554 return aFilterMgr.CreateLength()
555 elif theCriterion == FT_Length2D:
556 return aFilterMgr.CreateLength2D()
558 print "Error: given parameter is not numerucal functor type."
562 #Registering the new proxy for SMESH_Gen
563 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
569 ## This class allows defining and managing a mesh.
570 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
571 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
572 # new nodes and elements and by changing the existing entities), to get information
573 # about a mesh and to export a mesh into different formats.
582 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
583 # sets the GUI name of this mesh to \a name.
584 # @param smeshpyD an instance of smeshDC class
585 # @param geompyD an instance of geompyDC class
586 # @param obj Shape to be meshed or SMESH_Mesh object
587 # @param name Study name of the mesh
588 # @ingroup l2_construct
589 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
590 self.smeshpyD=smeshpyD
595 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
597 self.mesh = self.smeshpyD.CreateMesh(self.geom)
598 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
601 self.mesh = self.smeshpyD.CreateEmptyMesh()
603 SetName(self.mesh, name)
605 SetName(self.mesh, GetName(obj))
608 self.geom = self.mesh.GetShapeToMesh()
610 self.editor = self.mesh.GetMeshEditor()
612 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
613 # @param theMesh a SMESH_Mesh object
614 # @ingroup l2_construct
615 def SetMesh(self, theMesh):
617 self.geom = self.mesh.GetShapeToMesh()
619 ## Returns the mesh, that is an instance of SMESH_Mesh interface
620 # @return a SMESH_Mesh object
621 # @ingroup l2_construct
625 ## Gets the name of the mesh
626 # @return the name of the mesh as a string
627 # @ingroup l2_construct
629 name = GetName(self.GetMesh())
632 ## Sets a name to the mesh
633 # @param name a new name of the mesh
634 # @ingroup l2_construct
635 def SetName(self, name):
636 SetName(self.GetMesh(), name)
638 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
639 # The subMesh object gives access to the IDs of nodes and elements.
640 # @param theSubObject a geometrical object (shape)
641 # @param theName a name for the submesh
642 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
643 # @ingroup l2_submeshes
644 def GetSubMesh(self, theSubObject, theName):
645 submesh = self.mesh.GetSubMesh(theSubObject, theName)
648 ## Returns the shape associated to the mesh
649 # @return a GEOM_Object
650 # @ingroup l2_construct
654 ## Associates the given shape to the mesh (entails the recreation of the mesh)
655 # @param geom the shape to be meshed (GEOM_Object)
656 # @ingroup l2_construct
657 def SetShape(self, geom):
658 self.mesh = self.smeshpyD.CreateMesh(geom)
660 ## Returns true if the hypotheses are defined well
661 # @param theSubObject a subshape of a mesh shape
662 # @return True or False
663 # @ingroup l2_construct
664 def IsReadyToCompute(self, theSubObject):
665 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
667 ## Returns errors of hypotheses definition.
668 # The list of errors is empty if everything is OK.
669 # @param theSubObject a subshape of a mesh shape
670 # @return a list of errors
671 # @ingroup l2_construct
672 def GetAlgoState(self, theSubObject):
673 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
675 ## Returns a geometrical object on which the given element was built.
676 # The returned geometrical object, if not nil, is either found in the
677 # study or published by this method with the given name
678 # @param theElementID the id of the mesh element
679 # @param theGeomName the user-defined name of the geometrical object
680 # @return GEOM::GEOM_Object instance
681 # @ingroup l2_construct
682 def GetGeometryByMeshElement(self, theElementID, theGeomName):
683 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
685 ## Returns the mesh dimension depending on the dimension of the underlying shape
686 # @return mesh dimension as an integer value [0,3]
687 # @ingroup l1_auxiliary
688 def MeshDimension(self):
689 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
690 if len( shells ) > 0 :
692 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
694 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
700 ## Creates a segment discretization 1D algorithm.
701 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
702 # \n If the optional \a geom parameter is not set, this algorithm is global.
703 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
704 # @param algo the type of the required algorithm. Possible values are:
706 # - smesh.PYTHON for discretization via a python function,
707 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
708 # @param geom If defined is the subshape to be meshed
709 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
710 # @ingroup l3_algos_basic
711 def Segment(self, algo=REGULAR, geom=0):
712 ## if Segment(geom) is called by mistake
713 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
714 algo, geom = geom, algo
715 if not algo: algo = REGULAR
718 return Mesh_Segment(self, geom)
720 return Mesh_Segment_Python(self, geom)
721 elif algo == COMPOSITE:
722 return Mesh_CompositeSegment(self, geom)
724 return Mesh_Segment(self, geom)
726 ## Enables creation of nodes and segments usable by 2D algoritms.
727 # The added nodes and segments must be bound to edges and vertices by
728 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
729 # If the optional \a geom parameter is not set, this algorithm is global.
730 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
731 # @param geom the subshape to be manually meshed
732 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
733 # @ingroup l3_algos_basic
734 def UseExistingSegments(self, geom=0):
735 algo = Mesh_UseExisting(1,self,geom)
736 return algo.GetAlgorithm()
738 ## Enables creation of nodes and faces usable by 3D algoritms.
739 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
740 # and SetMeshElementOnShape()
741 # If the optional \a geom parameter is not set, this algorithm is global.
742 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
743 # @param geom the subshape to be manually meshed
744 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
745 # @ingroup l3_algos_basic
746 def UseExistingFaces(self, geom=0):
747 algo = Mesh_UseExisting(2,self,geom)
748 return algo.GetAlgorithm()
750 ## Creates a triangle 2D algorithm for faces.
751 # If the optional \a geom parameter is not set, this algorithm is global.
752 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
753 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
754 # @param geom If defined, the subshape to be meshed (GEOM_Object)
755 # @return an instance of Mesh_Triangle algorithm
756 # @ingroup l3_algos_basic
757 def Triangle(self, algo=MEFISTO, geom=0):
758 ## if Triangle(geom) is called by mistake
759 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
763 return Mesh_Triangle(self, algo, geom)
765 ## Creates a quadrangle 2D algorithm for faces.
766 # If the optional \a geom parameter is not set, this algorithm is global.
767 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
768 # @param geom If defined, the subshape to be meshed (GEOM_Object)
769 # @return an instance of Mesh_Quadrangle algorithm
770 # @ingroup l3_algos_basic
771 def Quadrangle(self, geom=0):
772 return Mesh_Quadrangle(self, geom)
774 ## Creates a tetrahedron 3D algorithm for solids.
775 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
776 # If the optional \a geom parameter is not set, this algorithm is global.
777 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
778 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
779 # @param geom If defined, the subshape to be meshed (GEOM_Object)
780 # @return an instance of Mesh_Tetrahedron algorithm
781 # @ingroup l3_algos_basic
782 def Tetrahedron(self, algo=NETGEN, geom=0):
783 ## if Tetrahedron(geom) is called by mistake
784 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
785 algo, geom = geom, algo
786 if not algo: algo = NETGEN
788 return Mesh_Tetrahedron(self, algo, geom)
790 ## Creates a hexahedron 3D algorithm for solids.
791 # If the optional \a geom parameter is not set, this algorithm is global.
792 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
793 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
794 # @param geom If defined, the subshape to be meshed (GEOM_Object)
795 # @return an instance of Mesh_Hexahedron algorithm
796 # @ingroup l3_algos_basic
797 def Hexahedron(self, algo=Hexa, geom=0):
798 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
799 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
800 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
801 elif geom == 0: algo, geom = Hexa, algo
802 return Mesh_Hexahedron(self, algo, geom)
804 ## Deprecated, used only for compatibility!
805 # @return an instance of Mesh_Netgen algorithm
806 # @ingroup l3_algos_basic
807 def Netgen(self, is3D, geom=0):
808 return Mesh_Netgen(self, is3D, geom)
810 ## Creates a projection 1D algorithm for edges.
811 # If the optional \a geom parameter is not set, this algorithm is global.
812 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
813 # @param geom If defined, the subshape to be meshed
814 # @return an instance of Mesh_Projection1D algorithm
815 # @ingroup l3_algos_proj
816 def Projection1D(self, geom=0):
817 return Mesh_Projection1D(self, geom)
819 ## Creates a projection 2D algorithm for faces.
820 # If the optional \a geom parameter is not set, this algorithm is global.
821 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
822 # @param geom If defined, the subshape to be meshed
823 # @return an instance of Mesh_Projection2D algorithm
824 # @ingroup l3_algos_proj
825 def Projection2D(self, geom=0):
826 return Mesh_Projection2D(self, geom)
828 ## Creates a projection 3D algorithm for solids.
829 # If the optional \a geom parameter is not set, this algorithm is global.
830 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
831 # @param geom If defined, the subshape to be meshed
832 # @return an instance of Mesh_Projection3D algorithm
833 # @ingroup l3_algos_proj
834 def Projection3D(self, geom=0):
835 return Mesh_Projection3D(self, geom)
837 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
838 # If the optional \a geom parameter is not set, this algorithm is global.
839 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
840 # @param geom If defined, the subshape to be meshed
841 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
842 # @ingroup l3_algos_radialp l3_algos_3dextr
843 def Prism(self, geom=0):
847 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
848 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
849 if nbSolids == 0 or nbSolids == nbShells:
850 return Mesh_Prism3D(self, geom)
851 return Mesh_RadialPrism3D(self, geom)
853 ## Computes the mesh and returns the status of the computation
854 # @return True or False
855 # @ingroup l2_construct
856 def Compute(self, geom=0):
857 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
859 geom = self.mesh.GetShapeToMesh()
864 ok = self.smeshpyD.Compute(self.mesh, geom)
865 except SALOME.SALOME_Exception, ex:
866 print "Mesh computation failed, exception caught:"
867 print " ", ex.details.text
870 print "Mesh computation failed, exception caught:"
871 traceback.print_exc()
873 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
884 reason = '%s %sD algorithm is missing' % (glob, dim)
885 elif err.state == HYP_MISSING:
886 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
887 % (glob, dim, name, dim))
888 elif err.state == HYP_NOTCONFORM:
889 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
890 elif err.state == HYP_BAD_PARAMETER:
891 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
892 % ( glob, dim, name ))
893 elif err.state == HYP_BAD_GEOMETRY:
894 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
895 'geometry' % ( glob, dim, name ))
897 reason = "For unknown reason."+\
898 " Revise Mesh.Compute() implementation in smeshDC.py!"
906 print '"' + GetName(self.mesh) + '"',"has not been computed:"
910 print '"' + GetName(self.mesh) + '"',"has not been computed."
913 if salome.sg.hasDesktop():
914 smeshgui = salome.ImportComponentGUI("SMESH")
915 smeshgui.Init(salome.myStudyId)
916 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
917 salome.sg.updateObjBrowser(1)
921 ## Removes all nodes and elements
922 # @ingroup l2_construct
925 if salome.sg.hasDesktop():
926 smeshgui = salome.ImportComponentGUI("SMESH")
927 smeshgui.Init(salome.myStudyId)
928 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
929 salome.sg.updateObjBrowser(1)
931 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
932 # @param fineness [0,-1] defines mesh fineness
933 # @return True or False
934 # @ingroup l3_algos_basic
935 def AutomaticTetrahedralization(self, fineness=0):
936 dim = self.MeshDimension()
938 self.RemoveGlobalHypotheses()
939 self.Segment().AutomaticLength(fineness)
941 self.Triangle().LengthFromEdges()
944 self.Tetrahedron(NETGEN)
946 return self.Compute()
948 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
949 # @param fineness [0,-1] defines mesh fineness
950 # @return True or False
951 # @ingroup l3_algos_basic
952 def AutomaticHexahedralization(self, fineness=0):
953 dim = self.MeshDimension()
954 # assign the hypotheses
955 self.RemoveGlobalHypotheses()
956 self.Segment().AutomaticLength(fineness)
963 return self.Compute()
965 ## Assigns a hypothesis
966 # @param hyp a hypothesis to assign
967 # @param geom a subhape of mesh geometry
968 # @return SMESH.Hypothesis_Status
969 # @ingroup l2_hypotheses
970 def AddHypothesis(self, hyp, geom=0):
971 if isinstance( hyp, Mesh_Algorithm ):
972 hyp = hyp.GetAlgorithm()
977 geom = self.mesh.GetShapeToMesh()
979 status = self.mesh.AddHypothesis(geom, hyp)
980 isAlgo = hyp._narrow( SMESH_Algo )
981 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
984 ## Unassigns a hypothesis
985 # @param hyp a hypothesis to unassign
986 # @param geom a subshape of mesh geometry
987 # @return SMESH.Hypothesis_Status
988 # @ingroup l2_hypotheses
989 def RemoveHypothesis(self, hyp, geom=0):
990 if isinstance( hyp, Mesh_Algorithm ):
991 hyp = hyp.GetAlgorithm()
996 status = self.mesh.RemoveHypothesis(geom, hyp)
999 ## Gets the list of hypotheses added on a geometry
1000 # @param geom a subshape of mesh geometry
1001 # @return the sequence of SMESH_Hypothesis
1002 # @ingroup l2_hypotheses
1003 def GetHypothesisList(self, geom):
1004 return self.mesh.GetHypothesisList( geom )
1006 ## Removes all global hypotheses
1007 # @ingroup l2_hypotheses
1008 def RemoveGlobalHypotheses(self):
1009 current_hyps = self.mesh.GetHypothesisList( self.geom )
1010 for hyp in current_hyps:
1011 self.mesh.RemoveHypothesis( self.geom, hyp )
1015 ## Creates a mesh group based on the geometric object \a grp
1016 # and gives a \a name, \n if this parameter is not defined
1017 # the name is the same as the geometric group name \n
1018 # Note: Works like GroupOnGeom().
1019 # @param grp a geometric group, a vertex, an edge, a face or a solid
1020 # @param name the name of the mesh group
1021 # @return SMESH_GroupOnGeom
1022 # @ingroup l2_grps_create
1023 def Group(self, grp, name=""):
1024 return self.GroupOnGeom(grp, name)
1026 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1027 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1028 # @param f the file name
1029 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1030 # @ingroup l2_impexp
1031 def ExportToMED(self, f, version, opt=0):
1032 self.mesh.ExportToMED(f, opt, version)
1034 ## Exports the mesh in a file in MED format
1035 # @param f is the file name
1036 # @param auto_groups boolean parameter for creating/not creating
1037 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1038 # the typical use is auto_groups=false.
1039 # @param version MED format version(MED_V2_1 or MED_V2_2)
1040 # @ingroup l2_impexp
1041 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1042 self.mesh.ExportToMED(f, auto_groups, version)
1044 ## Exports the mesh in a file in DAT format
1045 # @param f the file name
1046 # @ingroup l2_impexp
1047 def ExportDAT(self, f):
1048 self.mesh.ExportDAT(f)
1050 ## Exports the mesh in a file in UNV format
1051 # @param f the file name
1052 # @ingroup l2_impexp
1053 def ExportUNV(self, f):
1054 self.mesh.ExportUNV(f)
1056 ## Export the mesh in a file in STL format
1057 # @param f the file name
1058 # @param ascii defines the file encoding
1059 # @ingroup l2_impexp
1060 def ExportSTL(self, f, ascii=1):
1061 self.mesh.ExportSTL(f, ascii)
1064 # Operations with groups:
1065 # ----------------------
1067 ## Creates an empty mesh group
1068 # @param elementType the type of elements in the group
1069 # @param name the name of the mesh group
1070 # @return SMESH_Group
1071 # @ingroup l2_grps_create
1072 def CreateEmptyGroup(self, elementType, name):
1073 return self.mesh.CreateGroup(elementType, name)
1075 ## Creates a mesh group based on the geometrical object \a grp
1076 # and gives a \a name, \n if this parameter is not defined
1077 # the name is the same as the geometrical group name
1078 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1079 # @param name the name of the mesh group
1080 # @param typ the type of elements in the group. If not set, it is
1081 # automatically detected by the type of the geometry
1082 # @return SMESH_GroupOnGeom
1083 # @ingroup l2_grps_create
1084 def GroupOnGeom(self, grp, name="", typ=None):
1086 name = grp.GetName()
1089 tgeo = str(grp.GetShapeType())
1090 if tgeo == "VERTEX":
1092 elif tgeo == "EDGE":
1094 elif tgeo == "FACE":
1096 elif tgeo == "SOLID":
1098 elif tgeo == "SHELL":
1100 elif tgeo == "COMPOUND":
1101 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1102 print "Mesh.Group: empty geometric group", GetName( grp )
1104 tgeo = self.geompyD.GetType(grp)
1105 if tgeo == geompyDC.ShapeType["VERTEX"]:
1107 elif tgeo == geompyDC.ShapeType["EDGE"]:
1109 elif tgeo == geompyDC.ShapeType["FACE"]:
1111 elif tgeo == geompyDC.ShapeType["SOLID"]:
1115 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1118 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1120 ## Creates a mesh group by the given ids of elements
1121 # @param groupName the name of the mesh group
1122 # @param elementType the type of elements in the group
1123 # @param elemIDs the list of ids
1124 # @return SMESH_Group
1125 # @ingroup l2_grps_create
1126 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1127 group = self.mesh.CreateGroup(elementType, groupName)
1131 ## Creates a mesh group by the given conditions
1132 # @param groupName the name of the mesh group
1133 # @param elementType the type of elements in the group
1134 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1135 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1136 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1137 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1138 # @return SMESH_Group
1139 # @ingroup l2_grps_create
1143 CritType=FT_Undefined,
1146 UnaryOp=FT_Undefined):
1147 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1148 group = self.MakeGroupByCriterion(groupName, aCriterion)
1151 ## Creates a mesh group by the given criterion
1152 # @param groupName the name of the mesh group
1153 # @param Criterion the instance of Criterion class
1154 # @return SMESH_Group
1155 # @ingroup l2_grps_create
1156 def MakeGroupByCriterion(self, groupName, Criterion):
1157 aFilterMgr = self.smeshpyD.CreateFilterManager()
1158 aFilter = aFilterMgr.CreateFilter()
1160 aCriteria.append(Criterion)
1161 aFilter.SetCriteria(aCriteria)
1162 group = self.MakeGroupByFilter(groupName, aFilter)
1165 ## Creates a mesh group by the given criteria (list of criteria)
1166 # @param groupName the name of the mesh group
1167 # @param theCriteria the list of criteria
1168 # @return SMESH_Group
1169 # @ingroup l2_grps_create
1170 def MakeGroupByCriteria(self, groupName, theCriteria):
1171 aFilterMgr = self.smeshpyD.CreateFilterManager()
1172 aFilter = aFilterMgr.CreateFilter()
1173 aFilter.SetCriteria(theCriteria)
1174 group = self.MakeGroupByFilter(groupName, aFilter)
1177 ## Creates a mesh group by the given filter
1178 # @param groupName the name of the mesh group
1179 # @param theFilter the instance of Filter class
1180 # @return SMESH_Group
1181 # @ingroup l2_grps_create
1182 def MakeGroupByFilter(self, groupName, theFilter):
1183 anIds = theFilter.GetElementsId(self.mesh)
1184 anElemType = theFilter.GetElementType()
1185 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1188 ## Passes mesh elements through the given filter and return IDs of fitting elements
1189 # @param theFilter SMESH_Filter
1190 # @return a list of ids
1191 # @ingroup l1_controls
1192 def GetIdsFromFilter(self, theFilter):
1193 return theFilter.GetElementsId(self.mesh)
1195 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1196 # Returns a list of special structures (borders).
1197 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1198 # @ingroup l1_controls
1199 def GetFreeBorders(self):
1200 aFilterMgr = self.smeshpyD.CreateFilterManager()
1201 aPredicate = aFilterMgr.CreateFreeEdges()
1202 aPredicate.SetMesh(self.mesh)
1203 aBorders = aPredicate.GetBorders()
1207 # @ingroup l2_grps_delete
1208 def RemoveGroup(self, group):
1209 self.mesh.RemoveGroup(group)
1211 ## Removes a group with its contents
1212 # @ingroup l2_grps_delete
1213 def RemoveGroupWithContents(self, group):
1214 self.mesh.RemoveGroupWithContents(group)
1216 ## Gets the list of groups existing in the mesh
1217 # @return a sequence of SMESH_GroupBase
1218 # @ingroup l2_grps_create
1219 def GetGroups(self):
1220 return self.mesh.GetGroups()
1222 ## Gets the number of groups existing in the mesh
1223 # @return the quantity of groups as an integer value
1224 # @ingroup l2_grps_create
1226 return self.mesh.NbGroups()
1228 ## Gets the list of names of groups existing in the mesh
1229 # @return list of strings
1230 # @ingroup l2_grps_create
1231 def GetGroupNames(self):
1232 groups = self.GetGroups()
1234 for group in groups:
1235 names.append(group.GetName())
1238 ## Produces a union of two groups
1239 # A new group is created. All mesh elements that are
1240 # present in the initial groups are added to the new one
1241 # @return an instance of SMESH_Group
1242 # @ingroup l2_grps_operon
1243 def UnionGroups(self, group1, group2, name):
1244 return self.mesh.UnionGroups(group1, group2, name)
1246 ## Prodices an intersection of two groups
1247 # A new group is created. All mesh elements that are common
1248 # for the two initial groups are added to the new one.
1249 # @return an instance of SMESH_Group
1250 # @ingroup l2_grps_operon
1251 def IntersectGroups(self, group1, group2, name):
1252 return self.mesh.IntersectGroups(group1, group2, name)
1254 ## Produces a cut of two groups
1255 # A new group is created. All mesh elements that are present in
1256 # the main group but are not present in the tool group are added to the new one
1257 # @return an instance of SMESH_Group
1258 # @ingroup l2_grps_operon
1259 def CutGroups(self, mainGroup, toolGroup, name):
1260 return self.mesh.CutGroups(mainGroup, toolGroup, name)
1263 # Get some info about mesh:
1264 # ------------------------
1266 ## Returns the log of nodes and elements added or removed
1267 # since the previous clear of the log.
1268 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1269 # @return list of log_block structures:
1274 # @ingroup l1_auxiliary
1275 def GetLog(self, clearAfterGet):
1276 return self.mesh.GetLog(clearAfterGet)
1278 ## Clears the log of nodes and elements added or removed since the previous
1279 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1280 # @ingroup l1_auxiliary
1282 self.mesh.ClearLog()
1284 ## Toggles auto color mode on the object.
1285 # @param theAutoColor the flag which toggles auto color mode.
1286 # @ingroup l1_auxiliary
1287 def SetAutoColor(self, theAutoColor):
1288 self.mesh.SetAutoColor(theAutoColor)
1290 ## Gets flag of object auto color mode.
1291 # @return True or False
1292 # @ingroup l1_auxiliary
1293 def GetAutoColor(self):
1294 return self.mesh.GetAutoColor()
1296 ## Gets the internal ID
1297 # @return integer value, which is the internal Id of the mesh
1298 # @ingroup l1_auxiliary
1300 return self.mesh.GetId()
1303 # @return integer value, which is the study Id of the mesh
1304 # @ingroup l1_auxiliary
1305 def GetStudyId(self):
1306 return self.mesh.GetStudyId()
1308 ## Checks the group names for duplications.
1309 # Consider the maximum group name length stored in MED file.
1310 # @return True or False
1311 # @ingroup l1_auxiliary
1312 def HasDuplicatedGroupNamesMED(self):
1313 return self.mesh.HasDuplicatedGroupNamesMED()
1315 ## Obtains the mesh editor tool
1316 # @return an instance of SMESH_MeshEditor
1317 # @ingroup l1_modifying
1318 def GetMeshEditor(self):
1319 return self.mesh.GetMeshEditor()
1322 # @return an instance of SALOME_MED::MESH
1323 # @ingroup l1_auxiliary
1324 def GetMEDMesh(self):
1325 return self.mesh.GetMEDMesh()
1328 # Get informations about mesh contents:
1329 # ------------------------------------
1331 ## Returns the number of nodes in the mesh
1332 # @return an integer value
1333 # @ingroup l1_meshinfo
1335 return self.mesh.NbNodes()
1337 ## Returns the number of elements in the mesh
1338 # @return an integer value
1339 # @ingroup l1_meshinfo
1340 def NbElements(self):
1341 return self.mesh.NbElements()
1343 ## Returns the number of edges in the mesh
1344 # @return an integer value
1345 # @ingroup l1_meshinfo
1347 return self.mesh.NbEdges()
1349 ## Returns the number of edges with the given order in the mesh
1350 # @param elementOrder the order of elements:
1351 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1352 # @return an integer value
1353 # @ingroup l1_meshinfo
1354 def NbEdgesOfOrder(self, elementOrder):
1355 return self.mesh.NbEdgesOfOrder(elementOrder)
1357 ## Returns the number of faces in the mesh
1358 # @return an integer value
1359 # @ingroup l1_meshinfo
1361 return self.mesh.NbFaces()
1363 ## Returns the number of faces with the given order in the mesh
1364 # @param elementOrder the order of elements:
1365 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1366 # @return an integer value
1367 # @ingroup l1_meshinfo
1368 def NbFacesOfOrder(self, elementOrder):
1369 return self.mesh.NbFacesOfOrder(elementOrder)
1371 ## Returns the number of triangles in the mesh
1372 # @return an integer value
1373 # @ingroup l1_meshinfo
1374 def NbTriangles(self):
1375 return self.mesh.NbTriangles()
1377 ## Returns the number of triangles with the given order in the mesh
1378 # @param elementOrder is the order of elements:
1379 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1380 # @return an integer value
1381 # @ingroup l1_meshinfo
1382 def NbTrianglesOfOrder(self, elementOrder):
1383 return self.mesh.NbTrianglesOfOrder(elementOrder)
1385 ## Returns the number of quadrangles in the mesh
1386 # @return an integer value
1387 # @ingroup l1_meshinfo
1388 def NbQuadrangles(self):
1389 return self.mesh.NbQuadrangles()
1391 ## Returns the number of quadrangles with the given order in the mesh
1392 # @param elementOrder the order of elements:
1393 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1394 # @return an integer value
1395 # @ingroup l1_meshinfo
1396 def NbQuadranglesOfOrder(self, elementOrder):
1397 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1399 ## Returns the number of polygons in the mesh
1400 # @return an integer value
1401 # @ingroup l1_meshinfo
1402 def NbPolygons(self):
1403 return self.mesh.NbPolygons()
1405 ## Returns the number of volumes in the mesh
1406 # @return an integer value
1407 # @ingroup l1_meshinfo
1408 def NbVolumes(self):
1409 return self.mesh.NbVolumes()
1411 ## Returns the number of volumes with the given order in the mesh
1412 # @param elementOrder the order of elements:
1413 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1414 # @return an integer value
1415 # @ingroup l1_meshinfo
1416 def NbVolumesOfOrder(self, elementOrder):
1417 return self.mesh.NbVolumesOfOrder(elementOrder)
1419 ## Returns the number of tetrahedrons in the mesh
1420 # @return an integer value
1421 # @ingroup l1_meshinfo
1423 return self.mesh.NbTetras()
1425 ## Returns the number of tetrahedrons with the given order in the mesh
1426 # @param elementOrder the order of elements:
1427 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1428 # @return an integer value
1429 # @ingroup l1_meshinfo
1430 def NbTetrasOfOrder(self, elementOrder):
1431 return self.mesh.NbTetrasOfOrder(elementOrder)
1433 ## Returns the number of hexahedrons in the mesh
1434 # @return an integer value
1435 # @ingroup l1_meshinfo
1437 return self.mesh.NbHexas()
1439 ## Returns the number of hexahedrons with the given order in the mesh
1440 # @param elementOrder the order of elements:
1441 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1442 # @return an integer value
1443 # @ingroup l1_meshinfo
1444 def NbHexasOfOrder(self, elementOrder):
1445 return self.mesh.NbHexasOfOrder(elementOrder)
1447 ## Returns the number of pyramids in the mesh
1448 # @return an integer value
1449 # @ingroup l1_meshinfo
1450 def NbPyramids(self):
1451 return self.mesh.NbPyramids()
1453 ## Returns the number of pyramids with the given order in the mesh
1454 # @param elementOrder the order of elements:
1455 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1456 # @return an integer value
1457 # @ingroup l1_meshinfo
1458 def NbPyramidsOfOrder(self, elementOrder):
1459 return self.mesh.NbPyramidsOfOrder(elementOrder)
1461 ## Returns the number of prisms in the mesh
1462 # @return an integer value
1463 # @ingroup l1_meshinfo
1465 return self.mesh.NbPrisms()
1467 ## Returns the number of prisms with the given order in the mesh
1468 # @param elementOrder the order of elements:
1469 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1470 # @return an integer value
1471 # @ingroup l1_meshinfo
1472 def NbPrismsOfOrder(self, elementOrder):
1473 return self.mesh.NbPrismsOfOrder(elementOrder)
1475 ## Returns the number of polyhedrons in the mesh
1476 # @return an integer value
1477 # @ingroup l1_meshinfo
1478 def NbPolyhedrons(self):
1479 return self.mesh.NbPolyhedrons()
1481 ## Returns the number of submeshes in the mesh
1482 # @return an integer value
1483 # @ingroup l1_meshinfo
1484 def NbSubMesh(self):
1485 return self.mesh.NbSubMesh()
1487 ## Returns the list of mesh elements IDs
1488 # @return the list of integer values
1489 # @ingroup l1_meshinfo
1490 def GetElementsId(self):
1491 return self.mesh.GetElementsId()
1493 ## Returns the list of IDs of mesh elements with the given type
1494 # @param elementType the required type of elements
1495 # @return list of integer values
1496 # @ingroup l1_meshinfo
1497 def GetElementsByType(self, elementType):
1498 return self.mesh.GetElementsByType(elementType)
1500 ## Returns the list of mesh nodes IDs
1501 # @return the list of integer values
1502 # @ingroup l1_meshinfo
1503 def GetNodesId(self):
1504 return self.mesh.GetNodesId()
1506 # Get the information about mesh elements:
1507 # ------------------------------------
1509 ## Returns the type of mesh element
1510 # @return the value from SMESH::ElementType enumeration
1511 # @ingroup l1_meshinfo
1512 def GetElementType(self, id, iselem):
1513 return self.mesh.GetElementType(id, iselem)
1515 ## Returns the list of submesh elements IDs
1516 # @param Shape a geom object(subshape) IOR
1517 # Shape must be the subshape of a ShapeToMesh()
1518 # @return the list of integer values
1519 # @ingroup l1_meshinfo
1520 def GetSubMeshElementsId(self, Shape):
1521 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1522 ShapeID = Shape.GetSubShapeIndices()[0]
1525 return self.mesh.GetSubMeshElementsId(ShapeID)
1527 ## Returns the list of submesh nodes IDs
1528 # @param Shape a geom object(subshape) IOR
1529 # Shape must be the subshape of a ShapeToMesh()
1530 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1531 # @return the list of integer values
1532 # @ingroup l1_meshinfo
1533 def GetSubMeshNodesId(self, Shape, all):
1534 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1535 ShapeID = Shape.GetSubShapeIndices()[0]
1538 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1540 ## Returns the list of IDs of submesh elements with the given type
1541 # @param Shape a geom object(subshape) IOR
1542 # Shape must be a subshape of a ShapeToMesh()
1543 # @return the list of integer values
1544 # @ingroup l1_meshinfo
1545 def GetSubMeshElementType(self, Shape):
1546 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1547 ShapeID = Shape.GetSubShapeIndices()[0]
1550 return self.mesh.GetSubMeshElementType(ShapeID)
1552 ## Gets the mesh description
1553 # @return string value
1554 # @ingroup l1_meshinfo
1556 return self.mesh.Dump()
1559 # Get the information about nodes and elements of a mesh by its IDs:
1560 # -----------------------------------------------------------
1562 ## Gets XYZ coordinates of a node
1563 # \n If there is no nodes for the given ID - returns an empty list
1564 # @return a list of double precision values
1565 # @ingroup l1_meshinfo
1566 def GetNodeXYZ(self, id):
1567 return self.mesh.GetNodeXYZ(id)
1569 ## Returns list of IDs of inverse elements for the given node
1570 # \n If there is no node for the given ID - returns an empty list
1571 # @return a list of integer values
1572 # @ingroup l1_meshinfo
1573 def GetNodeInverseElements(self, id):
1574 return self.mesh.GetNodeInverseElements(id)
1576 ## @brief Returns the position of a node on the shape
1577 # @return SMESH::NodePosition
1578 # @ingroup l1_meshinfo
1579 def GetNodePosition(self,NodeID):
1580 return self.mesh.GetNodePosition(NodeID)
1582 ## If the given element is a node, returns the ID of shape
1583 # \n If there is no node for the given ID - returns -1
1584 # @return an integer value
1585 # @ingroup l1_meshinfo
1586 def GetShapeID(self, id):
1587 return self.mesh.GetShapeID(id)
1589 ## Returns the ID of the result shape after
1590 # FindShape() from SMESH_MeshEditor for the given element
1591 # \n If there is no element for the given ID - returns -1
1592 # @return an integer value
1593 # @ingroup l1_meshinfo
1594 def GetShapeIDForElem(self,id):
1595 return self.mesh.GetShapeIDForElem(id)
1597 ## Returns the number of nodes for the given element
1598 # \n If there is no element for the given ID - returns -1
1599 # @return an integer value
1600 # @ingroup l1_meshinfo
1601 def GetElemNbNodes(self, id):
1602 return self.mesh.GetElemNbNodes(id)
1604 ## Returns the node ID the given index for the given element
1605 # \n If there is no element for the given ID - returns -1
1606 # \n If there is no node for the given index - returns -2
1607 # @return an integer value
1608 # @ingroup l1_meshinfo
1609 def GetElemNode(self, id, index):
1610 return self.mesh.GetElemNode(id, index)
1612 ## Returns the IDs of nodes of the given element
1613 # @return a list of integer values
1614 # @ingroup l1_meshinfo
1615 def GetElemNodes(self, id):
1616 return self.mesh.GetElemNodes(id)
1618 ## Returns true if the given node is the medium node in the given quadratic element
1619 # @ingroup l1_meshinfo
1620 def IsMediumNode(self, elementID, nodeID):
1621 return self.mesh.IsMediumNode(elementID, nodeID)
1623 ## Returns true if the given node is the medium node in one of quadratic elements
1624 # @ingroup l1_meshinfo
1625 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1626 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1628 ## Returns the number of edges for the given element
1629 # @ingroup l1_meshinfo
1630 def ElemNbEdges(self, id):
1631 return self.mesh.ElemNbEdges(id)
1633 ## Returns the number of faces for the given element
1634 # @ingroup l1_meshinfo
1635 def ElemNbFaces(self, id):
1636 return self.mesh.ElemNbFaces(id)
1638 ## Returns true if the given element is a polygon
1639 # @ingroup l1_meshinfo
1640 def IsPoly(self, id):
1641 return self.mesh.IsPoly(id)
1643 ## Returns true if the given element is quadratic
1644 # @ingroup l1_meshinfo
1645 def IsQuadratic(self, id):
1646 return self.mesh.IsQuadratic(id)
1648 ## Returns XYZ coordinates of the barycenter of the given element
1649 # \n If there is no element for the given ID - returns an empty list
1650 # @return a list of three double values
1651 # @ingroup l1_meshinfo
1652 def BaryCenter(self, id):
1653 return self.mesh.BaryCenter(id)
1656 # Mesh edition (SMESH_MeshEditor functionality):
1657 # ---------------------------------------------
1659 ## Removes the elements from the mesh by ids
1660 # @param IDsOfElements is a list of ids of elements to remove
1661 # @return True or False
1662 # @ingroup l2_modif_del
1663 def RemoveElements(self, IDsOfElements):
1664 return self.editor.RemoveElements(IDsOfElements)
1666 ## Removes nodes from mesh by ids
1667 # @param IDsOfNodes is a list of ids of nodes to remove
1668 # @return True or False
1669 # @ingroup l2_modif_del
1670 def RemoveNodes(self, IDsOfNodes):
1671 return self.editor.RemoveNodes(IDsOfNodes)
1673 ## Add a node to the mesh by coordinates
1674 # @return Id of the new node
1675 # @ingroup l2_modif_add
1676 def AddNode(self, x, y, z):
1677 return self.editor.AddNode( x, y, z)
1679 ## Creates a linear or quadratic edge (this is determined
1680 # by the number of given nodes).
1681 # @param IDsOfNodes the list of node IDs for creation of the element.
1682 # The order of nodes in this list should correspond to the description
1683 # of MED. \n This description is located by the following link:
1684 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1685 # @return the Id of the new edge
1686 # @ingroup l2_modif_add
1687 def AddEdge(self, IDsOfNodes):
1688 return self.editor.AddEdge(IDsOfNodes)
1690 ## Creates a linear or quadratic face (this is determined
1691 # by the number of given nodes).
1692 # @param IDsOfNodes the list of node IDs for creation of the element.
1693 # The order of nodes in this list should correspond to the description
1694 # of MED. \n This description is located by the following link:
1695 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1696 # @return the Id of the new face
1697 # @ingroup l2_modif_add
1698 def AddFace(self, IDsOfNodes):
1699 return self.editor.AddFace(IDsOfNodes)
1701 ## Adds a polygonal face to the mesh by the list of node IDs
1702 # @param IdsOfNodes the list of node IDs for creation of the element.
1703 # @return the Id of the new face
1704 # @ingroup l2_modif_add
1705 def AddPolygonalFace(self, IdsOfNodes):
1706 return self.editor.AddPolygonalFace(IdsOfNodes)
1708 ## Creates both simple and quadratic volume (this is determined
1709 # by the number of given nodes).
1710 # @param IDsOfNodes the list of node IDs for creation of the element.
1711 # The order of nodes in this list should correspond to the description
1712 # of MED. \n This description is located by the following link:
1713 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1714 # @return the Id of the new volumic element
1715 # @ingroup l2_modif_add
1716 def AddVolume(self, IDsOfNodes):
1717 return self.editor.AddVolume(IDsOfNodes)
1719 ## Creates a volume of many faces, giving nodes for each face.
1720 # @param IdsOfNodes the list of node IDs for volume creation face by face.
1721 # @param Quantities the list of integer values, Quantities[i]
1722 # gives the quantity of nodes in face number i.
1723 # @return the Id of the new volumic element
1724 # @ingroup l2_modif_add
1725 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1726 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1728 ## Creates a volume of many faces, giving the IDs of the existing faces.
1729 # @param IdsOfFaces the list of face IDs for volume creation.
1731 # Note: The created volume will refer only to the nodes
1732 # of the given faces, not to the faces themselves.
1733 # @return the Id of the new volumic element
1734 # @ingroup l2_modif_add
1735 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1736 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1739 ## @brief Binds a node to a vertex
1740 # @param NodeID a node ID
1741 # @param Vertex a vertex or vertex ID
1742 # @return True if succeed else raises an exception
1743 # @ingroup l2_modif_add
1744 def SetNodeOnVertex(self, NodeID, Vertex):
1745 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
1746 VertexID = Vertex.GetSubShapeIndices()[0]
1750 self.editor.SetNodeOnVertex(NodeID, VertexID)
1751 except SALOME.SALOME_Exception, inst:
1752 raise ValueError, inst.details.text
1756 ## @brief Stores the node position on an edge
1757 # @param NodeID a node ID
1758 # @param Edge an edge or edge ID
1759 # @param paramOnEdge a parameter on the edge where the node is located
1760 # @return True if succeed else raises an exception
1761 # @ingroup l2_modif_add
1762 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
1763 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
1764 EdgeID = Edge.GetSubShapeIndices()[0]
1768 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
1769 except SALOME.SALOME_Exception, inst:
1770 raise ValueError, inst.details.text
1773 ## @brief Stores node position on a face
1774 # @param NodeID a node ID
1775 # @param Face a face or face ID
1776 # @param u U parameter on the face where the node is located
1777 # @param v V parameter on the face where the node is located
1778 # @return True if succeed else raises an exception
1779 # @ingroup l2_modif_add
1780 def SetNodeOnFace(self, NodeID, Face, u, v):
1781 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
1782 FaceID = Face.GetSubShapeIndices()[0]
1786 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
1787 except SALOME.SALOME_Exception, inst:
1788 raise ValueError, inst.details.text
1791 ## @brief Binds a node to a solid
1792 # @param NodeID a node ID
1793 # @param Solid a solid or solid ID
1794 # @return True if succeed else raises an exception
1795 # @ingroup l2_modif_add
1796 def SetNodeInVolume(self, NodeID, Solid):
1797 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
1798 SolidID = Solid.GetSubShapeIndices()[0]
1802 self.editor.SetNodeInVolume(NodeID, SolidID)
1803 except SALOME.SALOME_Exception, inst:
1804 raise ValueError, inst.details.text
1807 ## @brief Bind an element to a shape
1808 # @param ElementID an element ID
1809 # @param Shape a shape or shape ID
1810 # @return True if succeed else raises an exception
1811 # @ingroup l2_modif_add
1812 def SetMeshElementOnShape(self, ElementID, Shape):
1813 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1814 ShapeID = Shape.GetSubShapeIndices()[0]
1818 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
1819 except SALOME.SALOME_Exception, inst:
1820 raise ValueError, inst.details.text
1824 ## Moves the node with the given id
1825 # @param NodeID the id of the node
1826 # @param x a new X coordinate
1827 # @param y a new Y coordinate
1828 # @param z a new Z coordinate
1829 # @return True if succeed else False
1830 # @ingroup l2_modif_movenode
1831 def MoveNode(self, NodeID, x, y, z):
1832 return self.editor.MoveNode(NodeID, x, y, z)
1834 ## Finds the node closest to a point
1835 # @param x the X coordinate of a point
1836 # @param y the Y coordinate of a point
1837 # @param z the Z coordinate of a point
1838 # @return the ID of a node
1839 # @ingroup l2_modif_throughp
1840 def FindNodeClosestTo(self, x, y, z):
1841 preview = self.mesh.GetMeshEditPreviewer()
1842 return preview.MoveClosestNodeToPoint(x, y, z, -1)
1844 ## Finds the node closest to a point and moves it to a point location
1845 # @param x the X coordinate of a point
1846 # @param y the Y coordinate of a point
1847 # @param z the Z coordinate of a point
1848 # @return the ID of a moved node
1849 # @ingroup l2_modif_throughp
1850 def MeshToPassThroughAPoint(self, x, y, z):
1851 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
1853 ## Replaces two neighbour triangles sharing Node1-Node2 link
1854 # with the triangles built on the same 4 nodes but having other common link.
1855 # @param NodeID1 the ID of the first node
1856 # @param NodeID2 the ID of the second node
1857 # @return false if proper faces were not found
1858 # @ingroup l2_modif_invdiag
1859 def InverseDiag(self, NodeID1, NodeID2):
1860 return self.editor.InverseDiag(NodeID1, NodeID2)
1862 ## Replaces two neighbour triangles sharing Node1-Node2 link
1863 # with a quadrangle built on the same 4 nodes.
1864 # @param NodeID1 the ID of the first node
1865 # @param NodeID2 the ID of the second node
1866 # @return false if proper faces were not found
1867 # @ingroup l2_modif_unitetri
1868 def DeleteDiag(self, NodeID1, NodeID2):
1869 return self.editor.DeleteDiag(NodeID1, NodeID2)
1871 ## Reorients elements by ids
1872 # @param IDsOfElements if undefined reorients all mesh elements
1873 # @return True if succeed else False
1874 # @ingroup l2_modif_changori
1875 def Reorient(self, IDsOfElements=None):
1876 if IDsOfElements == None:
1877 IDsOfElements = self.GetElementsId()
1878 return self.editor.Reorient(IDsOfElements)
1880 ## Reorients all elements of the object
1881 # @param theObject mesh, submesh or group
1882 # @return True if succeed else False
1883 # @ingroup l2_modif_changori
1884 def ReorientObject(self, theObject):
1885 if ( isinstance( theObject, Mesh )):
1886 theObject = theObject.GetMesh()
1887 return self.editor.ReorientObject(theObject)
1889 ## Fuses the neighbouring triangles into quadrangles.
1890 # @param IDsOfElements The triangles to be fused,
1891 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1892 # @param MaxAngle is the maximum angle between element normals at which the fusion
1893 # is still performed; theMaxAngle is mesured in radians.
1894 # @return TRUE in case of success, FALSE otherwise.
1895 # @ingroup l2_modif_unitetri
1896 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
1897 if IDsOfElements == []:
1898 IDsOfElements = self.GetElementsId()
1899 return self.editor.TriToQuad(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1901 ## Fuses the neighbouring triangles of the object into quadrangles
1902 # @param theObject is mesh, submesh or group
1903 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1904 # @param MaxAngle a max angle between element normals at which the fusion
1905 # is still performed; theMaxAngle is mesured in radians.
1906 # @return TRUE in case of success, FALSE otherwise.
1907 # @ingroup l2_modif_unitetri
1908 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
1909 if ( isinstance( theObject, Mesh )):
1910 theObject = theObject.GetMesh()
1911 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1913 ## Splits quadrangles into triangles.
1914 # @param IDsOfElements the faces to be splitted.
1915 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1916 # @return TRUE in case of success, FALSE otherwise.
1917 # @ingroup l2_modif_cutquadr
1918 def QuadToTri (self, IDsOfElements, theCriterion):
1919 if IDsOfElements == []:
1920 IDsOfElements = self.GetElementsId()
1921 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
1923 ## Splits quadrangles into triangles.
1924 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1925 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1926 # @return TRUE in case of success, FALSE otherwise.
1927 # @ingroup l2_modif_cutquadr
1928 def QuadToTriObject (self, theObject, theCriterion):
1929 if ( isinstance( theObject, Mesh )):
1930 theObject = theObject.GetMesh()
1931 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
1933 ## Splits quadrangles into triangles.
1934 # @param IDsOfElements the faces to be splitted
1935 # @param Diag13 is used to choose a diagonal for splitting.
1936 # @return TRUE in case of success, FALSE otherwise.
1937 # @ingroup l2_modif_cutquadr
1938 def SplitQuad (self, IDsOfElements, Diag13):
1939 if IDsOfElements == []:
1940 IDsOfElements = self.GetElementsId()
1941 return self.editor.SplitQuad(IDsOfElements, Diag13)
1943 ## Splits quadrangles into triangles.
1944 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1945 # @param Diag13 is used to choose a diagonal for splitting.
1946 # @return TRUE in case of success, FALSE otherwise.
1947 # @ingroup l2_modif_cutquadr
1948 def SplitQuadObject (self, theObject, Diag13):
1949 if ( isinstance( theObject, Mesh )):
1950 theObject = theObject.GetMesh()
1951 return self.editor.SplitQuadObject(theObject, Diag13)
1953 ## Finds a better splitting of the given quadrangle.
1954 # @param IDOfQuad the ID of the quadrangle to be splitted.
1955 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
1956 # @return 1 if 1-3 diagonal is better, 2 if 2-4
1957 # diagonal is better, 0 if error occurs.
1958 # @ingroup l2_modif_cutquadr
1959 def BestSplit (self, IDOfQuad, theCriterion):
1960 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
1962 ## Splits quadrangle faces near triangular facets of volumes
1964 # @ingroup l1_auxiliary
1965 def SplitQuadsNearTriangularFacets(self):
1966 faces_array = self.GetElementsByType(SMESH.FACE)
1967 for face_id in faces_array:
1968 if self.GetElemNbNodes(face_id) == 4: # quadrangle
1969 quad_nodes = self.mesh.GetElemNodes(face_id)
1970 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
1971 isVolumeFound = False
1972 for node1_elem in node1_elems:
1973 if not isVolumeFound:
1974 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
1975 nb_nodes = self.GetElemNbNodes(node1_elem)
1976 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
1977 volume_elem = node1_elem
1978 volume_nodes = self.mesh.GetElemNodes(volume_elem)
1979 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
1980 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
1981 isVolumeFound = True
1982 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
1983 self.SplitQuad([face_id], False) # diagonal 2-4
1984 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
1985 isVolumeFound = True
1986 self.SplitQuad([face_id], True) # diagonal 1-3
1987 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
1988 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
1989 isVolumeFound = True
1990 self.SplitQuad([face_id], True) # diagonal 1-3
1992 ## @brief Splits hexahedrons into tetrahedrons.
1994 # This operation uses pattern mapping functionality for splitting.
1995 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
1996 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
1997 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
1998 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
1999 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2000 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2001 # @return TRUE in case of success, FALSE otherwise.
2002 # @ingroup l1_auxiliary
2003 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2004 # Pattern: 5.---------.6
2009 # (0,0,1) 4.---------.7 * |
2016 # (0,0,0) 0.---------.3
2017 pattern_tetra = "!!! Nb of points: \n 8 \n\
2027 !!! Indices of points of 6 tetras: \n\
2035 pattern = self.smeshpyD.GetPattern()
2036 isDone = pattern.LoadFromFile(pattern_tetra)
2038 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2041 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2042 isDone = pattern.MakeMesh(self.mesh, False, False)
2043 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2045 # split quafrangle faces near triangular facets of volumes
2046 self.SplitQuadsNearTriangularFacets()
2050 ## @brief Split hexahedrons into prisms.
2052 # Uses the pattern mapping functionality for splitting.
2053 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2054 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2055 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2056 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2057 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2058 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2059 # @return TRUE in case of success, FALSE otherwise.
2060 # @ingroup l1_auxiliary
2061 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2062 # Pattern: 5.---------.6
2067 # (0,0,1) 4.---------.7 |
2074 # (0,0,0) 0.---------.3
2075 pattern_prism = "!!! Nb of points: \n 8 \n\
2085 !!! Indices of points of 2 prisms: \n\
2089 pattern = self.smeshpyD.GetPattern()
2090 isDone = pattern.LoadFromFile(pattern_prism)
2092 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2095 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2096 isDone = pattern.MakeMesh(self.mesh, False, False)
2097 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2099 # Splits quafrangle faces near triangular facets of volumes
2100 self.SplitQuadsNearTriangularFacets()
2104 ## Smoothes elements
2105 # @param IDsOfElements the list if ids of elements to smooth
2106 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2107 # Note that nodes built on edges and boundary nodes are always fixed.
2108 # @param MaxNbOfIterations the maximum number of iterations
2109 # @param MaxAspectRatio varies in range [1.0, inf]
2110 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2111 # @return TRUE in case of success, FALSE otherwise.
2112 # @ingroup l2_modif_smooth
2113 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2114 MaxNbOfIterations, MaxAspectRatio, Method):
2115 if IDsOfElements == []:
2116 IDsOfElements = self.GetElementsId()
2117 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2118 MaxNbOfIterations, MaxAspectRatio, Method)
2120 ## Smoothes elements which belong to the given object
2121 # @param theObject the object to smooth
2122 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2123 # Note that nodes built on edges and boundary nodes are always fixed.
2124 # @param MaxNbOfIterations the maximum number of iterations
2125 # @param MaxAspectRatio varies in range [1.0, inf]
2126 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2127 # @return TRUE in case of success, FALSE otherwise.
2128 # @ingroup l2_modif_smooth
2129 def SmoothObject(self, theObject, IDsOfFixedNodes,
2130 MaxNbOfIterations, MaxAspectRatio, Method):
2131 if ( isinstance( theObject, Mesh )):
2132 theObject = theObject.GetMesh()
2133 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2134 MaxNbOfIterations, MaxAspectRatio, Method)
2136 ## Parametrically smoothes the given elements
2137 # @param IDsOfElements the list if ids of elements to smooth
2138 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2139 # Note that nodes built on edges and boundary nodes are always fixed.
2140 # @param MaxNbOfIterations the maximum number of iterations
2141 # @param MaxAspectRatio varies in range [1.0, inf]
2142 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2143 # @return TRUE in case of success, FALSE otherwise.
2144 # @ingroup l2_modif_smooth
2145 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2146 MaxNbOfIterations, MaxAspectRatio, Method):
2147 if IDsOfElements == []:
2148 IDsOfElements = self.GetElementsId()
2149 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2150 MaxNbOfIterations, MaxAspectRatio, Method)
2152 ## Parametrically smoothes the elements which belong to the given object
2153 # @param theObject the object to smooth
2154 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2155 # Note that nodes built on edges and boundary nodes are always fixed.
2156 # @param MaxNbOfIterations the maximum number of iterations
2157 # @param MaxAspectRatio varies in range [1.0, inf]
2158 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2159 # @return TRUE in case of success, FALSE otherwise.
2160 # @ingroup l2_modif_smooth
2161 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2162 MaxNbOfIterations, MaxAspectRatio, Method):
2163 if ( isinstance( theObject, Mesh )):
2164 theObject = theObject.GetMesh()
2165 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2166 MaxNbOfIterations, MaxAspectRatio, Method)
2168 ## Converts the mesh to quadratic, deletes old elements, replacing
2169 # them with quadratic with the same id.
2170 # @ingroup l2_modif_tofromqu
2171 def ConvertToQuadratic(self, theForce3d):
2172 self.editor.ConvertToQuadratic(theForce3d)
2174 ## Converts the mesh from quadratic to ordinary,
2175 # deletes old quadratic elements, \n replacing
2176 # them with ordinary mesh elements with the same id.
2177 # @return TRUE in case of success, FALSE otherwise.
2178 # @ingroup l2_modif_tofromqu
2179 def ConvertFromQuadratic(self):
2180 return self.editor.ConvertFromQuadratic()
2182 ## Renumber mesh nodes
2183 # @ingroup l2_modif_renumber
2184 def RenumberNodes(self):
2185 self.editor.RenumberNodes()
2187 ## Renumber mesh elements
2188 # @ingroup l2_modif_renumber
2189 def RenumberElements(self):
2190 self.editor.RenumberElements()
2192 ## Generates new elements by rotation of the elements around the axis
2193 # @param IDsOfElements the list of ids of elements to sweep
2194 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2195 # @param AngleInRadians the angle of Rotation
2196 # @param NbOfSteps the number of steps
2197 # @param Tolerance tolerance
2198 # @param MakeGroups forces the generation of new groups from existing ones
2199 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2200 # of all steps, else - size of each step
2201 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2202 # @ingroup l2_modif_extrurev
2203 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2204 MakeGroups=False, TotalAngle=False):
2205 if IDsOfElements == []:
2206 IDsOfElements = self.GetElementsId()
2207 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2208 Axis = self.smeshpyD.GetAxisStruct(Axis)
2209 if TotalAngle and NbOfSteps:
2210 AngleInRadians /= NbOfSteps
2212 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2213 AngleInRadians, NbOfSteps, Tolerance)
2214 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2217 ## Generates new elements by rotation of the elements of object around the axis
2218 # @param theObject object which elements should be sweeped
2219 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2220 # @param AngleInRadians the angle of Rotation
2221 # @param NbOfSteps number of steps
2222 # @param Tolerance tolerance
2223 # @param MakeGroups forces the generation of new groups from existing ones
2224 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2225 # of all steps, else - size of each step
2226 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2227 # @ingroup l2_modif_extrurev
2228 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2229 MakeGroups=False, TotalAngle=False):
2230 if ( isinstance( theObject, Mesh )):
2231 theObject = theObject.GetMesh()
2232 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2233 Axis = self.smeshpyD.GetAxisStruct(Axis)
2234 if TotalAngle and NbOfSteps:
2235 AngleInRadians /= NbOfSteps
2237 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2238 NbOfSteps, Tolerance)
2239 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2242 ## Generates new elements by extrusion of the elements with given ids
2243 # @param IDsOfElements the list of elements ids for extrusion
2244 # @param StepVector vector, defining the direction and value of extrusion
2245 # @param NbOfSteps the number of steps
2246 # @param MakeGroups forces the generation of new groups from existing ones
2247 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2248 # @ingroup l2_modif_extrurev
2249 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2250 if IDsOfElements == []:
2251 IDsOfElements = self.GetElementsId()
2252 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2253 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2255 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2256 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2259 ## Generates new elements by extrusion of the elements with given ids
2260 # @param IDsOfElements is ids of elements
2261 # @param StepVector vector, defining the direction and value of extrusion
2262 # @param NbOfSteps the number of steps
2263 # @param ExtrFlags sets flags for extrusion
2264 # @param SewTolerance uses for comparing locations of nodes if flag
2265 # EXTRUSION_FLAG_SEW is set
2266 # @param MakeGroups forces the generation of new groups from existing ones
2267 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2268 # @ingroup l2_modif_extrurev
2269 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2270 ExtrFlags, SewTolerance, MakeGroups=False):
2271 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2272 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2274 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2275 ExtrFlags, SewTolerance)
2276 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2277 ExtrFlags, SewTolerance)
2280 ## Generates new elements by extrusion of the elements which belong to the object
2281 # @param theObject the object which elements should be processed
2282 # @param StepVector vector, defining the direction and value of extrusion
2283 # @param NbOfSteps the number of steps
2284 # @param MakeGroups forces the generation of new groups from existing ones
2285 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2286 # @ingroup l2_modif_extrurev
2287 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2288 if ( isinstance( theObject, Mesh )):
2289 theObject = theObject.GetMesh()
2290 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2291 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2293 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2294 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2297 ## Generates new elements by extrusion of the elements which belong to the object
2298 # @param theObject object which elements should be processed
2299 # @param StepVector vector, defining the direction and value of extrusion
2300 # @param NbOfSteps the number of steps
2301 # @param MakeGroups to generate new groups from existing ones
2302 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2303 # @ingroup l2_modif_extrurev
2304 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2305 if ( isinstance( theObject, Mesh )):
2306 theObject = theObject.GetMesh()
2307 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2308 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2310 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2311 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2314 ## Generates new elements by extrusion of the elements which belong to the object
2315 # @param theObject object which elements should be processed
2316 # @param StepVector vector, defining the direction and value of extrusion
2317 # @param NbOfSteps the number of steps
2318 # @param MakeGroups forces the generation of new groups from existing ones
2319 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2320 # @ingroup l2_modif_extrurev
2321 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2322 if ( isinstance( theObject, Mesh )):
2323 theObject = theObject.GetMesh()
2324 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2325 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2327 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2328 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2331 ## Generates new elements by extrusion of the given elements
2332 # The path of extrusion must be a meshed edge.
2333 # @param IDsOfElements ids of elements
2334 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2335 # @param PathShape shape(edge) defines the sub-mesh for the path
2336 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2337 # @param HasAngles allows the shape to be rotated around the path
2338 # to get the resulting mesh in a helical fashion
2339 # @param Angles list of angles
2340 # @param HasRefPoint allows using the reference point
2341 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2342 # The User can specify any point as the Reference Point.
2343 # @param MakeGroups forces the generation of new groups from existing ones
2344 # @param LinearVariation forces the computation of rotation angles as linear
2345 # variation of the given Angles along path steps
2346 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2347 # only SMESH::Extrusion_Error otherwise
2348 # @ingroup l2_modif_extrurev
2349 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2350 HasAngles, Angles, HasRefPoint, RefPoint,
2351 MakeGroups=False, LinearVariation=False):
2352 if IDsOfElements == []:
2353 IDsOfElements = self.GetElementsId()
2354 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2355 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2357 if ( isinstance( PathMesh, Mesh )):
2358 PathMesh = PathMesh.GetMesh()
2359 if HasAngles and Angles and LinearVariation:
2360 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2363 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2364 PathShape, NodeStart, HasAngles,
2365 Angles, HasRefPoint, RefPoint)
2366 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2367 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2369 ## Generates new elements by extrusion of the elements which belong to the object
2370 # The path of extrusion must be a meshed edge.
2371 # @param theObject the object which elements should be processed
2372 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2373 # @param PathShape shape(edge) defines the sub-mesh for the path
2374 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2375 # @param HasAngles allows the shape to be rotated around the path
2376 # to get the resulting mesh in a helical fashion
2377 # @param Angles list of angles
2378 # @param HasRefPoint allows using the reference point
2379 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2380 # The User can specify any point as the Reference Point.
2381 # @param MakeGroups forces the generation of new groups from existing ones
2382 # @param LinearVariation forces the computation of rotation angles as linear
2383 # variation of the given Angles along path steps
2384 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2385 # only SMESH::Extrusion_Error otherwise
2386 # @ingroup l2_modif_extrurev
2387 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2388 HasAngles, Angles, HasRefPoint, RefPoint,
2389 MakeGroups=False, LinearVariation=False):
2390 if ( isinstance( theObject, Mesh )):
2391 theObject = theObject.GetMesh()
2392 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2393 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2394 if ( isinstance( PathMesh, Mesh )):
2395 PathMesh = PathMesh.GetMesh()
2396 if HasAngles and Angles and LinearVariation:
2397 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2400 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2401 PathShape, NodeStart, HasAngles,
2402 Angles, HasRefPoint, RefPoint)
2403 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2404 NodeStart, HasAngles, Angles, HasRefPoint,
2407 ## Creates a symmetrical copy of mesh elements
2408 # @param IDsOfElements list of elements ids
2409 # @param Mirror is AxisStruct or geom object(point, line, plane)
2410 # @param theMirrorType is POINT, AXIS or PLANE
2411 # If the Mirror is a geom object this parameter is unnecessary
2412 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2413 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2414 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2415 # @ingroup l2_modif_trsf
2416 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2417 if IDsOfElements == []:
2418 IDsOfElements = self.GetElementsId()
2419 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2420 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2421 if Copy and MakeGroups:
2422 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2423 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2426 ## Creates a new mesh by a symmetrical copy of mesh elements
2427 # @param IDsOfElements the list of elements ids
2428 # @param Mirror is AxisStruct or geom object (point, line, plane)
2429 # @param theMirrorType is POINT, AXIS or PLANE
2430 # If the Mirror is a geom object this parameter is unnecessary
2431 # @param MakeGroups to generate new groups from existing ones
2432 # @param NewMeshName a name of the new mesh to create
2433 # @return instance of Mesh class
2434 # @ingroup l2_modif_trsf
2435 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2436 if IDsOfElements == []:
2437 IDsOfElements = self.GetElementsId()
2438 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2439 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2440 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2441 MakeGroups, NewMeshName)
2442 return Mesh(self.smeshpyD,self.geompyD,mesh)
2444 ## Creates a symmetrical copy of the object
2445 # @param theObject mesh, submesh or group
2446 # @param Mirror AxisStruct or geom object (point, line, plane)
2447 # @param theMirrorType is POINT, AXIS or PLANE
2448 # If the Mirror is a geom object this parameter is unnecessary
2449 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2450 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2451 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2452 # @ingroup l2_modif_trsf
2453 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2454 if ( isinstance( theObject, Mesh )):
2455 theObject = theObject.GetMesh()
2456 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2457 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2458 if Copy and MakeGroups:
2459 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2460 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2463 ## Creates a new mesh by a symmetrical copy of the object
2464 # @param theObject mesh, submesh or group
2465 # @param Mirror AxisStruct or geom object (point, line, plane)
2466 # @param theMirrorType POINT, AXIS or PLANE
2467 # If the Mirror is a geom object this parameter is unnecessary
2468 # @param MakeGroups forces the generation of new groups from existing ones
2469 # @param NewMeshName the name of the new mesh to create
2470 # @return instance of Mesh class
2471 # @ingroup l2_modif_trsf
2472 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2473 if ( isinstance( theObject, Mesh )):
2474 theObject = theObject.GetMesh()
2475 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2476 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2477 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2478 MakeGroups, NewMeshName)
2479 return Mesh( self.smeshpyD,self.geompyD,mesh )
2481 ## Translates the elements
2482 # @param IDsOfElements list of elements ids
2483 # @param Vector the direction of translation (DirStruct or vector)
2484 # @param Copy allows copying the translated elements
2485 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2486 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2487 # @ingroup l2_modif_trsf
2488 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2489 if IDsOfElements == []:
2490 IDsOfElements = self.GetElementsId()
2491 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2492 Vector = self.smeshpyD.GetDirStruct(Vector)
2493 if Copy and MakeGroups:
2494 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
2495 self.editor.Translate(IDsOfElements, Vector, Copy)
2498 ## Creates a new mesh of translated elements
2499 # @param IDsOfElements list of elements ids
2500 # @param Vector the direction of translation (DirStruct or vector)
2501 # @param MakeGroups forces the generation of new groups from existing ones
2502 # @param NewMeshName the name of the newly created mesh
2503 # @return instance of Mesh class
2504 # @ingroup l2_modif_trsf
2505 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
2506 if IDsOfElements == []:
2507 IDsOfElements = self.GetElementsId()
2508 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2509 Vector = self.smeshpyD.GetDirStruct(Vector)
2510 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
2511 return Mesh ( self.smeshpyD, self.geompyD, mesh )
2513 ## Translates the object
2514 # @param theObject the object to translate (mesh, submesh, or group)
2515 # @param Vector direction of translation (DirStruct or geom vector)
2516 # @param Copy allows copying the translated elements
2517 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2518 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2519 # @ingroup l2_modif_trsf
2520 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
2521 if ( isinstance( theObject, Mesh )):
2522 theObject = theObject.GetMesh()
2523 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2524 Vector = self.smeshpyD.GetDirStruct(Vector)
2525 if Copy and MakeGroups:
2526 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
2527 self.editor.TranslateObject(theObject, Vector, Copy)
2530 ## Creates a new mesh from the translated object
2531 # @param theObject the object to translate (mesh, submesh, or group)
2532 # @param Vector the direction of translation (DirStruct or geom vector)
2533 # @param MakeGroups forces the generation of new groups from existing ones
2534 # @param NewMeshName the name of the newly created mesh
2535 # @return instance of Mesh class
2536 # @ingroup l2_modif_trsf
2537 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
2538 if (isinstance(theObject, Mesh)):
2539 theObject = theObject.GetMesh()
2540 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
2541 Vector = self.smeshpyD.GetDirStruct(Vector)
2542 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
2543 return Mesh( self.smeshpyD, self.geompyD, mesh )
2545 ## Rotates the elements
2546 # @param IDsOfElements list of elements ids
2547 # @param Axis the axis of rotation (AxisStruct or geom line)
2548 # @param AngleInRadians the angle of rotation (in radians)
2549 # @param Copy allows copying the rotated elements
2550 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2551 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2552 # @ingroup l2_modif_trsf
2553 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
2554 if IDsOfElements == []:
2555 IDsOfElements = self.GetElementsId()
2556 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2557 Axis = self.smeshpyD.GetAxisStruct(Axis)
2558 if Copy and MakeGroups:
2559 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
2560 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2563 ## Creates a new mesh of rotated elements
2564 # @param IDsOfElements list of element ids
2565 # @param Axis the axis of rotation (AxisStruct or geom line)
2566 # @param AngleInRadians the angle of rotation (in radians)
2567 # @param MakeGroups forces the generation of new groups from existing ones
2568 # @param NewMeshName the name of the newly created mesh
2569 # @return instance of Mesh class
2570 # @ingroup l2_modif_trsf
2571 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
2572 if IDsOfElements == []:
2573 IDsOfElements = self.GetElementsId()
2574 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2575 Axis = self.smeshpyD.GetAxisStruct(Axis)
2576 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
2577 MakeGroups, NewMeshName)
2578 return Mesh( self.smeshpyD, self.geompyD, mesh )
2580 ## Rotates the object
2581 # @param theObject the object to rotate( mesh, submesh, or group)
2582 # @param Axis the axis of rotation (AxisStruct or geom line)
2583 # @param AngleInRadians the angle of rotation (in radians)
2584 # @param Copy allows copying the rotated elements
2585 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2586 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2587 # @ingroup l2_modif_trsf
2588 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
2589 if (isinstance(theObject, Mesh)):
2590 theObject = theObject.GetMesh()
2591 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2592 Axis = self.smeshpyD.GetAxisStruct(Axis)
2593 if Copy and MakeGroups:
2594 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
2595 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2598 ## Creates a new mesh from the rotated object
2599 # @param theObject the object to rotate (mesh, submesh, or group)
2600 # @param Axis the axis of rotation (AxisStruct or geom line)
2601 # @param AngleInRadians the angle of rotation (in radians)
2602 # @param MakeGroups forces the generation of new groups from existing ones
2603 # @param NewMeshName the name of the newly created mesh
2604 # @return instance of Mesh class
2605 # @ingroup l2_modif_trsf
2606 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
2607 if (isinstance( theObject, Mesh )):
2608 theObject = theObject.GetMesh()
2609 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2610 Axis = self.smeshpyD.GetAxisStruct(Axis)
2611 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
2612 MakeGroups, NewMeshName)
2613 return Mesh( self.smeshpyD, self.geompyD, mesh )
2615 ## Finds groups of ajacent nodes within Tolerance.
2616 # @param Tolerance the value of tolerance
2617 # @return the list of groups of nodes
2618 # @ingroup l2_modif_trsf
2619 def FindCoincidentNodes (self, Tolerance):
2620 return self.editor.FindCoincidentNodes(Tolerance)
2622 ## Finds groups of ajacent nodes within Tolerance.
2623 # @param Tolerance the value of tolerance
2624 # @param SubMeshOrGroup SubMesh or Group
2625 # @return the list of groups of nodes
2626 # @ingroup l2_modif_trsf
2627 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
2628 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
2631 # @param GroupsOfNodes the list of groups of nodes
2632 # @ingroup l2_modif_trsf
2633 def MergeNodes (self, GroupsOfNodes):
2634 self.editor.MergeNodes(GroupsOfNodes)
2636 ## Finds the elements built on the same nodes.
2637 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
2638 # @return a list of groups of equal elements
2639 # @ingroup l2_modif_trsf
2640 def FindEqualElements (self, MeshOrSubMeshOrGroup):
2641 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
2643 ## Merges elements in each given group.
2644 # @param GroupsOfElementsID groups of elements for merging
2645 # @ingroup l2_modif_trsf
2646 def MergeElements(self, GroupsOfElementsID):
2647 self.editor.MergeElements(GroupsOfElementsID)
2649 ## Leaves one element and removes all other elements built on the same nodes.
2650 # @ingroup l2_modif_trsf
2651 def MergeEqualElements(self):
2652 self.editor.MergeEqualElements()
2654 ## Sews free borders
2655 # @return SMESH::Sew_Error
2656 # @ingroup l2_modif_trsf
2657 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2658 FirstNodeID2, SecondNodeID2, LastNodeID2,
2659 CreatePolygons, CreatePolyedrs):
2660 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2661 FirstNodeID2, SecondNodeID2, LastNodeID2,
2662 CreatePolygons, CreatePolyedrs)
2664 ## Sews conform free borders
2665 # @return SMESH::Sew_Error
2666 # @ingroup l2_modif_trsf
2667 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2668 FirstNodeID2, SecondNodeID2):
2669 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2670 FirstNodeID2, SecondNodeID2)
2672 ## Sews border to side
2673 # @return SMESH::Sew_Error
2674 # @ingroup l2_modif_trsf
2675 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2676 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
2677 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2678 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
2680 ## Sews two sides of a mesh. The nodes belonging to Side1 are
2681 # merged with the nodes of elements of Side2.
2682 # The number of elements in theSide1 and in theSide2 must be
2683 # equal and they should have similar nodal connectivity.
2684 # The nodes to merge should belong to side borders and
2685 # the first node should be linked to the second.
2686 # @return SMESH::Sew_Error
2687 # @ingroup l2_modif_trsf
2688 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
2689 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2690 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
2691 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
2692 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2693 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
2695 ## Sets new nodes for the given element.
2696 # @param ide the element id
2697 # @param newIDs nodes ids
2698 # @return If the number of nodes does not correspond to the type of element - returns false
2699 # @ingroup l2_modif_edit
2700 def ChangeElemNodes(self, ide, newIDs):
2701 return self.editor.ChangeElemNodes(ide, newIDs)
2703 ## If during the last operation of MeshEditor some nodes were
2704 # created, this method returns the list of their IDs, \n
2705 # if new nodes were not created - returns empty list
2706 # @return the list of integer values (can be empty)
2707 # @ingroup l1_auxiliary
2708 def GetLastCreatedNodes(self):
2709 return self.editor.GetLastCreatedNodes()
2711 ## If during the last operation of MeshEditor some elements were
2712 # created this method returns the list of their IDs, \n
2713 # if new elements were not created - returns empty list
2714 # @return the list of integer values (can be empty)
2715 # @ingroup l1_auxiliary
2716 def GetLastCreatedElems(self):
2717 return self.editor.GetLastCreatedElems()
2719 ## Creates a hole in a mesh by doubling the nodes of some particular elements
2720 # @param theNodes identifiers of nodes to be doubled
2721 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
2722 # nodes. If list of element identifiers is empty then nodes are doubled but
2723 # they not assigned to elements
2724 # @return TRUE if operation has been completed successfully, FALSE otherwise
2725 # @ingroup l2_modif_edit
2726 def DoubleNodes(self, theNodes, theModifiedElems):
2727 return self.editor.DoubleNodes(theNodes, theModifiedElems)
2729 ## Creates a hole in a mesh by doubling the nodes of some particular elements
2730 # This method provided for convenience works as DoubleNodes() described above.
2731 # @param theNodes identifiers of node to be doubled
2732 # @param theModifiedElems identifiers of elements to be updated
2733 # @return TRUE if operation has been completed successfully, FALSE otherwise
2734 # @ingroup l2_modif_edit
2735 def DoubleNode(self, theNodeId, theModifiedElems):
2736 return self.editor.DoubleNode(theNodeId, theModifiedElems)
2738 ## Creates a hole in a mesh by doubling the nodes of some particular elements
2739 # This method provided for convenience works as DoubleNodes() described above.
2740 # @param theNodes group of nodes to be doubled
2741 # @param theModifiedElems group of elements to be updated.
2742 # @return TRUE if operation has been completed successfully, FALSE otherwise
2743 # @ingroup l2_modif_edit
2744 def DoubleNodeGroup(self, theNodes, theModifiedElems):
2745 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
2747 ## Creates a hole in a mesh by doubling the nodes of some particular elements
2748 # This method provided for convenience works as DoubleNodes() described above.
2749 # @param theNodes list of groups of nodes to be doubled
2750 # @param theModifiedElems list of groups of elements to be updated.
2751 # @return TRUE if operation has been completed successfully, FALSE otherwise
2752 # @ingroup l2_modif_edit
2753 def DoubleNodeGroups(self, theNodes, theModifiedElems):
2754 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
2756 ## The mother class to define algorithm, it is not recommended to use it directly.
2759 # @ingroup l2_algorithms
2760 class Mesh_Algorithm:
2761 # @class Mesh_Algorithm
2762 # @brief Class Mesh_Algorithm
2764 #def __init__(self,smesh):
2772 ## Finds a hypothesis in the study by its type name and parameters.
2773 # Finds only the hypotheses created in smeshpyD engine.
2774 # @return SMESH.SMESH_Hypothesis
2775 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
2776 study = smeshpyD.GetCurrentStudy()
2777 #to do: find component by smeshpyD object, not by its data type
2778 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2779 if scomp is not None:
2780 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
2781 # Check if the root label of the hypotheses exists
2782 if res and hypRoot is not None:
2783 iter = study.NewChildIterator(hypRoot)
2784 # Check all published hypotheses
2786 hypo_so_i = iter.Value()
2787 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
2788 if attr is not None:
2789 anIOR = attr.Value()
2790 hypo_o_i = salome.orb.string_to_object(anIOR)
2791 if hypo_o_i is not None:
2792 # Check if this is a hypothesis
2793 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
2794 if hypo_i is not None:
2795 # Check if the hypothesis belongs to current engine
2796 if smeshpyD.GetObjectId(hypo_i) > 0:
2797 # Check if this is the required hypothesis
2798 if hypo_i.GetName() == hypname:
2800 if CompareMethod(hypo_i, args):
2814 ## Finds the algorithm in the study by its type name.
2815 # Finds only the algorithms, which have been created in smeshpyD engine.
2816 # @return SMESH.SMESH_Algo
2817 def FindAlgorithm (self, algoname, smeshpyD):
2818 study = smeshpyD.GetCurrentStudy()
2819 #to do: find component by smeshpyD object, not by its data type
2820 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2821 if scomp is not None:
2822 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
2823 # Check if the root label of the algorithms exists
2824 if res and hypRoot is not None:
2825 iter = study.NewChildIterator(hypRoot)
2826 # Check all published algorithms
2828 algo_so_i = iter.Value()
2829 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
2830 if attr is not None:
2831 anIOR = attr.Value()
2832 algo_o_i = salome.orb.string_to_object(anIOR)
2833 if algo_o_i is not None:
2834 # Check if this is an algorithm
2835 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
2836 if algo_i is not None:
2837 # Checks if the algorithm belongs to the current engine
2838 if smeshpyD.GetObjectId(algo_i) > 0:
2839 # Check if this is the required algorithm
2840 if algo_i.GetName() == algoname:
2853 ## If the algorithm is global, returns 0; \n
2854 # else returns the submesh associated to this algorithm.
2855 def GetSubMesh(self):
2858 ## Returns the wrapped mesher.
2859 def GetAlgorithm(self):
2862 ## Gets the list of hypothesis that can be used with this algorithm
2863 def GetCompatibleHypothesis(self):
2866 mylist = self.algo.GetCompatibleHypothesis()
2869 ## Gets the name of the algorithm
2873 ## Sets the name to the algorithm
2874 def SetName(self, name):
2875 SetName(self.algo, name)
2877 ## Gets the id of the algorithm
2879 return self.algo.GetId()
2882 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
2884 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
2885 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
2887 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
2889 self.Assign(algo, mesh, geom)
2893 def Assign(self, algo, mesh, geom):
2895 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
2902 name = GetName(geom)
2904 name = mesh.geompyD.SubShapeName(geom, piece)
2905 mesh.geompyD.addToStudyInFather(piece, geom, name)
2906 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
2909 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
2910 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
2912 def CompareHyp (self, hyp, args):
2913 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
2916 def CompareEqualHyp (self, hyp, args):
2920 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
2921 UseExisting=0, CompareMethod=""):
2924 if CompareMethod == "": CompareMethod = self.CompareHyp
2925 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
2928 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
2934 a = a + s + str(args[i])
2938 SetName(hypo, hyp + a)
2940 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
2941 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
2945 # Public class: Mesh_Segment
2946 # --------------------------
2948 ## Class to define a segment 1D algorithm for discretization
2951 # @ingroup l3_algos_basic
2952 class Mesh_Segment(Mesh_Algorithm):
2954 ## Private constructor.
2955 def __init__(self, mesh, geom=0):
2956 Mesh_Algorithm.__init__(self)
2957 self.Create(mesh, geom, "Regular_1D")
2959 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
2960 # @param l for the length of segments that cut an edge
2961 # @param UseExisting if ==true - searches for an existing hypothesis created with
2962 # the same parameters, else (default) - creates a new one
2963 # @param p precision, used for calculation of the number of segments.
2964 # The precision should be a positive, meaningful value within the range [0,1].
2965 # In general, the number of segments is calculated with the formula:
2966 # nb = ceil((edge_length / l) - p)
2967 # Function ceil rounds its argument to the higher integer.
2968 # So, p=0 means rounding of (edge_length / l) to the higher integer,
2969 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
2970 # p=1 means rounding of (edge_length / l) to the lower integer.
2971 # Default value is 1e-07.
2972 # @return an instance of StdMeshers_LocalLength hypothesis
2973 # @ingroup l3_hypos_1dhyps
2974 def LocalLength(self, l, UseExisting=0, p=1e-07):
2975 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
2976 CompareMethod=self.CompareLocalLength)
2982 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
2983 def CompareLocalLength(self, hyp, args):
2984 if IsEqual(hyp.GetLength(), args[0]):
2985 return IsEqual(hyp.GetPrecision(), args[1])
2988 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
2989 # @param n for the number of segments that cut an edge
2990 # @param s for the scale factor (optional)
2991 # @param UseExisting if ==true - searches for an existing hypothesis created with
2992 # the same parameters, else (default) - create a new one
2993 # @return an instance of StdMeshers_NumberOfSegments hypothesis
2994 # @ingroup l3_hypos_1dhyps
2995 def NumberOfSegments(self, n, s=[], UseExisting=0):
2997 hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
2998 CompareMethod=self.CompareNumberOfSegments)
3000 hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
3001 CompareMethod=self.CompareNumberOfSegments)
3002 hyp.SetDistrType( 1 )
3003 hyp.SetScaleFactor(s)
3004 hyp.SetNumberOfSegments(n)
3008 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3009 def CompareNumberOfSegments(self, hyp, args):
3010 if hyp.GetNumberOfSegments() == args[0]:
3014 if hyp.GetDistrType() == 1:
3015 if IsEqual(hyp.GetScaleFactor(), args[1]):
3019 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3020 # @param start defines the length of the first segment
3021 # @param end defines the length of the last segment
3022 # @param UseExisting if ==true - searches for an existing hypothesis created with
3023 # the same parameters, else (default) - creates a new one
3024 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3025 # @ingroup l3_hypos_1dhyps
3026 def Arithmetic1D(self, start, end, UseExisting=0):
3027 hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
3028 CompareMethod=self.CompareArithmetic1D)
3029 hyp.SetLength(start, 1)
3030 hyp.SetLength(end , 0)
3034 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3035 def CompareArithmetic1D(self, hyp, args):
3036 if IsEqual(hyp.GetLength(1), args[0]):
3037 if IsEqual(hyp.GetLength(0), args[1]):
3041 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3042 # @param start defines the length of the first segment
3043 # @param end defines the length of the last segment
3044 # @param UseExisting if ==true - searches for an existing hypothesis created with
3045 # the same parameters, else (default) - creates a new one
3046 # @return an instance of StdMeshers_StartEndLength hypothesis
3047 # @ingroup l3_hypos_1dhyps
3048 def StartEndLength(self, start, end, UseExisting=0):
3049 hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
3050 CompareMethod=self.CompareStartEndLength)
3051 hyp.SetLength(start, 1)
3052 hyp.SetLength(end , 0)
3055 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3056 def CompareStartEndLength(self, hyp, args):
3057 if IsEqual(hyp.GetLength(1), args[0]):
3058 if IsEqual(hyp.GetLength(0), args[1]):
3062 ## Defines "Deflection1D" hypothesis
3063 # @param d for the deflection
3064 # @param UseExisting if ==true - searches for an existing hypothesis created with
3065 # the same parameters, else (default) - create a new one
3066 # @ingroup l3_hypos_1dhyps
3067 def Deflection1D(self, d, UseExisting=0):
3068 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3069 CompareMethod=self.CompareDeflection1D)
3070 hyp.SetDeflection(d)
3073 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3074 def CompareDeflection1D(self, hyp, args):
3075 return IsEqual(hyp.GetDeflection(), args[0])
3077 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3078 # the opposite side in case of quadrangular faces
3079 # @ingroup l3_hypos_additi
3080 def Propagation(self):
3081 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3083 ## Defines "AutomaticLength" hypothesis
3084 # @param fineness for the fineness [0-1]
3085 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3086 # same parameters, else (default) - create a new one
3087 # @ingroup l3_hypos_1dhyps
3088 def AutomaticLength(self, fineness=0, UseExisting=0):
3089 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3090 CompareMethod=self.CompareAutomaticLength)
3091 hyp.SetFineness( fineness )
3094 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3095 def CompareAutomaticLength(self, hyp, args):
3096 return IsEqual(hyp.GetFineness(), args[0])
3098 ## Defines "SegmentLengthAroundVertex" hypothesis
3099 # @param length for the segment length
3100 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3101 # Any other integer value means that the hypothesis will be set on the
3102 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3103 # @param UseExisting if ==true - searches for an existing hypothesis created with
3104 # the same parameters, else (default) - creates a new one
3105 # @ingroup l3_algos_segmarv
3106 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3108 store_geom = self.geom
3109 if type(vertex) is types.IntType:
3110 if vertex == 0 or vertex == 1:
3111 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3119 if self.geom is None:
3120 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3121 name = GetName(self.geom)
3123 piece = self.mesh.geom
3124 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3125 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3126 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3128 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3130 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3131 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3133 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3134 CompareMethod=self.CompareLengthNearVertex)
3135 self.geom = store_geom
3136 hyp.SetLength( length )
3139 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3140 # @ingroup l3_algos_segmarv
3141 def CompareLengthNearVertex(self, hyp, args):
3142 return IsEqual(hyp.GetLength(), args[0])
3144 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3145 # If the 2D mesher sees that all boundary edges are quadratic,
3146 # it generates quadratic faces, else it generates linear faces using
3147 # medium nodes as if they are vertices.
3148 # The 3D mesher generates quadratic volumes only if all boundary faces
3149 # are quadratic, else it fails.
3151 # @ingroup l3_hypos_additi
3152 def QuadraticMesh(self):
3153 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3156 # Public class: Mesh_CompositeSegment
3157 # --------------------------
3159 ## Defines a segment 1D algorithm for discretization
3161 # @ingroup l3_algos_basic
3162 class Mesh_CompositeSegment(Mesh_Segment):
3164 ## Private constructor.
3165 def __init__(self, mesh, geom=0):
3166 self.Create(mesh, geom, "CompositeSegment_1D")
3169 # Public class: Mesh_Segment_Python
3170 # ---------------------------------
3172 ## Defines a segment 1D algorithm for discretization with python function
3174 # @ingroup l3_algos_basic
3175 class Mesh_Segment_Python(Mesh_Segment):
3177 ## Private constructor.
3178 def __init__(self, mesh, geom=0):
3179 import Python1dPlugin
3180 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3182 ## Defines "PythonSplit1D" hypothesis
3183 # @param n for the number of segments that cut an edge
3184 # @param func for the python function that calculates the length of all segments
3185 # @param UseExisting if ==true - searches for the existing hypothesis created with
3186 # the same parameters, else (default) - creates a new one
3187 # @ingroup l3_hypos_1dhyps
3188 def PythonSplit1D(self, n, func, UseExisting=0):
3189 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3190 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3191 hyp.SetNumberOfSegments(n)
3192 hyp.SetPythonLog10RatioFunction(func)
3195 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3196 def ComparePythonSplit1D(self, hyp, args):
3197 #if hyp.GetNumberOfSegments() == args[0]:
3198 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3202 # Public class: Mesh_Triangle
3203 # ---------------------------
3205 ## Defines a triangle 2D algorithm
3207 # @ingroup l3_algos_basic
3208 class Mesh_Triangle(Mesh_Algorithm):
3217 ## Private constructor.
3218 def __init__(self, mesh, algoType, geom=0):
3219 Mesh_Algorithm.__init__(self)
3221 self.algoType = algoType
3222 if algoType == MEFISTO:
3223 self.Create(mesh, geom, "MEFISTO_2D")
3225 elif algoType == BLSURF:
3227 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3228 #self.SetPhysicalMesh() - PAL19680
3229 elif algoType == NETGEN:
3231 print "Warning: NETGENPlugin module unavailable"
3233 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3235 elif algoType == NETGEN_2D:
3237 print "Warning: NETGENPlugin module unavailable"
3239 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3242 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3243 # @param area for the maximum area of each triangle
3244 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3245 # same parameters, else (default) - creates a new one
3247 # Only for algoType == MEFISTO || NETGEN_2D
3248 # @ingroup l3_hypos_2dhyps
3249 def MaxElementArea(self, area, UseExisting=0):
3250 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3251 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3252 CompareMethod=self.CompareMaxElementArea)
3253 elif self.algoType == NETGEN:
3254 hyp = self.Parameters(SIMPLE)
3255 hyp.SetMaxElementArea(area)
3258 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3259 def CompareMaxElementArea(self, hyp, args):
3260 return IsEqual(hyp.GetMaxElementArea(), args[0])
3262 ## Defines "LengthFromEdges" hypothesis to build triangles
3263 # based on the length of the edges taken from the wire
3265 # Only for algoType == MEFISTO || NETGEN_2D
3266 # @ingroup l3_hypos_2dhyps
3267 def LengthFromEdges(self):
3268 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3269 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3271 elif self.algoType == NETGEN:
3272 hyp = self.Parameters(SIMPLE)
3273 hyp.LengthFromEdges()
3276 ## Sets a way to define size of mesh elements to generate.
3277 # @param thePhysicalMesh is: DefaultSize or Custom.
3278 # @ingroup l3_hypos_blsurf
3279 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3280 # Parameter of BLSURF algo
3281 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3283 ## Sets size of mesh elements to generate.
3284 # @ingroup l3_hypos_blsurf
3285 def SetPhySize(self, theVal):
3286 # Parameter of BLSURF algo
3287 self.Parameters().SetPhySize(theVal)
3289 ## Sets lower boundary of mesh element size (PhySize).
3290 # @ingroup l3_hypos_blsurf
3291 def SetPhyMin(self, theVal=-1):
3292 # Parameter of BLSURF algo
3293 self.Parameters().SetPhyMin(theVal)
3295 ## Sets upper boundary of mesh element size (PhySize).
3296 # @ingroup l3_hypos_blsurf
3297 def SetPhyMax(self, theVal=-1):
3298 # Parameter of BLSURF algo
3299 self.Parameters().SetPhyMax(theVal)
3301 ## Sets a way to define maximum angular deflection of mesh from CAD model.
3302 # @param theGeometricMesh is: DefaultGeom or Custom
3303 # @ingroup l3_hypos_blsurf
3304 def SetGeometricMesh(self, theGeometricMesh=0):
3305 # Parameter of BLSURF algo
3306 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3307 self.params.SetGeometricMesh(theGeometricMesh)
3309 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3310 # @ingroup l3_hypos_blsurf
3311 def SetAngleMeshS(self, theVal=_angleMeshS):
3312 # Parameter of BLSURF algo
3313 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3314 self.params.SetAngleMeshS(theVal)
3316 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3317 # @ingroup l3_hypos_blsurf
3318 def SetAngleMeshC(self, theVal=_angleMeshS):
3319 # Parameter of BLSURF algo
3320 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3321 self.params.SetAngleMeshC(theVal)
3323 ## Sets lower boundary of mesh element size computed to respect angular deflection.
3324 # @ingroup l3_hypos_blsurf
3325 def SetGeoMin(self, theVal=-1):
3326 # Parameter of BLSURF algo
3327 self.Parameters().SetGeoMin(theVal)
3329 ## Sets upper boundary of mesh element size computed to respect angular deflection.
3330 # @ingroup l3_hypos_blsurf
3331 def SetGeoMax(self, theVal=-1):
3332 # Parameter of BLSURF algo
3333 self.Parameters().SetGeoMax(theVal)
3335 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3336 # @ingroup l3_hypos_blsurf
3337 def SetGradation(self, theVal=_gradation):
3338 # Parameter of BLSURF algo
3339 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3340 self.params.SetGradation(theVal)
3342 ## Sets topology usage way.
3343 # @param way defines how mesh conformity is assured <ul>
3344 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
3345 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
3346 # @ingroup l3_hypos_blsurf
3347 def SetTopology(self, way):
3348 # Parameter of BLSURF algo
3349 self.Parameters().SetTopology(way)
3351 ## To respect geometrical edges or not.
3352 # @ingroup l3_hypos_blsurf
3353 def SetDecimesh(self, toIgnoreEdges=False):
3354 # Parameter of BLSURF algo
3355 self.Parameters().SetDecimesh(toIgnoreEdges)
3357 ## Sets verbosity level in the range 0 to 100.
3358 # @ingroup l3_hypos_blsurf
3359 def SetVerbosity(self, level):
3360 # Parameter of BLSURF algo
3361 self.Parameters().SetVerbosity(level)
3363 ## Sets advanced option value.
3364 # @ingroup l3_hypos_blsurf
3365 def SetOptionValue(self, optionName, level):
3366 # Parameter of BLSURF algo
3367 self.Parameters().SetOptionValue(optionName,level)
3369 ## Sets QuadAllowed flag.
3370 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
3371 # @ingroup l3_hypos_netgen l3_hypos_blsurf
3372 def SetQuadAllowed(self, toAllow=True):
3373 if self.algoType == NETGEN_2D:
3374 if toAllow: # add QuadranglePreference
3375 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3376 else: # remove QuadranglePreference
3377 for hyp in self.mesh.GetHypothesisList( self.geom ):
3378 if hyp.GetName() == "QuadranglePreference":
3379 self.mesh.RemoveHypothesis( self.geom, hyp )
3384 if self.Parameters():
3385 self.params.SetQuadAllowed(toAllow)
3388 ## Defines hypothesis having several parameters
3390 # @ingroup l3_hypos_netgen
3391 def Parameters(self, which=SOLE):
3394 if self.algoType == NETGEN:
3396 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
3397 "libNETGENEngine.so", UseExisting=0)
3399 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
3400 "libNETGENEngine.so", UseExisting=0)
3402 elif self.algoType == MEFISTO:
3403 print "Mefisto algo support no multi-parameter hypothesis"
3405 elif self.algoType == NETGEN_2D:
3406 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
3407 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3409 elif self.algoType == BLSURF:
3410 self.params = self.Hypothesis("BLSURF_Parameters", [],
3411 "libBLSURFEngine.so", UseExisting=0)
3414 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
3419 # Only for algoType == NETGEN
3420 # @ingroup l3_hypos_netgen
3421 def SetMaxSize(self, theSize):
3422 if self.Parameters():
3423 self.params.SetMaxSize(theSize)
3425 ## Sets SecondOrder flag
3427 # Only for algoType == NETGEN
3428 # @ingroup l3_hypos_netgen
3429 def SetSecondOrder(self, theVal):
3430 if self.Parameters():
3431 self.params.SetSecondOrder(theVal)
3433 ## Sets Optimize flag
3435 # Only for algoType == NETGEN
3436 # @ingroup l3_hypos_netgen
3437 def SetOptimize(self, theVal):
3438 if self.Parameters():
3439 self.params.SetOptimize(theVal)
3442 # @param theFineness is:
3443 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3445 # Only for algoType == NETGEN
3446 # @ingroup l3_hypos_netgen
3447 def SetFineness(self, theFineness):
3448 if self.Parameters():
3449 self.params.SetFineness(theFineness)
3453 # Only for algoType == NETGEN
3454 # @ingroup l3_hypos_netgen
3455 def SetGrowthRate(self, theRate):
3456 if self.Parameters():
3457 self.params.SetGrowthRate(theRate)
3459 ## Sets NbSegPerEdge
3461 # Only for algoType == NETGEN
3462 # @ingroup l3_hypos_netgen
3463 def SetNbSegPerEdge(self, theVal):
3464 if self.Parameters():
3465 self.params.SetNbSegPerEdge(theVal)
3467 ## Sets NbSegPerRadius
3469 # Only for algoType == NETGEN
3470 # @ingroup l3_hypos_netgen
3471 def SetNbSegPerRadius(self, theVal):
3472 if self.Parameters():
3473 self.params.SetNbSegPerRadius(theVal)
3475 ## Sets number of segments overriding value set by SetLocalLength()
3477 # Only for algoType == NETGEN
3478 # @ingroup l3_hypos_netgen
3479 def SetNumberOfSegments(self, theVal):
3480 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3482 ## Sets number of segments overriding value set by SetNumberOfSegments()
3484 # Only for algoType == NETGEN
3485 # @ingroup l3_hypos_netgen
3486 def SetLocalLength(self, theVal):
3487 self.Parameters(SIMPLE).SetLocalLength(theVal)
3492 # Public class: Mesh_Quadrangle
3493 # -----------------------------
3495 ## Defines a quadrangle 2D algorithm
3497 # @ingroup l3_algos_basic
3498 class Mesh_Quadrangle(Mesh_Algorithm):
3500 ## Private constructor.
3501 def __init__(self, mesh, geom=0):
3502 Mesh_Algorithm.__init__(self)
3503 self.Create(mesh, geom, "Quadrangle_2D")
3505 ## Defines "QuadranglePreference" hypothesis, forcing construction
3506 # of quadrangles if the number of nodes on the opposite edges is not the same
3507 # while the total number of nodes on edges is even
3509 # @ingroup l3_hypos_additi
3510 def QuadranglePreference(self):
3511 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
3512 CompareMethod=self.CompareEqualHyp)
3515 ## Defines "TrianglePreference" hypothesis, forcing construction
3516 # of triangles in the refinement area if the number of nodes
3517 # on the opposite edges is not the same
3519 # @ingroup l3_hypos_additi
3520 def TrianglePreference(self):
3521 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
3522 CompareMethod=self.CompareEqualHyp)
3525 # Public class: Mesh_Tetrahedron
3526 # ------------------------------
3528 ## Defines a tetrahedron 3D algorithm
3530 # @ingroup l3_algos_basic
3531 class Mesh_Tetrahedron(Mesh_Algorithm):
3536 ## Private constructor.
3537 def __init__(self, mesh, algoType, geom=0):
3538 Mesh_Algorithm.__init__(self)
3540 if algoType == NETGEN:
3541 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
3544 elif algoType == FULL_NETGEN:
3546 print "Warning: NETGENPlugin module has not been imported."
3547 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3550 elif algoType == GHS3D:
3552 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
3555 self.algoType = algoType
3557 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
3558 # @param vol for the maximum volume of each tetrahedron
3559 # @param UseExisting if ==true - searches for the existing hypothesis created with
3560 # the same parameters, else (default) - creates a new one
3561 # @ingroup l3_hypos_maxvol
3562 def MaxElementVolume(self, vol, UseExisting=0):
3563 if self.algoType == NETGEN:
3564 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
3565 CompareMethod=self.CompareMaxElementVolume)
3566 hyp.SetMaxElementVolume(vol)
3568 elif self.algoType == FULL_NETGEN:
3569 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
3572 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
3573 def CompareMaxElementVolume(self, hyp, args):
3574 return IsEqual(hyp.GetMaxElementVolume(), args[0])
3576 ## Defines hypothesis having several parameters
3578 # @ingroup l3_hypos_netgen
3579 def Parameters(self, which=SOLE):
3582 if self.algoType == FULL_NETGEN:
3584 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
3585 "libNETGENEngine.so", UseExisting=0)
3587 self.params = self.Hypothesis("NETGEN_Parameters", [],
3588 "libNETGENEngine.so", UseExisting=0)
3590 if self.algoType == GHS3D:
3591 self.params = self.Hypothesis("GHS3D_Parameters", [],
3592 "libGHS3DEngine.so", UseExisting=0)
3595 print "Algo supports no multi-parameter hypothesis"
3599 # Parameter of FULL_NETGEN
3600 # @ingroup l3_hypos_netgen
3601 def SetMaxSize(self, theSize):
3602 self.Parameters().SetMaxSize(theSize)
3604 ## Sets SecondOrder flag
3605 # Parameter of FULL_NETGEN
3606 # @ingroup l3_hypos_netgen
3607 def SetSecondOrder(self, theVal):
3608 self.Parameters().SetSecondOrder(theVal)
3610 ## Sets Optimize flag
3611 # Parameter of FULL_NETGEN
3612 # @ingroup l3_hypos_netgen
3613 def SetOptimize(self, theVal):
3614 self.Parameters().SetOptimize(theVal)
3617 # @param theFineness is:
3618 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3619 # Parameter of FULL_NETGEN
3620 # @ingroup l3_hypos_netgen
3621 def SetFineness(self, theFineness):
3622 self.Parameters().SetFineness(theFineness)
3625 # Parameter of FULL_NETGEN
3626 # @ingroup l3_hypos_netgen
3627 def SetGrowthRate(self, theRate):
3628 self.Parameters().SetGrowthRate(theRate)
3630 ## Sets NbSegPerEdge
3631 # Parameter of FULL_NETGEN
3632 # @ingroup l3_hypos_netgen
3633 def SetNbSegPerEdge(self, theVal):
3634 self.Parameters().SetNbSegPerEdge(theVal)
3636 ## Sets NbSegPerRadius
3637 # Parameter of FULL_NETGEN
3638 # @ingroup l3_hypos_netgen
3639 def SetNbSegPerRadius(self, theVal):
3640 self.Parameters().SetNbSegPerRadius(theVal)
3642 ## Sets number of segments overriding value set by SetLocalLength()
3643 # Only for algoType == NETGEN_FULL
3644 # @ingroup l3_hypos_netgen
3645 def SetNumberOfSegments(self, theVal):
3646 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3648 ## Sets number of segments overriding value set by SetNumberOfSegments()
3649 # Only for algoType == NETGEN_FULL
3650 # @ingroup l3_hypos_netgen
3651 def SetLocalLength(self, theVal):
3652 self.Parameters(SIMPLE).SetLocalLength(theVal)
3654 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
3655 # Overrides value set by LengthFromEdges()
3656 # Only for algoType == NETGEN_FULL
3657 # @ingroup l3_hypos_netgen
3658 def MaxElementArea(self, area):
3659 self.Parameters(SIMPLE).SetMaxElementArea(area)
3661 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
3662 # Overrides value set by MaxElementArea()
3663 # Only for algoType == NETGEN_FULL
3664 # @ingroup l3_hypos_netgen
3665 def LengthFromEdges(self):
3666 self.Parameters(SIMPLE).LengthFromEdges()
3668 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
3669 # Overrides value set by MaxElementVolume()
3670 # Only for algoType == NETGEN_FULL
3671 # @ingroup l3_hypos_netgen
3672 def LengthFromFaces(self):
3673 self.Parameters(SIMPLE).LengthFromFaces()
3675 ## To mesh "holes" in a solid or not. Default is to mesh.
3676 # @ingroup l3_hypos_ghs3dh
3677 def SetToMeshHoles(self, toMesh):
3678 # Parameter of GHS3D
3679 self.Parameters().SetToMeshHoles(toMesh)
3681 ## Set Optimization level:
3682 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
3683 # Default is Medium_Optimization
3684 # @ingroup l3_hypos_ghs3dh
3685 def SetOptimizationLevel(self, level):
3686 # Parameter of GHS3D
3687 self.Parameters().SetOptimizationLevel(level)
3689 ## Maximal size of memory to be used by the algorithm (in Megabytes).
3690 # @ingroup l3_hypos_ghs3dh
3691 def SetMaximumMemory(self, MB):
3692 # Advanced parameter of GHS3D
3693 self.Parameters().SetMaximumMemory(MB)
3695 ## Initial size of memory to be used by the algorithm (in Megabytes) in
3696 # automatic memory adjustment mode.
3697 # @ingroup l3_hypos_ghs3dh
3698 def SetInitialMemory(self, MB):
3699 # Advanced parameter of GHS3D
3700 self.Parameters().SetInitialMemory(MB)
3702 ## Path to working directory.
3703 # @ingroup l3_hypos_ghs3dh
3704 def SetWorkingDirectory(self, path):
3705 # Advanced parameter of GHS3D
3706 self.Parameters().SetWorkingDirectory(path)
3708 ## To keep working files or remove them. Log file remains in case of errors anyway.
3709 # @ingroup l3_hypos_ghs3dh
3710 def SetKeepFiles(self, toKeep):
3711 # Advanced parameter of GHS3D
3712 self.Parameters().SetKeepFiles(toKeep)
3714 ## To set verbose level [0-10]. <ul>
3715 #<li> 0 - no standard output,
3716 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
3717 # indicates when the final mesh is being saved. In addition the software
3718 # gives indication regarding the CPU time.
3719 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
3720 # histogram of the skin mesh, quality statistics histogram together with
3721 # the characteristics of the final mesh.</ul>
3722 # @ingroup l3_hypos_ghs3dh
3723 def SetVerboseLevel(self, level):
3724 # Advanced parameter of GHS3D
3725 self.Parameters().SetVerboseLevel(level)
3727 ## To create new nodes.
3728 # @ingroup l3_hypos_ghs3dh
3729 def SetToCreateNewNodes(self, toCreate):
3730 # Advanced parameter of GHS3D
3731 self.Parameters().SetToCreateNewNodes(toCreate)
3733 ## To use boundary recovery version which tries to create mesh on a very poor
3734 # quality surface mesh.
3735 # @ingroup l3_hypos_ghs3dh
3736 def SetToUseBoundaryRecoveryVersion(self, toUse):
3737 # Advanced parameter of GHS3D
3738 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
3740 ## Sets command line option as text.
3741 # @ingroup l3_hypos_ghs3dh
3742 def SetTextOption(self, option):
3743 # Advanced parameter of GHS3D
3744 self.Parameters().SetTextOption(option)
3746 # Public class: Mesh_Hexahedron
3747 # ------------------------------
3749 ## Defines a hexahedron 3D algorithm
3751 # @ingroup l3_algos_basic
3752 class Mesh_Hexahedron(Mesh_Algorithm):
3757 ## Private constructor.
3758 def __init__(self, mesh, algoType=Hexa, geom=0):
3759 Mesh_Algorithm.__init__(self)
3761 self.algoType = algoType
3763 if algoType == Hexa:
3764 self.Create(mesh, geom, "Hexa_3D")
3767 elif algoType == Hexotic:
3768 import HexoticPlugin
3769 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
3772 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
3773 # @ingroup l3_hypos_hexotic
3774 def MinMaxQuad(self, min=3, max=8, quad=True):
3775 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
3777 self.params.SetHexesMinLevel(min)
3778 self.params.SetHexesMaxLevel(max)
3779 self.params.SetHexoticQuadrangles(quad)
3782 # Deprecated, only for compatibility!
3783 # Public class: Mesh_Netgen
3784 # ------------------------------
3786 ## Defines a NETGEN-based 2D or 3D algorithm
3787 # that needs no discrete boundary (i.e. independent)
3789 # This class is deprecated, only for compatibility!
3792 # @ingroup l3_algos_basic
3793 class Mesh_Netgen(Mesh_Algorithm):
3797 ## Private constructor.
3798 def __init__(self, mesh, is3D, geom=0):
3799 Mesh_Algorithm.__init__(self)
3802 print "Warning: NETGENPlugin module has not been imported."
3806 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3810 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3813 ## Defines the hypothesis containing parameters of the algorithm
3814 def Parameters(self):
3816 hyp = self.Hypothesis("NETGEN_Parameters", [],
3817 "libNETGENEngine.so", UseExisting=0)
3819 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
3820 "libNETGENEngine.so", UseExisting=0)
3823 # Public class: Mesh_Projection1D
3824 # ------------------------------
3826 ## Defines a projection 1D algorithm
3827 # @ingroup l3_algos_proj
3829 class Mesh_Projection1D(Mesh_Algorithm):
3831 ## Private constructor.
3832 def __init__(self, mesh, geom=0):
3833 Mesh_Algorithm.__init__(self)
3834 self.Create(mesh, geom, "Projection_1D")
3836 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
3837 # a mesh pattern is taken, and, optionally, the association of vertices
3838 # between the source edge and a target edge (to which a hypothesis is assigned)
3839 # @param edge from which nodes distribution is taken
3840 # @param mesh from which nodes distribution is taken (optional)
3841 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
3842 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
3843 # to associate with \a srcV (optional)
3844 # @param UseExisting if ==true - searches for the existing hypothesis created with
3845 # the same parameters, else (default) - creates a new one
3846 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
3847 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
3849 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
3850 hyp.SetSourceEdge( edge )
3851 if not mesh is None and isinstance(mesh, Mesh):
3852 mesh = mesh.GetMesh()
3853 hyp.SetSourceMesh( mesh )
3854 hyp.SetVertexAssociation( srcV, tgtV )
3857 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
3858 #def CompareSourceEdge(self, hyp, args):
3859 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
3863 # Public class: Mesh_Projection2D
3864 # ------------------------------
3866 ## Defines a projection 2D algorithm
3867 # @ingroup l3_algos_proj
3869 class Mesh_Projection2D(Mesh_Algorithm):
3871 ## Private constructor.
3872 def __init__(self, mesh, geom=0):
3873 Mesh_Algorithm.__init__(self)
3874 self.Create(mesh, geom, "Projection_2D")
3876 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
3877 # a mesh pattern is taken, and, optionally, the association of vertices
3878 # between the source face and the target face (to which a hypothesis is assigned)
3879 # @param face from which the mesh pattern is taken
3880 # @param mesh from which the mesh pattern is taken (optional)
3881 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
3882 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
3883 # to associate with \a srcV1 (optional)
3884 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
3885 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
3886 # to associate with \a srcV2 (optional)
3887 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
3888 # the same parameters, else (default) - forces the creation a new one
3890 # Note: all association vertices must belong to one edge of a face
3891 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
3892 srcV2=None, tgtV2=None, UseExisting=0):
3893 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
3895 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
3896 hyp.SetSourceFace( face )
3897 if not mesh is None and isinstance(mesh, Mesh):
3898 mesh = mesh.GetMesh()
3899 hyp.SetSourceMesh( mesh )
3900 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3903 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
3904 #def CompareSourceFace(self, hyp, args):
3905 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
3908 # Public class: Mesh_Projection3D
3909 # ------------------------------
3911 ## Defines a projection 3D algorithm
3912 # @ingroup l3_algos_proj
3914 class Mesh_Projection3D(Mesh_Algorithm):
3916 ## Private constructor.
3917 def __init__(self, mesh, geom=0):
3918 Mesh_Algorithm.__init__(self)
3919 self.Create(mesh, geom, "Projection_3D")
3921 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
3922 # the mesh pattern is taken, and, optionally, the association of vertices
3923 # between the source and the target solid (to which a hipothesis is assigned)
3924 # @param solid from where the mesh pattern is taken
3925 # @param mesh from where the mesh pattern is taken (optional)
3926 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
3927 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
3928 # to associate with \a srcV1 (optional)
3929 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
3930 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
3931 # to associate with \a srcV2 (optional)
3932 # @param UseExisting - if ==true - searches for the existing hypothesis created with
3933 # the same parameters, else (default) - creates a new one
3935 # Note: association vertices must belong to one edge of a solid
3936 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
3937 srcV2=0, tgtV2=0, UseExisting=0):
3938 hyp = self.Hypothesis("ProjectionSource3D",
3939 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
3941 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
3942 hyp.SetSource3DShape( solid )
3943 if not mesh is None and isinstance(mesh, Mesh):
3944 mesh = mesh.GetMesh()
3945 hyp.SetSourceMesh( mesh )
3946 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3949 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
3950 #def CompareSourceShape3D(self, hyp, args):
3951 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
3955 # Public class: Mesh_Prism
3956 # ------------------------
3958 ## Defines a 3D extrusion algorithm
3959 # @ingroup l3_algos_3dextr
3961 class Mesh_Prism3D(Mesh_Algorithm):
3963 ## Private constructor.
3964 def __init__(self, mesh, geom=0):
3965 Mesh_Algorithm.__init__(self)
3966 self.Create(mesh, geom, "Prism_3D")
3968 # Public class: Mesh_RadialPrism
3969 # -------------------------------
3971 ## Defines a Radial Prism 3D algorithm
3972 # @ingroup l3_algos_radialp
3974 class Mesh_RadialPrism3D(Mesh_Algorithm):
3976 ## Private constructor.
3977 def __init__(self, mesh, geom=0):
3978 Mesh_Algorithm.__init__(self)
3979 self.Create(mesh, geom, "RadialPrism_3D")
3981 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
3982 self.nbLayers = None
3984 ## Return 3D hypothesis holding the 1D one
3985 def Get3DHypothesis(self):
3986 return self.distribHyp
3988 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
3989 # hypothesis. Returns the created hypothesis
3990 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
3991 #print "OwnHypothesis",hypType
3992 if not self.nbLayers is None:
3993 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
3994 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
3995 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
3996 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
3997 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
3998 self.distribHyp.SetLayerDistribution( hyp )
4001 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4002 # prisms to build between the inner and outer shells
4003 # @param n number of layers
4004 # @param UseExisting if ==true - searches for the existing hypothesis created with
4005 # the same parameters, else (default) - creates a new one
4006 def NumberOfLayers(self, n, UseExisting=0):
4007 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4008 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4009 CompareMethod=self.CompareNumberOfLayers)
4010 self.nbLayers.SetNumberOfLayers( n )
4011 return self.nbLayers
4013 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4014 def CompareNumberOfLayers(self, hyp, args):
4015 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4017 ## Defines "LocalLength" hypothesis, specifying the segment length
4018 # to build between the inner and the outer shells
4019 # @param l the length of segments
4020 # @param p the precision of rounding
4021 def LocalLength(self, l, p=1e-07):
4022 hyp = self.OwnHypothesis("LocalLength", [l,p])
4027 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4028 # prisms to build between the inner and the outer shells.
4029 # @param n the number of layers
4030 # @param s the scale factor (optional)
4031 def NumberOfSegments(self, n, s=[]):
4033 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4035 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4036 hyp.SetDistrType( 1 )
4037 hyp.SetScaleFactor(s)
4038 hyp.SetNumberOfSegments(n)
4041 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4042 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4043 # @param start the length of the first segment
4044 # @param end the length of the last segment
4045 def Arithmetic1D(self, start, end ):
4046 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4047 hyp.SetLength(start, 1)
4048 hyp.SetLength(end , 0)
4051 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4052 # to build between the inner and the outer shells as geometric length increasing
4053 # @param start for the length of the first segment
4054 # @param end for the length of the last segment
4055 def StartEndLength(self, start, end):
4056 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4057 hyp.SetLength(start, 1)
4058 hyp.SetLength(end , 0)
4061 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4062 # to build between the inner and outer shells
4063 # @param fineness defines the quality of the mesh within the range [0-1]
4064 def AutomaticLength(self, fineness=0):
4065 hyp = self.OwnHypothesis("AutomaticLength")
4066 hyp.SetFineness( fineness )
4069 # Private class: Mesh_UseExisting
4070 # -------------------------------
4071 class Mesh_UseExisting(Mesh_Algorithm):
4073 def __init__(self, dim, mesh, geom=0):
4075 self.Create(mesh, geom, "UseExisting_1D")
4077 self.Create(mesh, geom, "UseExisting_2D")