1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 # Author : Francis KLOSS, OCC
31 ## @defgroup l1_auxiliary Auxiliary methods and structures
32 ## @defgroup l1_creating Creating meshes
34 ## @defgroup l2_impexp Importing and exporting meshes
35 ## @defgroup l2_construct Constructing meshes
36 ## @defgroup l2_algorithms Defining Algorithms
38 ## @defgroup l3_algos_basic Basic meshing algorithms
39 ## @defgroup l3_algos_proj Projection Algorithms
40 ## @defgroup l3_algos_radialp Radial Prism
41 ## @defgroup l3_algos_segmarv Segments around Vertex
42 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
45 ## @defgroup l2_hypotheses Defining hypotheses
47 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
48 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
49 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
50 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
51 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
52 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
53 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
54 ## @defgroup l3_hypos_additi Additional Hypotheses
57 ## @defgroup l2_submeshes Constructing submeshes
58 ## @defgroup l2_compounds Building Compounds
59 ## @defgroup l2_editing Editing Meshes
62 ## @defgroup l1_meshinfo Mesh Information
63 ## @defgroup l1_controls Quality controls and Filtering
64 ## @defgroup l1_grouping Grouping elements
66 ## @defgroup l2_grps_create Creating groups
67 ## @defgroup l2_grps_edit Editing groups
68 ## @defgroup l2_grps_operon Using operations on groups
69 ## @defgroup l2_grps_delete Deleting Groups
72 ## @defgroup l1_modifying Modifying meshes
74 ## @defgroup l2_modif_add Adding nodes and elements
75 ## @defgroup l2_modif_del Removing nodes and elements
76 ## @defgroup l2_modif_edit Modifying nodes and elements
77 ## @defgroup l2_modif_renumber Renumbering nodes and elements
78 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
79 ## @defgroup l2_modif_movenode Moving nodes
80 ## @defgroup l2_modif_throughp Mesh through point
81 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
82 ## @defgroup l2_modif_unitetri Uniting triangles
83 ## @defgroup l2_modif_changori Changing orientation of elements
84 ## @defgroup l2_modif_cutquadr Cutting quadrangles
85 ## @defgroup l2_modif_smooth Smoothing
86 ## @defgroup l2_modif_extrurev Extrusion and Revolution
87 ## @defgroup l2_modif_patterns Pattern mapping
88 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
95 import SMESH # This is necessary for back compatibility
102 # import NETGENPlugin module if possible
110 ## @addtogroup l1_auxiliary
113 # Types of algorithms
126 NETGEN_1D2D3D = FULL_NETGEN
127 NETGEN_FULL = FULL_NETGEN
133 # MirrorType enumeration
134 POINT = SMESH_MeshEditor.POINT
135 AXIS = SMESH_MeshEditor.AXIS
136 PLANE = SMESH_MeshEditor.PLANE
138 # Smooth_Method enumeration
139 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
140 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
142 # Fineness enumeration (for NETGEN)
150 # Optimization level of GHS3D
151 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
153 # Topology treatment way of BLSURF
154 FromCAD, PreProcess, PreProcessPlus = 0,1,2
156 # Element size flag of BLSURF
157 DefaultSize, DefaultGeom, Custom = 0,0,1
159 PrecisionConfusion = 1e-07
161 ## Converts an angle from degrees to radians
162 def DegreesToRadians(AngleInDegrees):
164 return AngleInDegrees * pi / 180.0
166 # Salome notebook variable separator
169 # Parametrized substitute for PointStruct
170 class PointStructStr:
179 def __init__(self, xStr, yStr, zStr):
183 if isinstance(xStr, str) and notebook.isVariable(xStr):
184 self.x = notebook.get(xStr)
187 if isinstance(yStr, str) and notebook.isVariable(yStr):
188 self.y = notebook.get(yStr)
191 if isinstance(zStr, str) and notebook.isVariable(zStr):
192 self.z = notebook.get(zStr)
196 # Parametrized substitute for PointStruct (with 6 parameters)
197 class PointStructStr6:
212 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
219 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
220 self.x1 = notebook.get(x1Str)
223 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
224 self.x2 = notebook.get(x2Str)
227 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
228 self.y1 = notebook.get(y1Str)
231 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
232 self.y2 = notebook.get(y2Str)
235 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
236 self.z1 = notebook.get(z1Str)
239 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
240 self.z2 = notebook.get(z2Str)
244 # Parametrized substitute for AxisStruct
260 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
267 if isinstance(xStr, str) and notebook.isVariable(xStr):
268 self.x = notebook.get(xStr)
271 if isinstance(yStr, str) and notebook.isVariable(yStr):
272 self.y = notebook.get(yStr)
275 if isinstance(zStr, str) and notebook.isVariable(zStr):
276 self.z = notebook.get(zStr)
279 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
280 self.dx = notebook.get(dxStr)
283 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
284 self.dy = notebook.get(dyStr)
287 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
288 self.dz = notebook.get(dzStr)
292 # Parametrized substitute for DirStruct
295 def __init__(self, pointStruct):
296 self.pointStruct = pointStruct
298 # Returns list of variable values from salome notebook
299 def ParsePointStruct(Point):
300 Parameters = 2*var_separator
301 if isinstance(Point, PointStructStr):
302 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
303 Point = PointStruct(Point.x, Point.y, Point.z)
304 return Point, Parameters
306 # Returns list of variable values from salome notebook
307 def ParseDirStruct(Dir):
308 Parameters = 2*var_separator
309 if isinstance(Dir, DirStructStr):
310 pntStr = Dir.pointStruct
311 if isinstance(pntStr, PointStructStr6):
312 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
313 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
314 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
315 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
317 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
318 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
319 Dir = DirStruct(Point)
320 return Dir, Parameters
322 # Returns list of variable values from salome notebook
323 def ParseAxisStruct(Axis):
324 Parameters = 5*var_separator
325 if isinstance(Axis, AxisStructStr):
326 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
327 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
328 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
329 return Axis, Parameters
331 ## Return list of variable values from salome notebook
332 def ParseAngles(list):
335 for parameter in list:
336 if isinstance(parameter,str) and notebook.isVariable(parameter):
337 Result.append(DegreesToRadians(notebook.get(parameter)))
340 Result.append(parameter)
343 Parameters = Parameters + str(parameter)
344 Parameters = Parameters + var_separator
346 Parameters = Parameters[:len(Parameters)-1]
347 return Result, Parameters
349 def IsEqual(val1, val2, tol=PrecisionConfusion):
350 if abs(val1 - val2) < tol:
358 ior = salome.orb.object_to_string(obj)
359 sobj = salome.myStudy.FindObjectIOR(ior)
363 attr = sobj.FindAttribute("AttributeName")[1]
366 ## Prints error message if a hypothesis was not assigned.
367 def TreatHypoStatus(status, hypName, geomName, isAlgo):
369 hypType = "algorithm"
371 hypType = "hypothesis"
373 if status == HYP_UNKNOWN_FATAL :
374 reason = "for unknown reason"
375 elif status == HYP_INCOMPATIBLE :
376 reason = "this hypothesis mismatches the algorithm"
377 elif status == HYP_NOTCONFORM :
378 reason = "a non-conform mesh would be built"
379 elif status == HYP_ALREADY_EXIST :
380 reason = hypType + " of the same dimension is already assigned to this shape"
381 elif status == HYP_BAD_DIM :
382 reason = hypType + " mismatches the shape"
383 elif status == HYP_CONCURENT :
384 reason = "there are concurrent hypotheses on sub-shapes"
385 elif status == HYP_BAD_SUBSHAPE :
386 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
387 elif status == HYP_BAD_GEOMETRY:
388 reason = "geometry mismatches the expectation of the algorithm"
389 elif status == HYP_HIDDEN_ALGO:
390 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
391 elif status == HYP_HIDING_ALGO:
392 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
393 elif status == HYP_NEED_SHAPE:
394 reason = "Algorithm can't work without shape"
397 hypName = '"' + hypName + '"'
398 geomName= '"' + geomName+ '"'
399 if status < HYP_UNKNOWN_FATAL:
400 print hypName, "was assigned to", geomName,"but", reason
402 print hypName, "was not assigned to",geomName,":", reason
405 # end of l1_auxiliary
408 # All methods of this class are accessible directly from the smesh.py package.
409 class smeshDC(SMESH._objref_SMESH_Gen):
411 ## Sets the current study and Geometry component
412 # @ingroup l1_auxiliary
413 def init_smesh(self,theStudy,geompyD):
414 self.SetCurrentStudy(theStudy,geompyD)
416 ## Creates an empty Mesh. This mesh can have an underlying geometry.
417 # @param obj the Geometrical object on which the mesh is built. If not defined,
418 # the mesh will have no underlying geometry.
419 # @param name the name for the new mesh.
420 # @return an instance of Mesh class.
421 # @ingroup l2_construct
422 def Mesh(self, obj=0, name=0):
423 return Mesh(self,self.geompyD,obj,name)
425 ## Returns a long value from enumeration
426 # Should be used for SMESH.FunctorType enumeration
427 # @ingroup l1_controls
428 def EnumToLong(self,theItem):
431 ## Gets PointStruct from vertex
432 # @param theVertex a GEOM object(vertex)
433 # @return SMESH.PointStruct
434 # @ingroup l1_auxiliary
435 def GetPointStruct(self,theVertex):
436 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
437 return PointStruct(x,y,z)
439 ## Gets DirStruct from vector
440 # @param theVector a GEOM object(vector)
441 # @return SMESH.DirStruct
442 # @ingroup l1_auxiliary
443 def GetDirStruct(self,theVector):
444 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
445 if(len(vertices) != 2):
446 print "Error: vector object is incorrect."
448 p1 = self.geompyD.PointCoordinates(vertices[0])
449 p2 = self.geompyD.PointCoordinates(vertices[1])
450 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
451 dirst = DirStruct(pnt)
454 ## Makes DirStruct from a triplet
455 # @param x,y,z vector components
456 # @return SMESH.DirStruct
457 # @ingroup l1_auxiliary
458 def MakeDirStruct(self,x,y,z):
459 pnt = PointStruct(x,y,z)
460 return DirStruct(pnt)
462 ## Get AxisStruct from object
463 # @param theObj a GEOM object (line or plane)
464 # @return SMESH.AxisStruct
465 # @ingroup l1_auxiliary
466 def GetAxisStruct(self,theObj):
467 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
469 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
470 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
471 vertex1 = self.geompyD.PointCoordinates(vertex1)
472 vertex2 = self.geompyD.PointCoordinates(vertex2)
473 vertex3 = self.geompyD.PointCoordinates(vertex3)
474 vertex4 = self.geompyD.PointCoordinates(vertex4)
475 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
476 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
477 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] ]
478 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
480 elif len(edges) == 1:
481 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
482 p1 = self.geompyD.PointCoordinates( vertex1 )
483 p2 = self.geompyD.PointCoordinates( vertex2 )
484 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
488 # From SMESH_Gen interface:
489 # ------------------------
491 ## Sets the given name to the object
492 # @param obj the object to rename
493 # @param name a new object name
494 # @ingroup l1_auxiliary
495 def SetName(self, obj, name):
496 print "obj_name = ", name
497 if isinstance( obj, Mesh ):
499 elif isinstance( obj, Mesh_Algorithm ):
500 obj = obj.GetAlgorithm()
501 ior = salome.orb.object_to_string(obj)
502 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
504 ## Sets the current mode
505 # @ingroup l1_auxiliary
506 def SetEmbeddedMode( self,theMode ):
507 #self.SetEmbeddedMode(theMode)
508 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
510 ## Gets the current mode
511 # @ingroup l1_auxiliary
512 def IsEmbeddedMode(self):
513 #return self.IsEmbeddedMode()
514 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
516 ## Sets the current study
517 # @ingroup l1_auxiliary
518 def SetCurrentStudy( self, theStudy, geompyD = None ):
519 #self.SetCurrentStudy(theStudy)
522 geompyD = geompy.geom
525 self.SetGeomEngine(geompyD)
526 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
528 ## Gets the current study
529 # @ingroup l1_auxiliary
530 def GetCurrentStudy(self):
531 #return self.GetCurrentStudy()
532 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
534 ## Creates a Mesh object importing data from the given UNV file
535 # @return an instance of Mesh class
537 def CreateMeshesFromUNV( self,theFileName ):
538 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
539 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
542 ## Creates a Mesh object(s) importing data from the given MED file
543 # @return a list of Mesh class instances
545 def CreateMeshesFromMED( self,theFileName ):
546 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
548 for iMesh in range(len(aSmeshMeshes)) :
549 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
550 aMeshes.append(aMesh)
551 return aMeshes, aStatus
553 ## Creates a Mesh object importing data from the given STL file
554 # @return an instance of Mesh class
556 def CreateMeshesFromSTL( self, theFileName ):
557 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
558 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
561 ## Concatenate the given meshes into one mesh.
562 # @return an instance of Mesh class
563 # @param meshes the meshes to combine into one mesh
564 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
565 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
566 # @param mergeTolerance tolerance for merging nodes
567 # @param allGroups forces creation of groups of all elements
568 def Concatenate( self, meshes, uniteIdenticalGroups,
569 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
571 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
572 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
574 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
575 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
576 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
579 ## From SMESH_Gen interface
580 # @return the list of integer values
581 # @ingroup l1_auxiliary
582 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
583 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
585 ## From SMESH_Gen interface. Creates a pattern
586 # @return an instance of SMESH_Pattern
588 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
589 # @ingroup l2_modif_patterns
590 def GetPattern(self):
591 return SMESH._objref_SMESH_Gen.GetPattern(self)
593 ## Sets number of segments per diagonal of boundary box of geometry by which
594 # default segment length of appropriate 1D hypotheses is defined.
595 # Default value is 10
596 # @ingroup l1_auxiliary
597 def SetBoundaryBoxSegmentation(self, nbSegments):
598 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
600 ## Concatenate the given meshes into one mesh.
601 # @return an instance of Mesh class
602 # @param meshes the meshes to combine into one mesh
603 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
604 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
605 # @param mergeTolerance tolerance for merging nodes
606 # @param allGroups forces creation of groups of all elements
607 def Concatenate( self, meshes, uniteIdenticalGroups,
608 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
609 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
611 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
612 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
614 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
615 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
616 aSmeshMesh.SetParameters(Parameters)
617 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
620 # Filtering. Auxiliary functions:
621 # ------------------------------
623 ## Creates an empty criterion
624 # @return SMESH.Filter.Criterion
625 # @ingroup l1_controls
626 def GetEmptyCriterion(self):
627 Type = self.EnumToLong(FT_Undefined)
628 Compare = self.EnumToLong(FT_Undefined)
632 UnaryOp = self.EnumToLong(FT_Undefined)
633 BinaryOp = self.EnumToLong(FT_Undefined)
636 Precision = -1 ##@1e-07
637 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
638 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
640 ## Creates a criterion by the given parameters
641 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
642 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
643 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
644 # @param Treshold the threshold value (range of ids as string, shape, numeric)
645 # @param UnaryOp FT_LogicalNOT or FT_Undefined
646 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
647 # FT_Undefined (must be for the last criterion of all criteria)
648 # @return SMESH.Filter.Criterion
649 # @ingroup l1_controls
650 def GetCriterion(self,elementType,
652 Compare = FT_EqualTo,
654 UnaryOp=FT_Undefined,
655 BinaryOp=FT_Undefined):
656 aCriterion = self.GetEmptyCriterion()
657 aCriterion.TypeOfElement = elementType
658 aCriterion.Type = self.EnumToLong(CritType)
662 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
663 aCriterion.Compare = self.EnumToLong(Compare)
664 elif Compare == "=" or Compare == "==":
665 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
667 aCriterion.Compare = self.EnumToLong(FT_LessThan)
669 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
671 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
674 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
675 FT_BelongToCylinder, FT_LyingOnGeom]:
676 # Checks the treshold
677 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
678 aCriterion.ThresholdStr = GetName(aTreshold)
679 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
681 print "Error: The treshold should be a shape."
683 elif CritType == FT_RangeOfIds:
684 # Checks the treshold
685 if isinstance(aTreshold, str):
686 aCriterion.ThresholdStr = aTreshold
688 print "Error: The treshold should be a string."
690 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
691 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
692 # At this point the treshold is unnecessary
693 if aTreshold == FT_LogicalNOT:
694 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
695 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
696 aCriterion.BinaryOp = aTreshold
700 aTreshold = float(aTreshold)
701 aCriterion.Threshold = aTreshold
703 print "Error: The treshold should be a number."
706 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
707 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
709 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
710 aCriterion.BinaryOp = self.EnumToLong(Treshold)
712 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
713 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
715 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
716 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
720 ## Creates a filter with the given parameters
721 # @param elementType the type of elements in the group
722 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
723 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
724 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
725 # @param UnaryOp FT_LogicalNOT or FT_Undefined
726 # @return SMESH_Filter
727 # @ingroup l1_controls
728 def GetFilter(self,elementType,
729 CritType=FT_Undefined,
732 UnaryOp=FT_Undefined):
733 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
734 aFilterMgr = self.CreateFilterManager()
735 aFilter = aFilterMgr.CreateFilter()
737 aCriteria.append(aCriterion)
738 aFilter.SetCriteria(aCriteria)
741 ## Creates a numerical functor by its type
742 # @param theCriterion FT_...; functor type
743 # @return SMESH_NumericalFunctor
744 # @ingroup l1_controls
745 def GetFunctor(self,theCriterion):
746 aFilterMgr = self.CreateFilterManager()
747 if theCriterion == FT_AspectRatio:
748 return aFilterMgr.CreateAspectRatio()
749 elif theCriterion == FT_AspectRatio3D:
750 return aFilterMgr.CreateAspectRatio3D()
751 elif theCriterion == FT_Warping:
752 return aFilterMgr.CreateWarping()
753 elif theCriterion == FT_MinimumAngle:
754 return aFilterMgr.CreateMinimumAngle()
755 elif theCriterion == FT_Taper:
756 return aFilterMgr.CreateTaper()
757 elif theCriterion == FT_Skew:
758 return aFilterMgr.CreateSkew()
759 elif theCriterion == FT_Area:
760 return aFilterMgr.CreateArea()
761 elif theCriterion == FT_Volume3D:
762 return aFilterMgr.CreateVolume3D()
763 elif theCriterion == FT_MultiConnection:
764 return aFilterMgr.CreateMultiConnection()
765 elif theCriterion == FT_MultiConnection2D:
766 return aFilterMgr.CreateMultiConnection2D()
767 elif theCriterion == FT_Length:
768 return aFilterMgr.CreateLength()
769 elif theCriterion == FT_Length2D:
770 return aFilterMgr.CreateLength2D()
772 print "Error: given parameter is not numerucal functor type."
774 ## Creates hypothesis
777 # @return created hypothesis instance
778 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
779 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
782 #Registering the new proxy for SMESH_Gen
783 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
789 ## This class allows defining and managing a mesh.
790 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
791 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
792 # new nodes and elements and by changing the existing entities), to get information
793 # about a mesh and to export a mesh into different formats.
802 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
803 # sets the GUI name of this mesh to \a name.
804 # @param smeshpyD an instance of smeshDC class
805 # @param geompyD an instance of geompyDC class
806 # @param obj Shape to be meshed or SMESH_Mesh object
807 # @param name Study name of the mesh
808 # @ingroup l2_construct
809 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
810 self.smeshpyD=smeshpyD
815 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
817 self.mesh = self.smeshpyD.CreateMesh(self.geom)
818 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
821 self.mesh = self.smeshpyD.CreateEmptyMesh()
823 self.smeshpyD.SetName(self.mesh, name)
825 self.smeshpyD.SetName(self.mesh, GetName(obj))
828 self.geom = self.mesh.GetShapeToMesh()
830 self.editor = self.mesh.GetMeshEditor()
832 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
833 # @param theMesh a SMESH_Mesh object
834 # @ingroup l2_construct
835 def SetMesh(self, theMesh):
837 self.geom = self.mesh.GetShapeToMesh()
839 ## Returns the mesh, that is an instance of SMESH_Mesh interface
840 # @return a SMESH_Mesh object
841 # @ingroup l2_construct
845 ## Gets the name of the mesh
846 # @return the name of the mesh as a string
847 # @ingroup l2_construct
849 name = GetName(self.GetMesh())
852 ## Sets a name to the mesh
853 # @param name a new name of the mesh
854 # @ingroup l2_construct
855 def SetName(self, name):
856 self.smeshpyD.SetName(self.GetMesh(), name)
858 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
859 # The subMesh object gives access to the IDs of nodes and elements.
860 # @param theSubObject a geometrical object (shape)
861 # @param theName a name for the submesh
862 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
863 # @ingroup l2_submeshes
864 def GetSubMesh(self, theSubObject, theName):
865 submesh = self.mesh.GetSubMesh(theSubObject, theName)
868 ## Returns the shape associated to the mesh
869 # @return a GEOM_Object
870 # @ingroup l2_construct
874 ## Associates the given shape to the mesh (entails the recreation of the mesh)
875 # @param geom the shape to be meshed (GEOM_Object)
876 # @ingroup l2_construct
877 def SetShape(self, geom):
878 self.mesh = self.smeshpyD.CreateMesh(geom)
880 ## Returns true if the hypotheses are defined well
881 # @param theSubObject a subshape of a mesh shape
882 # @return True or False
883 # @ingroup l2_construct
884 def IsReadyToCompute(self, theSubObject):
885 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
887 ## Returns errors of hypotheses definition.
888 # The list of errors is empty if everything is OK.
889 # @param theSubObject a subshape of a mesh shape
890 # @return a list of errors
891 # @ingroup l2_construct
892 def GetAlgoState(self, theSubObject):
893 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
895 ## Returns a geometrical object on which the given element was built.
896 # The returned geometrical object, if not nil, is either found in the
897 # study or published by this method with the given name
898 # @param theElementID the id of the mesh element
899 # @param theGeomName the user-defined name of the geometrical object
900 # @return GEOM::GEOM_Object instance
901 # @ingroup l2_construct
902 def GetGeometryByMeshElement(self, theElementID, theGeomName):
903 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
905 ## Returns the mesh dimension depending on the dimension of the underlying shape
906 # @return mesh dimension as an integer value [0,3]
907 # @ingroup l1_auxiliary
908 def MeshDimension(self):
909 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
910 if len( shells ) > 0 :
912 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
914 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
920 ## Creates a segment discretization 1D algorithm.
921 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
922 # \n If the optional \a geom parameter is not set, this algorithm is global.
923 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
924 # @param algo the type of the required algorithm. Possible values are:
926 # - smesh.PYTHON for discretization via a python function,
927 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
928 # @param geom If defined is the subshape to be meshed
929 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
930 # @ingroup l3_algos_basic
931 def Segment(self, algo=REGULAR, geom=0):
932 ## if Segment(geom) is called by mistake
933 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
934 algo, geom = geom, algo
935 if not algo: algo = REGULAR
938 return Mesh_Segment(self, geom)
940 return Mesh_Segment_Python(self, geom)
941 elif algo == COMPOSITE:
942 return Mesh_CompositeSegment(self, geom)
944 return Mesh_Segment(self, geom)
946 ## Enables creation of nodes and segments usable by 2D algoritms.
947 # The added nodes and segments must be bound to edges and vertices by
948 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
949 # If the optional \a geom parameter is not set, this algorithm is global.
950 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
951 # @param geom the subshape to be manually meshed
952 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
953 # @ingroup l3_algos_basic
954 def UseExistingSegments(self, geom=0):
955 algo = Mesh_UseExisting(1,self,geom)
956 return algo.GetAlgorithm()
958 ## Enables creation of nodes and faces usable by 3D algoritms.
959 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
960 # and SetMeshElementOnShape()
961 # If the optional \a geom parameter is not set, this algorithm is global.
962 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
963 # @param geom the subshape to be manually meshed
964 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
965 # @ingroup l3_algos_basic
966 def UseExistingFaces(self, geom=0):
967 algo = Mesh_UseExisting(2,self,geom)
968 return algo.GetAlgorithm()
970 ## Creates a triangle 2D algorithm for faces.
971 # If the optional \a geom parameter is not set, this algorithm is global.
972 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
973 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
974 # @param geom If defined, the subshape to be meshed (GEOM_Object)
975 # @return an instance of Mesh_Triangle algorithm
976 # @ingroup l3_algos_basic
977 def Triangle(self, algo=MEFISTO, geom=0):
978 ## if Triangle(geom) is called by mistake
979 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
983 return Mesh_Triangle(self, algo, geom)
985 ## Creates a quadrangle 2D algorithm for faces.
986 # If the optional \a geom parameter is not set, this algorithm is global.
987 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
988 # @param geom If defined, the subshape to be meshed (GEOM_Object)
989 # @return an instance of Mesh_Quadrangle algorithm
990 # @ingroup l3_algos_basic
991 def Quadrangle(self, geom=0):
992 return Mesh_Quadrangle(self, geom)
994 ## Creates a tetrahedron 3D algorithm for solids.
995 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
996 # If the optional \a geom parameter is not set, this algorithm is global.
997 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
998 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
999 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1000 # @return an instance of Mesh_Tetrahedron algorithm
1001 # @ingroup l3_algos_basic
1002 def Tetrahedron(self, algo=NETGEN, geom=0):
1003 ## if Tetrahedron(geom) is called by mistake
1004 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1005 algo, geom = geom, algo
1006 if not algo: algo = NETGEN
1008 return Mesh_Tetrahedron(self, algo, geom)
1010 ## Creates a hexahedron 3D algorithm for solids.
1011 # If the optional \a geom parameter is not set, this algorithm is global.
1012 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1013 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1014 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1015 # @return an instance of Mesh_Hexahedron algorithm
1016 # @ingroup l3_algos_basic
1017 def Hexahedron(self, algo=Hexa, geom=0):
1018 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1019 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1020 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1021 elif geom == 0: algo, geom = Hexa, algo
1022 return Mesh_Hexahedron(self, algo, geom)
1024 ## Deprecated, used only for compatibility!
1025 # @return an instance of Mesh_Netgen algorithm
1026 # @ingroup l3_algos_basic
1027 def Netgen(self, is3D, geom=0):
1028 return Mesh_Netgen(self, is3D, geom)
1030 ## Creates a projection 1D algorithm for edges.
1031 # If the optional \a geom parameter is not set, this algorithm is global.
1032 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1033 # @param geom If defined, the subshape to be meshed
1034 # @return an instance of Mesh_Projection1D algorithm
1035 # @ingroup l3_algos_proj
1036 def Projection1D(self, geom=0):
1037 return Mesh_Projection1D(self, geom)
1039 ## Creates a projection 2D algorithm for faces.
1040 # If the optional \a geom parameter is not set, this algorithm is global.
1041 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1042 # @param geom If defined, the subshape to be meshed
1043 # @return an instance of Mesh_Projection2D algorithm
1044 # @ingroup l3_algos_proj
1045 def Projection2D(self, geom=0):
1046 return Mesh_Projection2D(self, geom)
1048 ## Creates a projection 3D algorithm for solids.
1049 # If the optional \a geom parameter is not set, this algorithm is global.
1050 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1051 # @param geom If defined, the subshape to be meshed
1052 # @return an instance of Mesh_Projection3D algorithm
1053 # @ingroup l3_algos_proj
1054 def Projection3D(self, geom=0):
1055 return Mesh_Projection3D(self, geom)
1057 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1058 # If the optional \a geom parameter is not set, this algorithm is global.
1059 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1060 # @param geom If defined, the subshape to be meshed
1061 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1062 # @ingroup l3_algos_radialp l3_algos_3dextr
1063 def Prism(self, geom=0):
1067 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1068 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1069 if nbSolids == 0 or nbSolids == nbShells:
1070 return Mesh_Prism3D(self, geom)
1071 return Mesh_RadialPrism3D(self, geom)
1073 ## Computes the mesh and returns the status of the computation
1074 # @return True or False
1075 # @ingroup l2_construct
1076 def Compute(self, geom=0):
1077 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1079 geom = self.mesh.GetShapeToMesh()
1084 ok = self.smeshpyD.Compute(self.mesh, geom)
1085 except SALOME.SALOME_Exception, ex:
1086 print "Mesh computation failed, exception caught:"
1087 print " ", ex.details.text
1090 print "Mesh computation failed, exception caught:"
1091 traceback.print_exc()
1093 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1096 if err.isGlobalAlgo:
1104 reason = '%s %sD algorithm is missing' % (glob, dim)
1105 elif err.state == HYP_MISSING:
1106 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1107 % (glob, dim, name, dim))
1108 elif err.state == HYP_NOTCONFORM:
1109 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1110 elif err.state == HYP_BAD_PARAMETER:
1111 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1112 % ( glob, dim, name ))
1113 elif err.state == HYP_BAD_GEOMETRY:
1114 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1115 'geometry' % ( glob, dim, name ))
1117 reason = "For unknown reason."+\
1118 " Revise Mesh.Compute() implementation in smeshDC.py!"
1120 if allReasons != "":
1123 allReasons += reason
1125 if allReasons != "":
1126 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1130 print '"' + GetName(self.mesh) + '"',"has not been computed."
1133 if salome.sg.hasDesktop():
1134 smeshgui = salome.ImportComponentGUI("SMESH")
1135 smeshgui.Init(self.mesh.GetStudyId())
1136 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1137 salome.sg.updateObjBrowser(1)
1141 ## Removes all nodes and elements
1142 # @ingroup l2_construct
1145 if salome.sg.hasDesktop():
1146 smeshgui = salome.ImportComponentGUI("SMESH")
1147 smeshgui.Init(self.mesh.GetStudyId())
1148 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1149 salome.sg.updateObjBrowser(1)
1151 ## Removes all nodes and elements of indicated shape
1152 # @ingroup l2_construct
1153 def ClearSubMesh(self, geomId):
1154 self.mesh.ClearSubMesh(geomId)
1155 if salome.sg.hasDesktop():
1156 smeshgui = salome.ImportComponentGUI("SMESH")
1157 smeshgui.Init(self.mesh.GetStudyId())
1158 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1159 salome.sg.updateObjBrowser(1)
1161 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1162 # @param fineness [0,-1] defines mesh fineness
1163 # @return True or False
1164 # @ingroup l3_algos_basic
1165 def AutomaticTetrahedralization(self, fineness=0):
1166 dim = self.MeshDimension()
1168 self.RemoveGlobalHypotheses()
1169 self.Segment().AutomaticLength(fineness)
1171 self.Triangle().LengthFromEdges()
1174 self.Tetrahedron(NETGEN)
1176 return self.Compute()
1178 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1179 # @param fineness [0,-1] defines mesh fineness
1180 # @return True or False
1181 # @ingroup l3_algos_basic
1182 def AutomaticHexahedralization(self, fineness=0):
1183 dim = self.MeshDimension()
1184 # assign the hypotheses
1185 self.RemoveGlobalHypotheses()
1186 self.Segment().AutomaticLength(fineness)
1193 return self.Compute()
1195 ## Assigns a hypothesis
1196 # @param hyp a hypothesis to assign
1197 # @param geom a subhape of mesh geometry
1198 # @return SMESH.Hypothesis_Status
1199 # @ingroup l2_hypotheses
1200 def AddHypothesis(self, hyp, geom=0):
1201 if isinstance( hyp, Mesh_Algorithm ):
1202 hyp = hyp.GetAlgorithm()
1207 geom = self.mesh.GetShapeToMesh()
1209 status = self.mesh.AddHypothesis(geom, hyp)
1210 isAlgo = hyp._narrow( SMESH_Algo )
1211 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1214 ## Unassigns a hypothesis
1215 # @param hyp a hypothesis to unassign
1216 # @param geom a subshape of mesh geometry
1217 # @return SMESH.Hypothesis_Status
1218 # @ingroup l2_hypotheses
1219 def RemoveHypothesis(self, hyp, geom=0):
1220 if isinstance( hyp, Mesh_Algorithm ):
1221 hyp = hyp.GetAlgorithm()
1226 status = self.mesh.RemoveHypothesis(geom, hyp)
1229 ## Gets the list of hypotheses added on a geometry
1230 # @param geom a subshape of mesh geometry
1231 # @return the sequence of SMESH_Hypothesis
1232 # @ingroup l2_hypotheses
1233 def GetHypothesisList(self, geom):
1234 return self.mesh.GetHypothesisList( geom )
1236 ## Removes all global hypotheses
1237 # @ingroup l2_hypotheses
1238 def RemoveGlobalHypotheses(self):
1239 current_hyps = self.mesh.GetHypothesisList( self.geom )
1240 for hyp in current_hyps:
1241 self.mesh.RemoveHypothesis( self.geom, hyp )
1245 ## Creates a mesh group based on the geometric object \a grp
1246 # and gives a \a name, \n if this parameter is not defined
1247 # the name is the same as the geometric group name \n
1248 # Note: Works like GroupOnGeom().
1249 # @param grp a geometric group, a vertex, an edge, a face or a solid
1250 # @param name the name of the mesh group
1251 # @return SMESH_GroupOnGeom
1252 # @ingroup l2_grps_create
1253 def Group(self, grp, name=""):
1254 return self.GroupOnGeom(grp, name)
1256 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1257 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1258 # @param f the file name
1259 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1260 # @ingroup l2_impexp
1261 def ExportToMED(self, f, version, opt=0):
1262 self.mesh.ExportToMED(f, opt, version)
1264 ## Exports the mesh in a file in MED format
1265 # @param f is the file name
1266 # @param auto_groups boolean parameter for creating/not creating
1267 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1268 # the typical use is auto_groups=false.
1269 # @param version MED format version(MED_V2_1 or MED_V2_2)
1270 # @ingroup l2_impexp
1271 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1272 self.mesh.ExportToMED(f, auto_groups, version)
1274 ## Exports the mesh in a file in DAT format
1275 # @param f the file name
1276 # @ingroup l2_impexp
1277 def ExportDAT(self, f):
1278 self.mesh.ExportDAT(f)
1280 ## Exports the mesh in a file in UNV format
1281 # @param f the file name
1282 # @ingroup l2_impexp
1283 def ExportUNV(self, f):
1284 self.mesh.ExportUNV(f)
1286 ## Export the mesh in a file in STL format
1287 # @param f the file name
1288 # @param ascii defines the file encoding
1289 # @ingroup l2_impexp
1290 def ExportSTL(self, f, ascii=1):
1291 self.mesh.ExportSTL(f, ascii)
1294 # Operations with groups:
1295 # ----------------------
1297 ## Creates an empty mesh group
1298 # @param elementType the type of elements in the group
1299 # @param name the name of the mesh group
1300 # @return SMESH_Group
1301 # @ingroup l2_grps_create
1302 def CreateEmptyGroup(self, elementType, name):
1303 return self.mesh.CreateGroup(elementType, name)
1305 ## Creates a mesh group based on the geometrical object \a grp
1306 # and gives a \a name, \n if this parameter is not defined
1307 # the name is the same as the geometrical group name
1308 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1309 # @param name the name of the mesh group
1310 # @param typ the type of elements in the group. If not set, it is
1311 # automatically detected by the type of the geometry
1312 # @return SMESH_GroupOnGeom
1313 # @ingroup l2_grps_create
1314 def GroupOnGeom(self, grp, name="", typ=None):
1316 name = grp.GetName()
1319 tgeo = str(grp.GetShapeType())
1320 if tgeo == "VERTEX":
1322 elif tgeo == "EDGE":
1324 elif tgeo == "FACE":
1326 elif tgeo == "SOLID":
1328 elif tgeo == "SHELL":
1330 elif tgeo == "COMPOUND":
1331 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1332 print "Mesh.Group: empty geometric group", GetName( grp )
1334 tgeo = self.geompyD.GetType(grp)
1335 if tgeo == geompyDC.ShapeType["VERTEX"]:
1337 elif tgeo == geompyDC.ShapeType["EDGE"]:
1339 elif tgeo == geompyDC.ShapeType["FACE"]:
1341 elif tgeo == geompyDC.ShapeType["SOLID"]:
1345 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1348 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1350 ## Creates a mesh group by the given ids of elements
1351 # @param groupName the name of the mesh group
1352 # @param elementType the type of elements in the group
1353 # @param elemIDs the list of ids
1354 # @return SMESH_Group
1355 # @ingroup l2_grps_create
1356 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1357 group = self.mesh.CreateGroup(elementType, groupName)
1361 ## Creates a mesh group by the given conditions
1362 # @param groupName the name of the mesh group
1363 # @param elementType the type of elements in the group
1364 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1365 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1366 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1367 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1368 # @return SMESH_Group
1369 # @ingroup l2_grps_create
1373 CritType=FT_Undefined,
1376 UnaryOp=FT_Undefined):
1377 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1378 group = self.MakeGroupByCriterion(groupName, aCriterion)
1381 ## Creates a mesh group by the given criterion
1382 # @param groupName the name of the mesh group
1383 # @param Criterion the instance of Criterion class
1384 # @return SMESH_Group
1385 # @ingroup l2_grps_create
1386 def MakeGroupByCriterion(self, groupName, Criterion):
1387 aFilterMgr = self.smeshpyD.CreateFilterManager()
1388 aFilter = aFilterMgr.CreateFilter()
1390 aCriteria.append(Criterion)
1391 aFilter.SetCriteria(aCriteria)
1392 group = self.MakeGroupByFilter(groupName, aFilter)
1395 ## Creates a mesh group by the given criteria (list of criteria)
1396 # @param groupName the name of the mesh group
1397 # @param theCriteria the list of criteria
1398 # @return SMESH_Group
1399 # @ingroup l2_grps_create
1400 def MakeGroupByCriteria(self, groupName, theCriteria):
1401 aFilterMgr = self.smeshpyD.CreateFilterManager()
1402 aFilter = aFilterMgr.CreateFilter()
1403 aFilter.SetCriteria(theCriteria)
1404 group = self.MakeGroupByFilter(groupName, aFilter)
1407 ## Creates a mesh group by the given filter
1408 # @param groupName the name of the mesh group
1409 # @param theFilter the instance of Filter class
1410 # @return SMESH_Group
1411 # @ingroup l2_grps_create
1412 def MakeGroupByFilter(self, groupName, theFilter):
1413 anIds = theFilter.GetElementsId(self.mesh)
1414 anElemType = theFilter.GetElementType()
1415 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1418 ## Passes mesh elements through the given filter and return IDs of fitting elements
1419 # @param theFilter SMESH_Filter
1420 # @return a list of ids
1421 # @ingroup l1_controls
1422 def GetIdsFromFilter(self, theFilter):
1423 return theFilter.GetElementsId(self.mesh)
1425 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1426 # Returns a list of special structures (borders).
1427 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1428 # @ingroup l1_controls
1429 def GetFreeBorders(self):
1430 aFilterMgr = self.smeshpyD.CreateFilterManager()
1431 aPredicate = aFilterMgr.CreateFreeEdges()
1432 aPredicate.SetMesh(self.mesh)
1433 aBorders = aPredicate.GetBorders()
1437 # @ingroup l2_grps_delete
1438 def RemoveGroup(self, group):
1439 self.mesh.RemoveGroup(group)
1441 ## Removes a group with its contents
1442 # @ingroup l2_grps_delete
1443 def RemoveGroupWithContents(self, group):
1444 self.mesh.RemoveGroupWithContents(group)
1446 ## Gets the list of groups existing in the mesh
1447 # @return a sequence of SMESH_GroupBase
1448 # @ingroup l2_grps_create
1449 def GetGroups(self):
1450 return self.mesh.GetGroups()
1452 ## Gets the number of groups existing in the mesh
1453 # @return the quantity of groups as an integer value
1454 # @ingroup l2_grps_create
1456 return self.mesh.NbGroups()
1458 ## Gets the list of names of groups existing in the mesh
1459 # @return list of strings
1460 # @ingroup l2_grps_create
1461 def GetGroupNames(self):
1462 groups = self.GetGroups()
1464 for group in groups:
1465 names.append(group.GetName())
1468 ## Produces a union of two groups
1469 # A new group is created. All mesh elements that are
1470 # present in the initial groups are added to the new one
1471 # @return an instance of SMESH_Group
1472 # @ingroup l2_grps_operon
1473 def UnionGroups(self, group1, group2, name):
1474 return self.mesh.UnionGroups(group1, group2, name)
1476 ## Produces a union list of groups
1477 # New group is created. All mesh elements that are present in
1478 # initial groups are added to the new one
1479 # @return an instance of SMESH_Group
1480 # @ingroup l2_grps_operon
1481 def UnionListOfGroups(self, groups, name):
1482 return self.mesh.UnionListOfGroups(groups, name)
1484 ## Prodices an intersection of two groups
1485 # A new group is created. All mesh elements that are common
1486 # for the two initial groups are added to the new one.
1487 # @return an instance of SMESH_Group
1488 # @ingroup l2_grps_operon
1489 def IntersectGroups(self, group1, group2, name):
1490 return self.mesh.IntersectGroups(group1, group2, name)
1492 ## Produces an intersection of groups
1493 # New group is created. All mesh elements that are present in all
1494 # initial groups simultaneously are added to the new one
1495 # @return an instance of SMESH_Group
1496 # @ingroup l2_grps_operon
1497 def IntersectListOfGroups(self, groups, name):
1498 return self.mesh.IntersectListOfGroups(groups, name)
1500 ## Produces a cut of two groups
1501 # A new group is created. All mesh elements that are present in
1502 # the main group but are not present in the tool group are added to the new one
1503 # @return an instance of SMESH_Group
1504 # @ingroup l2_grps_operon
1505 def CutGroups(self, main_group, tool_group, name):
1506 return self.mesh.CutGroups(main_group, tool_group, name)
1508 ## Produces a cut of groups
1509 # A new group is created. All mesh elements that are present in main groups
1510 # but do not present in tool groups are added to the new one
1511 # @return an instance of SMESH_Group
1512 # @ingroup l2_grps_operon
1513 def CutListOfGroups(self, main_groups, tool_groups, name):
1514 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1516 ## Produces a group of elements with specified element type using list of existing groups
1517 # A new group is created. System
1518 # 1) extract all nodes on which groups elements are built
1519 # 2) combine all elements of specified dimension laying on these nodes
1520 # @return an instance of SMESH_Group
1521 # @ingroup l2_grps_operon
1522 def CreateDimGroup(self, groups, elem_type, name):
1523 return self.mesh.CreateDimGroup(groups, elem_type, name)
1526 ## Convert group on geom into standalone group
1527 # @ingroup l2_grps_delete
1528 def ConvertToStandalone(self, group):
1529 return self.mesh.ConvertToStandalone(group)
1531 # Get some info about mesh:
1532 # ------------------------
1534 ## Returns the log of nodes and elements added or removed
1535 # since the previous clear of the log.
1536 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1537 # @return list of log_block structures:
1542 # @ingroup l1_auxiliary
1543 def GetLog(self, clearAfterGet):
1544 return self.mesh.GetLog(clearAfterGet)
1546 ## Clears the log of nodes and elements added or removed since the previous
1547 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1548 # @ingroup l1_auxiliary
1550 self.mesh.ClearLog()
1552 ## Toggles auto color mode on the object.
1553 # @param theAutoColor the flag which toggles auto color mode.
1554 # @ingroup l1_auxiliary
1555 def SetAutoColor(self, theAutoColor):
1556 self.mesh.SetAutoColor(theAutoColor)
1558 ## Gets flag of object auto color mode.
1559 # @return True or False
1560 # @ingroup l1_auxiliary
1561 def GetAutoColor(self):
1562 return self.mesh.GetAutoColor()
1564 ## Gets the internal ID
1565 # @return integer value, which is the internal Id of the mesh
1566 # @ingroup l1_auxiliary
1568 return self.mesh.GetId()
1571 # @return integer value, which is the study Id of the mesh
1572 # @ingroup l1_auxiliary
1573 def GetStudyId(self):
1574 return self.mesh.GetStudyId()
1576 ## Checks the group names for duplications.
1577 # Consider the maximum group name length stored in MED file.
1578 # @return True or False
1579 # @ingroup l1_auxiliary
1580 def HasDuplicatedGroupNamesMED(self):
1581 return self.mesh.HasDuplicatedGroupNamesMED()
1583 ## Obtains the mesh editor tool
1584 # @return an instance of SMESH_MeshEditor
1585 # @ingroup l1_modifying
1586 def GetMeshEditor(self):
1587 return self.mesh.GetMeshEditor()
1590 # @return an instance of SALOME_MED::MESH
1591 # @ingroup l1_auxiliary
1592 def GetMEDMesh(self):
1593 return self.mesh.GetMEDMesh()
1596 # Get informations about mesh contents:
1597 # ------------------------------------
1599 ## Returns the number of nodes in the mesh
1600 # @return an integer value
1601 # @ingroup l1_meshinfo
1603 return self.mesh.NbNodes()
1605 ## Returns the number of elements in the mesh
1606 # @return an integer value
1607 # @ingroup l1_meshinfo
1608 def NbElements(self):
1609 return self.mesh.NbElements()
1611 ## Returns the number of edges in the mesh
1612 # @return an integer value
1613 # @ingroup l1_meshinfo
1615 return self.mesh.NbEdges()
1617 ## Returns the number of edges with the given order in the mesh
1618 # @param elementOrder the order of elements:
1619 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1620 # @return an integer value
1621 # @ingroup l1_meshinfo
1622 def NbEdgesOfOrder(self, elementOrder):
1623 return self.mesh.NbEdgesOfOrder(elementOrder)
1625 ## Returns the number of faces in the mesh
1626 # @return an integer value
1627 # @ingroup l1_meshinfo
1629 return self.mesh.NbFaces()
1631 ## Returns the number of faces with the given order in the mesh
1632 # @param elementOrder the order of elements:
1633 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1634 # @return an integer value
1635 # @ingroup l1_meshinfo
1636 def NbFacesOfOrder(self, elementOrder):
1637 return self.mesh.NbFacesOfOrder(elementOrder)
1639 ## Returns the number of triangles in the mesh
1640 # @return an integer value
1641 # @ingroup l1_meshinfo
1642 def NbTriangles(self):
1643 return self.mesh.NbTriangles()
1645 ## Returns the number of triangles with the given order in the mesh
1646 # @param elementOrder is the order of elements:
1647 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1648 # @return an integer value
1649 # @ingroup l1_meshinfo
1650 def NbTrianglesOfOrder(self, elementOrder):
1651 return self.mesh.NbTrianglesOfOrder(elementOrder)
1653 ## Returns the number of quadrangles in the mesh
1654 # @return an integer value
1655 # @ingroup l1_meshinfo
1656 def NbQuadrangles(self):
1657 return self.mesh.NbQuadrangles()
1659 ## Returns the number of quadrangles with the given order in the mesh
1660 # @param elementOrder the order of elements:
1661 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1662 # @return an integer value
1663 # @ingroup l1_meshinfo
1664 def NbQuadranglesOfOrder(self, elementOrder):
1665 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1667 ## Returns the number of polygons in the mesh
1668 # @return an integer value
1669 # @ingroup l1_meshinfo
1670 def NbPolygons(self):
1671 return self.mesh.NbPolygons()
1673 ## Returns the number of volumes in the mesh
1674 # @return an integer value
1675 # @ingroup l1_meshinfo
1676 def NbVolumes(self):
1677 return self.mesh.NbVolumes()
1679 ## Returns the number of volumes with the given order in the mesh
1680 # @param elementOrder the order of elements:
1681 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1682 # @return an integer value
1683 # @ingroup l1_meshinfo
1684 def NbVolumesOfOrder(self, elementOrder):
1685 return self.mesh.NbVolumesOfOrder(elementOrder)
1687 ## Returns the number of tetrahedrons in the mesh
1688 # @return an integer value
1689 # @ingroup l1_meshinfo
1691 return self.mesh.NbTetras()
1693 ## Returns the number of tetrahedrons with the given order in the mesh
1694 # @param elementOrder the order of elements:
1695 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1696 # @return an integer value
1697 # @ingroup l1_meshinfo
1698 def NbTetrasOfOrder(self, elementOrder):
1699 return self.mesh.NbTetrasOfOrder(elementOrder)
1701 ## Returns the number of hexahedrons in the mesh
1702 # @return an integer value
1703 # @ingroup l1_meshinfo
1705 return self.mesh.NbHexas()
1707 ## Returns the number of hexahedrons with the given order in the mesh
1708 # @param elementOrder the order of elements:
1709 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1710 # @return an integer value
1711 # @ingroup l1_meshinfo
1712 def NbHexasOfOrder(self, elementOrder):
1713 return self.mesh.NbHexasOfOrder(elementOrder)
1715 ## Returns the number of pyramids in the mesh
1716 # @return an integer value
1717 # @ingroup l1_meshinfo
1718 def NbPyramids(self):
1719 return self.mesh.NbPyramids()
1721 ## Returns the number of pyramids with the given order in the mesh
1722 # @param elementOrder the order of elements:
1723 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1724 # @return an integer value
1725 # @ingroup l1_meshinfo
1726 def NbPyramidsOfOrder(self, elementOrder):
1727 return self.mesh.NbPyramidsOfOrder(elementOrder)
1729 ## Returns the number of prisms in the mesh
1730 # @return an integer value
1731 # @ingroup l1_meshinfo
1733 return self.mesh.NbPrisms()
1735 ## Returns the number of prisms with the given order in the mesh
1736 # @param elementOrder the order of elements:
1737 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1738 # @return an integer value
1739 # @ingroup l1_meshinfo
1740 def NbPrismsOfOrder(self, elementOrder):
1741 return self.mesh.NbPrismsOfOrder(elementOrder)
1743 ## Returns the number of polyhedrons in the mesh
1744 # @return an integer value
1745 # @ingroup l1_meshinfo
1746 def NbPolyhedrons(self):
1747 return self.mesh.NbPolyhedrons()
1749 ## Returns the number of submeshes in the mesh
1750 # @return an integer value
1751 # @ingroup l1_meshinfo
1752 def NbSubMesh(self):
1753 return self.mesh.NbSubMesh()
1755 ## Returns the list of mesh elements IDs
1756 # @return the list of integer values
1757 # @ingroup l1_meshinfo
1758 def GetElementsId(self):
1759 return self.mesh.GetElementsId()
1761 ## Returns the list of IDs of mesh elements with the given type
1762 # @param elementType the required type of elements
1763 # @return list of integer values
1764 # @ingroup l1_meshinfo
1765 def GetElementsByType(self, elementType):
1766 return self.mesh.GetElementsByType(elementType)
1768 ## Returns the list of mesh nodes IDs
1769 # @return the list of integer values
1770 # @ingroup l1_meshinfo
1771 def GetNodesId(self):
1772 return self.mesh.GetNodesId()
1774 # Get the information about mesh elements:
1775 # ------------------------------------
1777 ## Returns the type of mesh element
1778 # @return the value from SMESH::ElementType enumeration
1779 # @ingroup l1_meshinfo
1780 def GetElementType(self, id, iselem):
1781 return self.mesh.GetElementType(id, iselem)
1783 ## Returns the list of submesh elements IDs
1784 # @param Shape a geom object(subshape) IOR
1785 # Shape must be the subshape of a ShapeToMesh()
1786 # @return the list of integer values
1787 # @ingroup l1_meshinfo
1788 def GetSubMeshElementsId(self, Shape):
1789 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1790 ShapeID = Shape.GetSubShapeIndices()[0]
1793 return self.mesh.GetSubMeshElementsId(ShapeID)
1795 ## Returns the list of submesh nodes IDs
1796 # @param Shape a geom object(subshape) IOR
1797 # Shape must be the subshape of a ShapeToMesh()
1798 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1799 # @return the list of integer values
1800 # @ingroup l1_meshinfo
1801 def GetSubMeshNodesId(self, Shape, all):
1802 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1803 ShapeID = Shape.GetSubShapeIndices()[0]
1806 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1808 ## Returns the list of IDs of submesh elements with the given type
1809 # @param Shape a geom object(subshape) IOR
1810 # Shape must be a subshape of a ShapeToMesh()
1811 # @return the list of integer values
1812 # @ingroup l1_meshinfo
1813 def GetSubMeshElementType(self, Shape):
1814 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1815 ShapeID = Shape.GetSubShapeIndices()[0]
1818 return self.mesh.GetSubMeshElementType(ShapeID)
1820 ## Gets the mesh description
1821 # @return string value
1822 # @ingroup l1_meshinfo
1824 return self.mesh.Dump()
1827 # Get the information about nodes and elements of a mesh by its IDs:
1828 # -----------------------------------------------------------
1830 ## Gets XYZ coordinates of a node
1831 # \n If there is no nodes for the given ID - returns an empty list
1832 # @return a list of double precision values
1833 # @ingroup l1_meshinfo
1834 def GetNodeXYZ(self, id):
1835 return self.mesh.GetNodeXYZ(id)
1837 ## Returns list of IDs of inverse elements for the given node
1838 # \n If there is no node for the given ID - returns an empty list
1839 # @return a list of integer values
1840 # @ingroup l1_meshinfo
1841 def GetNodeInverseElements(self, id):
1842 return self.mesh.GetNodeInverseElements(id)
1844 ## @brief Returns the position of a node on the shape
1845 # @return SMESH::NodePosition
1846 # @ingroup l1_meshinfo
1847 def GetNodePosition(self,NodeID):
1848 return self.mesh.GetNodePosition(NodeID)
1850 ## If the given element is a node, returns the ID of shape
1851 # \n If there is no node for the given ID - returns -1
1852 # @return an integer value
1853 # @ingroup l1_meshinfo
1854 def GetShapeID(self, id):
1855 return self.mesh.GetShapeID(id)
1857 ## Returns the ID of the result shape after
1858 # FindShape() from SMESH_MeshEditor for the given element
1859 # \n If there is no element for the given ID - returns -1
1860 # @return an integer value
1861 # @ingroup l1_meshinfo
1862 def GetShapeIDForElem(self,id):
1863 return self.mesh.GetShapeIDForElem(id)
1865 ## Returns the number of nodes for the given element
1866 # \n If there is no element for the given ID - returns -1
1867 # @return an integer value
1868 # @ingroup l1_meshinfo
1869 def GetElemNbNodes(self, id):
1870 return self.mesh.GetElemNbNodes(id)
1872 ## Returns the node ID the given index for the given element
1873 # \n If there is no element for the given ID - returns -1
1874 # \n If there is no node for the given index - returns -2
1875 # @return an integer value
1876 # @ingroup l1_meshinfo
1877 def GetElemNode(self, id, index):
1878 return self.mesh.GetElemNode(id, index)
1880 ## Returns the IDs of nodes of the given element
1881 # @return a list of integer values
1882 # @ingroup l1_meshinfo
1883 def GetElemNodes(self, id):
1884 return self.mesh.GetElemNodes(id)
1886 ## Returns true if the given node is the medium node in the given quadratic element
1887 # @ingroup l1_meshinfo
1888 def IsMediumNode(self, elementID, nodeID):
1889 return self.mesh.IsMediumNode(elementID, nodeID)
1891 ## Returns true if the given node is the medium node in one of quadratic elements
1892 # @ingroup l1_meshinfo
1893 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1894 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1896 ## Returns the number of edges for the given element
1897 # @ingroup l1_meshinfo
1898 def ElemNbEdges(self, id):
1899 return self.mesh.ElemNbEdges(id)
1901 ## Returns the number of faces for the given element
1902 # @ingroup l1_meshinfo
1903 def ElemNbFaces(self, id):
1904 return self.mesh.ElemNbFaces(id)
1906 ## Returns true if the given element is a polygon
1907 # @ingroup l1_meshinfo
1908 def IsPoly(self, id):
1909 return self.mesh.IsPoly(id)
1911 ## Returns true if the given element is quadratic
1912 # @ingroup l1_meshinfo
1913 def IsQuadratic(self, id):
1914 return self.mesh.IsQuadratic(id)
1916 ## Returns XYZ coordinates of the barycenter of the given element
1917 # \n If there is no element for the given ID - returns an empty list
1918 # @return a list of three double values
1919 # @ingroup l1_meshinfo
1920 def BaryCenter(self, id):
1921 return self.mesh.BaryCenter(id)
1924 # Mesh edition (SMESH_MeshEditor functionality):
1925 # ---------------------------------------------
1927 ## Removes the elements from the mesh by ids
1928 # @param IDsOfElements is a list of ids of elements to remove
1929 # @return True or False
1930 # @ingroup l2_modif_del
1931 def RemoveElements(self, IDsOfElements):
1932 return self.editor.RemoveElements(IDsOfElements)
1934 ## Removes nodes from mesh by ids
1935 # @param IDsOfNodes is a list of ids of nodes to remove
1936 # @return True or False
1937 # @ingroup l2_modif_del
1938 def RemoveNodes(self, IDsOfNodes):
1939 return self.editor.RemoveNodes(IDsOfNodes)
1941 ## Add a node to the mesh by coordinates
1942 # @return Id of the new node
1943 # @ingroup l2_modif_add
1944 def AddNode(self, x, y, z):
1945 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
1946 self.mesh.SetParameters(Parameters)
1947 return self.editor.AddNode( x, y, z)
1949 ## Creates a linear or quadratic edge (this is determined
1950 # by the number of given nodes).
1951 # @param IDsOfNodes the list of node IDs for creation of the element.
1952 # The order of nodes in this list should correspond to the description
1953 # of MED. \n This description is located by the following link:
1954 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1955 # @return the Id of the new edge
1956 # @ingroup l2_modif_add
1957 def AddEdge(self, IDsOfNodes):
1958 return self.editor.AddEdge(IDsOfNodes)
1960 ## Creates a linear or quadratic face (this is determined
1961 # by the number of given nodes).
1962 # @param IDsOfNodes the list of node IDs for creation of the element.
1963 # The order of nodes in this list should correspond to the description
1964 # of MED. \n This description is located by the following link:
1965 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1966 # @return the Id of the new face
1967 # @ingroup l2_modif_add
1968 def AddFace(self, IDsOfNodes):
1969 return self.editor.AddFace(IDsOfNodes)
1971 ## Adds a polygonal face to the mesh by the list of node IDs
1972 # @param IdsOfNodes the list of node IDs for creation of the element.
1973 # @return the Id of the new face
1974 # @ingroup l2_modif_add
1975 def AddPolygonalFace(self, IdsOfNodes):
1976 return self.editor.AddPolygonalFace(IdsOfNodes)
1978 ## Creates both simple and quadratic volume (this is determined
1979 # by the number of given nodes).
1980 # @param IDsOfNodes the list of node IDs for creation of the element.
1981 # The order of nodes in this list should correspond to the description
1982 # of MED. \n This description is located by the following link:
1983 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1984 # @return the Id of the new volumic element
1985 # @ingroup l2_modif_add
1986 def AddVolume(self, IDsOfNodes):
1987 return self.editor.AddVolume(IDsOfNodes)
1989 ## Creates a volume of many faces, giving nodes for each face.
1990 # @param IdsOfNodes the list of node IDs for volume creation face by face.
1991 # @param Quantities the list of integer values, Quantities[i]
1992 # gives the quantity of nodes in face number i.
1993 # @return the Id of the new volumic element
1994 # @ingroup l2_modif_add
1995 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1996 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1998 ## Creates a volume of many faces, giving the IDs of the existing faces.
1999 # @param IdsOfFaces the list of face IDs for volume creation.
2001 # Note: The created volume will refer only to the nodes
2002 # of the given faces, not to the faces themselves.
2003 # @return the Id of the new volumic element
2004 # @ingroup l2_modif_add
2005 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2006 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2009 ## @brief Binds a node to a vertex
2010 # @param NodeID a node ID
2011 # @param Vertex a vertex or vertex ID
2012 # @return True if succeed else raises an exception
2013 # @ingroup l2_modif_add
2014 def SetNodeOnVertex(self, NodeID, Vertex):
2015 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2016 VertexID = Vertex.GetSubShapeIndices()[0]
2020 self.editor.SetNodeOnVertex(NodeID, VertexID)
2021 except SALOME.SALOME_Exception, inst:
2022 raise ValueError, inst.details.text
2026 ## @brief Stores the node position on an edge
2027 # @param NodeID a node ID
2028 # @param Edge an edge or edge ID
2029 # @param paramOnEdge a parameter on the edge where the node is located
2030 # @return True if succeed else raises an exception
2031 # @ingroup l2_modif_add
2032 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2033 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2034 EdgeID = Edge.GetSubShapeIndices()[0]
2038 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2039 except SALOME.SALOME_Exception, inst:
2040 raise ValueError, inst.details.text
2043 ## @brief Stores node position on a face
2044 # @param NodeID a node ID
2045 # @param Face a face or face ID
2046 # @param u U parameter on the face where the node is located
2047 # @param v V parameter on the face where the node is located
2048 # @return True if succeed else raises an exception
2049 # @ingroup l2_modif_add
2050 def SetNodeOnFace(self, NodeID, Face, u, v):
2051 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2052 FaceID = Face.GetSubShapeIndices()[0]
2056 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2057 except SALOME.SALOME_Exception, inst:
2058 raise ValueError, inst.details.text
2061 ## @brief Binds a node to a solid
2062 # @param NodeID a node ID
2063 # @param Solid a solid or solid ID
2064 # @return True if succeed else raises an exception
2065 # @ingroup l2_modif_add
2066 def SetNodeInVolume(self, NodeID, Solid):
2067 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2068 SolidID = Solid.GetSubShapeIndices()[0]
2072 self.editor.SetNodeInVolume(NodeID, SolidID)
2073 except SALOME.SALOME_Exception, inst:
2074 raise ValueError, inst.details.text
2077 ## @brief Bind an element to a shape
2078 # @param ElementID an element ID
2079 # @param Shape a shape or shape ID
2080 # @return True if succeed else raises an exception
2081 # @ingroup l2_modif_add
2082 def SetMeshElementOnShape(self, ElementID, Shape):
2083 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2084 ShapeID = Shape.GetSubShapeIndices()[0]
2088 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2089 except SALOME.SALOME_Exception, inst:
2090 raise ValueError, inst.details.text
2094 ## Moves the node with the given id
2095 # @param NodeID the id of the node
2096 # @param x a new X coordinate
2097 # @param y a new Y coordinate
2098 # @param z a new Z coordinate
2099 # @return True if succeed else False
2100 # @ingroup l2_modif_movenode
2101 def MoveNode(self, NodeID, x, y, z):
2102 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2103 self.mesh.SetParameters(Parameters)
2104 return self.editor.MoveNode(NodeID, x, y, z)
2106 ## Finds the node closest to a point and moves it to a point location
2107 # @param x the X coordinate of a point
2108 # @param y the Y coordinate of a point
2109 # @param z the Z coordinate of a point
2110 # @return the ID of a node
2111 # @ingroup l2_modif_throughp
2112 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2113 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2114 self.mesh.SetParameters(Parameters)
2115 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2117 ## Finds the node closest to a point
2118 # @param x the X coordinate of a point
2119 # @param y the Y coordinate of a point
2120 # @param z the Z coordinate of a point
2121 # @return the ID of a node
2122 # @ingroup l2_modif_throughp
2123 def FindNodeClosestTo(self, x, y, z):
2124 preview = self.mesh.GetMeshEditPreviewer()
2125 return preview.MoveClosestNodeToPoint(x, y, z, -1)
2127 ## Finds the node closest to a point and moves it to a point location
2128 # @param x the X coordinate of a point
2129 # @param y the Y coordinate of a point
2130 # @param z the Z coordinate of a point
2131 # @return the ID of a moved node
2132 # @ingroup l2_modif_throughp
2133 def MeshToPassThroughAPoint(self, x, y, z):
2134 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2136 ## Replaces two neighbour triangles sharing Node1-Node2 link
2137 # with the triangles built on the same 4 nodes but having other common link.
2138 # @param NodeID1 the ID of the first node
2139 # @param NodeID2 the ID of the second node
2140 # @return false if proper faces were not found
2141 # @ingroup l2_modif_invdiag
2142 def InverseDiag(self, NodeID1, NodeID2):
2143 return self.editor.InverseDiag(NodeID1, NodeID2)
2145 ## Replaces two neighbour triangles sharing Node1-Node2 link
2146 # with a quadrangle built on the same 4 nodes.
2147 # @param NodeID1 the ID of the first node
2148 # @param NodeID2 the ID of the second node
2149 # @return false if proper faces were not found
2150 # @ingroup l2_modif_unitetri
2151 def DeleteDiag(self, NodeID1, NodeID2):
2152 return self.editor.DeleteDiag(NodeID1, NodeID2)
2154 ## Reorients elements by ids
2155 # @param IDsOfElements if undefined reorients all mesh elements
2156 # @return True if succeed else False
2157 # @ingroup l2_modif_changori
2158 def Reorient(self, IDsOfElements=None):
2159 if IDsOfElements == None:
2160 IDsOfElements = self.GetElementsId()
2161 return self.editor.Reorient(IDsOfElements)
2163 ## Reorients all elements of the object
2164 # @param theObject mesh, submesh or group
2165 # @return True if succeed else False
2166 # @ingroup l2_modif_changori
2167 def ReorientObject(self, theObject):
2168 if ( isinstance( theObject, Mesh )):
2169 theObject = theObject.GetMesh()
2170 return self.editor.ReorientObject(theObject)
2172 ## Fuses the neighbouring triangles into quadrangles.
2173 # @param IDsOfElements The triangles to be fused,
2174 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2175 # @param MaxAngle is the maximum angle between element normals at which the fusion
2176 # is still performed; theMaxAngle is mesured in radians.
2177 # Also it could be a name of variable which defines angle in degrees.
2178 # @return TRUE in case of success, FALSE otherwise.
2179 # @ingroup l2_modif_unitetri
2180 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2182 if isinstance(MaxAngle,str):
2184 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2186 MaxAngle = DegreesToRadians(MaxAngle)
2187 if IDsOfElements == []:
2188 IDsOfElements = self.GetElementsId()
2189 self.mesh.SetParameters(Parameters)
2191 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2192 Functor = theCriterion
2194 Functor = self.smeshpyD.GetFunctor(theCriterion)
2195 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2197 ## Fuses the neighbouring triangles of the object into quadrangles
2198 # @param theObject is mesh, submesh or group
2199 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2200 # @param MaxAngle a max angle between element normals at which the fusion
2201 # is still performed; theMaxAngle is mesured in radians.
2202 # @return TRUE in case of success, FALSE otherwise.
2203 # @ingroup l2_modif_unitetri
2204 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2205 if ( isinstance( theObject, Mesh )):
2206 theObject = theObject.GetMesh()
2207 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2209 ## Splits quadrangles into triangles.
2210 # @param IDsOfElements the faces to be splitted.
2211 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2212 # @return TRUE in case of success, FALSE otherwise.
2213 # @ingroup l2_modif_cutquadr
2214 def QuadToTri (self, IDsOfElements, theCriterion):
2215 if IDsOfElements == []:
2216 IDsOfElements = self.GetElementsId()
2217 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2219 ## Splits quadrangles into triangles.
2220 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2221 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2222 # @return TRUE in case of success, FALSE otherwise.
2223 # @ingroup l2_modif_cutquadr
2224 def QuadToTriObject (self, theObject, theCriterion):
2225 if ( isinstance( theObject, Mesh )):
2226 theObject = theObject.GetMesh()
2227 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2229 ## Splits quadrangles into triangles.
2230 # @param IDsOfElements the faces to be splitted
2231 # @param Diag13 is used to choose a diagonal for splitting.
2232 # @return TRUE in case of success, FALSE otherwise.
2233 # @ingroup l2_modif_cutquadr
2234 def SplitQuad (self, IDsOfElements, Diag13):
2235 if IDsOfElements == []:
2236 IDsOfElements = self.GetElementsId()
2237 return self.editor.SplitQuad(IDsOfElements, Diag13)
2239 ## Splits quadrangles into triangles.
2240 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2241 # @param Diag13 is used to choose a diagonal for splitting.
2242 # @return TRUE in case of success, FALSE otherwise.
2243 # @ingroup l2_modif_cutquadr
2244 def SplitQuadObject (self, theObject, Diag13):
2245 if ( isinstance( theObject, Mesh )):
2246 theObject = theObject.GetMesh()
2247 return self.editor.SplitQuadObject(theObject, Diag13)
2249 ## Finds a better splitting of the given quadrangle.
2250 # @param IDOfQuad the ID of the quadrangle to be splitted.
2251 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2252 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2253 # diagonal is better, 0 if error occurs.
2254 # @ingroup l2_modif_cutquadr
2255 def BestSplit (self, IDOfQuad, theCriterion):
2256 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2258 ## Splits quadrangle faces near triangular facets of volumes
2260 # @ingroup l1_auxiliary
2261 def SplitQuadsNearTriangularFacets(self):
2262 faces_array = self.GetElementsByType(SMESH.FACE)
2263 for face_id in faces_array:
2264 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2265 quad_nodes = self.mesh.GetElemNodes(face_id)
2266 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2267 isVolumeFound = False
2268 for node1_elem in node1_elems:
2269 if not isVolumeFound:
2270 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2271 nb_nodes = self.GetElemNbNodes(node1_elem)
2272 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2273 volume_elem = node1_elem
2274 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2275 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2276 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2277 isVolumeFound = True
2278 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2279 self.SplitQuad([face_id], False) # diagonal 2-4
2280 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2281 isVolumeFound = True
2282 self.SplitQuad([face_id], True) # diagonal 1-3
2283 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2284 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2285 isVolumeFound = True
2286 self.SplitQuad([face_id], True) # diagonal 1-3
2288 ## @brief Splits hexahedrons into tetrahedrons.
2290 # This operation uses pattern mapping functionality for splitting.
2291 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2292 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2293 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2294 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2295 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2296 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2297 # @return TRUE in case of success, FALSE otherwise.
2298 # @ingroup l1_auxiliary
2299 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2300 # Pattern: 5.---------.6
2305 # (0,0,1) 4.---------.7 * |
2312 # (0,0,0) 0.---------.3
2313 pattern_tetra = "!!! Nb of points: \n 8 \n\
2323 !!! Indices of points of 6 tetras: \n\
2331 pattern = self.smeshpyD.GetPattern()
2332 isDone = pattern.LoadFromFile(pattern_tetra)
2334 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2337 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2338 isDone = pattern.MakeMesh(self.mesh, False, False)
2339 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2341 # split quafrangle faces near triangular facets of volumes
2342 self.SplitQuadsNearTriangularFacets()
2346 ## @brief Split hexahedrons into prisms.
2348 # Uses the pattern mapping functionality for splitting.
2349 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2350 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2351 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2352 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2353 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2354 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2355 # @return TRUE in case of success, FALSE otherwise.
2356 # @ingroup l1_auxiliary
2357 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2358 # Pattern: 5.---------.6
2363 # (0,0,1) 4.---------.7 |
2370 # (0,0,0) 0.---------.3
2371 pattern_prism = "!!! Nb of points: \n 8 \n\
2381 !!! Indices of points of 2 prisms: \n\
2385 pattern = self.smeshpyD.GetPattern()
2386 isDone = pattern.LoadFromFile(pattern_prism)
2388 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2391 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2392 isDone = pattern.MakeMesh(self.mesh, False, False)
2393 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2395 # Splits quafrangle faces near triangular facets of volumes
2396 self.SplitQuadsNearTriangularFacets()
2400 ## Smoothes elements
2401 # @param IDsOfElements the list if ids of elements to smooth
2402 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2403 # Note that nodes built on edges and boundary nodes are always fixed.
2404 # @param MaxNbOfIterations the maximum number of iterations
2405 # @param MaxAspectRatio varies in range [1.0, inf]
2406 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2407 # @return TRUE in case of success, FALSE otherwise.
2408 # @ingroup l2_modif_smooth
2409 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2410 MaxNbOfIterations, MaxAspectRatio, Method):
2411 if IDsOfElements == []:
2412 IDsOfElements = self.GetElementsId()
2413 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2414 self.mesh.SetParameters(Parameters)
2415 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2416 MaxNbOfIterations, MaxAspectRatio, Method)
2418 ## Smoothes elements which belong to the given object
2419 # @param theObject the object to smooth
2420 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2421 # Note that nodes built on edges and boundary nodes are always fixed.
2422 # @param MaxNbOfIterations the maximum number of iterations
2423 # @param MaxAspectRatio varies in range [1.0, inf]
2424 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2425 # @return TRUE in case of success, FALSE otherwise.
2426 # @ingroup l2_modif_smooth
2427 def SmoothObject(self, theObject, IDsOfFixedNodes,
2428 MaxNbOfIterations, MaxAspectRatio, Method):
2429 if ( isinstance( theObject, Mesh )):
2430 theObject = theObject.GetMesh()
2431 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2432 MaxNbOfIterations, MaxAspectRatio, Method)
2434 ## Parametrically smoothes the given elements
2435 # @param IDsOfElements the list if ids of elements to smooth
2436 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2437 # Note that nodes built on edges and boundary nodes are always fixed.
2438 # @param MaxNbOfIterations the maximum number of iterations
2439 # @param MaxAspectRatio varies in range [1.0, inf]
2440 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2441 # @return TRUE in case of success, FALSE otherwise.
2442 # @ingroup l2_modif_smooth
2443 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2444 MaxNbOfIterations, MaxAspectRatio, Method):
2445 if IDsOfElements == []:
2446 IDsOfElements = self.GetElementsId()
2447 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2448 self.mesh.SetParameters(Parameters)
2449 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2450 MaxNbOfIterations, MaxAspectRatio, Method)
2452 ## Parametrically smoothes the elements which belong to the given object
2453 # @param theObject the object to smooth
2454 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2455 # Note that nodes built on edges and boundary nodes are always fixed.
2456 # @param MaxNbOfIterations the maximum number of iterations
2457 # @param MaxAspectRatio varies in range [1.0, inf]
2458 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2459 # @return TRUE in case of success, FALSE otherwise.
2460 # @ingroup l2_modif_smooth
2461 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2462 MaxNbOfIterations, MaxAspectRatio, Method):
2463 if ( isinstance( theObject, Mesh )):
2464 theObject = theObject.GetMesh()
2465 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2466 MaxNbOfIterations, MaxAspectRatio, Method)
2468 ## Converts the mesh to quadratic, deletes old elements, replacing
2469 # them with quadratic with the same id.
2470 # @ingroup l2_modif_tofromqu
2471 def ConvertToQuadratic(self, theForce3d):
2472 self.editor.ConvertToQuadratic(theForce3d)
2474 ## Converts the mesh from quadratic to ordinary,
2475 # deletes old quadratic elements, \n replacing
2476 # them with ordinary mesh elements with the same id.
2477 # @return TRUE in case of success, FALSE otherwise.
2478 # @ingroup l2_modif_tofromqu
2479 def ConvertFromQuadratic(self):
2480 return self.editor.ConvertFromQuadratic()
2482 ## Renumber mesh nodes
2483 # @ingroup l2_modif_renumber
2484 def RenumberNodes(self):
2485 self.editor.RenumberNodes()
2487 ## Renumber mesh elements
2488 # @ingroup l2_modif_renumber
2489 def RenumberElements(self):
2490 self.editor.RenumberElements()
2492 ## Generates new elements by rotation of the elements around the axis
2493 # @param IDsOfElements the list of ids of elements to sweep
2494 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2495 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2496 # @param NbOfSteps the number of steps
2497 # @param Tolerance tolerance
2498 # @param MakeGroups forces the generation of new groups from existing ones
2499 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2500 # of all steps, else - size of each step
2501 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2502 # @ingroup l2_modif_extrurev
2503 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2504 MakeGroups=False, TotalAngle=False):
2506 if isinstance(AngleInRadians,str):
2508 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2510 AngleInRadians = DegreesToRadians(AngleInRadians)
2511 if IDsOfElements == []:
2512 IDsOfElements = self.GetElementsId()
2513 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2514 Axis = self.smeshpyD.GetAxisStruct(Axis)
2515 Axis,AxisParameters = ParseAxisStruct(Axis)
2516 if TotalAngle and NbOfSteps:
2517 AngleInRadians /= NbOfSteps
2518 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2519 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2520 self.mesh.SetParameters(Parameters)
2522 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2523 AngleInRadians, NbOfSteps, Tolerance)
2524 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2527 ## Generates new elements by rotation of the elements of object around the axis
2528 # @param theObject object which elements should be sweeped
2529 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2530 # @param AngleInRadians the angle of Rotation
2531 # @param NbOfSteps number of steps
2532 # @param Tolerance tolerance
2533 # @param MakeGroups forces the generation of new groups from existing ones
2534 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2535 # of all steps, else - size of each step
2536 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2537 # @ingroup l2_modif_extrurev
2538 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2539 MakeGroups=False, TotalAngle=False):
2541 if isinstance(AngleInRadians,str):
2543 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2545 AngleInRadians = DegreesToRadians(AngleInRadians)
2546 if ( isinstance( theObject, Mesh )):
2547 theObject = theObject.GetMesh()
2548 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2549 Axis = self.smeshpyD.GetAxisStruct(Axis)
2550 Axis,AxisParameters = ParseAxisStruct(Axis)
2551 if TotalAngle and NbOfSteps:
2552 AngleInRadians /= NbOfSteps
2553 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2554 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2555 self.mesh.SetParameters(Parameters)
2557 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2558 NbOfSteps, Tolerance)
2559 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2562 ## Generates new elements by rotation of the elements of object around the axis
2563 # @param theObject object which elements should be sweeped
2564 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2565 # @param AngleInRadians the angle of Rotation
2566 # @param NbOfSteps number of steps
2567 # @param Tolerance tolerance
2568 # @param MakeGroups forces the generation of new groups from existing ones
2569 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2570 # of all steps, else - size of each step
2571 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2572 # @ingroup l2_modif_extrurev
2573 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2574 MakeGroups=False, TotalAngle=False):
2576 if isinstance(AngleInRadians,str):
2578 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2580 AngleInRadians = DegreesToRadians(AngleInRadians)
2581 if ( isinstance( theObject, Mesh )):
2582 theObject = theObject.GetMesh()
2583 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2584 Axis = self.smeshpyD.GetAxisStruct(Axis)
2585 Axis,AxisParameters = ParseAxisStruct(Axis)
2586 if TotalAngle and NbOfSteps:
2587 AngleInRadians /= NbOfSteps
2588 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2589 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2590 self.mesh.SetParameters(Parameters)
2592 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2593 NbOfSteps, Tolerance)
2594 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2597 ## Generates new elements by rotation of the elements of object around the axis
2598 # @param theObject object which elements should be sweeped
2599 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2600 # @param AngleInRadians the angle of Rotation
2601 # @param NbOfSteps number of steps
2602 # @param Tolerance tolerance
2603 # @param MakeGroups forces the generation of new groups from existing ones
2604 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2605 # of all steps, else - size of each step
2606 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2607 # @ingroup l2_modif_extrurev
2608 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2609 MakeGroups=False, TotalAngle=False):
2611 if isinstance(AngleInRadians,str):
2613 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2615 AngleInRadians = DegreesToRadians(AngleInRadians)
2616 if ( isinstance( theObject, Mesh )):
2617 theObject = theObject.GetMesh()
2618 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2619 Axis = self.smeshpyD.GetAxisStruct(Axis)
2620 Axis,AxisParameters = ParseAxisStruct(Axis)
2621 if TotalAngle and NbOfSteps:
2622 AngleInRadians /= NbOfSteps
2623 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2624 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2625 self.mesh.SetParameters(Parameters)
2627 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2628 NbOfSteps, Tolerance)
2629 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2632 ## Generates new elements by extrusion of the elements with given ids
2633 # @param IDsOfElements the list of elements ids for extrusion
2634 # @param StepVector vector, defining the direction and value of extrusion
2635 # @param NbOfSteps the number of steps
2636 # @param MakeGroups forces the generation of new groups from existing ones
2637 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2638 # @ingroup l2_modif_extrurev
2639 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2640 if IDsOfElements == []:
2641 IDsOfElements = self.GetElementsId()
2642 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2643 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2644 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2645 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2646 Parameters = StepVectorParameters + var_separator + Parameters
2647 self.mesh.SetParameters(Parameters)
2649 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2650 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2653 ## Generates new elements by extrusion of the elements with given ids
2654 # @param IDsOfElements is ids of elements
2655 # @param StepVector vector, defining the direction and value of extrusion
2656 # @param NbOfSteps the number of steps
2657 # @param ExtrFlags sets flags for extrusion
2658 # @param SewTolerance uses for comparing locations of nodes if flag
2659 # EXTRUSION_FLAG_SEW is set
2660 # @param MakeGroups forces the generation of new groups from existing ones
2661 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2662 # @ingroup l2_modif_extrurev
2663 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2664 ExtrFlags, SewTolerance, MakeGroups=False):
2665 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2666 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2668 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2669 ExtrFlags, SewTolerance)
2670 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2671 ExtrFlags, SewTolerance)
2674 ## Generates new elements by extrusion of the elements which belong to the object
2675 # @param theObject the object which elements should be processed
2676 # @param StepVector vector, defining the direction and value of extrusion
2677 # @param NbOfSteps the number of steps
2678 # @param MakeGroups forces the generation of new groups from existing ones
2679 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2680 # @ingroup l2_modif_extrurev
2681 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2682 if ( isinstance( theObject, Mesh )):
2683 theObject = theObject.GetMesh()
2684 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2685 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2686 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2687 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2688 Parameters = StepVectorParameters + var_separator + Parameters
2689 self.mesh.SetParameters(Parameters)
2691 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2692 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2695 ## Generates new elements by extrusion of the elements which belong to the object
2696 # @param theObject object which elements should be processed
2697 # @param StepVector vector, defining the direction and value of extrusion
2698 # @param NbOfSteps the number of steps
2699 # @param MakeGroups to generate new groups from existing ones
2700 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2701 # @ingroup l2_modif_extrurev
2702 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2703 if ( isinstance( theObject, Mesh )):
2704 theObject = theObject.GetMesh()
2705 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2706 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2707 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2708 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2709 Parameters = StepVectorParameters + var_separator + Parameters
2710 self.mesh.SetParameters(Parameters)
2712 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2713 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2716 ## Generates new elements by extrusion of the elements which belong to the object
2717 # @param theObject object which elements should be processed
2718 # @param StepVector vector, defining the direction and value of extrusion
2719 # @param NbOfSteps the number of steps
2720 # @param MakeGroups forces the generation of new groups from existing ones
2721 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2722 # @ingroup l2_modif_extrurev
2723 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2724 if ( isinstance( theObject, Mesh )):
2725 theObject = theObject.GetMesh()
2726 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2727 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2728 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2729 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2730 Parameters = StepVectorParameters + var_separator + Parameters
2731 self.mesh.SetParameters(Parameters)
2733 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2734 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2737 ## Generates new elements by extrusion of the given elements
2738 # The path of extrusion must be a meshed edge.
2739 # @param IDsOfElements ids of elements
2740 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2741 # @param PathShape shape(edge) defines the sub-mesh for the path
2742 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2743 # @param HasAngles allows the shape to be rotated around the path
2744 # to get the resulting mesh in a helical fashion
2745 # @param Angles list of angles
2746 # @param HasRefPoint allows using the reference point
2747 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2748 # The User can specify any point as the Reference Point.
2749 # @param MakeGroups forces the generation of new groups from existing ones
2750 # @param LinearVariation forces the computation of rotation angles as linear
2751 # variation of the given Angles along path steps
2752 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2753 # only SMESH::Extrusion_Error otherwise
2754 # @ingroup l2_modif_extrurev
2755 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2756 HasAngles, Angles, HasRefPoint, RefPoint,
2757 MakeGroups=False, LinearVariation=False):
2758 Angles,AnglesParameters = ParseAngles(Angles)
2759 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2760 if IDsOfElements == []:
2761 IDsOfElements = self.GetElementsId()
2762 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2763 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2765 if ( isinstance( PathMesh, Mesh )):
2766 PathMesh = PathMesh.GetMesh()
2767 if HasAngles and Angles and LinearVariation:
2768 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2770 Parameters = AnglesParameters + var_separator + RefPointParameters
2771 self.mesh.SetParameters(Parameters)
2773 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2774 PathShape, NodeStart, HasAngles,
2775 Angles, HasRefPoint, RefPoint)
2776 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2777 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2779 ## Generates new elements by extrusion of the elements which belong to the object
2780 # The path of extrusion must be a meshed edge.
2781 # @param theObject the object which elements should be processed
2782 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2783 # @param PathShape shape(edge) defines the sub-mesh for the path
2784 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2785 # @param HasAngles allows the shape to be rotated around the path
2786 # to get the resulting mesh in a helical fashion
2787 # @param Angles list of angles
2788 # @param HasRefPoint allows using the reference point
2789 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2790 # The User can specify any point as the Reference Point.
2791 # @param MakeGroups forces the generation of new groups from existing ones
2792 # @param LinearVariation forces the computation of rotation angles as linear
2793 # variation of the given Angles along path steps
2794 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2795 # only SMESH::Extrusion_Error otherwise
2796 # @ingroup l2_modif_extrurev
2797 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2798 HasAngles, Angles, HasRefPoint, RefPoint,
2799 MakeGroups=False, LinearVariation=False):
2800 Angles,AnglesParameters = ParseAngles(Angles)
2801 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2802 if ( isinstance( theObject, Mesh )):
2803 theObject = theObject.GetMesh()
2804 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2805 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2806 if ( isinstance( PathMesh, Mesh )):
2807 PathMesh = PathMesh.GetMesh()
2808 if HasAngles and Angles and LinearVariation:
2809 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2811 Parameters = AnglesParameters + var_separator + RefPointParameters
2812 self.mesh.SetParameters(Parameters)
2814 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2815 PathShape, NodeStart, HasAngles,
2816 Angles, HasRefPoint, RefPoint)
2817 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2818 NodeStart, HasAngles, Angles, HasRefPoint,
2821 ## Generates new elements by extrusion of the elements which belong to the object
2822 # The path of extrusion must be a meshed edge.
2823 # @param theObject the object which elements should be processed
2824 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2825 # @param PathShape shape(edge) defines the sub-mesh for the path
2826 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2827 # @param HasAngles allows the shape to be rotated around the path
2828 # to get the resulting mesh in a helical fashion
2829 # @param Angles list of angles
2830 # @param HasRefPoint allows using the reference point
2831 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2832 # The User can specify any point as the Reference Point.
2833 # @param MakeGroups forces the generation of new groups from existing ones
2834 # @param LinearVariation forces the computation of rotation angles as linear
2835 # variation of the given Angles along path steps
2836 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2837 # only SMESH::Extrusion_Error otherwise
2838 # @ingroup l2_modif_extrurev
2839 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
2840 HasAngles, Angles, HasRefPoint, RefPoint,
2841 MakeGroups=False, LinearVariation=False):
2842 Angles,AnglesParameters = ParseAngles(Angles)
2843 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2844 if ( isinstance( theObject, Mesh )):
2845 theObject = theObject.GetMesh()
2846 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2847 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2848 if ( isinstance( PathMesh, Mesh )):
2849 PathMesh = PathMesh.GetMesh()
2850 if HasAngles and Angles and LinearVariation:
2851 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2853 Parameters = AnglesParameters + var_separator + RefPointParameters
2854 self.mesh.SetParameters(Parameters)
2856 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
2857 PathShape, NodeStart, HasAngles,
2858 Angles, HasRefPoint, RefPoint)
2859 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
2860 NodeStart, HasAngles, Angles, HasRefPoint,
2863 ## Generates new elements by extrusion of the elements which belong to the object
2864 # The path of extrusion must be a meshed edge.
2865 # @param theObject the object which elements should be processed
2866 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2867 # @param PathShape shape(edge) defines the sub-mesh for the path
2868 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2869 # @param HasAngles allows the shape to be rotated around the path
2870 # to get the resulting mesh in a helical fashion
2871 # @param Angles list of angles
2872 # @param HasRefPoint allows using the reference point
2873 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2874 # The User can specify any point as the Reference Point.
2875 # @param MakeGroups forces the generation of new groups from existing ones
2876 # @param LinearVariation forces the computation of rotation angles as linear
2877 # variation of the given Angles along path steps
2878 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2879 # only SMESH::Extrusion_Error otherwise
2880 # @ingroup l2_modif_extrurev
2881 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
2882 HasAngles, Angles, HasRefPoint, RefPoint,
2883 MakeGroups=False, LinearVariation=False):
2884 Angles,AnglesParameters = ParseAngles(Angles)
2885 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2886 if ( isinstance( theObject, Mesh )):
2887 theObject = theObject.GetMesh()
2888 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2889 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2890 if ( isinstance( PathMesh, Mesh )):
2891 PathMesh = PathMesh.GetMesh()
2892 if HasAngles and Angles and LinearVariation:
2893 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2895 Parameters = AnglesParameters + var_separator + RefPointParameters
2896 self.mesh.SetParameters(Parameters)
2898 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
2899 PathShape, NodeStart, HasAngles,
2900 Angles, HasRefPoint, RefPoint)
2901 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
2902 NodeStart, HasAngles, Angles, HasRefPoint,
2905 ## Creates a symmetrical copy of mesh elements
2906 # @param IDsOfElements list of elements ids
2907 # @param Mirror is AxisStruct or geom object(point, line, plane)
2908 # @param theMirrorType is POINT, AXIS or PLANE
2909 # If the Mirror is a geom object this parameter is unnecessary
2910 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2911 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2912 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2913 # @ingroup l2_modif_trsf
2914 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2915 if IDsOfElements == []:
2916 IDsOfElements = self.GetElementsId()
2917 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2918 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2919 Mirror,Parameters = ParseAxisStruct(Mirror)
2920 self.mesh.SetParameters(Parameters)
2921 if Copy and MakeGroups:
2922 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2923 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2926 ## Creates a new mesh by a symmetrical copy of mesh elements
2927 # @param IDsOfElements the list of elements ids
2928 # @param Mirror is AxisStruct or geom object (point, line, plane)
2929 # @param theMirrorType is POINT, AXIS or PLANE
2930 # If the Mirror is a geom object this parameter is unnecessary
2931 # @param MakeGroups to generate new groups from existing ones
2932 # @param NewMeshName a name of the new mesh to create
2933 # @return instance of Mesh class
2934 # @ingroup l2_modif_trsf
2935 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2936 if IDsOfElements == []:
2937 IDsOfElements = self.GetElementsId()
2938 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2939 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2940 Mirror,Parameters = ParseAxisStruct(Mirror)
2941 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2942 MakeGroups, NewMeshName)
2943 mesh.SetParameters(Parameters)
2944 return Mesh(self.smeshpyD,self.geompyD,mesh)
2946 ## Creates a symmetrical copy of the object
2947 # @param theObject mesh, submesh or group
2948 # @param Mirror AxisStruct or geom object (point, line, plane)
2949 # @param theMirrorType is POINT, AXIS or PLANE
2950 # If the Mirror is a geom object this parameter is unnecessary
2951 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2952 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2953 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2954 # @ingroup l2_modif_trsf
2955 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2956 if ( isinstance( theObject, Mesh )):
2957 theObject = theObject.GetMesh()
2958 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2959 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2960 Mirror,Parameters = ParseAxisStruct(Mirror)
2961 self.mesh.SetParameters(Parameters)
2962 if Copy and MakeGroups:
2963 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2964 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2967 ## Creates a new mesh by a symmetrical copy of the object
2968 # @param theObject mesh, submesh or group
2969 # @param Mirror AxisStruct or geom object (point, line, plane)
2970 # @param theMirrorType POINT, AXIS or PLANE
2971 # If the Mirror is a geom object this parameter is unnecessary
2972 # @param MakeGroups forces the generation of new groups from existing ones
2973 # @param NewMeshName the name of the new mesh to create
2974 # @return instance of Mesh class
2975 # @ingroup l2_modif_trsf
2976 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2977 if ( isinstance( theObject, Mesh )):
2978 theObject = theObject.GetMesh()
2979 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2980 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2981 Mirror,Parameters = ParseAxisStruct(Mirror)
2982 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2983 MakeGroups, NewMeshName)
2984 mesh.SetParameters(Parameters)
2985 return Mesh( self.smeshpyD,self.geompyD,mesh )
2987 ## Translates the elements
2988 # @param IDsOfElements list of elements ids
2989 # @param Vector the direction of translation (DirStruct or vector)
2990 # @param Copy allows copying the translated elements
2991 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2992 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2993 # @ingroup l2_modif_trsf
2994 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2995 if IDsOfElements == []:
2996 IDsOfElements = self.GetElementsId()
2997 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2998 Vector = self.smeshpyD.GetDirStruct(Vector)
2999 Vector,Parameters = ParseDirStruct(Vector)
3000 self.mesh.SetParameters(Parameters)
3001 if Copy and MakeGroups:
3002 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3003 self.editor.Translate(IDsOfElements, Vector, Copy)
3006 ## Creates a new mesh of translated elements
3007 # @param IDsOfElements list of elements ids
3008 # @param Vector the direction of translation (DirStruct or vector)
3009 # @param MakeGroups forces the generation of new groups from existing ones
3010 # @param NewMeshName the name of the newly created mesh
3011 # @return instance of Mesh class
3012 # @ingroup l2_modif_trsf
3013 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3014 if IDsOfElements == []:
3015 IDsOfElements = self.GetElementsId()
3016 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3017 Vector = self.smeshpyD.GetDirStruct(Vector)
3018 Vector,Parameters = ParseDirStruct(Vector)
3019 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3020 mesh.SetParameters(Parameters)
3021 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3023 ## Translates the object
3024 # @param theObject the object to translate (mesh, submesh, or group)
3025 # @param Vector direction of translation (DirStruct or geom vector)
3026 # @param Copy allows copying the translated elements
3027 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3028 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3029 # @ingroup l2_modif_trsf
3030 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3031 if ( isinstance( theObject, Mesh )):
3032 theObject = theObject.GetMesh()
3033 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3034 Vector = self.smeshpyD.GetDirStruct(Vector)
3035 Vector,Parameters = ParseDirStruct(Vector)
3036 self.mesh.SetParameters(Parameters)
3037 if Copy and MakeGroups:
3038 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3039 self.editor.TranslateObject(theObject, Vector, Copy)
3042 ## Creates a new mesh from the translated object
3043 # @param theObject the object to translate (mesh, submesh, or group)
3044 # @param Vector the direction of translation (DirStruct or geom vector)
3045 # @param MakeGroups forces the generation of new groups from existing ones
3046 # @param NewMeshName the name of the newly created mesh
3047 # @return instance of Mesh class
3048 # @ingroup l2_modif_trsf
3049 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3050 if (isinstance(theObject, Mesh)):
3051 theObject = theObject.GetMesh()
3052 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3053 Vector = self.smeshpyD.GetDirStruct(Vector)
3054 Vector,Parameters = ParseDirStruct(Vector)
3055 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3056 mesh.SetParameters(Parameters)
3057 return Mesh( self.smeshpyD, self.geompyD, mesh )
3059 ## Rotates the elements
3060 # @param IDsOfElements list of elements ids
3061 # @param Axis the axis of rotation (AxisStruct or geom line)
3062 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3063 # @param Copy allows copying the rotated elements
3064 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3065 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3066 # @ingroup l2_modif_trsf
3067 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3069 if isinstance(AngleInRadians,str):
3071 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3073 AngleInRadians = DegreesToRadians(AngleInRadians)
3074 if IDsOfElements == []:
3075 IDsOfElements = self.GetElementsId()
3076 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3077 Axis = self.smeshpyD.GetAxisStruct(Axis)
3078 Axis,AxisParameters = ParseAxisStruct(Axis)
3079 Parameters = AxisParameters + var_separator + Parameters
3080 self.mesh.SetParameters(Parameters)
3081 if Copy and MakeGroups:
3082 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3083 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3086 ## Creates a new mesh of rotated elements
3087 # @param IDsOfElements list of element ids
3088 # @param Axis the axis of rotation (AxisStruct or geom line)
3089 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3090 # @param MakeGroups forces the generation of new groups from existing ones
3091 # @param NewMeshName the name of the newly created mesh
3092 # @return instance of Mesh class
3093 # @ingroup l2_modif_trsf
3094 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3096 if isinstance(AngleInRadians,str):
3098 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3100 AngleInRadians = DegreesToRadians(AngleInRadians)
3101 if IDsOfElements == []:
3102 IDsOfElements = self.GetElementsId()
3103 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3104 Axis = self.smeshpyD.GetAxisStruct(Axis)
3105 Axis,AxisParameters = ParseAxisStruct(Axis)
3106 Parameters = AxisParameters + var_separator + Parameters
3107 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3108 MakeGroups, NewMeshName)
3109 mesh.SetParameters(Parameters)
3110 return Mesh( self.smeshpyD, self.geompyD, mesh )
3112 ## Rotates the object
3113 # @param theObject the object to rotate( mesh, submesh, or group)
3114 # @param Axis the axis of rotation (AxisStruct or geom line)
3115 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3116 # @param Copy allows copying the rotated elements
3117 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3118 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3119 # @ingroup l2_modif_trsf
3120 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3122 if isinstance(AngleInRadians,str):
3124 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3126 AngleInRadians = DegreesToRadians(AngleInRadians)
3127 if (isinstance(theObject, Mesh)):
3128 theObject = theObject.GetMesh()
3129 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3130 Axis = self.smeshpyD.GetAxisStruct(Axis)
3131 Axis,AxisParameters = ParseAxisStruct(Axis)
3132 Parameters = AxisParameters + ":" + Parameters
3133 self.mesh.SetParameters(Parameters)
3134 if Copy and MakeGroups:
3135 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3136 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3139 ## Creates a new mesh from the rotated object
3140 # @param theObject the object to rotate (mesh, submesh, or group)
3141 # @param Axis the axis of rotation (AxisStruct or geom line)
3142 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3143 # @param MakeGroups forces the generation of new groups from existing ones
3144 # @param NewMeshName the name of the newly created mesh
3145 # @return instance of Mesh class
3146 # @ingroup l2_modif_trsf
3147 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3149 if isinstance(AngleInRadians,str):
3151 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3153 AngleInRadians = DegreesToRadians(AngleInRadians)
3154 if (isinstance( theObject, Mesh )):
3155 theObject = theObject.GetMesh()
3156 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3157 Axis = self.smeshpyD.GetAxisStruct(Axis)
3158 Axis,AxisParameters = ParseAxisStruct(Axis)
3159 Parameters = AxisParameters + ":" + Parameters
3160 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3161 MakeGroups, NewMeshName)
3162 mesh.SetParameters(Parameters)
3163 return Mesh( self.smeshpyD, self.geompyD, mesh )
3165 ## Finds groups of ajacent nodes within Tolerance.
3166 # @param Tolerance the value of tolerance
3167 # @return the list of groups of nodes
3168 # @ingroup l2_modif_trsf
3169 def FindCoincidentNodes (self, Tolerance):
3170 return self.editor.FindCoincidentNodes(Tolerance)
3172 ## Finds groups of ajacent nodes within Tolerance.
3173 # @param Tolerance the value of tolerance
3174 # @param SubMeshOrGroup SubMesh or Group
3175 # @return the list of groups of nodes
3176 # @ingroup l2_modif_trsf
3177 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3178 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3181 # @param GroupsOfNodes the list of groups of nodes
3182 # @ingroup l2_modif_trsf
3183 def MergeNodes (self, GroupsOfNodes):
3184 self.editor.MergeNodes(GroupsOfNodes)
3186 ## Finds the elements built on the same nodes.
3187 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3188 # @return a list of groups of equal elements
3189 # @ingroup l2_modif_trsf
3190 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3191 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3193 ## Merges elements in each given group.
3194 # @param GroupsOfElementsID groups of elements for merging
3195 # @ingroup l2_modif_trsf
3196 def MergeElements(self, GroupsOfElementsID):
3197 self.editor.MergeElements(GroupsOfElementsID)
3199 ## Leaves one element and removes all other elements built on the same nodes.
3200 # @ingroup l2_modif_trsf
3201 def MergeEqualElements(self):
3202 self.editor.MergeEqualElements()
3204 ## Sews free borders
3205 # @return SMESH::Sew_Error
3206 # @ingroup l2_modif_trsf
3207 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3208 FirstNodeID2, SecondNodeID2, LastNodeID2,
3209 CreatePolygons, CreatePolyedrs):
3210 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3211 FirstNodeID2, SecondNodeID2, LastNodeID2,
3212 CreatePolygons, CreatePolyedrs)
3214 ## Sews conform free borders
3215 # @return SMESH::Sew_Error
3216 # @ingroup l2_modif_trsf
3217 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3218 FirstNodeID2, SecondNodeID2):
3219 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3220 FirstNodeID2, SecondNodeID2)
3222 ## Sews border to side
3223 # @return SMESH::Sew_Error
3224 # @ingroup l2_modif_trsf
3225 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3226 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3227 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3228 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3230 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3231 # merged with the nodes of elements of Side2.
3232 # The number of elements in theSide1 and in theSide2 must be
3233 # equal and they should have similar nodal connectivity.
3234 # The nodes to merge should belong to side borders and
3235 # the first node should be linked to the second.
3236 # @return SMESH::Sew_Error
3237 # @ingroup l2_modif_trsf
3238 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3239 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3240 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3241 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3242 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3243 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3245 ## Sets new nodes for the given element.
3246 # @param ide the element id
3247 # @param newIDs nodes ids
3248 # @return If the number of nodes does not correspond to the type of element - returns false
3249 # @ingroup l2_modif_edit
3250 def ChangeElemNodes(self, ide, newIDs):
3251 return self.editor.ChangeElemNodes(ide, newIDs)
3253 ## If during the last operation of MeshEditor some nodes were
3254 # created, this method returns the list of their IDs, \n
3255 # if new nodes were not created - returns empty list
3256 # @return the list of integer values (can be empty)
3257 # @ingroup l1_auxiliary
3258 def GetLastCreatedNodes(self):
3259 return self.editor.GetLastCreatedNodes()
3261 ## If during the last operation of MeshEditor some elements were
3262 # created this method returns the list of their IDs, \n
3263 # if new elements were not created - returns empty list
3264 # @return the list of integer values (can be empty)
3265 # @ingroup l1_auxiliary
3266 def GetLastCreatedElems(self):
3267 return self.editor.GetLastCreatedElems()
3269 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3270 # @param theNodes identifiers of nodes to be doubled
3271 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3272 # nodes. If list of element identifiers is empty then nodes are doubled but
3273 # they not assigned to elements
3274 # @return TRUE if operation has been completed successfully, FALSE otherwise
3275 # @ingroup l2_modif_edit
3276 def DoubleNodes(self, theNodes, theModifiedElems):
3277 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3279 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3280 # This method provided for convenience works as DoubleNodes() described above.
3281 # @param theNodes identifiers of node to be doubled
3282 # @param theModifiedElems identifiers of elements to be updated
3283 # @return TRUE if operation has been completed successfully, FALSE otherwise
3284 # @ingroup l2_modif_edit
3285 def DoubleNode(self, theNodeId, theModifiedElems):
3286 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3288 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3289 # This method provided for convenience works as DoubleNodes() described above.
3290 # @param theNodes group of nodes to be doubled
3291 # @param theModifiedElems group of elements to be updated.
3292 # @return TRUE if operation has been completed successfully, FALSE otherwise
3293 # @ingroup l2_modif_edit
3294 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3295 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3297 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3298 # This method provided for convenience works as DoubleNodes() described above.
3299 # @param theNodes list of groups of nodes to be doubled
3300 # @param theModifiedElems list of groups of elements to be updated.
3301 # @return TRUE if operation has been completed successfully, FALSE otherwise
3302 # @ingroup l2_modif_edit
3303 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3304 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3306 ## The mother class to define algorithm, it is not recommended to use it directly.
3309 # @ingroup l2_algorithms
3310 class Mesh_Algorithm:
3311 # @class Mesh_Algorithm
3312 # @brief Class Mesh_Algorithm
3314 #def __init__(self,smesh):
3322 ## Finds a hypothesis in the study by its type name and parameters.
3323 # Finds only the hypotheses created in smeshpyD engine.
3324 # @return SMESH.SMESH_Hypothesis
3325 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3326 study = smeshpyD.GetCurrentStudy()
3327 #to do: find component by smeshpyD object, not by its data type
3328 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3329 if scomp is not None:
3330 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3331 # Check if the root label of the hypotheses exists
3332 if res and hypRoot is not None:
3333 iter = study.NewChildIterator(hypRoot)
3334 # Check all published hypotheses
3336 hypo_so_i = iter.Value()
3337 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3338 if attr is not None:
3339 anIOR = attr.Value()
3340 hypo_o_i = salome.orb.string_to_object(anIOR)
3341 if hypo_o_i is not None:
3342 # Check if this is a hypothesis
3343 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3344 if hypo_i is not None:
3345 # Check if the hypothesis belongs to current engine
3346 if smeshpyD.GetObjectId(hypo_i) > 0:
3347 # Check if this is the required hypothesis
3348 if hypo_i.GetName() == hypname:
3350 if CompareMethod(hypo_i, args):
3364 ## Finds the algorithm in the study by its type name.
3365 # Finds only the algorithms, which have been created in smeshpyD engine.
3366 # @return SMESH.SMESH_Algo
3367 def FindAlgorithm (self, algoname, smeshpyD):
3368 study = smeshpyD.GetCurrentStudy()
3369 #to do: find component by smeshpyD object, not by its data type
3370 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3371 if scomp is not None:
3372 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3373 # Check if the root label of the algorithms exists
3374 if res and hypRoot is not None:
3375 iter = study.NewChildIterator(hypRoot)
3376 # Check all published algorithms
3378 algo_so_i = iter.Value()
3379 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3380 if attr is not None:
3381 anIOR = attr.Value()
3382 algo_o_i = salome.orb.string_to_object(anIOR)
3383 if algo_o_i is not None:
3384 # Check if this is an algorithm
3385 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3386 if algo_i is not None:
3387 # Checks if the algorithm belongs to the current engine
3388 if smeshpyD.GetObjectId(algo_i) > 0:
3389 # Check if this is the required algorithm
3390 if algo_i.GetName() == algoname:
3403 ## If the algorithm is global, returns 0; \n
3404 # else returns the submesh associated to this algorithm.
3405 def GetSubMesh(self):
3408 ## Returns the wrapped mesher.
3409 def GetAlgorithm(self):
3412 ## Gets the list of hypothesis that can be used with this algorithm
3413 def GetCompatibleHypothesis(self):
3416 mylist = self.algo.GetCompatibleHypothesis()
3419 ## Gets the name of the algorithm
3423 ## Sets the name to the algorithm
3424 def SetName(self, name):
3425 self.mesh.smeshpyD.SetName(self.algo, name)
3427 ## Gets the id of the algorithm
3429 return self.algo.GetId()
3432 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3434 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3435 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3437 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3439 self.Assign(algo, mesh, geom)
3443 def Assign(self, algo, mesh, geom):
3445 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3452 name = GetName(geom)
3454 name = mesh.geompyD.SubShapeName(geom, piece)
3455 mesh.geompyD.addToStudyInFather(piece, geom, name)
3456 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3459 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3460 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3462 def CompareHyp (self, hyp, args):
3463 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3466 def CompareEqualHyp (self, hyp, args):
3470 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3471 UseExisting=0, CompareMethod=""):
3474 if CompareMethod == "": CompareMethod = self.CompareHyp
3475 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3478 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3484 a = a + s + str(args[i])
3488 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3490 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3491 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3495 # Public class: Mesh_Segment
3496 # --------------------------
3498 ## Class to define a segment 1D algorithm for discretization
3501 # @ingroup l3_algos_basic
3502 class Mesh_Segment(Mesh_Algorithm):
3504 ## Private constructor.
3505 def __init__(self, mesh, geom=0):
3506 Mesh_Algorithm.__init__(self)
3507 self.Create(mesh, geom, "Regular_1D")
3509 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3510 # @param l for the length of segments that cut an edge
3511 # @param UseExisting if ==true - searches for an existing hypothesis created with
3512 # the same parameters, else (default) - creates a new one
3513 # @param p precision, used for calculation of the number of segments.
3514 # The precision should be a positive, meaningful value within the range [0,1].
3515 # In general, the number of segments is calculated with the formula:
3516 # nb = ceil((edge_length / l) - p)
3517 # Function ceil rounds its argument to the higher integer.
3518 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3519 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3520 # p=1 means rounding of (edge_length / l) to the lower integer.
3521 # Default value is 1e-07.
3522 # @return an instance of StdMeshers_LocalLength hypothesis
3523 # @ingroup l3_hypos_1dhyps
3524 def LocalLength(self, l, UseExisting=0, p=1e-07):
3525 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3526 CompareMethod=self.CompareLocalLength)
3532 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3533 def CompareLocalLength(self, hyp, args):
3534 if IsEqual(hyp.GetLength(), args[0]):
3535 return IsEqual(hyp.GetPrecision(), args[1])
3538 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3539 # @param length is optional maximal allowed length of segment, if it is omitted
3540 # the preestimated length is used that depends on geometry size
3541 # @param UseExisting if ==true - searches for an existing hypothesis created with
3542 # the same parameters, else (default) - create a new one
3543 # @return an instance of StdMeshers_MaxLength hypothesis
3544 # @ingroup l3_hypos_1dhyps
3545 def MaxSize(self, length=0.0, UseExisting=0):
3546 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3549 hyp.SetLength(length)
3551 # set preestimated length
3552 gen = self.mesh.smeshpyD
3553 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3554 self.mesh.GetMesh(), self.mesh.GetShape(),
3556 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3558 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3561 hyp.SetUsePreestimatedLength( length == 0.0 )
3564 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3565 # @param n for the number of segments that cut an edge
3566 # @param s for the scale factor (optional)
3567 # @param UseExisting if ==true - searches for an existing hypothesis created with
3568 # the same parameters, else (default) - create a new one
3569 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3570 # @ingroup l3_hypos_1dhyps
3571 def NumberOfSegments(self, n, s=[], UseExisting=0):
3573 hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
3574 CompareMethod=self.CompareNumberOfSegments)
3576 hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
3577 CompareMethod=self.CompareNumberOfSegments)
3578 hyp.SetDistrType( 1 )
3579 hyp.SetScaleFactor(s)
3580 hyp.SetNumberOfSegments(n)
3584 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3585 def CompareNumberOfSegments(self, hyp, args):
3586 if hyp.GetNumberOfSegments() == args[0]:
3590 if hyp.GetDistrType() == 1:
3591 if IsEqual(hyp.GetScaleFactor(), args[1]):
3595 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3596 # @param start defines the length of the first segment
3597 # @param end defines the length of the last segment
3598 # @param UseExisting if ==true - searches for an existing hypothesis created with
3599 # the same parameters, else (default) - creates a new one
3600 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3601 # @ingroup l3_hypos_1dhyps
3602 def Arithmetic1D(self, start, end, UseExisting=0):
3603 hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
3604 CompareMethod=self.CompareArithmetic1D)
3605 hyp.SetLength(start, 1)
3606 hyp.SetLength(end , 0)
3610 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3611 def CompareArithmetic1D(self, hyp, args):
3612 if IsEqual(hyp.GetLength(1), args[0]):
3613 if IsEqual(hyp.GetLength(0), args[1]):
3617 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3618 # @param start defines the length of the first segment
3619 # @param end defines the length of the last segment
3620 # @param UseExisting if ==true - searches for an existing hypothesis created with
3621 # the same parameters, else (default) - creates a new one
3622 # @return an instance of StdMeshers_StartEndLength hypothesis
3623 # @ingroup l3_hypos_1dhyps
3624 def StartEndLength(self, start, end, UseExisting=0):
3625 hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
3626 CompareMethod=self.CompareStartEndLength)
3627 hyp.SetLength(start, 1)
3628 hyp.SetLength(end , 0)
3631 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3632 def CompareStartEndLength(self, hyp, args):
3633 if IsEqual(hyp.GetLength(1), args[0]):
3634 if IsEqual(hyp.GetLength(0), args[1]):
3638 ## Defines "Deflection1D" hypothesis
3639 # @param d for the deflection
3640 # @param UseExisting if ==true - searches for an existing hypothesis created with
3641 # the same parameters, else (default) - create a new one
3642 # @ingroup l3_hypos_1dhyps
3643 def Deflection1D(self, d, UseExisting=0):
3644 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3645 CompareMethod=self.CompareDeflection1D)
3646 hyp.SetDeflection(d)
3649 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3650 def CompareDeflection1D(self, hyp, args):
3651 return IsEqual(hyp.GetDeflection(), args[0])
3653 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3654 # the opposite side in case of quadrangular faces
3655 # @ingroup l3_hypos_additi
3656 def Propagation(self):
3657 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3659 ## Defines "AutomaticLength" hypothesis
3660 # @param fineness for the fineness [0-1]
3661 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3662 # same parameters, else (default) - create a new one
3663 # @ingroup l3_hypos_1dhyps
3664 def AutomaticLength(self, fineness=0, UseExisting=0):
3665 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3666 CompareMethod=self.CompareAutomaticLength)
3667 hyp.SetFineness( fineness )
3670 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3671 def CompareAutomaticLength(self, hyp, args):
3672 return IsEqual(hyp.GetFineness(), args[0])
3674 ## Defines "SegmentLengthAroundVertex" hypothesis
3675 # @param length for the segment length
3676 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3677 # Any other integer value means that the hypothesis will be set on the
3678 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3679 # @param UseExisting if ==true - searches for an existing hypothesis created with
3680 # the same parameters, else (default) - creates a new one
3681 # @ingroup l3_algos_segmarv
3682 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3684 store_geom = self.geom
3685 if type(vertex) is types.IntType:
3686 if vertex == 0 or vertex == 1:
3687 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3695 if self.geom is None:
3696 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3697 name = GetName(self.geom)
3699 piece = self.mesh.geom
3700 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3701 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3702 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3704 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3706 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3707 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3709 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3710 CompareMethod=self.CompareLengthNearVertex)
3711 self.geom = store_geom
3712 hyp.SetLength( length )
3715 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3716 # @ingroup l3_algos_segmarv
3717 def CompareLengthNearVertex(self, hyp, args):
3718 return IsEqual(hyp.GetLength(), args[0])
3720 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3721 # If the 2D mesher sees that all boundary edges are quadratic,
3722 # it generates quadratic faces, else it generates linear faces using
3723 # medium nodes as if they are vertices.
3724 # The 3D mesher generates quadratic volumes only if all boundary faces
3725 # are quadratic, else it fails.
3727 # @ingroup l3_hypos_additi
3728 def QuadraticMesh(self):
3729 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3732 # Public class: Mesh_CompositeSegment
3733 # --------------------------
3735 ## Defines a segment 1D algorithm for discretization
3737 # @ingroup l3_algos_basic
3738 class Mesh_CompositeSegment(Mesh_Segment):
3740 ## Private constructor.
3741 def __init__(self, mesh, geom=0):
3742 self.Create(mesh, geom, "CompositeSegment_1D")
3745 # Public class: Mesh_Segment_Python
3746 # ---------------------------------
3748 ## Defines a segment 1D algorithm for discretization with python function
3750 # @ingroup l3_algos_basic
3751 class Mesh_Segment_Python(Mesh_Segment):
3753 ## Private constructor.
3754 def __init__(self, mesh, geom=0):
3755 import Python1dPlugin
3756 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3758 ## Defines "PythonSplit1D" hypothesis
3759 # @param n for the number of segments that cut an edge
3760 # @param func for the python function that calculates the length of all segments
3761 # @param UseExisting if ==true - searches for the existing hypothesis created with
3762 # the same parameters, else (default) - creates a new one
3763 # @ingroup l3_hypos_1dhyps
3764 def PythonSplit1D(self, n, func, UseExisting=0):
3765 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3766 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3767 hyp.SetNumberOfSegments(n)
3768 hyp.SetPythonLog10RatioFunction(func)
3771 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3772 def ComparePythonSplit1D(self, hyp, args):
3773 #if hyp.GetNumberOfSegments() == args[0]:
3774 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3778 # Public class: Mesh_Triangle
3779 # ---------------------------
3781 ## Defines a triangle 2D algorithm
3783 # @ingroup l3_algos_basic
3784 class Mesh_Triangle(Mesh_Algorithm):
3793 ## Private constructor.
3794 def __init__(self, mesh, algoType, geom=0):
3795 Mesh_Algorithm.__init__(self)
3797 self.algoType = algoType
3798 if algoType == MEFISTO:
3799 self.Create(mesh, geom, "MEFISTO_2D")
3801 elif algoType == BLSURF:
3803 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3804 #self.SetPhysicalMesh() - PAL19680
3805 elif algoType == NETGEN:
3807 print "Warning: NETGENPlugin module unavailable"
3809 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3811 elif algoType == NETGEN_2D:
3813 print "Warning: NETGENPlugin module unavailable"
3815 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3818 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3819 # @param area for the maximum area of each triangle
3820 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3821 # same parameters, else (default) - creates a new one
3823 # Only for algoType == MEFISTO || NETGEN_2D
3824 # @ingroup l3_hypos_2dhyps
3825 def MaxElementArea(self, area, UseExisting=0):
3826 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3827 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3828 CompareMethod=self.CompareMaxElementArea)
3829 elif self.algoType == NETGEN:
3830 hyp = self.Parameters(SIMPLE)
3831 hyp.SetMaxElementArea(area)
3834 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3835 def CompareMaxElementArea(self, hyp, args):
3836 return IsEqual(hyp.GetMaxElementArea(), args[0])
3838 ## Defines "LengthFromEdges" hypothesis to build triangles
3839 # based on the length of the edges taken from the wire
3841 # Only for algoType == MEFISTO || NETGEN_2D
3842 # @ingroup l3_hypos_2dhyps
3843 def LengthFromEdges(self):
3844 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3845 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3847 elif self.algoType == NETGEN:
3848 hyp = self.Parameters(SIMPLE)
3849 hyp.LengthFromEdges()
3852 ## Sets a way to define size of mesh elements to generate.
3853 # @param thePhysicalMesh is: DefaultSize or Custom.
3854 # @ingroup l3_hypos_blsurf
3855 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3856 # Parameter of BLSURF algo
3857 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3859 ## Sets size of mesh elements to generate.
3860 # @ingroup l3_hypos_blsurf
3861 def SetPhySize(self, theVal):
3862 # Parameter of BLSURF algo
3863 self.Parameters().SetPhySize(theVal)
3865 ## Sets lower boundary of mesh element size (PhySize).
3866 # @ingroup l3_hypos_blsurf
3867 def SetPhyMin(self, theVal=-1):
3868 # Parameter of BLSURF algo
3869 self.Parameters().SetPhyMin(theVal)
3871 ## Sets upper boundary of mesh element size (PhySize).
3872 # @ingroup l3_hypos_blsurf
3873 def SetPhyMax(self, theVal=-1):
3874 # Parameter of BLSURF algo
3875 self.Parameters().SetPhyMax(theVal)
3877 ## Sets a way to define maximum angular deflection of mesh from CAD model.
3878 # @param theGeometricMesh is: DefaultGeom or Custom
3879 # @ingroup l3_hypos_blsurf
3880 def SetGeometricMesh(self, theGeometricMesh=0):
3881 # Parameter of BLSURF algo
3882 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3883 self.params.SetGeometricMesh(theGeometricMesh)
3885 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3886 # @ingroup l3_hypos_blsurf
3887 def SetAngleMeshS(self, theVal=_angleMeshS):
3888 # Parameter of BLSURF algo
3889 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3890 self.params.SetAngleMeshS(theVal)
3892 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3893 # @ingroup l3_hypos_blsurf
3894 def SetAngleMeshC(self, theVal=_angleMeshS):
3895 # Parameter of BLSURF algo
3896 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3897 self.params.SetAngleMeshC(theVal)
3899 ## Sets lower boundary of mesh element size computed to respect angular deflection.
3900 # @ingroup l3_hypos_blsurf
3901 def SetGeoMin(self, theVal=-1):
3902 # Parameter of BLSURF algo
3903 self.Parameters().SetGeoMin(theVal)
3905 ## Sets upper boundary of mesh element size computed to respect angular deflection.
3906 # @ingroup l3_hypos_blsurf
3907 def SetGeoMax(self, theVal=-1):
3908 # Parameter of BLSURF algo
3909 self.Parameters().SetGeoMax(theVal)
3911 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3912 # @ingroup l3_hypos_blsurf
3913 def SetGradation(self, theVal=_gradation):
3914 # Parameter of BLSURF algo
3915 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3916 self.params.SetGradation(theVal)
3918 ## Sets topology usage way.
3919 # @param way defines how mesh conformity is assured <ul>
3920 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
3921 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
3922 # @ingroup l3_hypos_blsurf
3923 def SetTopology(self, way):
3924 # Parameter of BLSURF algo
3925 self.Parameters().SetTopology(way)
3927 ## To respect geometrical edges or not.
3928 # @ingroup l3_hypos_blsurf
3929 def SetDecimesh(self, toIgnoreEdges=False):
3930 # Parameter of BLSURF algo
3931 self.Parameters().SetDecimesh(toIgnoreEdges)
3933 ## Sets verbosity level in the range 0 to 100.
3934 # @ingroup l3_hypos_blsurf
3935 def SetVerbosity(self, level):
3936 # Parameter of BLSURF algo
3937 self.Parameters().SetVerbosity(level)
3939 ## Sets advanced option value.
3940 # @ingroup l3_hypos_blsurf
3941 def SetOptionValue(self, optionName, level):
3942 # Parameter of BLSURF algo
3943 self.Parameters().SetOptionValue(optionName,level)
3945 ## Sets QuadAllowed flag.
3946 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
3947 # @ingroup l3_hypos_netgen l3_hypos_blsurf
3948 def SetQuadAllowed(self, toAllow=True):
3949 if self.algoType == NETGEN_2D:
3950 if toAllow: # add QuadranglePreference
3951 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3952 else: # remove QuadranglePreference
3953 for hyp in self.mesh.GetHypothesisList( self.geom ):
3954 if hyp.GetName() == "QuadranglePreference":
3955 self.mesh.RemoveHypothesis( self.geom, hyp )
3960 if self.Parameters():
3961 self.params.SetQuadAllowed(toAllow)
3964 ## Defines hypothesis having several parameters
3966 # @ingroup l3_hypos_netgen
3967 def Parameters(self, which=SOLE):
3970 if self.algoType == NETGEN:
3972 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
3973 "libNETGENEngine.so", UseExisting=0)
3975 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
3976 "libNETGENEngine.so", UseExisting=0)
3978 elif self.algoType == MEFISTO:
3979 print "Mefisto algo support no multi-parameter hypothesis"
3981 elif self.algoType == NETGEN_2D:
3982 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
3983 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3985 elif self.algoType == BLSURF:
3986 self.params = self.Hypothesis("BLSURF_Parameters", [],
3987 "libBLSURFEngine.so", UseExisting=0)
3990 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
3995 # Only for algoType == NETGEN
3996 # @ingroup l3_hypos_netgen
3997 def SetMaxSize(self, theSize):
3998 if self.Parameters():
3999 self.params.SetMaxSize(theSize)
4001 ## Sets SecondOrder flag
4003 # Only for algoType == NETGEN
4004 # @ingroup l3_hypos_netgen
4005 def SetSecondOrder(self, theVal):
4006 if self.Parameters():
4007 self.params.SetSecondOrder(theVal)
4009 ## Sets Optimize flag
4011 # Only for algoType == NETGEN
4012 # @ingroup l3_hypos_netgen
4013 def SetOptimize(self, theVal):
4014 if self.Parameters():
4015 self.params.SetOptimize(theVal)
4018 # @param theFineness is:
4019 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4021 # Only for algoType == NETGEN
4022 # @ingroup l3_hypos_netgen
4023 def SetFineness(self, theFineness):
4024 if self.Parameters():
4025 self.params.SetFineness(theFineness)
4029 # Only for algoType == NETGEN
4030 # @ingroup l3_hypos_netgen
4031 def SetGrowthRate(self, theRate):
4032 if self.Parameters():
4033 self.params.SetGrowthRate(theRate)
4035 ## Sets NbSegPerEdge
4037 # Only for algoType == NETGEN
4038 # @ingroup l3_hypos_netgen
4039 def SetNbSegPerEdge(self, theVal):
4040 if self.Parameters():
4041 self.params.SetNbSegPerEdge(theVal)
4043 ## Sets NbSegPerRadius
4045 # Only for algoType == NETGEN
4046 # @ingroup l3_hypos_netgen
4047 def SetNbSegPerRadius(self, theVal):
4048 if self.Parameters():
4049 self.params.SetNbSegPerRadius(theVal)
4051 ## Sets number of segments overriding value set by SetLocalLength()
4053 # Only for algoType == NETGEN
4054 # @ingroup l3_hypos_netgen
4055 def SetNumberOfSegments(self, theVal):
4056 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4058 ## Sets number of segments overriding value set by SetNumberOfSegments()
4060 # Only for algoType == NETGEN
4061 # @ingroup l3_hypos_netgen
4062 def SetLocalLength(self, theVal):
4063 self.Parameters(SIMPLE).SetLocalLength(theVal)
4068 # Public class: Mesh_Quadrangle
4069 # -----------------------------
4071 ## Defines a quadrangle 2D algorithm
4073 # @ingroup l3_algos_basic
4074 class Mesh_Quadrangle(Mesh_Algorithm):
4076 ## Private constructor.
4077 def __init__(self, mesh, geom=0):
4078 Mesh_Algorithm.__init__(self)
4079 self.Create(mesh, geom, "Quadrangle_2D")
4081 ## Defines "QuadranglePreference" hypothesis, forcing construction
4082 # of quadrangles if the number of nodes on the opposite edges is not the same
4083 # while the total number of nodes on edges is even
4085 # @ingroup l3_hypos_additi
4086 def QuadranglePreference(self):
4087 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4088 CompareMethod=self.CompareEqualHyp)
4091 ## Defines "TrianglePreference" hypothesis, forcing construction
4092 # of triangles in the refinement area if the number of nodes
4093 # on the opposite edges is not the same
4095 # @ingroup l3_hypos_additi
4096 def TrianglePreference(self):
4097 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4098 CompareMethod=self.CompareEqualHyp)
4101 # Public class: Mesh_Tetrahedron
4102 # ------------------------------
4104 ## Defines a tetrahedron 3D algorithm
4106 # @ingroup l3_algos_basic
4107 class Mesh_Tetrahedron(Mesh_Algorithm):
4112 ## Private constructor.
4113 def __init__(self, mesh, algoType, geom=0):
4114 Mesh_Algorithm.__init__(self)
4116 if algoType == NETGEN:
4117 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4120 elif algoType == FULL_NETGEN:
4122 print "Warning: NETGENPlugin module has not been imported."
4123 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4126 elif algoType == GHS3D:
4128 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4131 elif algoType == GHS3DPRL:
4132 import GHS3DPRLPlugin
4133 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4136 self.algoType = algoType
4138 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4139 # @param vol for the maximum volume of each tetrahedron
4140 # @param UseExisting if ==true - searches for the existing hypothesis created with
4141 # the same parameters, else (default) - creates a new one
4142 # @ingroup l3_hypos_maxvol
4143 def MaxElementVolume(self, vol, UseExisting=0):
4144 if self.algoType == NETGEN:
4145 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4146 CompareMethod=self.CompareMaxElementVolume)
4147 hyp.SetMaxElementVolume(vol)
4149 elif self.algoType == FULL_NETGEN:
4150 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4153 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4154 def CompareMaxElementVolume(self, hyp, args):
4155 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4157 ## Defines hypothesis having several parameters
4159 # @ingroup l3_hypos_netgen
4160 def Parameters(self, which=SOLE):
4164 if self.algoType == FULL_NETGEN:
4166 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4167 "libNETGENEngine.so", UseExisting=0)
4169 self.params = self.Hypothesis("NETGEN_Parameters", [],
4170 "libNETGENEngine.so", UseExisting=0)
4173 if self.algoType == GHS3D:
4174 self.params = self.Hypothesis("GHS3D_Parameters", [],
4175 "libGHS3DEngine.so", UseExisting=0)
4178 if self.algoType == GHS3DPRL:
4179 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4180 "libGHS3DPRLEngine.so", UseExisting=0)
4183 print "Algo supports no multi-parameter hypothesis"
4187 # Parameter of FULL_NETGEN
4188 # @ingroup l3_hypos_netgen
4189 def SetMaxSize(self, theSize):
4190 self.Parameters().SetMaxSize(theSize)
4192 ## Sets SecondOrder flag
4193 # Parameter of FULL_NETGEN
4194 # @ingroup l3_hypos_netgen
4195 def SetSecondOrder(self, theVal):
4196 self.Parameters().SetSecondOrder(theVal)
4198 ## Sets Optimize flag
4199 # Parameter of FULL_NETGEN
4200 # @ingroup l3_hypos_netgen
4201 def SetOptimize(self, theVal):
4202 self.Parameters().SetOptimize(theVal)
4205 # @param theFineness is:
4206 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4207 # Parameter of FULL_NETGEN
4208 # @ingroup l3_hypos_netgen
4209 def SetFineness(self, theFineness):
4210 self.Parameters().SetFineness(theFineness)
4213 # Parameter of FULL_NETGEN
4214 # @ingroup l3_hypos_netgen
4215 def SetGrowthRate(self, theRate):
4216 self.Parameters().SetGrowthRate(theRate)
4218 ## Sets NbSegPerEdge
4219 # Parameter of FULL_NETGEN
4220 # @ingroup l3_hypos_netgen
4221 def SetNbSegPerEdge(self, theVal):
4222 self.Parameters().SetNbSegPerEdge(theVal)
4224 ## Sets NbSegPerRadius
4225 # Parameter of FULL_NETGEN
4226 # @ingroup l3_hypos_netgen
4227 def SetNbSegPerRadius(self, theVal):
4228 self.Parameters().SetNbSegPerRadius(theVal)
4230 ## Sets number of segments overriding value set by SetLocalLength()
4231 # Only for algoType == NETGEN_FULL
4232 # @ingroup l3_hypos_netgen
4233 def SetNumberOfSegments(self, theVal):
4234 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4236 ## Sets number of segments overriding value set by SetNumberOfSegments()
4237 # Only for algoType == NETGEN_FULL
4238 # @ingroup l3_hypos_netgen
4239 def SetLocalLength(self, theVal):
4240 self.Parameters(SIMPLE).SetLocalLength(theVal)
4242 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4243 # Overrides value set by LengthFromEdges()
4244 # Only for algoType == NETGEN_FULL
4245 # @ingroup l3_hypos_netgen
4246 def MaxElementArea(self, area):
4247 self.Parameters(SIMPLE).SetMaxElementArea(area)
4249 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4250 # Overrides value set by MaxElementArea()
4251 # Only for algoType == NETGEN_FULL
4252 # @ingroup l3_hypos_netgen
4253 def LengthFromEdges(self):
4254 self.Parameters(SIMPLE).LengthFromEdges()
4256 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4257 # Overrides value set by MaxElementVolume()
4258 # Only for algoType == NETGEN_FULL
4259 # @ingroup l3_hypos_netgen
4260 def LengthFromFaces(self):
4261 self.Parameters(SIMPLE).LengthFromFaces()
4263 ## To mesh "holes" in a solid or not. Default is to mesh.
4264 # @ingroup l3_hypos_ghs3dh
4265 def SetToMeshHoles(self, toMesh):
4266 # Parameter of GHS3D
4267 self.Parameters().SetToMeshHoles(toMesh)
4269 ## Set Optimization level:
4270 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
4271 # Default is Medium_Optimization
4272 # @ingroup l3_hypos_ghs3dh
4273 def SetOptimizationLevel(self, level):
4274 # Parameter of GHS3D
4275 self.Parameters().SetOptimizationLevel(level)
4277 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4278 # @ingroup l3_hypos_ghs3dh
4279 def SetMaximumMemory(self, MB):
4280 # Advanced parameter of GHS3D
4281 self.Parameters().SetMaximumMemory(MB)
4283 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4284 # automatic memory adjustment mode.
4285 # @ingroup l3_hypos_ghs3dh
4286 def SetInitialMemory(self, MB):
4287 # Advanced parameter of GHS3D
4288 self.Parameters().SetInitialMemory(MB)
4290 ## Path to working directory.
4291 # @ingroup l3_hypos_ghs3dh
4292 def SetWorkingDirectory(self, path):
4293 # Advanced parameter of GHS3D
4294 self.Parameters().SetWorkingDirectory(path)
4296 ## To keep working files or remove them. Log file remains in case of errors anyway.
4297 # @ingroup l3_hypos_ghs3dh
4298 def SetKeepFiles(self, toKeep):
4299 # Advanced parameter of GHS3D and GHS3DPRL
4300 self.Parameters().SetKeepFiles(toKeep)
4302 ## To set verbose level [0-10]. <ul>
4303 #<li> 0 - no standard output,
4304 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4305 # indicates when the final mesh is being saved. In addition the software
4306 # gives indication regarding the CPU time.
4307 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4308 # histogram of the skin mesh, quality statistics histogram together with
4309 # the characteristics of the final mesh.</ul>
4310 # @ingroup l3_hypos_ghs3dh
4311 def SetVerboseLevel(self, level):
4312 # Advanced parameter of GHS3D
4313 self.Parameters().SetVerboseLevel(level)
4315 ## To create new nodes.
4316 # @ingroup l3_hypos_ghs3dh
4317 def SetToCreateNewNodes(self, toCreate):
4318 # Advanced parameter of GHS3D
4319 self.Parameters().SetToCreateNewNodes(toCreate)
4321 ## To use boundary recovery version which tries to create mesh on a very poor
4322 # quality surface mesh.
4323 # @ingroup l3_hypos_ghs3dh
4324 def SetToUseBoundaryRecoveryVersion(self, toUse):
4325 # Advanced parameter of GHS3D
4326 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4328 ## Sets command line option as text.
4329 # @ingroup l3_hypos_ghs3dh
4330 def SetTextOption(self, option):
4331 # Advanced parameter of GHS3D
4332 self.Parameters().SetTextOption(option)
4334 ## Sets MED files name and path.
4335 def SetMEDName(self, value):
4336 self.Parameters().SetMEDName(value)
4338 ## Sets the number of partition of the initial mesh
4339 def SetNbPart(self, value):
4340 self.Parameters().SetNbPart(value)
4342 ## When big mesh, start tepal in background
4343 def SetBackground(self, value):
4344 self.Parameters().SetBackground(value)
4346 # Public class: Mesh_Hexahedron
4347 # ------------------------------
4349 ## Defines a hexahedron 3D algorithm
4351 # @ingroup l3_algos_basic
4352 class Mesh_Hexahedron(Mesh_Algorithm):
4357 ## Private constructor.
4358 def __init__(self, mesh, algoType=Hexa, geom=0):
4359 Mesh_Algorithm.__init__(self)
4361 self.algoType = algoType
4363 if algoType == Hexa:
4364 self.Create(mesh, geom, "Hexa_3D")
4367 elif algoType == Hexotic:
4368 import HexoticPlugin
4369 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4372 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4373 # @ingroup l3_hypos_hexotic
4374 def MinMaxQuad(self, min=3, max=8, quad=True):
4375 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4377 self.params.SetHexesMinLevel(min)
4378 self.params.SetHexesMaxLevel(max)
4379 self.params.SetHexoticQuadrangles(quad)
4382 # Deprecated, only for compatibility!
4383 # Public class: Mesh_Netgen
4384 # ------------------------------
4386 ## Defines a NETGEN-based 2D or 3D algorithm
4387 # that needs no discrete boundary (i.e. independent)
4389 # This class is deprecated, only for compatibility!
4392 # @ingroup l3_algos_basic
4393 class Mesh_Netgen(Mesh_Algorithm):
4397 ## Private constructor.
4398 def __init__(self, mesh, is3D, geom=0):
4399 Mesh_Algorithm.__init__(self)
4402 print "Warning: NETGENPlugin module has not been imported."
4406 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4410 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4413 ## Defines the hypothesis containing parameters of the algorithm
4414 def Parameters(self):
4416 hyp = self.Hypothesis("NETGEN_Parameters", [],
4417 "libNETGENEngine.so", UseExisting=0)
4419 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4420 "libNETGENEngine.so", UseExisting=0)
4423 # Public class: Mesh_Projection1D
4424 # ------------------------------
4426 ## Defines a projection 1D algorithm
4427 # @ingroup l3_algos_proj
4429 class Mesh_Projection1D(Mesh_Algorithm):
4431 ## Private constructor.
4432 def __init__(self, mesh, geom=0):
4433 Mesh_Algorithm.__init__(self)
4434 self.Create(mesh, geom, "Projection_1D")
4436 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4437 # a mesh pattern is taken, and, optionally, the association of vertices
4438 # between the source edge and a target edge (to which a hypothesis is assigned)
4439 # @param edge from which nodes distribution is taken
4440 # @param mesh from which nodes distribution is taken (optional)
4441 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4442 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4443 # to associate with \a srcV (optional)
4444 # @param UseExisting if ==true - searches for the existing hypothesis created with
4445 # the same parameters, else (default) - creates a new one
4446 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4447 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4449 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4450 hyp.SetSourceEdge( edge )
4451 if not mesh is None and isinstance(mesh, Mesh):
4452 mesh = mesh.GetMesh()
4453 hyp.SetSourceMesh( mesh )
4454 hyp.SetVertexAssociation( srcV, tgtV )
4457 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4458 #def CompareSourceEdge(self, hyp, args):
4459 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4463 # Public class: Mesh_Projection2D
4464 # ------------------------------
4466 ## Defines a projection 2D algorithm
4467 # @ingroup l3_algos_proj
4469 class Mesh_Projection2D(Mesh_Algorithm):
4471 ## Private constructor.
4472 def __init__(self, mesh, geom=0):
4473 Mesh_Algorithm.__init__(self)
4474 self.Create(mesh, geom, "Projection_2D")
4476 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4477 # a mesh pattern is taken, and, optionally, the association of vertices
4478 # between the source face and the target face (to which a hypothesis is assigned)
4479 # @param face from which the mesh pattern is taken
4480 # @param mesh from which the mesh pattern is taken (optional)
4481 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4482 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4483 # to associate with \a srcV1 (optional)
4484 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4485 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4486 # to associate with \a srcV2 (optional)
4487 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4488 # the same parameters, else (default) - forces the creation a new one
4490 # Note: all association vertices must belong to one edge of a face
4491 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4492 srcV2=None, tgtV2=None, UseExisting=0):
4493 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4495 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4496 hyp.SetSourceFace( face )
4497 if not mesh is None and isinstance(mesh, Mesh):
4498 mesh = mesh.GetMesh()
4499 hyp.SetSourceMesh( mesh )
4500 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4503 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4504 #def CompareSourceFace(self, hyp, args):
4505 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4508 # Public class: Mesh_Projection3D
4509 # ------------------------------
4511 ## Defines a projection 3D algorithm
4512 # @ingroup l3_algos_proj
4514 class Mesh_Projection3D(Mesh_Algorithm):
4516 ## Private constructor.
4517 def __init__(self, mesh, geom=0):
4518 Mesh_Algorithm.__init__(self)
4519 self.Create(mesh, geom, "Projection_3D")
4521 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4522 # the mesh pattern is taken, and, optionally, the association of vertices
4523 # between the source and the target solid (to which a hipothesis is assigned)
4524 # @param solid from where the mesh pattern is taken
4525 # @param mesh from where the mesh pattern is taken (optional)
4526 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4527 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4528 # to associate with \a srcV1 (optional)
4529 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4530 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4531 # to associate with \a srcV2 (optional)
4532 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4533 # the same parameters, else (default) - creates a new one
4535 # Note: association vertices must belong to one edge of a solid
4536 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4537 srcV2=0, tgtV2=0, UseExisting=0):
4538 hyp = self.Hypothesis("ProjectionSource3D",
4539 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4541 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4542 hyp.SetSource3DShape( solid )
4543 if not mesh is None and isinstance(mesh, Mesh):
4544 mesh = mesh.GetMesh()
4545 hyp.SetSourceMesh( mesh )
4546 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4549 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4550 #def CompareSourceShape3D(self, hyp, args):
4551 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4555 # Public class: Mesh_Prism
4556 # ------------------------
4558 ## Defines a 3D extrusion algorithm
4559 # @ingroup l3_algos_3dextr
4561 class Mesh_Prism3D(Mesh_Algorithm):
4563 ## Private constructor.
4564 def __init__(self, mesh, geom=0):
4565 Mesh_Algorithm.__init__(self)
4566 self.Create(mesh, geom, "Prism_3D")
4568 # Public class: Mesh_RadialPrism
4569 # -------------------------------
4571 ## Defines a Radial Prism 3D algorithm
4572 # @ingroup l3_algos_radialp
4574 class Mesh_RadialPrism3D(Mesh_Algorithm):
4576 ## Private constructor.
4577 def __init__(self, mesh, geom=0):
4578 Mesh_Algorithm.__init__(self)
4579 self.Create(mesh, geom, "RadialPrism_3D")
4581 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4582 self.nbLayers = None
4584 ## Return 3D hypothesis holding the 1D one
4585 def Get3DHypothesis(self):
4586 return self.distribHyp
4588 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4589 # hypothesis. Returns the created hypothesis
4590 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4591 #print "OwnHypothesis",hypType
4592 if not self.nbLayers is None:
4593 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4594 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4595 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4596 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4597 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4598 self.distribHyp.SetLayerDistribution( hyp )
4601 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4602 # prisms to build between the inner and outer shells
4603 # @param n number of layers
4604 # @param UseExisting if ==true - searches for the existing hypothesis created with
4605 # the same parameters, else (default) - creates a new one
4606 def NumberOfLayers(self, n, UseExisting=0):
4607 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4608 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4609 CompareMethod=self.CompareNumberOfLayers)
4610 self.nbLayers.SetNumberOfLayers( n )
4611 return self.nbLayers
4613 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4614 def CompareNumberOfLayers(self, hyp, args):
4615 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4617 ## Defines "LocalLength" hypothesis, specifying the segment length
4618 # to build between the inner and the outer shells
4619 # @param l the length of segments
4620 # @param p the precision of rounding
4621 def LocalLength(self, l, p=1e-07):
4622 hyp = self.OwnHypothesis("LocalLength", [l,p])
4627 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4628 # prisms to build between the inner and the outer shells.
4629 # @param n the number of layers
4630 # @param s the scale factor (optional)
4631 def NumberOfSegments(self, n, s=[]):
4633 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4635 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4636 hyp.SetDistrType( 1 )
4637 hyp.SetScaleFactor(s)
4638 hyp.SetNumberOfSegments(n)
4641 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4642 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4643 # @param start the length of the first segment
4644 # @param end the length of the last segment
4645 def Arithmetic1D(self, start, end ):
4646 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4647 hyp.SetLength(start, 1)
4648 hyp.SetLength(end , 0)
4651 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4652 # to build between the inner and the outer shells as geometric length increasing
4653 # @param start for the length of the first segment
4654 # @param end for the length of the last segment
4655 def StartEndLength(self, start, end):
4656 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4657 hyp.SetLength(start, 1)
4658 hyp.SetLength(end , 0)
4661 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4662 # to build between the inner and outer shells
4663 # @param fineness defines the quality of the mesh within the range [0-1]
4664 def AutomaticLength(self, fineness=0):
4665 hyp = self.OwnHypothesis("AutomaticLength")
4666 hyp.SetFineness( fineness )
4669 # Private class: Mesh_UseExisting
4670 # -------------------------------
4671 class Mesh_UseExisting(Mesh_Algorithm):
4673 def __init__(self, dim, mesh, geom=0):
4675 self.Create(mesh, geom, "UseExisting_1D")
4677 self.Create(mesh, geom, "UseExisting_2D")
4680 import salome_notebook
4681 notebook = salome_notebook.notebook
4683 ##Return values of the notebook variables
4684 def ParseParameters(last, nbParams,nbParam, value):
4688 listSize = len(last)
4689 for n in range(0,nbParams):
4691 if counter < listSize:
4692 strResult = strResult + last[counter]
4694 strResult = strResult + ""
4696 if isinstance(value, str):
4697 if notebook.isVariable(value):
4698 result = notebook.get(value)
4699 strResult=strResult+value
4701 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
4703 strResult=strResult+str(value)
4705 if nbParams - 1 != counter:
4706 strResult=strResult+var_separator #":"
4708 return result, strResult
4710 #Wrapper class for StdMeshers_LocalLength hypothesis
4711 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
4713 ## Set Length parameter value
4714 # @param length numerical value or name of variable from notebook
4715 def SetLength(self, length):
4716 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
4717 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4718 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
4720 ## Set Precision parameter value
4721 # @param precision numerical value or name of variable from notebook
4722 def SetPrecision(self, precision):
4723 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
4724 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4725 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
4727 #Registering the new proxy for LocalLength
4728 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
4731 #Wrapper class for StdMeshers_LayerDistribution hypothesis
4732 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
4734 def SetLayerDistribution(self, hypo):
4735 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
4736 hypo.ClearParameters();
4737 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
4739 #Registering the new proxy for LayerDistribution
4740 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
4742 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
4743 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
4745 ## Set Length parameter value
4746 # @param length numerical value or name of variable from notebook
4747 def SetLength(self, length):
4748 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
4749 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
4750 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
4752 #Registering the new proxy for SegmentLengthAroundVertex
4753 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
4756 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
4757 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
4759 ## Set Length parameter value
4760 # @param length numerical value or name of variable from notebook
4761 # @param isStart true is length is Start Length, otherwise false
4762 def SetLength(self, length, isStart):
4766 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
4767 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
4768 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
4770 #Registering the new proxy for Arithmetic1D
4771 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
4773 #Wrapper class for StdMeshers_Deflection1D hypothesis
4774 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
4776 ## Set Deflection parameter value
4777 # @param deflection numerical value or name of variable from notebook
4778 def SetDeflection(self, deflection):
4779 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
4780 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
4781 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
4783 #Registering the new proxy for Deflection1D
4784 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
4786 #Wrapper class for StdMeshers_StartEndLength hypothesis
4787 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
4789 ## Set Length parameter value
4790 # @param length numerical value or name of variable from notebook
4791 # @param isStart true is length is Start Length, otherwise false
4792 def SetLength(self, length, isStart):
4796 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
4797 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
4798 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
4800 #Registering the new proxy for StartEndLength
4801 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
4803 #Wrapper class for StdMeshers_MaxElementArea hypothesis
4804 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
4806 ## Set Max Element Area parameter value
4807 # @param area numerical value or name of variable from notebook
4808 def SetMaxElementArea(self, area):
4809 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
4810 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
4811 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
4813 #Registering the new proxy for MaxElementArea
4814 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
4817 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
4818 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
4820 ## Set Max Element Volume parameter value
4821 # @param area numerical value or name of variable from notebook
4822 def SetMaxElementVolume(self, volume):
4823 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
4824 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
4825 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
4827 #Registering the new proxy for MaxElementVolume
4828 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
4831 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
4832 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
4834 ## Set Number Of Layers parameter value
4835 # @param nbLayers numerical value or name of variable from notebook
4836 def SetNumberOfLayers(self, nbLayers):
4837 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
4838 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
4839 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
4841 #Registering the new proxy for NumberOfLayers
4842 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
4844 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
4845 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
4847 ## Set Number Of Segments parameter value
4848 # @param nbSeg numerical value or name of variable from notebook
4849 def SetNumberOfSegments(self, nbSeg):
4850 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
4851 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
4852 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4853 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
4855 ## Set Scale Factor parameter value
4856 # @param factor numerical value or name of variable from notebook
4857 def SetScaleFactor(self, factor):
4858 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
4859 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4860 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
4862 #Registering the new proxy for NumberOfSegments
4863 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
4866 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
4867 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
4869 ## Set Max Size parameter value
4870 # @param maxsize numerical value or name of variable from notebook
4871 def SetMaxSize(self, maxsize):
4872 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4873 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
4874 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4875 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
4877 ## Set Growth Rate parameter value
4878 # @param value numerical value or name of variable from notebook
4879 def SetGrowthRate(self, value):
4880 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4881 value, parameters = ParseParameters(lastParameters,4,2,value)
4882 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4883 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
4885 ## Set Number of Segments per Edge parameter value
4886 # @param value numerical value or name of variable from notebook
4887 def SetNbSegPerEdge(self, value):
4888 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4889 value, parameters = ParseParameters(lastParameters,4,3,value)
4890 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4891 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
4893 ## Set Number of Segments per Radius parameter value
4894 # @param value numerical value or name of variable from notebook
4895 def SetNbSegPerRadius(self, value):
4896 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4897 value, parameters = ParseParameters(lastParameters,4,4,value)
4898 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4899 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
4901 #Registering the new proxy for NETGENPlugin_Hypothesis
4902 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
4905 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
4906 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
4909 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
4910 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
4912 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
4913 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
4915 ## Set Number of Segments parameter value
4916 # @param nbSeg numerical value or name of variable from notebook
4917 def SetNumberOfSegments(self, nbSeg):
4918 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4919 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
4920 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4921 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
4923 ## Set Local Length parameter value
4924 # @param length numerical value or name of variable from notebook
4925 def SetLocalLength(self, length):
4926 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4927 length, parameters = ParseParameters(lastParameters,2,1,length)
4928 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4929 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
4931 ## Set Max Element Area parameter value
4932 # @param area numerical value or name of variable from notebook
4933 def SetMaxElementArea(self, area):
4934 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4935 area, parameters = ParseParameters(lastParameters,2,2,area)
4936 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4937 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
4939 def LengthFromEdges(self):
4940 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4942 value, parameters = ParseParameters(lastParameters,2,2,value)
4943 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4944 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
4946 #Registering the new proxy for NETGEN_SimpleParameters_2D
4947 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
4950 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
4951 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
4952 ## Set Max Element Volume parameter value
4953 # @param volume numerical value or name of variable from notebook
4954 def SetMaxElementVolume(self, volume):
4955 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
4956 volume, parameters = ParseParameters(lastParameters,3,3,volume)
4957 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
4958 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
4960 def LengthFromFaces(self):
4961 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
4963 value, parameters = ParseParameters(lastParameters,3,3,value)
4964 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
4965 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
4967 #Registering the new proxy for NETGEN_SimpleParameters_3D
4968 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
4970 class Pattern(SMESH._objref_SMESH_Pattern):
4972 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
4974 if isinstance(theNodeIndexOnKeyPoint1,str):
4976 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
4978 theNodeIndexOnKeyPoint1 -= 1
4979 theMesh.SetParameters(Parameters)
4980 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
4982 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
4985 if isinstance(theNode000Index,str):
4987 if isinstance(theNode001Index,str):
4989 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
4991 theNode000Index -= 1
4993 theNode001Index -= 1
4994 theMesh.SetParameters(Parameters)
4995 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
4997 #Registering the new proxy for Pattern
4998 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)