1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # Author : Francis KLOSS, OCC
32 ## @defgroup l1_auxiliary Auxiliary methods and structures
33 ## @defgroup l1_creating Creating meshes
35 ## @defgroup l2_impexp Importing and exporting meshes
36 ## @defgroup l2_construct Constructing meshes
37 ## @defgroup l2_algorithms Defining Algorithms
39 ## @defgroup l3_algos_basic Basic meshing algorithms
40 ## @defgroup l3_algos_proj Projection Algorithms
41 ## @defgroup l3_algos_radialp Radial Prism
42 ## @defgroup l3_algos_segmarv Segments around Vertex
43 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
46 ## @defgroup l2_hypotheses Defining hypotheses
48 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
49 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
50 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
51 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
52 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
53 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
54 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
55 ## @defgroup l3_hypos_additi Additional Hypotheses
58 ## @defgroup l2_submeshes Constructing submeshes
59 ## @defgroup l2_compounds Building Compounds
60 ## @defgroup l2_editing Editing Meshes
63 ## @defgroup l1_meshinfo Mesh Information
64 ## @defgroup l1_controls Quality controls and Filtering
65 ## @defgroup l1_grouping Grouping elements
67 ## @defgroup l2_grps_create Creating groups
68 ## @defgroup l2_grps_edit Editing groups
69 ## @defgroup l2_grps_operon Using operations on groups
70 ## @defgroup l2_grps_delete Deleting Groups
73 ## @defgroup l1_modifying Modifying meshes
75 ## @defgroup l2_modif_add Adding nodes and elements
76 ## @defgroup l2_modif_del Removing nodes and elements
77 ## @defgroup l2_modif_edit Modifying nodes and elements
78 ## @defgroup l2_modif_renumber Renumbering nodes and elements
79 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
80 ## @defgroup l2_modif_movenode Moving nodes
81 ## @defgroup l2_modif_throughp Mesh through point
82 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
83 ## @defgroup l2_modif_unitetri Uniting triangles
84 ## @defgroup l2_modif_changori Changing orientation of elements
85 ## @defgroup l2_modif_cutquadr Cutting quadrangles
86 ## @defgroup l2_modif_smooth Smoothing
87 ## @defgroup l2_modif_extrurev Extrusion and Revolution
88 ## @defgroup l2_modif_patterns Pattern mapping
89 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
96 import SMESH # This is necessary for back compatibility
103 # import NETGENPlugin module if possible
111 # import GHS3DPlugin module if possible
119 # import GHS3DPRLPlugin module if possible
122 import GHS3DPRLPlugin
127 # import HexoticPlugin module if possible
135 # import BLSURFPlugin module if possible
143 ## @addtogroup l1_auxiliary
146 # Types of algorithms
159 NETGEN_1D2D3D = FULL_NETGEN
160 NETGEN_FULL = FULL_NETGEN
166 # MirrorType enumeration
167 POINT = SMESH_MeshEditor.POINT
168 AXIS = SMESH_MeshEditor.AXIS
169 PLANE = SMESH_MeshEditor.PLANE
171 # Smooth_Method enumeration
172 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
173 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
175 # Fineness enumeration (for NETGEN)
183 # Optimization level of GHS3D
185 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
186 # V4.1 (partialy redefines V3.1). Issue 0020574
187 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
189 # Topology treatment way of BLSURF
190 FromCAD, PreProcess, PreProcessPlus = 0,1,2
192 # Element size flag of BLSURF
193 DefaultSize, DefaultGeom, Custom = 0,0,1
195 PrecisionConfusion = 1e-07
197 ## Converts an angle from degrees to radians
198 def DegreesToRadians(AngleInDegrees):
200 return AngleInDegrees * pi / 180.0
202 # Salome notebook variable separator
205 # Parametrized substitute for PointStruct
206 class PointStructStr:
215 def __init__(self, xStr, yStr, zStr):
219 if isinstance(xStr, str) and notebook.isVariable(xStr):
220 self.x = notebook.get(xStr)
223 if isinstance(yStr, str) and notebook.isVariable(yStr):
224 self.y = notebook.get(yStr)
227 if isinstance(zStr, str) and notebook.isVariable(zStr):
228 self.z = notebook.get(zStr)
232 # Parametrized substitute for PointStruct (with 6 parameters)
233 class PointStructStr6:
248 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
255 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
256 self.x1 = notebook.get(x1Str)
259 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
260 self.x2 = notebook.get(x2Str)
263 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
264 self.y1 = notebook.get(y1Str)
267 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
268 self.y2 = notebook.get(y2Str)
271 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
272 self.z1 = notebook.get(z1Str)
275 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
276 self.z2 = notebook.get(z2Str)
280 # Parametrized substitute for AxisStruct
296 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
303 if isinstance(xStr, str) and notebook.isVariable(xStr):
304 self.x = notebook.get(xStr)
307 if isinstance(yStr, str) and notebook.isVariable(yStr):
308 self.y = notebook.get(yStr)
311 if isinstance(zStr, str) and notebook.isVariable(zStr):
312 self.z = notebook.get(zStr)
315 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
316 self.dx = notebook.get(dxStr)
319 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
320 self.dy = notebook.get(dyStr)
323 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
324 self.dz = notebook.get(dzStr)
328 # Parametrized substitute for DirStruct
331 def __init__(self, pointStruct):
332 self.pointStruct = pointStruct
334 # Returns list of variable values from salome notebook
335 def ParsePointStruct(Point):
336 Parameters = 2*var_separator
337 if isinstance(Point, PointStructStr):
338 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
339 Point = PointStruct(Point.x, Point.y, Point.z)
340 return Point, Parameters
342 # Returns list of variable values from salome notebook
343 def ParseDirStruct(Dir):
344 Parameters = 2*var_separator
345 if isinstance(Dir, DirStructStr):
346 pntStr = Dir.pointStruct
347 if isinstance(pntStr, PointStructStr6):
348 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
349 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
350 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
351 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
353 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
354 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
355 Dir = DirStruct(Point)
356 return Dir, Parameters
358 # Returns list of variable values from salome notebook
359 def ParseAxisStruct(Axis):
360 Parameters = 5*var_separator
361 if isinstance(Axis, AxisStructStr):
362 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
363 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
364 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
365 return Axis, Parameters
367 ## Return list of variable values from salome notebook
368 def ParseAngles(list):
371 for parameter in list:
372 if isinstance(parameter,str) and notebook.isVariable(parameter):
373 Result.append(DegreesToRadians(notebook.get(parameter)))
376 Result.append(parameter)
379 Parameters = Parameters + str(parameter)
380 Parameters = Parameters + var_separator
382 Parameters = Parameters[:len(Parameters)-1]
383 return Result, Parameters
385 def IsEqual(val1, val2, tol=PrecisionConfusion):
386 if abs(val1 - val2) < tol:
394 ior = salome.orb.object_to_string(obj)
395 sobj = salome.myStudy.FindObjectIOR(ior)
399 attr = sobj.FindAttribute("AttributeName")[1]
402 ## Prints error message if a hypothesis was not assigned.
403 def TreatHypoStatus(status, hypName, geomName, isAlgo):
405 hypType = "algorithm"
407 hypType = "hypothesis"
409 if status == HYP_UNKNOWN_FATAL :
410 reason = "for unknown reason"
411 elif status == HYP_INCOMPATIBLE :
412 reason = "this hypothesis mismatches the algorithm"
413 elif status == HYP_NOTCONFORM :
414 reason = "a non-conform mesh would be built"
415 elif status == HYP_ALREADY_EXIST :
416 reason = hypType + " of the same dimension is already assigned to this shape"
417 elif status == HYP_BAD_DIM :
418 reason = hypType + " mismatches the shape"
419 elif status == HYP_CONCURENT :
420 reason = "there are concurrent hypotheses on sub-shapes"
421 elif status == HYP_BAD_SUBSHAPE :
422 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
423 elif status == HYP_BAD_GEOMETRY:
424 reason = "geometry mismatches the expectation of the algorithm"
425 elif status == HYP_HIDDEN_ALGO:
426 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
427 elif status == HYP_HIDING_ALGO:
428 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
429 elif status == HYP_NEED_SHAPE:
430 reason = "Algorithm can't work without shape"
433 hypName = '"' + hypName + '"'
434 geomName= '"' + geomName+ '"'
435 if status < HYP_UNKNOWN_FATAL:
436 print hypName, "was assigned to", geomName,"but", reason
438 print hypName, "was not assigned to",geomName,":", reason
441 ## Check meshing plugin availability
442 def CheckPlugin(plugin):
443 if plugin == NETGEN and noNETGENPlugin:
444 print "Warning: NETGENPlugin module unavailable"
446 elif plugin == GHS3D and noGHS3DPlugin:
447 print "Warning: GHS3DPlugin module unavailable"
449 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
450 print "Warning: GHS3DPRLPlugin module unavailable"
452 elif plugin == Hexotic and noHexoticPlugin:
453 print "Warning: HexoticPlugin module unavailable"
455 elif plugin == BLSURF and noBLSURFPlugin:
456 print "Warning: BLSURFPlugin module unavailable"
460 # end of l1_auxiliary
463 # All methods of this class are accessible directly from the smesh.py package.
464 class smeshDC(SMESH._objref_SMESH_Gen):
466 ## Sets the current study and Geometry component
467 # @ingroup l1_auxiliary
468 def init_smesh(self,theStudy,geompyD):
469 self.SetCurrentStudy(theStudy,geompyD)
471 ## Creates an empty Mesh. This mesh can have an underlying geometry.
472 # @param obj the Geometrical object on which the mesh is built. If not defined,
473 # the mesh will have no underlying geometry.
474 # @param name the name for the new mesh.
475 # @return an instance of Mesh class.
476 # @ingroup l2_construct
477 def Mesh(self, obj=0, name=0):
478 if isinstance(obj,str):
480 return Mesh(self,self.geompyD,obj,name)
482 ## Returns a long value from enumeration
483 # Should be used for SMESH.FunctorType enumeration
484 # @ingroup l1_controls
485 def EnumToLong(self,theItem):
488 ## Gets PointStruct from vertex
489 # @param theVertex a GEOM object(vertex)
490 # @return SMESH.PointStruct
491 # @ingroup l1_auxiliary
492 def GetPointStruct(self,theVertex):
493 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
494 return PointStruct(x,y,z)
496 ## Gets DirStruct from vector
497 # @param theVector a GEOM object(vector)
498 # @return SMESH.DirStruct
499 # @ingroup l1_auxiliary
500 def GetDirStruct(self,theVector):
501 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
502 if(len(vertices) != 2):
503 print "Error: vector object is incorrect."
505 p1 = self.geompyD.PointCoordinates(vertices[0])
506 p2 = self.geompyD.PointCoordinates(vertices[1])
507 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
508 dirst = DirStruct(pnt)
511 ## Makes DirStruct from a triplet
512 # @param x,y,z vector components
513 # @return SMESH.DirStruct
514 # @ingroup l1_auxiliary
515 def MakeDirStruct(self,x,y,z):
516 pnt = PointStruct(x,y,z)
517 return DirStruct(pnt)
519 ## Get AxisStruct from object
520 # @param theObj a GEOM object (line or plane)
521 # @return SMESH.AxisStruct
522 # @ingroup l1_auxiliary
523 def GetAxisStruct(self,theObj):
524 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
526 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
527 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
528 vertex1 = self.geompyD.PointCoordinates(vertex1)
529 vertex2 = self.geompyD.PointCoordinates(vertex2)
530 vertex3 = self.geompyD.PointCoordinates(vertex3)
531 vertex4 = self.geompyD.PointCoordinates(vertex4)
532 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
533 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
534 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] ]
535 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
537 elif len(edges) == 1:
538 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
539 p1 = self.geompyD.PointCoordinates( vertex1 )
540 p2 = self.geompyD.PointCoordinates( vertex2 )
541 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
545 # From SMESH_Gen interface:
546 # ------------------------
548 ## Sets the given name to the object
549 # @param obj the object to rename
550 # @param name a new object name
551 # @ingroup l1_auxiliary
552 def SetName(self, obj, name):
553 if isinstance( obj, Mesh ):
555 elif isinstance( obj, Mesh_Algorithm ):
556 obj = obj.GetAlgorithm()
557 ior = salome.orb.object_to_string(obj)
558 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
560 ## Sets the current mode
561 # @ingroup l1_auxiliary
562 def SetEmbeddedMode( self,theMode ):
563 #self.SetEmbeddedMode(theMode)
564 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
566 ## Gets the current mode
567 # @ingroup l1_auxiliary
568 def IsEmbeddedMode(self):
569 #return self.IsEmbeddedMode()
570 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
572 ## Sets the current study
573 # @ingroup l1_auxiliary
574 def SetCurrentStudy( self, theStudy, geompyD = None ):
575 #self.SetCurrentStudy(theStudy)
578 geompyD = geompy.geom
581 self.SetGeomEngine(geompyD)
582 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
584 ## Gets the current study
585 # @ingroup l1_auxiliary
586 def GetCurrentStudy(self):
587 #return self.GetCurrentStudy()
588 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
590 ## Creates a Mesh object importing data from the given UNV file
591 # @return an instance of Mesh class
593 def CreateMeshesFromUNV( self,theFileName ):
594 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
595 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
598 ## Creates a Mesh object(s) importing data from the given MED file
599 # @return a list of Mesh class instances
601 def CreateMeshesFromMED( self,theFileName ):
602 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
604 for iMesh in range(len(aSmeshMeshes)) :
605 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
606 aMeshes.append(aMesh)
607 return aMeshes, aStatus
609 ## Creates a Mesh object importing data from the given STL file
610 # @return an instance of Mesh class
612 def CreateMeshesFromSTL( self, theFileName ):
613 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
614 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
617 ## From SMESH_Gen interface
618 # @return the list of integer values
619 # @ingroup l1_auxiliary
620 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
621 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
623 ## From SMESH_Gen interface. Creates a pattern
624 # @return an instance of SMESH_Pattern
626 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
627 # @ingroup l2_modif_patterns
628 def GetPattern(self):
629 return SMESH._objref_SMESH_Gen.GetPattern(self)
631 ## Sets number of segments per diagonal of boundary box of geometry by which
632 # default segment length of appropriate 1D hypotheses is defined.
633 # Default value is 10
634 # @ingroup l1_auxiliary
635 def SetBoundaryBoxSegmentation(self, nbSegments):
636 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
638 ## Concatenate the given meshes into one mesh.
639 # @return an instance of Mesh class
640 # @param meshes the meshes to combine into one mesh
641 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
642 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
643 # @param mergeTolerance tolerance for merging nodes
644 # @param allGroups forces creation of groups of all elements
645 def Concatenate( self, meshes, uniteIdenticalGroups,
646 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
647 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
649 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
650 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
652 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
653 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
654 aSmeshMesh.SetParameters(Parameters)
655 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
658 # Filtering. Auxiliary functions:
659 # ------------------------------
661 ## Creates an empty criterion
662 # @return SMESH.Filter.Criterion
663 # @ingroup l1_controls
664 def GetEmptyCriterion(self):
665 Type = self.EnumToLong(FT_Undefined)
666 Compare = self.EnumToLong(FT_Undefined)
670 UnaryOp = self.EnumToLong(FT_Undefined)
671 BinaryOp = self.EnumToLong(FT_Undefined)
674 Precision = -1 ##@1e-07
675 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
676 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
678 ## Creates a criterion by the given parameters
679 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
680 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
681 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
682 # @param Treshold the threshold value (range of ids as string, shape, numeric)
683 # @param UnaryOp FT_LogicalNOT or FT_Undefined
684 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
685 # FT_Undefined (must be for the last criterion of all criteria)
686 # @return SMESH.Filter.Criterion
687 # @ingroup l1_controls
688 def GetCriterion(self,elementType,
690 Compare = FT_EqualTo,
692 UnaryOp=FT_Undefined,
693 BinaryOp=FT_Undefined):
694 aCriterion = self.GetEmptyCriterion()
695 aCriterion.TypeOfElement = elementType
696 aCriterion.Type = self.EnumToLong(CritType)
700 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
701 aCriterion.Compare = self.EnumToLong(Compare)
702 elif Compare == "=" or Compare == "==":
703 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
705 aCriterion.Compare = self.EnumToLong(FT_LessThan)
707 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
709 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
712 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
713 FT_BelongToCylinder, FT_LyingOnGeom]:
714 # Checks the treshold
715 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
716 aCriterion.ThresholdStr = GetName(aTreshold)
717 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
719 print "Error: The treshold should be a shape."
721 elif CritType == FT_RangeOfIds:
722 # Checks the treshold
723 if isinstance(aTreshold, str):
724 aCriterion.ThresholdStr = aTreshold
726 print "Error: The treshold should be a string."
728 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
729 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
730 # At this point the treshold is unnecessary
731 if aTreshold == FT_LogicalNOT:
732 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
733 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
734 aCriterion.BinaryOp = aTreshold
738 aTreshold = float(aTreshold)
739 aCriterion.Threshold = aTreshold
741 print "Error: The treshold should be a number."
744 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
745 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
747 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
748 aCriterion.BinaryOp = self.EnumToLong(Treshold)
750 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
751 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
753 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
754 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
758 ## Creates a filter with the given parameters
759 # @param elementType the type of elements in the group
760 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
761 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
762 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
763 # @param UnaryOp FT_LogicalNOT or FT_Undefined
764 # @return SMESH_Filter
765 # @ingroup l1_controls
766 def GetFilter(self,elementType,
767 CritType=FT_Undefined,
770 UnaryOp=FT_Undefined):
771 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
772 aFilterMgr = self.CreateFilterManager()
773 aFilter = aFilterMgr.CreateFilter()
775 aCriteria.append(aCriterion)
776 aFilter.SetCriteria(aCriteria)
779 ## Creates a numerical functor by its type
780 # @param theCriterion FT_...; functor type
781 # @return SMESH_NumericalFunctor
782 # @ingroup l1_controls
783 def GetFunctor(self,theCriterion):
784 aFilterMgr = self.CreateFilterManager()
785 if theCriterion == FT_AspectRatio:
786 return aFilterMgr.CreateAspectRatio()
787 elif theCriterion == FT_AspectRatio3D:
788 return aFilterMgr.CreateAspectRatio3D()
789 elif theCriterion == FT_Warping:
790 return aFilterMgr.CreateWarping()
791 elif theCriterion == FT_MinimumAngle:
792 return aFilterMgr.CreateMinimumAngle()
793 elif theCriterion == FT_Taper:
794 return aFilterMgr.CreateTaper()
795 elif theCriterion == FT_Skew:
796 return aFilterMgr.CreateSkew()
797 elif theCriterion == FT_Area:
798 return aFilterMgr.CreateArea()
799 elif theCriterion == FT_Volume3D:
800 return aFilterMgr.CreateVolume3D()
801 elif theCriterion == FT_MultiConnection:
802 return aFilterMgr.CreateMultiConnection()
803 elif theCriterion == FT_MultiConnection2D:
804 return aFilterMgr.CreateMultiConnection2D()
805 elif theCriterion == FT_Length:
806 return aFilterMgr.CreateLength()
807 elif theCriterion == FT_Length2D:
808 return aFilterMgr.CreateLength2D()
810 print "Error: given parameter is not numerucal functor type."
812 ## Creates hypothesis
813 # @param theHType mesh hypothesis type (string)
814 # @param theLibName mesh plug-in library name
815 # @return created hypothesis instance
816 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
817 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
819 ## Gets the mesh stattistic
820 # @return dictionary type element - count of elements
821 # @ingroup l1_meshinfo
822 def GetMeshInfo(self, obj):
823 if isinstance( obj, Mesh ):
826 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
827 values = obj.GetMeshInfo()
828 for i in range(SMESH.Entity_Last._v):
829 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
834 #Registering the new proxy for SMESH_Gen
835 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
841 ## This class allows defining and managing a mesh.
842 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
843 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
844 # new nodes and elements and by changing the existing entities), to get information
845 # about a mesh and to export a mesh into different formats.
854 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
855 # sets the GUI name of this mesh to \a name.
856 # @param smeshpyD an instance of smeshDC class
857 # @param geompyD an instance of geompyDC class
858 # @param obj Shape to be meshed or SMESH_Mesh object
859 # @param name Study name of the mesh
860 # @ingroup l2_construct
861 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
862 self.smeshpyD=smeshpyD
867 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
869 self.mesh = self.smeshpyD.CreateMesh(self.geom)
870 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
873 self.mesh = self.smeshpyD.CreateEmptyMesh()
875 self.smeshpyD.SetName(self.mesh, name)
877 self.smeshpyD.SetName(self.mesh, GetName(obj))
880 self.geom = self.mesh.GetShapeToMesh()
882 self.editor = self.mesh.GetMeshEditor()
884 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
885 # @param theMesh a SMESH_Mesh object
886 # @ingroup l2_construct
887 def SetMesh(self, theMesh):
889 self.geom = self.mesh.GetShapeToMesh()
891 ## Returns the mesh, that is an instance of SMESH_Mesh interface
892 # @return a SMESH_Mesh object
893 # @ingroup l2_construct
897 ## Gets the name of the mesh
898 # @return the name of the mesh as a string
899 # @ingroup l2_construct
901 name = GetName(self.GetMesh())
904 ## Sets a name to the mesh
905 # @param name a new name of the mesh
906 # @ingroup l2_construct
907 def SetName(self, name):
908 self.smeshpyD.SetName(self.GetMesh(), name)
910 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
911 # The subMesh object gives access to the IDs of nodes and elements.
912 # @param theSubObject a geometrical object (shape)
913 # @param theName a name for the submesh
914 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
915 # @ingroup l2_submeshes
916 def GetSubMesh(self, theSubObject, theName):
917 submesh = self.mesh.GetSubMesh(theSubObject, theName)
920 ## Returns the shape associated to the mesh
921 # @return a GEOM_Object
922 # @ingroup l2_construct
926 ## Associates the given shape to the mesh (entails the recreation of the mesh)
927 # @param geom the shape to be meshed (GEOM_Object)
928 # @ingroup l2_construct
929 def SetShape(self, geom):
930 self.mesh = self.smeshpyD.CreateMesh(geom)
932 ## Returns true if the hypotheses are defined well
933 # @param theSubObject a subshape of a mesh shape
934 # @return True or False
935 # @ingroup l2_construct
936 def IsReadyToCompute(self, theSubObject):
937 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
939 ## Returns errors of hypotheses definition.
940 # The list of errors is empty if everything is OK.
941 # @param theSubObject a subshape of a mesh shape
942 # @return a list of errors
943 # @ingroup l2_construct
944 def GetAlgoState(self, theSubObject):
945 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
947 ## Returns a geometrical object on which the given element was built.
948 # The returned geometrical object, if not nil, is either found in the
949 # study or published by this method with the given name
950 # @param theElementID the id of the mesh element
951 # @param theGeomName the user-defined name of the geometrical object
952 # @return GEOM::GEOM_Object instance
953 # @ingroup l2_construct
954 def GetGeometryByMeshElement(self, theElementID, theGeomName):
955 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
957 ## Returns the mesh dimension depending on the dimension of the underlying shape
958 # @return mesh dimension as an integer value [0,3]
959 # @ingroup l1_auxiliary
960 def MeshDimension(self):
961 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
962 if len( shells ) > 0 :
964 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
966 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
972 ## Creates a segment discretization 1D algorithm.
973 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
974 # \n If the optional \a geom parameter is not set, this algorithm is global.
975 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
976 # @param algo the type of the required algorithm. Possible values are:
978 # - smesh.PYTHON for discretization via a python function,
979 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
980 # @param geom If defined is the subshape to be meshed
981 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
982 # @ingroup l3_algos_basic
983 def Segment(self, algo=REGULAR, geom=0):
984 ## if Segment(geom) is called by mistake
985 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
986 algo, geom = geom, algo
987 if not algo: algo = REGULAR
990 return Mesh_Segment(self, geom)
992 return Mesh_Segment_Python(self, geom)
993 elif algo == COMPOSITE:
994 return Mesh_CompositeSegment(self, geom)
996 return Mesh_Segment(self, geom)
998 ## Enables creation of nodes and segments usable by 2D algoritms.
999 # The added nodes and segments must be bound to edges and vertices by
1000 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1001 # If the optional \a geom parameter is not set, this algorithm is global.
1002 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1003 # @param geom the subshape to be manually meshed
1004 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1005 # @ingroup l3_algos_basic
1006 def UseExistingSegments(self, geom=0):
1007 algo = Mesh_UseExisting(1,self,geom)
1008 return algo.GetAlgorithm()
1010 ## Enables creation of nodes and faces usable by 3D algoritms.
1011 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1012 # and SetMeshElementOnShape()
1013 # If the optional \a geom parameter is not set, this algorithm is global.
1014 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1015 # @param geom the subshape to be manually meshed
1016 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1017 # @ingroup l3_algos_basic
1018 def UseExistingFaces(self, geom=0):
1019 algo = Mesh_UseExisting(2,self,geom)
1020 return algo.GetAlgorithm()
1022 ## Creates a triangle 2D algorithm for faces.
1023 # If the optional \a geom parameter is not set, this algorithm is global.
1024 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1025 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1026 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1027 # @return an instance of Mesh_Triangle algorithm
1028 # @ingroup l3_algos_basic
1029 def Triangle(self, algo=MEFISTO, geom=0):
1030 ## if Triangle(geom) is called by mistake
1031 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1035 return Mesh_Triangle(self, algo, geom)
1037 ## Creates a quadrangle 2D algorithm for faces.
1038 # If the optional \a geom parameter is not set, this algorithm is global.
1039 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1040 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1041 # @return an instance of Mesh_Quadrangle algorithm
1042 # @ingroup l3_algos_basic
1043 def Quadrangle(self, geom=0):
1044 return Mesh_Quadrangle(self, geom)
1046 ## Creates a tetrahedron 3D algorithm for solids.
1047 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1048 # If the optional \a geom parameter is not set, this algorithm is global.
1049 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1050 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1051 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1052 # @return an instance of Mesh_Tetrahedron algorithm
1053 # @ingroup l3_algos_basic
1054 def Tetrahedron(self, algo=NETGEN, geom=0):
1055 ## if Tetrahedron(geom) is called by mistake
1056 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1057 algo, geom = geom, algo
1058 if not algo: algo = NETGEN
1060 return Mesh_Tetrahedron(self, algo, geom)
1062 ## Creates a hexahedron 3D algorithm for solids.
1063 # If the optional \a geom parameter is not set, this algorithm is global.
1064 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1065 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1066 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1067 # @return an instance of Mesh_Hexahedron algorithm
1068 # @ingroup l3_algos_basic
1069 def Hexahedron(self, algo=Hexa, geom=0):
1070 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1071 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1072 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1073 elif geom == 0: algo, geom = Hexa, algo
1074 return Mesh_Hexahedron(self, algo, geom)
1076 ## Deprecated, used only for compatibility!
1077 # @return an instance of Mesh_Netgen algorithm
1078 # @ingroup l3_algos_basic
1079 def Netgen(self, is3D, geom=0):
1080 return Mesh_Netgen(self, is3D, geom)
1082 ## Creates a projection 1D algorithm for edges.
1083 # If the optional \a geom parameter is not set, this algorithm is global.
1084 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1085 # @param geom If defined, the subshape to be meshed
1086 # @return an instance of Mesh_Projection1D algorithm
1087 # @ingroup l3_algos_proj
1088 def Projection1D(self, geom=0):
1089 return Mesh_Projection1D(self, geom)
1091 ## Creates a projection 2D algorithm for faces.
1092 # If the optional \a geom parameter is not set, this algorithm is global.
1093 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1094 # @param geom If defined, the subshape to be meshed
1095 # @return an instance of Mesh_Projection2D algorithm
1096 # @ingroup l3_algos_proj
1097 def Projection2D(self, geom=0):
1098 return Mesh_Projection2D(self, geom)
1100 ## Creates a projection 3D algorithm for solids.
1101 # If the optional \a geom parameter is not set, this algorithm is global.
1102 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1103 # @param geom If defined, the subshape to be meshed
1104 # @return an instance of Mesh_Projection3D algorithm
1105 # @ingroup l3_algos_proj
1106 def Projection3D(self, geom=0):
1107 return Mesh_Projection3D(self, geom)
1109 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1110 # If the optional \a geom parameter is not set, this algorithm is global.
1111 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1112 # @param geom If defined, the subshape to be meshed
1113 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1114 # @ingroup l3_algos_radialp l3_algos_3dextr
1115 def Prism(self, geom=0):
1119 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1120 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1121 if nbSolids == 0 or nbSolids == nbShells:
1122 return Mesh_Prism3D(self, geom)
1123 return Mesh_RadialPrism3D(self, geom)
1125 ## Evaluates size of prospective mesh on a shape
1126 # @return True or False
1127 def Evaluate(self, geom=0):
1128 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1130 geom = self.mesh.GetShapeToMesh()
1133 return self.smeshpyD.Evaluate(self.mesh, geom)
1136 ## Computes the mesh and returns the status of the computation
1137 # @return True or False
1138 # @ingroup l2_construct
1139 def Compute(self, geom=0):
1140 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1142 geom = self.mesh.GetShapeToMesh()
1147 ok = self.smeshpyD.Compute(self.mesh, geom)
1148 except SALOME.SALOME_Exception, ex:
1149 print "Mesh computation failed, exception caught:"
1150 print " ", ex.details.text
1153 print "Mesh computation failed, exception caught:"
1154 traceback.print_exc()
1156 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1159 if err.isGlobalAlgo:
1167 reason = '%s %sD algorithm is missing' % (glob, dim)
1168 elif err.state == HYP_MISSING:
1169 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1170 % (glob, dim, name, dim))
1171 elif err.state == HYP_NOTCONFORM:
1172 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1173 elif err.state == HYP_BAD_PARAMETER:
1174 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1175 % ( glob, dim, name ))
1176 elif err.state == HYP_BAD_GEOMETRY:
1177 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1178 'geometry' % ( glob, dim, name ))
1180 reason = "For unknown reason."+\
1181 " Revise Mesh.Compute() implementation in smeshDC.py!"
1183 if allReasons != "":
1186 allReasons += reason
1188 if allReasons != "":
1189 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1193 print '"' + GetName(self.mesh) + '"',"has not been computed."
1196 if salome.sg.hasDesktop():
1197 smeshgui = salome.ImportComponentGUI("SMESH")
1198 smeshgui.Init(self.mesh.GetStudyId())
1199 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1200 salome.sg.updateObjBrowser(1)
1204 ## Removes all nodes and elements
1205 # @ingroup l2_construct
1208 if salome.sg.hasDesktop():
1209 smeshgui = salome.ImportComponentGUI("SMESH")
1210 smeshgui.Init(self.mesh.GetStudyId())
1211 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1212 salome.sg.updateObjBrowser(1)
1214 ## Removes all nodes and elements of indicated shape
1215 # @ingroup l2_construct
1216 def ClearSubMesh(self, geomId):
1217 self.mesh.ClearSubMesh(geomId)
1218 if salome.sg.hasDesktop():
1219 smeshgui = salome.ImportComponentGUI("SMESH")
1220 smeshgui.Init(self.mesh.GetStudyId())
1221 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1222 salome.sg.updateObjBrowser(1)
1224 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1225 # @param fineness [0,-1] defines mesh fineness
1226 # @return True or False
1227 # @ingroup l3_algos_basic
1228 def AutomaticTetrahedralization(self, fineness=0):
1229 dim = self.MeshDimension()
1231 self.RemoveGlobalHypotheses()
1232 self.Segment().AutomaticLength(fineness)
1234 self.Triangle().LengthFromEdges()
1237 self.Tetrahedron(NETGEN)
1239 return self.Compute()
1241 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1242 # @param fineness [0,-1] defines mesh fineness
1243 # @return True or False
1244 # @ingroup l3_algos_basic
1245 def AutomaticHexahedralization(self, fineness=0):
1246 dim = self.MeshDimension()
1247 # assign the hypotheses
1248 self.RemoveGlobalHypotheses()
1249 self.Segment().AutomaticLength(fineness)
1256 return self.Compute()
1258 ## Assigns a hypothesis
1259 # @param hyp a hypothesis to assign
1260 # @param geom a subhape of mesh geometry
1261 # @return SMESH.Hypothesis_Status
1262 # @ingroup l2_hypotheses
1263 def AddHypothesis(self, hyp, geom=0):
1264 if isinstance( hyp, Mesh_Algorithm ):
1265 hyp = hyp.GetAlgorithm()
1270 geom = self.mesh.GetShapeToMesh()
1272 status = self.mesh.AddHypothesis(geom, hyp)
1273 isAlgo = hyp._narrow( SMESH_Algo )
1274 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1277 ## Unassigns a hypothesis
1278 # @param hyp a hypothesis to unassign
1279 # @param geom a subshape of mesh geometry
1280 # @return SMESH.Hypothesis_Status
1281 # @ingroup l2_hypotheses
1282 def RemoveHypothesis(self, hyp, geom=0):
1283 if isinstance( hyp, Mesh_Algorithm ):
1284 hyp = hyp.GetAlgorithm()
1289 status = self.mesh.RemoveHypothesis(geom, hyp)
1292 ## Gets the list of hypotheses added on a geometry
1293 # @param geom a subshape of mesh geometry
1294 # @return the sequence of SMESH_Hypothesis
1295 # @ingroup l2_hypotheses
1296 def GetHypothesisList(self, geom):
1297 return self.mesh.GetHypothesisList( geom )
1299 ## Removes all global hypotheses
1300 # @ingroup l2_hypotheses
1301 def RemoveGlobalHypotheses(self):
1302 current_hyps = self.mesh.GetHypothesisList( self.geom )
1303 for hyp in current_hyps:
1304 self.mesh.RemoveHypothesis( self.geom, hyp )
1308 ## Creates a mesh group based on the geometric object \a grp
1309 # and gives a \a name, \n if this parameter is not defined
1310 # the name is the same as the geometric group name \n
1311 # Note: Works like GroupOnGeom().
1312 # @param grp a geometric group, a vertex, an edge, a face or a solid
1313 # @param name the name of the mesh group
1314 # @return SMESH_GroupOnGeom
1315 # @ingroup l2_grps_create
1316 def Group(self, grp, name=""):
1317 return self.GroupOnGeom(grp, name)
1319 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1320 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1321 # @param f the file name
1322 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1323 # @param opt boolean parameter for creating/not creating
1324 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1325 # @ingroup l2_impexp
1326 def ExportToMED(self, f, version, opt=0):
1327 self.mesh.ExportToMED(f, opt, version)
1329 ## Exports the mesh in a file in MED format
1330 # @param f is the file name
1331 # @param auto_groups boolean parameter for creating/not creating
1332 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1333 # the typical use is auto_groups=false.
1334 # @param version MED format version(MED_V2_1 or MED_V2_2)
1335 # @ingroup l2_impexp
1336 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1337 self.mesh.ExportToMED(f, auto_groups, version)
1339 ## Exports the mesh in a file in DAT format
1340 # @param f the file name
1341 # @ingroup l2_impexp
1342 def ExportDAT(self, f):
1343 self.mesh.ExportDAT(f)
1345 ## Exports the mesh in a file in UNV format
1346 # @param f the file name
1347 # @ingroup l2_impexp
1348 def ExportUNV(self, f):
1349 self.mesh.ExportUNV(f)
1351 ## Export the mesh in a file in STL format
1352 # @param f the file name
1353 # @param ascii defines the file encoding
1354 # @ingroup l2_impexp
1355 def ExportSTL(self, f, ascii=1):
1356 self.mesh.ExportSTL(f, ascii)
1359 # Operations with groups:
1360 # ----------------------
1362 ## Creates an empty mesh group
1363 # @param elementType the type of elements in the group
1364 # @param name the name of the mesh group
1365 # @return SMESH_Group
1366 # @ingroup l2_grps_create
1367 def CreateEmptyGroup(self, elementType, name):
1368 return self.mesh.CreateGroup(elementType, name)
1370 ## Creates a mesh group based on the geometrical object \a grp
1371 # and gives a \a name, \n if this parameter is not defined
1372 # the name is the same as the geometrical group name
1373 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1374 # @param name the name of the mesh group
1375 # @param typ the type of elements in the group. If not set, it is
1376 # automatically detected by the type of the geometry
1377 # @return SMESH_GroupOnGeom
1378 # @ingroup l2_grps_create
1379 def GroupOnGeom(self, grp, name="", typ=None):
1381 name = grp.GetName()
1384 tgeo = str(grp.GetShapeType())
1385 if tgeo == "VERTEX":
1387 elif tgeo == "EDGE":
1389 elif tgeo == "FACE":
1391 elif tgeo == "SOLID":
1393 elif tgeo == "SHELL":
1395 elif tgeo == "COMPOUND":
1396 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1397 print "Mesh.Group: empty geometric group", GetName( grp )
1399 tgeo = self.geompyD.GetType(grp)
1400 if tgeo == geompyDC.ShapeType["VERTEX"]:
1402 elif tgeo == geompyDC.ShapeType["EDGE"]:
1404 elif tgeo == geompyDC.ShapeType["FACE"]:
1406 elif tgeo == geompyDC.ShapeType["SOLID"]:
1410 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1413 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1415 ## Creates a mesh group by the given ids of elements
1416 # @param groupName the name of the mesh group
1417 # @param elementType the type of elements in the group
1418 # @param elemIDs the list of ids
1419 # @return SMESH_Group
1420 # @ingroup l2_grps_create
1421 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1422 group = self.mesh.CreateGroup(elementType, groupName)
1426 ## Creates a mesh group by the given conditions
1427 # @param groupName the name of the mesh group
1428 # @param elementType the type of elements in the group
1429 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1430 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1431 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1432 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1433 # @return SMESH_Group
1434 # @ingroup l2_grps_create
1438 CritType=FT_Undefined,
1441 UnaryOp=FT_Undefined):
1442 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1443 group = self.MakeGroupByCriterion(groupName, aCriterion)
1446 ## Creates a mesh group by the given criterion
1447 # @param groupName the name of the mesh group
1448 # @param Criterion the instance of Criterion class
1449 # @return SMESH_Group
1450 # @ingroup l2_grps_create
1451 def MakeGroupByCriterion(self, groupName, Criterion):
1452 aFilterMgr = self.smeshpyD.CreateFilterManager()
1453 aFilter = aFilterMgr.CreateFilter()
1455 aCriteria.append(Criterion)
1456 aFilter.SetCriteria(aCriteria)
1457 group = self.MakeGroupByFilter(groupName, aFilter)
1460 ## Creates a mesh group by the given criteria (list of criteria)
1461 # @param groupName the name of the mesh group
1462 # @param theCriteria the list of criteria
1463 # @return SMESH_Group
1464 # @ingroup l2_grps_create
1465 def MakeGroupByCriteria(self, groupName, theCriteria):
1466 aFilterMgr = self.smeshpyD.CreateFilterManager()
1467 aFilter = aFilterMgr.CreateFilter()
1468 aFilter.SetCriteria(theCriteria)
1469 group = self.MakeGroupByFilter(groupName, aFilter)
1472 ## Creates a mesh group by the given filter
1473 # @param groupName the name of the mesh group
1474 # @param theFilter the instance of Filter class
1475 # @return SMESH_Group
1476 # @ingroup l2_grps_create
1477 def MakeGroupByFilter(self, groupName, theFilter):
1478 anIds = theFilter.GetElementsId(self.mesh)
1479 anElemType = theFilter.GetElementType()
1480 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1483 ## Passes mesh elements through the given filter and return IDs of fitting elements
1484 # @param theFilter SMESH_Filter
1485 # @return a list of ids
1486 # @ingroup l1_controls
1487 def GetIdsFromFilter(self, theFilter):
1488 return theFilter.GetElementsId(self.mesh)
1490 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1491 # Returns a list of special structures (borders).
1492 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1493 # @ingroup l1_controls
1494 def GetFreeBorders(self):
1495 aFilterMgr = self.smeshpyD.CreateFilterManager()
1496 aPredicate = aFilterMgr.CreateFreeEdges()
1497 aPredicate.SetMesh(self.mesh)
1498 aBorders = aPredicate.GetBorders()
1502 # @ingroup l2_grps_delete
1503 def RemoveGroup(self, group):
1504 self.mesh.RemoveGroup(group)
1506 ## Removes a group with its contents
1507 # @ingroup l2_grps_delete
1508 def RemoveGroupWithContents(self, group):
1509 self.mesh.RemoveGroupWithContents(group)
1511 ## Gets the list of groups existing in the mesh
1512 # @return a sequence of SMESH_GroupBase
1513 # @ingroup l2_grps_create
1514 def GetGroups(self):
1515 return self.mesh.GetGroups()
1517 ## Gets the number of groups existing in the mesh
1518 # @return the quantity of groups as an integer value
1519 # @ingroup l2_grps_create
1521 return self.mesh.NbGroups()
1523 ## Gets the list of names of groups existing in the mesh
1524 # @return list of strings
1525 # @ingroup l2_grps_create
1526 def GetGroupNames(self):
1527 groups = self.GetGroups()
1529 for group in groups:
1530 names.append(group.GetName())
1533 ## Produces a union of two groups
1534 # A new group is created. All mesh elements that are
1535 # present in the initial groups are added to the new one
1536 # @return an instance of SMESH_Group
1537 # @ingroup l2_grps_operon
1538 def UnionGroups(self, group1, group2, name):
1539 return self.mesh.UnionGroups(group1, group2, name)
1541 ## Produces a union list of groups
1542 # New group is created. All mesh elements that are present in
1543 # initial groups are added to the new one
1544 # @return an instance of SMESH_Group
1545 # @ingroup l2_grps_operon
1546 def UnionListOfGroups(self, groups, name):
1547 return self.mesh.UnionListOfGroups(groups, name)
1549 ## Prodices an intersection of two groups
1550 # A new group is created. All mesh elements that are common
1551 # for the two initial groups are added to the new one.
1552 # @return an instance of SMESH_Group
1553 # @ingroup l2_grps_operon
1554 def IntersectGroups(self, group1, group2, name):
1555 return self.mesh.IntersectGroups(group1, group2, name)
1557 ## Produces an intersection of groups
1558 # New group is created. All mesh elements that are present in all
1559 # initial groups simultaneously are added to the new one
1560 # @return an instance of SMESH_Group
1561 # @ingroup l2_grps_operon
1562 def IntersectListOfGroups(self, groups, name):
1563 return self.mesh.IntersectListOfGroups(groups, name)
1565 ## Produces a cut of two groups
1566 # A new group is created. All mesh elements that are present in
1567 # the main group but are not present in the tool group are added to the new one
1568 # @return an instance of SMESH_Group
1569 # @ingroup l2_grps_operon
1570 def CutGroups(self, main_group, tool_group, name):
1571 return self.mesh.CutGroups(main_group, tool_group, name)
1573 ## Produces a cut of groups
1574 # A new group is created. All mesh elements that are present in main groups
1575 # but do not present in tool groups are added to the new one
1576 # @return an instance of SMESH_Group
1577 # @ingroup l2_grps_operon
1578 def CutListOfGroups(self, main_groups, tool_groups, name):
1579 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1581 ## Produces a group of elements with specified element type using list of existing groups
1582 # A new group is created. System
1583 # 1) extract all nodes on which groups elements are built
1584 # 2) combine all elements of specified dimension laying on these nodes
1585 # @return an instance of SMESH_Group
1586 # @ingroup l2_grps_operon
1587 def CreateDimGroup(self, groups, elem_type, name):
1588 return self.mesh.CreateDimGroup(groups, elem_type, name)
1591 ## Convert group on geom into standalone group
1592 # @ingroup l2_grps_delete
1593 def ConvertToStandalone(self, group):
1594 return self.mesh.ConvertToStandalone(group)
1596 # Get some info about mesh:
1597 # ------------------------
1599 ## Returns the log of nodes and elements added or removed
1600 # since the previous clear of the log.
1601 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1602 # @return list of log_block structures:
1607 # @ingroup l1_auxiliary
1608 def GetLog(self, clearAfterGet):
1609 return self.mesh.GetLog(clearAfterGet)
1611 ## Clears the log of nodes and elements added or removed since the previous
1612 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1613 # @ingroup l1_auxiliary
1615 self.mesh.ClearLog()
1617 ## Toggles auto color mode on the object.
1618 # @param theAutoColor the flag which toggles auto color mode.
1619 # @ingroup l1_auxiliary
1620 def SetAutoColor(self, theAutoColor):
1621 self.mesh.SetAutoColor(theAutoColor)
1623 ## Gets flag of object auto color mode.
1624 # @return True or False
1625 # @ingroup l1_auxiliary
1626 def GetAutoColor(self):
1627 return self.mesh.GetAutoColor()
1629 ## Gets the internal ID
1630 # @return integer value, which is the internal Id of the mesh
1631 # @ingroup l1_auxiliary
1633 return self.mesh.GetId()
1636 # @return integer value, which is the study Id of the mesh
1637 # @ingroup l1_auxiliary
1638 def GetStudyId(self):
1639 return self.mesh.GetStudyId()
1641 ## Checks the group names for duplications.
1642 # Consider the maximum group name length stored in MED file.
1643 # @return True or False
1644 # @ingroup l1_auxiliary
1645 def HasDuplicatedGroupNamesMED(self):
1646 return self.mesh.HasDuplicatedGroupNamesMED()
1648 ## Obtains the mesh editor tool
1649 # @return an instance of SMESH_MeshEditor
1650 # @ingroup l1_modifying
1651 def GetMeshEditor(self):
1652 return self.mesh.GetMeshEditor()
1655 # @return an instance of SALOME_MED::MESH
1656 # @ingroup l1_auxiliary
1657 def GetMEDMesh(self):
1658 return self.mesh.GetMEDMesh()
1661 # Get informations about mesh contents:
1662 # ------------------------------------
1664 ## Gets the mesh stattistic
1665 # @return dictionary type element - count of elements
1666 # @ingroup l1_meshinfo
1667 def GetMeshInfo(self, obj = None):
1668 if not obj: obj = self.mesh
1669 return self.smeshpyD.GetMeshInfo(obj)
1671 ## Returns the number of nodes in the mesh
1672 # @return an integer value
1673 # @ingroup l1_meshinfo
1675 return self.mesh.NbNodes()
1677 ## Returns the number of elements in the mesh
1678 # @return an integer value
1679 # @ingroup l1_meshinfo
1680 def NbElements(self):
1681 return self.mesh.NbElements()
1683 ## Returns the number of 0d elements in the mesh
1684 # @return an integer value
1685 # @ingroup l1_meshinfo
1686 def Nb0DElements(self):
1687 return self.mesh.Nb0DElements()
1689 ## Returns the number of edges in the mesh
1690 # @return an integer value
1691 # @ingroup l1_meshinfo
1693 return self.mesh.NbEdges()
1695 ## Returns the number of edges with the given order in the mesh
1696 # @param elementOrder the order of elements:
1697 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1698 # @return an integer value
1699 # @ingroup l1_meshinfo
1700 def NbEdgesOfOrder(self, elementOrder):
1701 return self.mesh.NbEdgesOfOrder(elementOrder)
1703 ## Returns the number of faces in the mesh
1704 # @return an integer value
1705 # @ingroup l1_meshinfo
1707 return self.mesh.NbFaces()
1709 ## Returns the number of faces with the given order in the mesh
1710 # @param elementOrder the order of elements:
1711 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1712 # @return an integer value
1713 # @ingroup l1_meshinfo
1714 def NbFacesOfOrder(self, elementOrder):
1715 return self.mesh.NbFacesOfOrder(elementOrder)
1717 ## Returns the number of triangles in the mesh
1718 # @return an integer value
1719 # @ingroup l1_meshinfo
1720 def NbTriangles(self):
1721 return self.mesh.NbTriangles()
1723 ## Returns the number of triangles with the given order in the mesh
1724 # @param elementOrder is the order of elements:
1725 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1726 # @return an integer value
1727 # @ingroup l1_meshinfo
1728 def NbTrianglesOfOrder(self, elementOrder):
1729 return self.mesh.NbTrianglesOfOrder(elementOrder)
1731 ## Returns the number of quadrangles in the mesh
1732 # @return an integer value
1733 # @ingroup l1_meshinfo
1734 def NbQuadrangles(self):
1735 return self.mesh.NbQuadrangles()
1737 ## Returns the number of quadrangles with the given order in the mesh
1738 # @param elementOrder the order of elements:
1739 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1740 # @return an integer value
1741 # @ingroup l1_meshinfo
1742 def NbQuadranglesOfOrder(self, elementOrder):
1743 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1745 ## Returns the number of polygons in the mesh
1746 # @return an integer value
1747 # @ingroup l1_meshinfo
1748 def NbPolygons(self):
1749 return self.mesh.NbPolygons()
1751 ## Returns the number of volumes in the mesh
1752 # @return an integer value
1753 # @ingroup l1_meshinfo
1754 def NbVolumes(self):
1755 return self.mesh.NbVolumes()
1757 ## Returns the number of volumes with the given order in the mesh
1758 # @param elementOrder the order of elements:
1759 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1760 # @return an integer value
1761 # @ingroup l1_meshinfo
1762 def NbVolumesOfOrder(self, elementOrder):
1763 return self.mesh.NbVolumesOfOrder(elementOrder)
1765 ## Returns the number of tetrahedrons in the mesh
1766 # @return an integer value
1767 # @ingroup l1_meshinfo
1769 return self.mesh.NbTetras()
1771 ## Returns the number of tetrahedrons with the given order in the mesh
1772 # @param elementOrder the order of elements:
1773 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1774 # @return an integer value
1775 # @ingroup l1_meshinfo
1776 def NbTetrasOfOrder(self, elementOrder):
1777 return self.mesh.NbTetrasOfOrder(elementOrder)
1779 ## Returns the number of hexahedrons in the mesh
1780 # @return an integer value
1781 # @ingroup l1_meshinfo
1783 return self.mesh.NbHexas()
1785 ## Returns the number of hexahedrons with the given order in the mesh
1786 # @param elementOrder the order of elements:
1787 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1788 # @return an integer value
1789 # @ingroup l1_meshinfo
1790 def NbHexasOfOrder(self, elementOrder):
1791 return self.mesh.NbHexasOfOrder(elementOrder)
1793 ## Returns the number of pyramids in the mesh
1794 # @return an integer value
1795 # @ingroup l1_meshinfo
1796 def NbPyramids(self):
1797 return self.mesh.NbPyramids()
1799 ## Returns the number of pyramids with the given order in the mesh
1800 # @param elementOrder the order of elements:
1801 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1802 # @return an integer value
1803 # @ingroup l1_meshinfo
1804 def NbPyramidsOfOrder(self, elementOrder):
1805 return self.mesh.NbPyramidsOfOrder(elementOrder)
1807 ## Returns the number of prisms in the mesh
1808 # @return an integer value
1809 # @ingroup l1_meshinfo
1811 return self.mesh.NbPrisms()
1813 ## Returns the number of prisms with the given order in the mesh
1814 # @param elementOrder the order of elements:
1815 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1816 # @return an integer value
1817 # @ingroup l1_meshinfo
1818 def NbPrismsOfOrder(self, elementOrder):
1819 return self.mesh.NbPrismsOfOrder(elementOrder)
1821 ## Returns the number of polyhedrons in the mesh
1822 # @return an integer value
1823 # @ingroup l1_meshinfo
1824 def NbPolyhedrons(self):
1825 return self.mesh.NbPolyhedrons()
1827 ## Returns the number of submeshes in the mesh
1828 # @return an integer value
1829 # @ingroup l1_meshinfo
1830 def NbSubMesh(self):
1831 return self.mesh.NbSubMesh()
1833 ## Returns the list of mesh elements IDs
1834 # @return the list of integer values
1835 # @ingroup l1_meshinfo
1836 def GetElementsId(self):
1837 return self.mesh.GetElementsId()
1839 ## Returns the list of IDs of mesh elements with the given type
1840 # @param elementType the required type of elements
1841 # @return list of integer values
1842 # @ingroup l1_meshinfo
1843 def GetElementsByType(self, elementType):
1844 return self.mesh.GetElementsByType(elementType)
1846 ## Returns the list of mesh nodes IDs
1847 # @return the list of integer values
1848 # @ingroup l1_meshinfo
1849 def GetNodesId(self):
1850 return self.mesh.GetNodesId()
1852 # Get the information about mesh elements:
1853 # ------------------------------------
1855 ## Returns the type of mesh element
1856 # @return the value from SMESH::ElementType enumeration
1857 # @ingroup l1_meshinfo
1858 def GetElementType(self, id, iselem):
1859 return self.mesh.GetElementType(id, iselem)
1861 ## Returns the list of submesh elements IDs
1862 # @param Shape a geom object(subshape) IOR
1863 # Shape must be the subshape of a ShapeToMesh()
1864 # @return the list of integer values
1865 # @ingroup l1_meshinfo
1866 def GetSubMeshElementsId(self, Shape):
1867 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1868 ShapeID = Shape.GetSubShapeIndices()[0]
1871 return self.mesh.GetSubMeshElementsId(ShapeID)
1873 ## Returns the list of submesh nodes IDs
1874 # @param Shape a geom object(subshape) IOR
1875 # Shape must be the subshape of a ShapeToMesh()
1876 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1877 # @return the list of integer values
1878 # @ingroup l1_meshinfo
1879 def GetSubMeshNodesId(self, Shape, all):
1880 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1881 ShapeID = Shape.GetSubShapeIndices()[0]
1884 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1886 ## Returns type of elements on given shape
1887 # @param Shape a geom object(subshape) IOR
1888 # Shape must be a subshape of a ShapeToMesh()
1889 # @return element type
1890 # @ingroup l1_meshinfo
1891 def GetSubMeshElementType(self, Shape):
1892 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1893 ShapeID = Shape.GetSubShapeIndices()[0]
1896 return self.mesh.GetSubMeshElementType(ShapeID)
1898 ## Gets the mesh description
1899 # @return string value
1900 # @ingroup l1_meshinfo
1902 return self.mesh.Dump()
1905 # Get the information about nodes and elements of a mesh by its IDs:
1906 # -----------------------------------------------------------
1908 ## Gets XYZ coordinates of a node
1909 # \n If there is no nodes for the given ID - returns an empty list
1910 # @return a list of double precision values
1911 # @ingroup l1_meshinfo
1912 def GetNodeXYZ(self, id):
1913 return self.mesh.GetNodeXYZ(id)
1915 ## Returns list of IDs of inverse elements for the given node
1916 # \n If there is no node for the given ID - returns an empty list
1917 # @return a list of integer values
1918 # @ingroup l1_meshinfo
1919 def GetNodeInverseElements(self, id):
1920 return self.mesh.GetNodeInverseElements(id)
1922 ## @brief Returns the position of a node on the shape
1923 # @return SMESH::NodePosition
1924 # @ingroup l1_meshinfo
1925 def GetNodePosition(self,NodeID):
1926 return self.mesh.GetNodePosition(NodeID)
1928 ## If the given element is a node, returns the ID of shape
1929 # \n If there is no node for the given ID - returns -1
1930 # @return an integer value
1931 # @ingroup l1_meshinfo
1932 def GetShapeID(self, id):
1933 return self.mesh.GetShapeID(id)
1935 ## Returns the ID of the result shape after
1936 # FindShape() from SMESH_MeshEditor for the given element
1937 # \n If there is no element for the given ID - returns -1
1938 # @return an integer value
1939 # @ingroup l1_meshinfo
1940 def GetShapeIDForElem(self,id):
1941 return self.mesh.GetShapeIDForElem(id)
1943 ## Returns the number of nodes for the given element
1944 # \n If there is no element for the given ID - returns -1
1945 # @return an integer value
1946 # @ingroup l1_meshinfo
1947 def GetElemNbNodes(self, id):
1948 return self.mesh.GetElemNbNodes(id)
1950 ## Returns the node ID the given index for the given element
1951 # \n If there is no element for the given ID - returns -1
1952 # \n If there is no node for the given index - returns -2
1953 # @return an integer value
1954 # @ingroup l1_meshinfo
1955 def GetElemNode(self, id, index):
1956 return self.mesh.GetElemNode(id, index)
1958 ## Returns the IDs of nodes of the given element
1959 # @return a list of integer values
1960 # @ingroup l1_meshinfo
1961 def GetElemNodes(self, id):
1962 return self.mesh.GetElemNodes(id)
1964 ## Returns true if the given node is the medium node in the given quadratic element
1965 # @ingroup l1_meshinfo
1966 def IsMediumNode(self, elementID, nodeID):
1967 return self.mesh.IsMediumNode(elementID, nodeID)
1969 ## Returns true if the given node is the medium node in one of quadratic elements
1970 # @ingroup l1_meshinfo
1971 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1972 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1974 ## Returns the number of edges for the given element
1975 # @ingroup l1_meshinfo
1976 def ElemNbEdges(self, id):
1977 return self.mesh.ElemNbEdges(id)
1979 ## Returns the number of faces for the given element
1980 # @ingroup l1_meshinfo
1981 def ElemNbFaces(self, id):
1982 return self.mesh.ElemNbFaces(id)
1984 ## Returns true if the given element is a polygon
1985 # @ingroup l1_meshinfo
1986 def IsPoly(self, id):
1987 return self.mesh.IsPoly(id)
1989 ## Returns true if the given element is quadratic
1990 # @ingroup l1_meshinfo
1991 def IsQuadratic(self, id):
1992 return self.mesh.IsQuadratic(id)
1994 ## Returns XYZ coordinates of the barycenter of the given element
1995 # \n If there is no element for the given ID - returns an empty list
1996 # @return a list of three double values
1997 # @ingroup l1_meshinfo
1998 def BaryCenter(self, id):
1999 return self.mesh.BaryCenter(id)
2002 # Mesh edition (SMESH_MeshEditor functionality):
2003 # ---------------------------------------------
2005 ## Removes the elements from the mesh by ids
2006 # @param IDsOfElements is a list of ids of elements to remove
2007 # @return True or False
2008 # @ingroup l2_modif_del
2009 def RemoveElements(self, IDsOfElements):
2010 return self.editor.RemoveElements(IDsOfElements)
2012 ## Removes nodes from mesh by ids
2013 # @param IDsOfNodes is a list of ids of nodes to remove
2014 # @return True or False
2015 # @ingroup l2_modif_del
2016 def RemoveNodes(self, IDsOfNodes):
2017 return self.editor.RemoveNodes(IDsOfNodes)
2019 ## Add a node to the mesh by coordinates
2020 # @return Id of the new node
2021 # @ingroup l2_modif_add
2022 def AddNode(self, x, y, z):
2023 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2024 self.mesh.SetParameters(Parameters)
2025 return self.editor.AddNode( x, y, z)
2027 ## Creates a 0D element on a node with given number.
2028 # @param IDOfNode the ID of node for creation of the element.
2029 # @return the Id of the new 0D element
2030 # @ingroup l2_modif_add
2031 def Add0DElement(self, IDOfNode):
2032 return self.editor.Add0DElement(IDOfNode)
2034 ## Creates a linear or quadratic edge (this is determined
2035 # by the number of given nodes).
2036 # @param IDsOfNodes the list of node IDs for creation of the element.
2037 # The order of nodes in this list should correspond to the description
2038 # of MED. \n This description is located by the following link:
2039 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2040 # @return the Id of the new edge
2041 # @ingroup l2_modif_add
2042 def AddEdge(self, IDsOfNodes):
2043 return self.editor.AddEdge(IDsOfNodes)
2045 ## Creates a linear or quadratic face (this is determined
2046 # by the number of given nodes).
2047 # @param IDsOfNodes the list of node IDs for creation of the element.
2048 # The order of nodes in this list should correspond to the description
2049 # of MED. \n This description is located by the following link:
2050 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2051 # @return the Id of the new face
2052 # @ingroup l2_modif_add
2053 def AddFace(self, IDsOfNodes):
2054 return self.editor.AddFace(IDsOfNodes)
2056 ## Adds a polygonal face to the mesh by the list of node IDs
2057 # @param IdsOfNodes the list of node IDs for creation of the element.
2058 # @return the Id of the new face
2059 # @ingroup l2_modif_add
2060 def AddPolygonalFace(self, IdsOfNodes):
2061 return self.editor.AddPolygonalFace(IdsOfNodes)
2063 ## Creates both simple and quadratic volume (this is determined
2064 # by the number of given nodes).
2065 # @param IDsOfNodes the list of node IDs for creation of the element.
2066 # The order of nodes in this list should correspond to the description
2067 # of MED. \n This description is located by the following link:
2068 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2069 # @return the Id of the new volumic element
2070 # @ingroup l2_modif_add
2071 def AddVolume(self, IDsOfNodes):
2072 return self.editor.AddVolume(IDsOfNodes)
2074 ## Creates a volume of many faces, giving nodes for each face.
2075 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2076 # @param Quantities the list of integer values, Quantities[i]
2077 # gives the quantity of nodes in face number i.
2078 # @return the Id of the new volumic element
2079 # @ingroup l2_modif_add
2080 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2081 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2083 ## Creates a volume of many faces, giving the IDs of the existing faces.
2084 # @param IdsOfFaces the list of face IDs for volume creation.
2086 # Note: The created volume will refer only to the nodes
2087 # of the given faces, not to the faces themselves.
2088 # @return the Id of the new volumic element
2089 # @ingroup l2_modif_add
2090 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2091 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2094 ## @brief Binds a node to a vertex
2095 # @param NodeID a node ID
2096 # @param Vertex a vertex or vertex ID
2097 # @return True if succeed else raises an exception
2098 # @ingroup l2_modif_add
2099 def SetNodeOnVertex(self, NodeID, Vertex):
2100 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2101 VertexID = Vertex.GetSubShapeIndices()[0]
2105 self.editor.SetNodeOnVertex(NodeID, VertexID)
2106 except SALOME.SALOME_Exception, inst:
2107 raise ValueError, inst.details.text
2111 ## @brief Stores the node position on an edge
2112 # @param NodeID a node ID
2113 # @param Edge an edge or edge ID
2114 # @param paramOnEdge a parameter on the edge where the node is located
2115 # @return True if succeed else raises an exception
2116 # @ingroup l2_modif_add
2117 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2118 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2119 EdgeID = Edge.GetSubShapeIndices()[0]
2123 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2124 except SALOME.SALOME_Exception, inst:
2125 raise ValueError, inst.details.text
2128 ## @brief Stores node position on a face
2129 # @param NodeID a node ID
2130 # @param Face a face or face ID
2131 # @param u U parameter on the face where the node is located
2132 # @param v V parameter on the face where the node is located
2133 # @return True if succeed else raises an exception
2134 # @ingroup l2_modif_add
2135 def SetNodeOnFace(self, NodeID, Face, u, v):
2136 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2137 FaceID = Face.GetSubShapeIndices()[0]
2141 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2142 except SALOME.SALOME_Exception, inst:
2143 raise ValueError, inst.details.text
2146 ## @brief Binds a node to a solid
2147 # @param NodeID a node ID
2148 # @param Solid a solid or solid ID
2149 # @return True if succeed else raises an exception
2150 # @ingroup l2_modif_add
2151 def SetNodeInVolume(self, NodeID, Solid):
2152 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2153 SolidID = Solid.GetSubShapeIndices()[0]
2157 self.editor.SetNodeInVolume(NodeID, SolidID)
2158 except SALOME.SALOME_Exception, inst:
2159 raise ValueError, inst.details.text
2162 ## @brief Bind an element to a shape
2163 # @param ElementID an element ID
2164 # @param Shape a shape or shape ID
2165 # @return True if succeed else raises an exception
2166 # @ingroup l2_modif_add
2167 def SetMeshElementOnShape(self, ElementID, Shape):
2168 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2169 ShapeID = Shape.GetSubShapeIndices()[0]
2173 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2174 except SALOME.SALOME_Exception, inst:
2175 raise ValueError, inst.details.text
2179 ## Moves the node with the given id
2180 # @param NodeID the id of the node
2181 # @param x a new X coordinate
2182 # @param y a new Y coordinate
2183 # @param z a new Z coordinate
2184 # @return True if succeed else False
2185 # @ingroup l2_modif_movenode
2186 def MoveNode(self, NodeID, x, y, z):
2187 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2188 self.mesh.SetParameters(Parameters)
2189 return self.editor.MoveNode(NodeID, x, y, z)
2191 ## Finds the node closest to a point and moves it to a point location
2192 # @param x the X coordinate of a point
2193 # @param y the Y coordinate of a point
2194 # @param z the Z coordinate of a point
2195 # @param NodeID if specified (>0), the node with this ID is moved,
2196 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2197 # @return the ID of a node
2198 # @ingroup l2_modif_throughp
2199 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2200 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2201 self.mesh.SetParameters(Parameters)
2202 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2204 ## Finds the node closest to a point
2205 # @param x the X coordinate of a point
2206 # @param y the Y coordinate of a point
2207 # @param z the Z coordinate of a point
2208 # @return the ID of a node
2209 # @ingroup l2_modif_throughp
2210 def FindNodeClosestTo(self, x, y, z):
2211 #preview = self.mesh.GetMeshEditPreviewer()
2212 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2213 return self.editor.FindNodeClosestTo(x, y, z)
2215 ## Finds the elements where a point lays IN or ON
2216 # @param x the X coordinate of a point
2217 # @param y the Y coordinate of a point
2218 # @param z the Z coordinate of a point
2219 # @param elementType type of elements to find (SMESH.ALL type
2220 # means elements of any type excluding nodes and 0D elements)
2221 # @return list of IDs of found elements
2222 # @ingroup l2_modif_throughp
2223 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2224 return self.editor.FindElementsByPoint(x, y, z, elementType)
2227 ## Finds the node closest to a point and moves it to a point location
2228 # @param x the X coordinate of a point
2229 # @param y the Y coordinate of a point
2230 # @param z the Z coordinate of a point
2231 # @return the ID of a moved node
2232 # @ingroup l2_modif_throughp
2233 def MeshToPassThroughAPoint(self, x, y, z):
2234 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2236 ## Replaces two neighbour triangles sharing Node1-Node2 link
2237 # with the triangles built on the same 4 nodes but having other common link.
2238 # @param NodeID1 the ID of the first node
2239 # @param NodeID2 the ID of the second node
2240 # @return false if proper faces were not found
2241 # @ingroup l2_modif_invdiag
2242 def InverseDiag(self, NodeID1, NodeID2):
2243 return self.editor.InverseDiag(NodeID1, NodeID2)
2245 ## Replaces two neighbour triangles sharing Node1-Node2 link
2246 # with a quadrangle built on the same 4 nodes.
2247 # @param NodeID1 the ID of the first node
2248 # @param NodeID2 the ID of the second node
2249 # @return false if proper faces were not found
2250 # @ingroup l2_modif_unitetri
2251 def DeleteDiag(self, NodeID1, NodeID2):
2252 return self.editor.DeleteDiag(NodeID1, NodeID2)
2254 ## Reorients elements by ids
2255 # @param IDsOfElements if undefined reorients all mesh elements
2256 # @return True if succeed else False
2257 # @ingroup l2_modif_changori
2258 def Reorient(self, IDsOfElements=None):
2259 if IDsOfElements == None:
2260 IDsOfElements = self.GetElementsId()
2261 return self.editor.Reorient(IDsOfElements)
2263 ## Reorients all elements of the object
2264 # @param theObject mesh, submesh or group
2265 # @return True if succeed else False
2266 # @ingroup l2_modif_changori
2267 def ReorientObject(self, theObject):
2268 if ( isinstance( theObject, Mesh )):
2269 theObject = theObject.GetMesh()
2270 return self.editor.ReorientObject(theObject)
2272 ## Fuses the neighbouring triangles into quadrangles.
2273 # @param IDsOfElements The triangles to be fused,
2274 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2275 # @param MaxAngle is the maximum angle between element normals at which the fusion
2276 # is still performed; theMaxAngle is mesured in radians.
2277 # Also it could be a name of variable which defines angle in degrees.
2278 # @return TRUE in case of success, FALSE otherwise.
2279 # @ingroup l2_modif_unitetri
2280 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2282 if isinstance(MaxAngle,str):
2284 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2286 MaxAngle = DegreesToRadians(MaxAngle)
2287 if IDsOfElements == []:
2288 IDsOfElements = self.GetElementsId()
2289 self.mesh.SetParameters(Parameters)
2291 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2292 Functor = theCriterion
2294 Functor = self.smeshpyD.GetFunctor(theCriterion)
2295 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2297 ## Fuses the neighbouring triangles of the object into quadrangles
2298 # @param theObject is mesh, submesh or group
2299 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2300 # @param MaxAngle a max angle between element normals at which the fusion
2301 # is still performed; theMaxAngle is mesured in radians.
2302 # @return TRUE in case of success, FALSE otherwise.
2303 # @ingroup l2_modif_unitetri
2304 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2305 if ( isinstance( theObject, Mesh )):
2306 theObject = theObject.GetMesh()
2307 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2309 ## Splits quadrangles into triangles.
2310 # @param IDsOfElements the faces to be splitted.
2311 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2312 # @return TRUE in case of success, FALSE otherwise.
2313 # @ingroup l2_modif_cutquadr
2314 def QuadToTri (self, IDsOfElements, theCriterion):
2315 if IDsOfElements == []:
2316 IDsOfElements = self.GetElementsId()
2317 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2319 ## Splits quadrangles into triangles.
2320 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2321 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2322 # @return TRUE in case of success, FALSE otherwise.
2323 # @ingroup l2_modif_cutquadr
2324 def QuadToTriObject (self, theObject, theCriterion):
2325 if ( isinstance( theObject, Mesh )):
2326 theObject = theObject.GetMesh()
2327 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2329 ## Splits quadrangles into triangles.
2330 # @param IDsOfElements the faces to be splitted
2331 # @param Diag13 is used to choose a diagonal for splitting.
2332 # @return TRUE in case of success, FALSE otherwise.
2333 # @ingroup l2_modif_cutquadr
2334 def SplitQuad (self, IDsOfElements, Diag13):
2335 if IDsOfElements == []:
2336 IDsOfElements = self.GetElementsId()
2337 return self.editor.SplitQuad(IDsOfElements, Diag13)
2339 ## Splits quadrangles into triangles.
2340 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2341 # @param Diag13 is used to choose a diagonal for splitting.
2342 # @return TRUE in case of success, FALSE otherwise.
2343 # @ingroup l2_modif_cutquadr
2344 def SplitQuadObject (self, theObject, Diag13):
2345 if ( isinstance( theObject, Mesh )):
2346 theObject = theObject.GetMesh()
2347 return self.editor.SplitQuadObject(theObject, Diag13)
2349 ## Finds a better splitting of the given quadrangle.
2350 # @param IDOfQuad the ID of the quadrangle to be splitted.
2351 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2352 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2353 # diagonal is better, 0 if error occurs.
2354 # @ingroup l2_modif_cutquadr
2355 def BestSplit (self, IDOfQuad, theCriterion):
2356 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2358 ## Splits quadrangle faces near triangular facets of volumes
2360 # @ingroup l1_auxiliary
2361 def SplitQuadsNearTriangularFacets(self):
2362 faces_array = self.GetElementsByType(SMESH.FACE)
2363 for face_id in faces_array:
2364 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2365 quad_nodes = self.mesh.GetElemNodes(face_id)
2366 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2367 isVolumeFound = False
2368 for node1_elem in node1_elems:
2369 if not isVolumeFound:
2370 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2371 nb_nodes = self.GetElemNbNodes(node1_elem)
2372 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2373 volume_elem = node1_elem
2374 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2375 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2376 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2377 isVolumeFound = True
2378 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2379 self.SplitQuad([face_id], False) # diagonal 2-4
2380 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2381 isVolumeFound = True
2382 self.SplitQuad([face_id], True) # diagonal 1-3
2383 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2384 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2385 isVolumeFound = True
2386 self.SplitQuad([face_id], True) # diagonal 1-3
2388 ## @brief Splits hexahedrons into tetrahedrons.
2390 # This operation uses pattern mapping functionality for splitting.
2391 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2392 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2393 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2394 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2395 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2396 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2397 # @return TRUE in case of success, FALSE otherwise.
2398 # @ingroup l1_auxiliary
2399 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2400 # Pattern: 5.---------.6
2405 # (0,0,1) 4.---------.7 * |
2412 # (0,0,0) 0.---------.3
2413 pattern_tetra = "!!! Nb of points: \n 8 \n\
2423 !!! Indices of points of 6 tetras: \n\
2431 pattern = self.smeshpyD.GetPattern()
2432 isDone = pattern.LoadFromFile(pattern_tetra)
2434 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2437 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2438 isDone = pattern.MakeMesh(self.mesh, False, False)
2439 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2441 # split quafrangle faces near triangular facets of volumes
2442 self.SplitQuadsNearTriangularFacets()
2446 ## @brief Split hexahedrons into prisms.
2448 # Uses the pattern mapping functionality for splitting.
2449 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2450 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2451 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2452 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2453 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2454 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2455 # @return TRUE in case of success, FALSE otherwise.
2456 # @ingroup l1_auxiliary
2457 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2458 # Pattern: 5.---------.6
2463 # (0,0,1) 4.---------.7 |
2470 # (0,0,0) 0.---------.3
2471 pattern_prism = "!!! Nb of points: \n 8 \n\
2481 !!! Indices of points of 2 prisms: \n\
2485 pattern = self.smeshpyD.GetPattern()
2486 isDone = pattern.LoadFromFile(pattern_prism)
2488 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2491 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2492 isDone = pattern.MakeMesh(self.mesh, False, False)
2493 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2495 # Splits quafrangle faces near triangular facets of volumes
2496 self.SplitQuadsNearTriangularFacets()
2500 ## Smoothes elements
2501 # @param IDsOfElements the list if ids of elements to smooth
2502 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2503 # Note that nodes built on edges and boundary nodes are always fixed.
2504 # @param MaxNbOfIterations the maximum number of iterations
2505 # @param MaxAspectRatio varies in range [1.0, inf]
2506 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2507 # @return TRUE in case of success, FALSE otherwise.
2508 # @ingroup l2_modif_smooth
2509 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2510 MaxNbOfIterations, MaxAspectRatio, Method):
2511 if IDsOfElements == []:
2512 IDsOfElements = self.GetElementsId()
2513 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2514 self.mesh.SetParameters(Parameters)
2515 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2516 MaxNbOfIterations, MaxAspectRatio, Method)
2518 ## Smoothes elements which belong to the given object
2519 # @param theObject the object to smooth
2520 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2521 # Note that nodes built on edges and boundary nodes are always fixed.
2522 # @param MaxNbOfIterations the maximum number of iterations
2523 # @param MaxAspectRatio varies in range [1.0, inf]
2524 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2525 # @return TRUE in case of success, FALSE otherwise.
2526 # @ingroup l2_modif_smooth
2527 def SmoothObject(self, theObject, IDsOfFixedNodes,
2528 MaxNbOfIterations, MaxAspectRatio, Method):
2529 if ( isinstance( theObject, Mesh )):
2530 theObject = theObject.GetMesh()
2531 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2532 MaxNbOfIterations, MaxAspectRatio, Method)
2534 ## Parametrically smoothes the given elements
2535 # @param IDsOfElements the list if ids of elements to smooth
2536 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2537 # Note that nodes built on edges and boundary nodes are always fixed.
2538 # @param MaxNbOfIterations the maximum number of iterations
2539 # @param MaxAspectRatio varies in range [1.0, inf]
2540 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2541 # @return TRUE in case of success, FALSE otherwise.
2542 # @ingroup l2_modif_smooth
2543 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2544 MaxNbOfIterations, MaxAspectRatio, Method):
2545 if IDsOfElements == []:
2546 IDsOfElements = self.GetElementsId()
2547 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2548 self.mesh.SetParameters(Parameters)
2549 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2550 MaxNbOfIterations, MaxAspectRatio, Method)
2552 ## Parametrically smoothes the elements which belong to the given object
2553 # @param theObject the object to smooth
2554 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2555 # Note that nodes built on edges and boundary nodes are always fixed.
2556 # @param MaxNbOfIterations the maximum number of iterations
2557 # @param MaxAspectRatio varies in range [1.0, inf]
2558 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2559 # @return TRUE in case of success, FALSE otherwise.
2560 # @ingroup l2_modif_smooth
2561 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2562 MaxNbOfIterations, MaxAspectRatio, Method):
2563 if ( isinstance( theObject, Mesh )):
2564 theObject = theObject.GetMesh()
2565 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2566 MaxNbOfIterations, MaxAspectRatio, Method)
2568 ## Converts the mesh to quadratic, deletes old elements, replacing
2569 # them with quadratic with the same id.
2570 # @ingroup l2_modif_tofromqu
2571 def ConvertToQuadratic(self, theForce3d):
2572 self.editor.ConvertToQuadratic(theForce3d)
2574 ## Converts the mesh from quadratic to ordinary,
2575 # deletes old quadratic elements, \n replacing
2576 # them with ordinary mesh elements with the same id.
2577 # @return TRUE in case of success, FALSE otherwise.
2578 # @ingroup l2_modif_tofromqu
2579 def ConvertFromQuadratic(self):
2580 return self.editor.ConvertFromQuadratic()
2582 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2583 # @return TRUE if operation has been completed successfully, FALSE otherwise
2584 # @ingroup l2_modif_edit
2585 def Make2DMeshFrom3D(self):
2586 return self.editor. Make2DMeshFrom3D()
2588 ## Renumber mesh nodes
2589 # @ingroup l2_modif_renumber
2590 def RenumberNodes(self):
2591 self.editor.RenumberNodes()
2593 ## Renumber mesh elements
2594 # @ingroup l2_modif_renumber
2595 def RenumberElements(self):
2596 self.editor.RenumberElements()
2598 ## Generates new elements by rotation of the elements around the axis
2599 # @param IDsOfElements the list of ids of elements to sweep
2600 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2601 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2602 # @param NbOfSteps the number of steps
2603 # @param Tolerance tolerance
2604 # @param MakeGroups forces the generation of new groups from existing ones
2605 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2606 # of all steps, else - size of each step
2607 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2608 # @ingroup l2_modif_extrurev
2609 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2610 MakeGroups=False, TotalAngle=False):
2612 if isinstance(AngleInRadians,str):
2614 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2616 AngleInRadians = DegreesToRadians(AngleInRadians)
2617 if IDsOfElements == []:
2618 IDsOfElements = self.GetElementsId()
2619 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2620 Axis = self.smeshpyD.GetAxisStruct(Axis)
2621 Axis,AxisParameters = ParseAxisStruct(Axis)
2622 if TotalAngle and NbOfSteps:
2623 AngleInRadians /= NbOfSteps
2624 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2625 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2626 self.mesh.SetParameters(Parameters)
2628 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2629 AngleInRadians, NbOfSteps, Tolerance)
2630 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2633 ## Generates new elements by rotation of the elements of object around the axis
2634 # @param theObject object which elements should be sweeped
2635 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2636 # @param AngleInRadians the angle of Rotation
2637 # @param NbOfSteps number of steps
2638 # @param Tolerance tolerance
2639 # @param MakeGroups forces the generation of new groups from existing ones
2640 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2641 # of all steps, else - size of each step
2642 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2643 # @ingroup l2_modif_extrurev
2644 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2645 MakeGroups=False, TotalAngle=False):
2647 if isinstance(AngleInRadians,str):
2649 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2651 AngleInRadians = DegreesToRadians(AngleInRadians)
2652 if ( isinstance( theObject, Mesh )):
2653 theObject = theObject.GetMesh()
2654 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2655 Axis = self.smeshpyD.GetAxisStruct(Axis)
2656 Axis,AxisParameters = ParseAxisStruct(Axis)
2657 if TotalAngle and NbOfSteps:
2658 AngleInRadians /= NbOfSteps
2659 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2660 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2661 self.mesh.SetParameters(Parameters)
2663 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2664 NbOfSteps, Tolerance)
2665 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2668 ## Generates new elements by rotation of the elements of object around the axis
2669 # @param theObject object which elements should be sweeped
2670 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2671 # @param AngleInRadians the angle of Rotation
2672 # @param NbOfSteps number of steps
2673 # @param Tolerance tolerance
2674 # @param MakeGroups forces the generation of new groups from existing ones
2675 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2676 # of all steps, else - size of each step
2677 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2678 # @ingroup l2_modif_extrurev
2679 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2680 MakeGroups=False, TotalAngle=False):
2682 if isinstance(AngleInRadians,str):
2684 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2686 AngleInRadians = DegreesToRadians(AngleInRadians)
2687 if ( isinstance( theObject, Mesh )):
2688 theObject = theObject.GetMesh()
2689 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2690 Axis = self.smeshpyD.GetAxisStruct(Axis)
2691 Axis,AxisParameters = ParseAxisStruct(Axis)
2692 if TotalAngle and NbOfSteps:
2693 AngleInRadians /= NbOfSteps
2694 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2695 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2696 self.mesh.SetParameters(Parameters)
2698 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2699 NbOfSteps, Tolerance)
2700 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2703 ## Generates new elements by rotation of the elements of object around the axis
2704 # @param theObject object which elements should be sweeped
2705 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2706 # @param AngleInRadians the angle of Rotation
2707 # @param NbOfSteps number of steps
2708 # @param Tolerance tolerance
2709 # @param MakeGroups forces the generation of new groups from existing ones
2710 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2711 # of all steps, else - size of each step
2712 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2713 # @ingroup l2_modif_extrurev
2714 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2715 MakeGroups=False, TotalAngle=False):
2717 if isinstance(AngleInRadians,str):
2719 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2721 AngleInRadians = DegreesToRadians(AngleInRadians)
2722 if ( isinstance( theObject, Mesh )):
2723 theObject = theObject.GetMesh()
2724 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2725 Axis = self.smeshpyD.GetAxisStruct(Axis)
2726 Axis,AxisParameters = ParseAxisStruct(Axis)
2727 if TotalAngle and NbOfSteps:
2728 AngleInRadians /= NbOfSteps
2729 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2730 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2731 self.mesh.SetParameters(Parameters)
2733 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2734 NbOfSteps, Tolerance)
2735 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2738 ## Generates new elements by extrusion of the elements with given ids
2739 # @param IDsOfElements the list of elements ids for extrusion
2740 # @param StepVector vector, defining the direction and value of extrusion
2741 # @param NbOfSteps the number of steps
2742 # @param MakeGroups forces the generation of new groups from existing ones
2743 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2744 # @ingroup l2_modif_extrurev
2745 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2746 if IDsOfElements == []:
2747 IDsOfElements = self.GetElementsId()
2748 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2749 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2750 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2751 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2752 Parameters = StepVectorParameters + var_separator + Parameters
2753 self.mesh.SetParameters(Parameters)
2755 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2756 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2759 ## Generates new elements by extrusion of the elements with given ids
2760 # @param IDsOfElements is ids of elements
2761 # @param StepVector vector, defining the direction and value of extrusion
2762 # @param NbOfSteps the number of steps
2763 # @param ExtrFlags sets flags for extrusion
2764 # @param SewTolerance uses for comparing locations of nodes if flag
2765 # EXTRUSION_FLAG_SEW is set
2766 # @param MakeGroups forces the generation of new groups from existing ones
2767 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2768 # @ingroup l2_modif_extrurev
2769 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2770 ExtrFlags, SewTolerance, MakeGroups=False):
2771 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2772 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2774 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2775 ExtrFlags, SewTolerance)
2776 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2777 ExtrFlags, SewTolerance)
2780 ## Generates new elements by extrusion of the elements which belong to the object
2781 # @param theObject the object which elements should be processed
2782 # @param StepVector vector, defining the direction and value of extrusion
2783 # @param NbOfSteps the number of steps
2784 # @param MakeGroups forces the generation of new groups from existing ones
2785 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2786 # @ingroup l2_modif_extrurev
2787 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2788 if ( isinstance( theObject, Mesh )):
2789 theObject = theObject.GetMesh()
2790 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2791 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2792 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2793 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2794 Parameters = StepVectorParameters + var_separator + Parameters
2795 self.mesh.SetParameters(Parameters)
2797 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2798 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2801 ## Generates new elements by extrusion of the elements which belong to the object
2802 # @param theObject object which elements should be processed
2803 # @param StepVector vector, defining the direction and value of extrusion
2804 # @param NbOfSteps the number of steps
2805 # @param MakeGroups to generate new groups from existing ones
2806 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2807 # @ingroup l2_modif_extrurev
2808 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2809 if ( isinstance( theObject, Mesh )):
2810 theObject = theObject.GetMesh()
2811 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2812 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2813 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2814 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2815 Parameters = StepVectorParameters + var_separator + Parameters
2816 self.mesh.SetParameters(Parameters)
2818 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2819 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2822 ## Generates new elements by extrusion of the elements which belong to the object
2823 # @param theObject object which elements should be processed
2824 # @param StepVector vector, defining the direction and value of extrusion
2825 # @param NbOfSteps the number of steps
2826 # @param MakeGroups forces the generation of new groups from existing ones
2827 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2828 # @ingroup l2_modif_extrurev
2829 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2830 if ( isinstance( theObject, Mesh )):
2831 theObject = theObject.GetMesh()
2832 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2833 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2834 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2835 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2836 Parameters = StepVectorParameters + var_separator + Parameters
2837 self.mesh.SetParameters(Parameters)
2839 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2840 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2845 ## Generates new elements by extrusion of the given elements
2846 # The path of extrusion must be a meshed edge.
2847 # @param Base mesh or list of ids of elements for extrusion
2848 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2849 # @param NodeStart the start node from Path. Defines the direction of extrusion
2850 # @param HasAngles allows the shape to be rotated around the path
2851 # to get the resulting mesh in a helical fashion
2852 # @param Angles list of angles in radians
2853 # @param LinearVariation forces the computation of rotation angles as linear
2854 # variation of the given Angles along path steps
2855 # @param HasRefPoint allows using the reference point
2856 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2857 # The User can specify any point as the Reference Point.
2858 # @param MakeGroups forces the generation of new groups from existing ones
2859 # @param ElemType type of elements for extrusion (if param Base is a mesh)
2860 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2861 # only SMESH::Extrusion_Error otherwise
2862 # @ingroup l2_modif_extrurev
2863 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2864 HasAngles, Angles, LinearVariation,
2865 HasRefPoint, RefPoint, MakeGroups, ElemType):
2866 Angles,AnglesParameters = ParseAngles(Angles)
2867 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2868 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2869 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2871 Parameters = AnglesParameters + var_separator + RefPointParameters
2872 self.mesh.SetParameters(Parameters)
2874 if isinstance(Base,list):
2876 if Base == []: IDsOfElements = self.GetElementsId()
2877 else: IDsOfElements = Base
2878 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2879 HasAngles, Angles, LinearVariation,
2880 HasRefPoint, RefPoint, MakeGroups, ElemType)
2882 if isinstance(Base,Mesh):
2883 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
2884 HasAngles, Angles, LinearVariation,
2885 HasRefPoint, RefPoint, MakeGroups, ElemType)
2887 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2890 ## Generates new elements by extrusion of the given elements
2891 # The path of extrusion must be a meshed edge.
2892 # @param IDsOfElements ids of elements
2893 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2894 # @param PathShape shape(edge) defines the sub-mesh for the path
2895 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2896 # @param HasAngles allows the shape to be rotated around the path
2897 # to get the resulting mesh in a helical fashion
2898 # @param Angles list of angles in radians
2899 # @param HasRefPoint allows using the reference point
2900 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2901 # The User can specify any point as the Reference Point.
2902 # @param MakeGroups forces the generation of new groups from existing ones
2903 # @param LinearVariation forces the computation of rotation angles as linear
2904 # variation of the given Angles along path steps
2905 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2906 # only SMESH::Extrusion_Error otherwise
2907 # @ingroup l2_modif_extrurev
2908 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2909 HasAngles, Angles, HasRefPoint, RefPoint,
2910 MakeGroups=False, LinearVariation=False):
2911 Angles,AnglesParameters = ParseAngles(Angles)
2912 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2913 if IDsOfElements == []:
2914 IDsOfElements = self.GetElementsId()
2915 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2916 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2918 if ( isinstance( PathMesh, Mesh )):
2919 PathMesh = PathMesh.GetMesh()
2920 if HasAngles and Angles and LinearVariation:
2921 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2923 Parameters = AnglesParameters + var_separator + RefPointParameters
2924 self.mesh.SetParameters(Parameters)
2926 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2927 PathShape, NodeStart, HasAngles,
2928 Angles, HasRefPoint, RefPoint)
2929 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2930 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2932 ## Generates new elements by extrusion of the elements which belong to the object
2933 # The path of extrusion must be a meshed edge.
2934 # @param theObject the object which elements should be processed
2935 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2936 # @param PathShape shape(edge) defines the sub-mesh for the path
2937 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2938 # @param HasAngles allows the shape to be rotated around the path
2939 # to get the resulting mesh in a helical fashion
2940 # @param Angles list of angles
2941 # @param HasRefPoint allows using the reference point
2942 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2943 # The User can specify any point as the Reference Point.
2944 # @param MakeGroups forces the generation of new groups from existing ones
2945 # @param LinearVariation forces the computation of rotation angles as linear
2946 # variation of the given Angles along path steps
2947 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2948 # only SMESH::Extrusion_Error otherwise
2949 # @ingroup l2_modif_extrurev
2950 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2951 HasAngles, Angles, HasRefPoint, RefPoint,
2952 MakeGroups=False, LinearVariation=False):
2953 Angles,AnglesParameters = ParseAngles(Angles)
2954 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2955 if ( isinstance( theObject, Mesh )):
2956 theObject = theObject.GetMesh()
2957 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2958 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2959 if ( isinstance( PathMesh, Mesh )):
2960 PathMesh = PathMesh.GetMesh()
2961 if HasAngles and Angles and LinearVariation:
2962 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2964 Parameters = AnglesParameters + var_separator + RefPointParameters
2965 self.mesh.SetParameters(Parameters)
2967 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2968 PathShape, NodeStart, HasAngles,
2969 Angles, HasRefPoint, RefPoint)
2970 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2971 NodeStart, HasAngles, Angles, HasRefPoint,
2974 ## Generates new elements by extrusion of the elements which belong to the object
2975 # The path of extrusion must be a meshed edge.
2976 # @param theObject the object which elements should be processed
2977 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2978 # @param PathShape shape(edge) defines the sub-mesh for the path
2979 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2980 # @param HasAngles allows the shape to be rotated around the path
2981 # to get the resulting mesh in a helical fashion
2982 # @param Angles list of angles
2983 # @param HasRefPoint allows using the reference point
2984 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2985 # The User can specify any point as the Reference Point.
2986 # @param MakeGroups forces the generation of new groups from existing ones
2987 # @param LinearVariation forces the computation of rotation angles as linear
2988 # variation of the given Angles along path steps
2989 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2990 # only SMESH::Extrusion_Error otherwise
2991 # @ingroup l2_modif_extrurev
2992 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
2993 HasAngles, Angles, HasRefPoint, RefPoint,
2994 MakeGroups=False, LinearVariation=False):
2995 Angles,AnglesParameters = ParseAngles(Angles)
2996 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2997 if ( isinstance( theObject, Mesh )):
2998 theObject = theObject.GetMesh()
2999 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3000 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3001 if ( isinstance( PathMesh, Mesh )):
3002 PathMesh = PathMesh.GetMesh()
3003 if HasAngles and Angles and LinearVariation:
3004 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3006 Parameters = AnglesParameters + var_separator + RefPointParameters
3007 self.mesh.SetParameters(Parameters)
3009 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3010 PathShape, NodeStart, HasAngles,
3011 Angles, HasRefPoint, RefPoint)
3012 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3013 NodeStart, HasAngles, Angles, HasRefPoint,
3016 ## Generates new elements by extrusion of the elements which belong to the object
3017 # The path of extrusion must be a meshed edge.
3018 # @param theObject the object which elements should be processed
3019 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3020 # @param PathShape shape(edge) defines the sub-mesh for the path
3021 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3022 # @param HasAngles allows the shape to be rotated around the path
3023 # to get the resulting mesh in a helical fashion
3024 # @param Angles list of angles
3025 # @param HasRefPoint allows using the reference point
3026 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3027 # The User can specify any point as the Reference Point.
3028 # @param MakeGroups forces the generation of new groups from existing ones
3029 # @param LinearVariation forces the computation of rotation angles as linear
3030 # variation of the given Angles along path steps
3031 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3032 # only SMESH::Extrusion_Error otherwise
3033 # @ingroup l2_modif_extrurev
3034 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3035 HasAngles, Angles, HasRefPoint, RefPoint,
3036 MakeGroups=False, LinearVariation=False):
3037 Angles,AnglesParameters = ParseAngles(Angles)
3038 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3039 if ( isinstance( theObject, Mesh )):
3040 theObject = theObject.GetMesh()
3041 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3042 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3043 if ( isinstance( PathMesh, Mesh )):
3044 PathMesh = PathMesh.GetMesh()
3045 if HasAngles and Angles and LinearVariation:
3046 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3048 Parameters = AnglesParameters + var_separator + RefPointParameters
3049 self.mesh.SetParameters(Parameters)
3051 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3052 PathShape, NodeStart, HasAngles,
3053 Angles, HasRefPoint, RefPoint)
3054 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3055 NodeStart, HasAngles, Angles, HasRefPoint,
3058 ## Creates a symmetrical copy of mesh elements
3059 # @param IDsOfElements list of elements ids
3060 # @param Mirror is AxisStruct or geom object(point, line, plane)
3061 # @param theMirrorType is POINT, AXIS or PLANE
3062 # If the Mirror is a geom object this parameter is unnecessary
3063 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
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 Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3068 if IDsOfElements == []:
3069 IDsOfElements = self.GetElementsId()
3070 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3071 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3072 Mirror,Parameters = ParseAxisStruct(Mirror)
3073 self.mesh.SetParameters(Parameters)
3074 if Copy and MakeGroups:
3075 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3076 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3079 ## Creates a new mesh by a symmetrical copy of mesh elements
3080 # @param IDsOfElements the list of elements ids
3081 # @param Mirror is AxisStruct or geom object (point, line, plane)
3082 # @param theMirrorType is POINT, AXIS or PLANE
3083 # If the Mirror is a geom object this parameter is unnecessary
3084 # @param MakeGroups to generate new groups from existing ones
3085 # @param NewMeshName a name of the new mesh to create
3086 # @return instance of Mesh class
3087 # @ingroup l2_modif_trsf
3088 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3089 if IDsOfElements == []:
3090 IDsOfElements = self.GetElementsId()
3091 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3092 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3093 Mirror,Parameters = ParseAxisStruct(Mirror)
3094 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3095 MakeGroups, NewMeshName)
3096 mesh.SetParameters(Parameters)
3097 return Mesh(self.smeshpyD,self.geompyD,mesh)
3099 ## Creates a symmetrical copy of the object
3100 # @param theObject mesh, submesh or group
3101 # @param Mirror AxisStruct or geom object (point, line, plane)
3102 # @param theMirrorType is POINT, AXIS or PLANE
3103 # If the Mirror is a geom object this parameter is unnecessary
3104 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3105 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3106 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3107 # @ingroup l2_modif_trsf
3108 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3109 if ( isinstance( theObject, Mesh )):
3110 theObject = theObject.GetMesh()
3111 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3112 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3113 Mirror,Parameters = ParseAxisStruct(Mirror)
3114 self.mesh.SetParameters(Parameters)
3115 if Copy and MakeGroups:
3116 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3117 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3120 ## Creates a new mesh by a symmetrical copy of the object
3121 # @param theObject mesh, submesh or group
3122 # @param Mirror AxisStruct or geom object (point, line, plane)
3123 # @param theMirrorType POINT, AXIS or PLANE
3124 # If the Mirror is a geom object this parameter is unnecessary
3125 # @param MakeGroups forces the generation of new groups from existing ones
3126 # @param NewMeshName the name of the new mesh to create
3127 # @return instance of Mesh class
3128 # @ingroup l2_modif_trsf
3129 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3130 if ( isinstance( theObject, Mesh )):
3131 theObject = theObject.GetMesh()
3132 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3133 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3134 Mirror,Parameters = ParseAxisStruct(Mirror)
3135 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3136 MakeGroups, NewMeshName)
3137 mesh.SetParameters(Parameters)
3138 return Mesh( self.smeshpyD,self.geompyD,mesh )
3140 ## Translates the elements
3141 # @param IDsOfElements list of elements ids
3142 # @param Vector the direction of translation (DirStruct or vector)
3143 # @param Copy allows copying the translated elements
3144 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3145 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3146 # @ingroup l2_modif_trsf
3147 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3148 if IDsOfElements == []:
3149 IDsOfElements = self.GetElementsId()
3150 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3151 Vector = self.smeshpyD.GetDirStruct(Vector)
3152 Vector,Parameters = ParseDirStruct(Vector)
3153 self.mesh.SetParameters(Parameters)
3154 if Copy and MakeGroups:
3155 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3156 self.editor.Translate(IDsOfElements, Vector, Copy)
3159 ## Creates a new mesh of translated elements
3160 # @param IDsOfElements list of elements ids
3161 # @param Vector the direction of translation (DirStruct or vector)
3162 # @param MakeGroups forces the generation of new groups from existing ones
3163 # @param NewMeshName the name of the newly created mesh
3164 # @return instance of Mesh class
3165 # @ingroup l2_modif_trsf
3166 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3167 if IDsOfElements == []:
3168 IDsOfElements = self.GetElementsId()
3169 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3170 Vector = self.smeshpyD.GetDirStruct(Vector)
3171 Vector,Parameters = ParseDirStruct(Vector)
3172 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3173 mesh.SetParameters(Parameters)
3174 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3176 ## Translates the object
3177 # @param theObject the object to translate (mesh, submesh, or group)
3178 # @param Vector direction of translation (DirStruct or geom vector)
3179 # @param Copy allows copying the translated elements
3180 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3181 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3182 # @ingroup l2_modif_trsf
3183 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3184 if ( isinstance( theObject, Mesh )):
3185 theObject = theObject.GetMesh()
3186 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3187 Vector = self.smeshpyD.GetDirStruct(Vector)
3188 Vector,Parameters = ParseDirStruct(Vector)
3189 self.mesh.SetParameters(Parameters)
3190 if Copy and MakeGroups:
3191 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3192 self.editor.TranslateObject(theObject, Vector, Copy)
3195 ## Creates a new mesh from the translated object
3196 # @param theObject the object to translate (mesh, submesh, or group)
3197 # @param Vector the direction of translation (DirStruct or geom vector)
3198 # @param MakeGroups forces the generation of new groups from existing ones
3199 # @param NewMeshName the name of the newly created mesh
3200 # @return instance of Mesh class
3201 # @ingroup l2_modif_trsf
3202 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3203 if (isinstance(theObject, Mesh)):
3204 theObject = theObject.GetMesh()
3205 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3206 Vector = self.smeshpyD.GetDirStruct(Vector)
3207 Vector,Parameters = ParseDirStruct(Vector)
3208 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3209 mesh.SetParameters(Parameters)
3210 return Mesh( self.smeshpyD, self.geompyD, mesh )
3212 ## Rotates the elements
3213 # @param IDsOfElements list of elements ids
3214 # @param Axis the axis of rotation (AxisStruct or geom line)
3215 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3216 # @param Copy allows copying the rotated elements
3217 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3218 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3219 # @ingroup l2_modif_trsf
3220 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3222 if isinstance(AngleInRadians,str):
3224 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3226 AngleInRadians = DegreesToRadians(AngleInRadians)
3227 if IDsOfElements == []:
3228 IDsOfElements = self.GetElementsId()
3229 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3230 Axis = self.smeshpyD.GetAxisStruct(Axis)
3231 Axis,AxisParameters = ParseAxisStruct(Axis)
3232 Parameters = AxisParameters + var_separator + Parameters
3233 self.mesh.SetParameters(Parameters)
3234 if Copy and MakeGroups:
3235 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3236 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3239 ## Creates a new mesh of rotated elements
3240 # @param IDsOfElements list of element ids
3241 # @param Axis the axis of rotation (AxisStruct or geom line)
3242 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3243 # @param MakeGroups forces the generation of new groups from existing ones
3244 # @param NewMeshName the name of the newly created mesh
3245 # @return instance of Mesh class
3246 # @ingroup l2_modif_trsf
3247 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3249 if isinstance(AngleInRadians,str):
3251 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3253 AngleInRadians = DegreesToRadians(AngleInRadians)
3254 if IDsOfElements == []:
3255 IDsOfElements = self.GetElementsId()
3256 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3257 Axis = self.smeshpyD.GetAxisStruct(Axis)
3258 Axis,AxisParameters = ParseAxisStruct(Axis)
3259 Parameters = AxisParameters + var_separator + Parameters
3260 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3261 MakeGroups, NewMeshName)
3262 mesh.SetParameters(Parameters)
3263 return Mesh( self.smeshpyD, self.geompyD, mesh )
3265 ## Rotates the object
3266 # @param theObject the object to rotate( mesh, submesh, or group)
3267 # @param Axis the axis of rotation (AxisStruct or geom line)
3268 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3269 # @param Copy allows copying the rotated elements
3270 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3271 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3272 # @ingroup l2_modif_trsf
3273 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3275 if isinstance(AngleInRadians,str):
3277 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3279 AngleInRadians = DegreesToRadians(AngleInRadians)
3280 if (isinstance(theObject, Mesh)):
3281 theObject = theObject.GetMesh()
3282 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3283 Axis = self.smeshpyD.GetAxisStruct(Axis)
3284 Axis,AxisParameters = ParseAxisStruct(Axis)
3285 Parameters = AxisParameters + ":" + Parameters
3286 self.mesh.SetParameters(Parameters)
3287 if Copy and MakeGroups:
3288 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3289 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3292 ## Creates a new mesh from the rotated object
3293 # @param theObject the object to rotate (mesh, submesh, or group)
3294 # @param Axis the axis of rotation (AxisStruct or geom line)
3295 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3296 # @param MakeGroups forces the generation of new groups from existing ones
3297 # @param NewMeshName the name of the newly created mesh
3298 # @return instance of Mesh class
3299 # @ingroup l2_modif_trsf
3300 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3302 if isinstance(AngleInRadians,str):
3304 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3306 AngleInRadians = DegreesToRadians(AngleInRadians)
3307 if (isinstance( theObject, Mesh )):
3308 theObject = theObject.GetMesh()
3309 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3310 Axis = self.smeshpyD.GetAxisStruct(Axis)
3311 Axis,AxisParameters = ParseAxisStruct(Axis)
3312 Parameters = AxisParameters + ":" + Parameters
3313 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3314 MakeGroups, NewMeshName)
3315 mesh.SetParameters(Parameters)
3316 return Mesh( self.smeshpyD, self.geompyD, mesh )
3318 ## Finds groups of ajacent nodes within Tolerance.
3319 # @param Tolerance the value of tolerance
3320 # @return the list of groups of nodes
3321 # @ingroup l2_modif_trsf
3322 def FindCoincidentNodes (self, Tolerance):
3323 return self.editor.FindCoincidentNodes(Tolerance)
3325 ## Finds groups of ajacent nodes within Tolerance.
3326 # @param Tolerance the value of tolerance
3327 # @param SubMeshOrGroup SubMesh or Group
3328 # @return the list of groups of nodes
3329 # @ingroup l2_modif_trsf
3330 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3331 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3334 # @param GroupsOfNodes the list of groups of nodes
3335 # @ingroup l2_modif_trsf
3336 def MergeNodes (self, GroupsOfNodes):
3337 self.editor.MergeNodes(GroupsOfNodes)
3339 ## Finds the elements built on the same nodes.
3340 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3341 # @return a list of groups of equal elements
3342 # @ingroup l2_modif_trsf
3343 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3344 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3345 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3346 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3348 ## Merges elements in each given group.
3349 # @param GroupsOfElementsID groups of elements for merging
3350 # @ingroup l2_modif_trsf
3351 def MergeElements(self, GroupsOfElementsID):
3352 self.editor.MergeElements(GroupsOfElementsID)
3354 ## Leaves one element and removes all other elements built on the same nodes.
3355 # @ingroup l2_modif_trsf
3356 def MergeEqualElements(self):
3357 self.editor.MergeEqualElements()
3359 ## Sews free borders
3360 # @return SMESH::Sew_Error
3361 # @ingroup l2_modif_trsf
3362 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3363 FirstNodeID2, SecondNodeID2, LastNodeID2,
3364 CreatePolygons, CreatePolyedrs):
3365 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3366 FirstNodeID2, SecondNodeID2, LastNodeID2,
3367 CreatePolygons, CreatePolyedrs)
3369 ## Sews conform free borders
3370 # @return SMESH::Sew_Error
3371 # @ingroup l2_modif_trsf
3372 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3373 FirstNodeID2, SecondNodeID2):
3374 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3375 FirstNodeID2, SecondNodeID2)
3377 ## Sews border to side
3378 # @return SMESH::Sew_Error
3379 # @ingroup l2_modif_trsf
3380 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3381 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3382 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3383 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3385 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3386 # merged with the nodes of elements of Side2.
3387 # The number of elements in theSide1 and in theSide2 must be
3388 # equal and they should have similar nodal connectivity.
3389 # The nodes to merge should belong to side borders and
3390 # the first node should be linked to the second.
3391 # @return SMESH::Sew_Error
3392 # @ingroup l2_modif_trsf
3393 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3394 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3395 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3396 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3397 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3398 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3400 ## Sets new nodes for the given element.
3401 # @param ide the element id
3402 # @param newIDs nodes ids
3403 # @return If the number of nodes does not correspond to the type of element - returns false
3404 # @ingroup l2_modif_edit
3405 def ChangeElemNodes(self, ide, newIDs):
3406 return self.editor.ChangeElemNodes(ide, newIDs)
3408 ## If during the last operation of MeshEditor some nodes were
3409 # created, this method returns the list of their IDs, \n
3410 # if new nodes were not created - returns empty list
3411 # @return the list of integer values (can be empty)
3412 # @ingroup l1_auxiliary
3413 def GetLastCreatedNodes(self):
3414 return self.editor.GetLastCreatedNodes()
3416 ## If during the last operation of MeshEditor some elements were
3417 # created this method returns the list of their IDs, \n
3418 # if new elements were not created - returns empty list
3419 # @return the list of integer values (can be empty)
3420 # @ingroup l1_auxiliary
3421 def GetLastCreatedElems(self):
3422 return self.editor.GetLastCreatedElems()
3424 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3425 # @param theNodes identifiers of nodes to be doubled
3426 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3427 # nodes. If list of element identifiers is empty then nodes are doubled but
3428 # they not assigned to elements
3429 # @return TRUE if operation has been completed successfully, FALSE otherwise
3430 # @ingroup l2_modif_edit
3431 def DoubleNodes(self, theNodes, theModifiedElems):
3432 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3434 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3435 # This method provided for convenience works as DoubleNodes() described above.
3436 # @param theNodes identifiers of node to be doubled
3437 # @param theModifiedElems identifiers of elements to be updated
3438 # @return TRUE if operation has been completed successfully, FALSE otherwise
3439 # @ingroup l2_modif_edit
3440 def DoubleNode(self, theNodeId, theModifiedElems):
3441 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3443 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3444 # This method provided for convenience works as DoubleNodes() described above.
3445 # @param theNodes group of nodes to be doubled
3446 # @param theModifiedElems group of elements to be updated.
3447 # @return TRUE if operation has been completed successfully, FALSE otherwise
3448 # @ingroup l2_modif_edit
3449 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3450 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3452 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3453 # This method provided for convenience works as DoubleNodes() described above.
3454 # @param theNodes list of groups of nodes to be doubled
3455 # @param theModifiedElems list of groups of elements to be updated.
3456 # @return TRUE if operation has been completed successfully, FALSE otherwise
3457 # @ingroup l2_modif_edit
3458 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3459 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3461 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3462 # @param theElems - the list of elements (edges or faces) to be replicated
3463 # The nodes for duplication could be found from these elements
3464 # @param theNodesNot - list of nodes to NOT replicate
3465 # @param theAffectedElems - the list of elements (cells and edges) to which the
3466 # replicated nodes should be associated to.
3467 # @return TRUE if operation has been completed successfully, FALSE otherwise
3468 # @ingroup l2_modif_edit
3469 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3470 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3472 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3473 # @param theElems - the list of elements (edges or faces) to be replicated
3474 # The nodes for duplication could be found from these elements
3475 # @param theNodesNot - list of nodes to NOT replicate
3476 # @param theShape - shape to detect affected elements (element which geometric center
3477 # located on or inside shape).
3478 # The replicated nodes should be associated to affected elements.
3479 # @return TRUE if operation has been completed successfully, FALSE otherwise
3480 # @ingroup l2_modif_edit
3481 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3482 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3484 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3485 # This method provided for convenience works as DoubleNodes() described above.
3486 # @param theElems - group of of elements (edges or faces) to be replicated
3487 # @param theNodesNot - group of nodes not to replicated
3488 # @param theAffectedElems - group of elements to which the replicated nodes
3489 # should be associated to.
3490 # @ingroup l2_modif_edit
3491 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
3492 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3494 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3495 # This method provided for convenience works as DoubleNodes() described above.
3496 # @param theElems - group of of elements (edges or faces) to be replicated
3497 # @param theNodesNot - group of nodes not to replicated
3498 # @param theShape - shape to detect affected elements (element which geometric center
3499 # located on or inside shape).
3500 # The replicated nodes should be associated to affected elements.
3501 # @ingroup l2_modif_edit
3502 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3503 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theShape)
3505 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3506 # This method provided for convenience works as DoubleNodes() described above.
3507 # @param theElems - list of groups of elements (edges or faces) to be replicated
3508 # @param theNodesNot - list of groups of nodes not to replicated
3509 # @param theAffectedElems - group of elements to which the replicated nodes
3510 # should be associated to.
3511 # @return TRUE if operation has been completed successfully, FALSE otherwise
3512 # @ingroup l2_modif_edit
3513 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3514 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3516 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3517 # This method provided for convenience works as DoubleNodes() described above.
3518 # @param theElems - list of groups of elements (edges or faces) to be replicated
3519 # @param theNodesNot - list of groups of nodes not to replicated
3520 # @param theShape - shape to detect affected elements (element which geometric center
3521 # located on or inside shape).
3522 # The replicated nodes should be associated to affected elements.
3523 # @return TRUE if operation has been completed successfully, FALSE otherwise
3524 # @ingroup l2_modif_edit
3525 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3526 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3528 ## The mother class to define algorithm, it is not recommended to use it directly.
3531 # @ingroup l2_algorithms
3532 class Mesh_Algorithm:
3533 # @class Mesh_Algorithm
3534 # @brief Class Mesh_Algorithm
3536 #def __init__(self,smesh):
3544 ## Finds a hypothesis in the study by its type name and parameters.
3545 # Finds only the hypotheses created in smeshpyD engine.
3546 # @return SMESH.SMESH_Hypothesis
3547 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3548 study = smeshpyD.GetCurrentStudy()
3549 #to do: find component by smeshpyD object, not by its data type
3550 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3551 if scomp is not None:
3552 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3553 # Check if the root label of the hypotheses exists
3554 if res and hypRoot is not None:
3555 iter = study.NewChildIterator(hypRoot)
3556 # Check all published hypotheses
3558 hypo_so_i = iter.Value()
3559 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3560 if attr is not None:
3561 anIOR = attr.Value()
3562 hypo_o_i = salome.orb.string_to_object(anIOR)
3563 if hypo_o_i is not None:
3564 # Check if this is a hypothesis
3565 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3566 if hypo_i is not None:
3567 # Check if the hypothesis belongs to current engine
3568 if smeshpyD.GetObjectId(hypo_i) > 0:
3569 # Check if this is the required hypothesis
3570 if hypo_i.GetName() == hypname:
3572 if CompareMethod(hypo_i, args):
3586 ## Finds the algorithm in the study by its type name.
3587 # Finds only the algorithms, which have been created in smeshpyD engine.
3588 # @return SMESH.SMESH_Algo
3589 def FindAlgorithm (self, algoname, smeshpyD):
3590 study = smeshpyD.GetCurrentStudy()
3591 #to do: find component by smeshpyD object, not by its data type
3592 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3593 if scomp is not None:
3594 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3595 # Check if the root label of the algorithms exists
3596 if res and hypRoot is not None:
3597 iter = study.NewChildIterator(hypRoot)
3598 # Check all published algorithms
3600 algo_so_i = iter.Value()
3601 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3602 if attr is not None:
3603 anIOR = attr.Value()
3604 algo_o_i = salome.orb.string_to_object(anIOR)
3605 if algo_o_i is not None:
3606 # Check if this is an algorithm
3607 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3608 if algo_i is not None:
3609 # Checks if the algorithm belongs to the current engine
3610 if smeshpyD.GetObjectId(algo_i) > 0:
3611 # Check if this is the required algorithm
3612 if algo_i.GetName() == algoname:
3625 ## If the algorithm is global, returns 0; \n
3626 # else returns the submesh associated to this algorithm.
3627 def GetSubMesh(self):
3630 ## Returns the wrapped mesher.
3631 def GetAlgorithm(self):
3634 ## Gets the list of hypothesis that can be used with this algorithm
3635 def GetCompatibleHypothesis(self):
3638 mylist = self.algo.GetCompatibleHypothesis()
3641 ## Gets the name of the algorithm
3645 ## Sets the name to the algorithm
3646 def SetName(self, name):
3647 self.mesh.smeshpyD.SetName(self.algo, name)
3649 ## Gets the id of the algorithm
3651 return self.algo.GetId()
3654 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3656 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3657 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3659 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3661 self.Assign(algo, mesh, geom)
3665 def Assign(self, algo, mesh, geom):
3667 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3674 name = GetName(geom)
3676 name = mesh.geompyD.SubShapeName(geom, piece)
3677 mesh.geompyD.addToStudyInFather(piece, geom, name)
3678 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3681 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3682 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3684 def CompareHyp (self, hyp, args):
3685 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3688 def CompareEqualHyp (self, hyp, args):
3692 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3693 UseExisting=0, CompareMethod=""):
3696 if CompareMethod == "": CompareMethod = self.CompareHyp
3697 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3700 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3706 a = a + s + str(args[i])
3710 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3712 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3713 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3716 ## Returns entry of the shape to mesh in the study
3717 def MainShapeEntry(self):
3719 if not self.mesh or not self.mesh.GetMesh(): return entry
3720 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3721 study = self.mesh.smeshpyD.GetCurrentStudy()
3722 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3723 sobj = study.FindObjectIOR(ior)
3724 if sobj: entry = sobj.GetID()
3725 if not entry: return ""
3728 # Public class: Mesh_Segment
3729 # --------------------------
3731 ## Class to define a segment 1D algorithm for discretization
3734 # @ingroup l3_algos_basic
3735 class Mesh_Segment(Mesh_Algorithm):
3737 ## Private constructor.
3738 def __init__(self, mesh, geom=0):
3739 Mesh_Algorithm.__init__(self)
3740 self.Create(mesh, geom, "Regular_1D")
3742 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3743 # @param l for the length of segments that cut an edge
3744 # @param UseExisting if ==true - searches for an existing hypothesis created with
3745 # the same parameters, else (default) - creates a new one
3746 # @param p precision, used for calculation of the number of segments.
3747 # The precision should be a positive, meaningful value within the range [0,1].
3748 # In general, the number of segments is calculated with the formula:
3749 # nb = ceil((edge_length / l) - p)
3750 # Function ceil rounds its argument to the higher integer.
3751 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3752 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3753 # p=1 means rounding of (edge_length / l) to the lower integer.
3754 # Default value is 1e-07.
3755 # @return an instance of StdMeshers_LocalLength hypothesis
3756 # @ingroup l3_hypos_1dhyps
3757 def LocalLength(self, l, UseExisting=0, p=1e-07):
3758 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3759 CompareMethod=self.CompareLocalLength)
3765 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3766 def CompareLocalLength(self, hyp, args):
3767 if IsEqual(hyp.GetLength(), args[0]):
3768 return IsEqual(hyp.GetPrecision(), args[1])
3771 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3772 # @param length is optional maximal allowed length of segment, if it is omitted
3773 # the preestimated length is used that depends on geometry size
3774 # @param UseExisting if ==true - searches for an existing hypothesis created with
3775 # the same parameters, else (default) - create a new one
3776 # @return an instance of StdMeshers_MaxLength hypothesis
3777 # @ingroup l3_hypos_1dhyps
3778 def MaxSize(self, length=0.0, UseExisting=0):
3779 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3782 hyp.SetLength(length)
3784 # set preestimated length
3785 gen = self.mesh.smeshpyD
3786 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3787 self.mesh.GetMesh(), self.mesh.GetShape(),
3789 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3791 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3794 hyp.SetUsePreestimatedLength( length == 0.0 )
3797 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3798 # @param n for the number of segments that cut an edge
3799 # @param s for the scale factor (optional)
3800 # @param reversedEdges is a list of edges to mesh using reversed orientation
3801 # @param UseExisting if ==true - searches for an existing hypothesis created with
3802 # the same parameters, else (default) - create a new one
3803 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3804 # @ingroup l3_hypos_1dhyps
3805 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3806 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3807 reversedEdges, UseExisting = [], reversedEdges
3808 entry = self.MainShapeEntry()
3810 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3811 UseExisting=UseExisting,
3812 CompareMethod=self.CompareNumberOfSegments)
3814 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3815 UseExisting=UseExisting,
3816 CompareMethod=self.CompareNumberOfSegments)
3817 hyp.SetDistrType( 1 )
3818 hyp.SetScaleFactor(s)
3819 hyp.SetNumberOfSegments(n)
3820 hyp.SetReversedEdges( reversedEdges )
3821 hyp.SetObjectEntry( entry )
3825 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3826 def CompareNumberOfSegments(self, hyp, args):
3827 if hyp.GetNumberOfSegments() == args[0]:
3829 if hyp.GetReversedEdges() == args[1]:
3830 if not args[1] or hyp.GetObjectEntry() == args[2]:
3833 if hyp.GetReversedEdges() == args[2]:
3834 if not args[2] or hyp.GetObjectEntry() == args[3]:
3835 if hyp.GetDistrType() == 1:
3836 if IsEqual(hyp.GetScaleFactor(), args[1]):
3840 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3841 # @param start defines the length of the first segment
3842 # @param end defines the length of the last segment
3843 # @param reversedEdges is a list of edges to mesh using reversed orientation
3844 # @param UseExisting if ==true - searches for an existing hypothesis created with
3845 # the same parameters, else (default) - creates a new one
3846 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3847 # @ingroup l3_hypos_1dhyps
3848 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3849 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3850 reversedEdges, UseExisting = [], reversedEdges
3851 entry = self.MainShapeEntry()
3852 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
3853 UseExisting=UseExisting,
3854 CompareMethod=self.CompareArithmetic1D)
3855 hyp.SetStartLength(start)
3856 hyp.SetEndLength(end)
3857 hyp.SetReversedEdges( reversedEdges )
3858 hyp.SetObjectEntry( entry )
3862 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3863 def CompareArithmetic1D(self, hyp, args):
3864 if IsEqual(hyp.GetLength(1), args[0]):
3865 if IsEqual(hyp.GetLength(0), args[1]):
3866 if hyp.GetReversedEdges() == args[2]:
3867 if not args[2] or hyp.GetObjectEntry() == args[3]:
3872 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
3873 # on curve from 0 to 1 (additionally it is neecessary to check
3874 # orientation of edges and create list of reversed edges if it is
3875 # needed) and sets numbers of segments between given points (default
3876 # values are equals 1
3877 # @param points defines the list of parameters on curve
3878 # @param nbSegs defines the list of numbers of segments
3879 # @param reversedEdges is a list of edges to mesh using reversed orientation
3880 # @param UseExisting if ==true - searches for an existing hypothesis created with
3881 # the same parameters, else (default) - creates a new one
3882 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3883 # @ingroup l3_hypos_1dhyps
3884 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
3885 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3886 reversedEdges, UseExisting = [], reversedEdges
3887 entry = self.MainShapeEntry()
3888 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
3889 UseExisting=UseExisting,
3890 CompareMethod=self.CompareArithmetic1D)
3891 hyp.SetPoints(points)
3892 hyp.SetNbSegments(nbSegs)
3893 hyp.SetReversedEdges(reversedEdges)
3894 hyp.SetObjectEntry(entry)
3898 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
3899 ## as the given arguments
3900 def CompareFixedPoints1D(self, hyp, args):
3901 if hyp.GetPoints() == args[0]:
3902 if hyp.GetNbSegments() == args[1]:
3903 if hyp.GetReversedEdges() == args[2]:
3904 if not args[2] or hyp.GetObjectEntry() == args[3]:
3910 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3911 # @param start defines the length of the first segment
3912 # @param end defines the length of the last segment
3913 # @param reversedEdges is a list of edges to mesh using reversed orientation
3914 # @param UseExisting if ==true - searches for an existing hypothesis created with
3915 # the same parameters, else (default) - creates a new one
3916 # @return an instance of StdMeshers_StartEndLength hypothesis
3917 # @ingroup l3_hypos_1dhyps
3918 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3919 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3920 reversedEdges, UseExisting = [], reversedEdges
3921 entry = self.MainShapeEntry()
3922 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3923 UseExisting=UseExisting,
3924 CompareMethod=self.CompareStartEndLength)
3925 hyp.SetStartLength(start)
3926 hyp.SetEndLength(end)
3927 hyp.SetReversedEdges( reversedEdges )
3928 hyp.SetObjectEntry( entry )
3931 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3932 def CompareStartEndLength(self, hyp, args):
3933 if IsEqual(hyp.GetLength(1), args[0]):
3934 if IsEqual(hyp.GetLength(0), args[1]):
3935 if hyp.GetReversedEdges() == args[2]:
3936 if not args[2] or hyp.GetObjectEntry() == args[3]:
3940 ## Defines "Deflection1D" hypothesis
3941 # @param d for the deflection
3942 # @param UseExisting if ==true - searches for an existing hypothesis created with
3943 # the same parameters, else (default) - create a new one
3944 # @ingroup l3_hypos_1dhyps
3945 def Deflection1D(self, d, UseExisting=0):
3946 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3947 CompareMethod=self.CompareDeflection1D)
3948 hyp.SetDeflection(d)
3951 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3952 def CompareDeflection1D(self, hyp, args):
3953 return IsEqual(hyp.GetDeflection(), args[0])
3955 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3956 # the opposite side in case of quadrangular faces
3957 # @ingroup l3_hypos_additi
3958 def Propagation(self):
3959 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3961 ## Defines "AutomaticLength" hypothesis
3962 # @param fineness for the fineness [0-1]
3963 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3964 # same parameters, else (default) - create a new one
3965 # @ingroup l3_hypos_1dhyps
3966 def AutomaticLength(self, fineness=0, UseExisting=0):
3967 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3968 CompareMethod=self.CompareAutomaticLength)
3969 hyp.SetFineness( fineness )
3972 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3973 def CompareAutomaticLength(self, hyp, args):
3974 return IsEqual(hyp.GetFineness(), args[0])
3976 ## Defines "SegmentLengthAroundVertex" hypothesis
3977 # @param length for the segment length
3978 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3979 # Any other integer value means that the hypothesis will be set on the
3980 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3981 # @param UseExisting if ==true - searches for an existing hypothesis created with
3982 # the same parameters, else (default) - creates a new one
3983 # @ingroup l3_algos_segmarv
3984 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3986 store_geom = self.geom
3987 if type(vertex) is types.IntType:
3988 if vertex == 0 or vertex == 1:
3989 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3997 if self.geom is None:
3998 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3999 name = GetName(self.geom)
4001 piece = self.mesh.geom
4002 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4003 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4004 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4006 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4008 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4009 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4011 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4012 CompareMethod=self.CompareLengthNearVertex)
4013 self.geom = store_geom
4014 hyp.SetLength( length )
4017 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4018 # @ingroup l3_algos_segmarv
4019 def CompareLengthNearVertex(self, hyp, args):
4020 return IsEqual(hyp.GetLength(), args[0])
4022 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4023 # If the 2D mesher sees that all boundary edges are quadratic,
4024 # it generates quadratic faces, else it generates linear faces using
4025 # medium nodes as if they are vertices.
4026 # The 3D mesher generates quadratic volumes only if all boundary faces
4027 # are quadratic, else it fails.
4029 # @ingroup l3_hypos_additi
4030 def QuadraticMesh(self):
4031 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4034 # Public class: Mesh_CompositeSegment
4035 # --------------------------
4037 ## Defines a segment 1D algorithm for discretization
4039 # @ingroup l3_algos_basic
4040 class Mesh_CompositeSegment(Mesh_Segment):
4042 ## Private constructor.
4043 def __init__(self, mesh, geom=0):
4044 self.Create(mesh, geom, "CompositeSegment_1D")
4047 # Public class: Mesh_Segment_Python
4048 # ---------------------------------
4050 ## Defines a segment 1D algorithm for discretization with python function
4052 # @ingroup l3_algos_basic
4053 class Mesh_Segment_Python(Mesh_Segment):
4055 ## Private constructor.
4056 def __init__(self, mesh, geom=0):
4057 import Python1dPlugin
4058 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4060 ## Defines "PythonSplit1D" hypothesis
4061 # @param n for the number of segments that cut an edge
4062 # @param func for the python function that calculates the length of all segments
4063 # @param UseExisting if ==true - searches for the existing hypothesis created with
4064 # the same parameters, else (default) - creates a new one
4065 # @ingroup l3_hypos_1dhyps
4066 def PythonSplit1D(self, n, func, UseExisting=0):
4067 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4068 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4069 hyp.SetNumberOfSegments(n)
4070 hyp.SetPythonLog10RatioFunction(func)
4073 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4074 def ComparePythonSplit1D(self, hyp, args):
4075 #if hyp.GetNumberOfSegments() == args[0]:
4076 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4080 # Public class: Mesh_Triangle
4081 # ---------------------------
4083 ## Defines a triangle 2D algorithm
4085 # @ingroup l3_algos_basic
4086 class Mesh_Triangle(Mesh_Algorithm):
4095 ## Private constructor.
4096 def __init__(self, mesh, algoType, geom=0):
4097 Mesh_Algorithm.__init__(self)
4099 self.algoType = algoType
4100 if algoType == MEFISTO:
4101 self.Create(mesh, geom, "MEFISTO_2D")
4103 elif algoType == BLSURF:
4105 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4106 #self.SetPhysicalMesh() - PAL19680
4107 elif algoType == NETGEN:
4109 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4111 elif algoType == NETGEN_2D:
4113 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4116 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4117 # @param area for the maximum area of each triangle
4118 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4119 # same parameters, else (default) - creates a new one
4121 # Only for algoType == MEFISTO || NETGEN_2D
4122 # @ingroup l3_hypos_2dhyps
4123 def MaxElementArea(self, area, UseExisting=0):
4124 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4125 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4126 CompareMethod=self.CompareMaxElementArea)
4127 elif self.algoType == NETGEN:
4128 hyp = self.Parameters(SIMPLE)
4129 hyp.SetMaxElementArea(area)
4132 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4133 def CompareMaxElementArea(self, hyp, args):
4134 return IsEqual(hyp.GetMaxElementArea(), args[0])
4136 ## Defines "LengthFromEdges" hypothesis to build triangles
4137 # based on the length of the edges taken from the wire
4139 # Only for algoType == MEFISTO || NETGEN_2D
4140 # @ingroup l3_hypos_2dhyps
4141 def LengthFromEdges(self):
4142 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4143 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4145 elif self.algoType == NETGEN:
4146 hyp = self.Parameters(SIMPLE)
4147 hyp.LengthFromEdges()
4150 ## Sets a way to define size of mesh elements to generate.
4151 # @param thePhysicalMesh is: DefaultSize or Custom.
4152 # @ingroup l3_hypos_blsurf
4153 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4154 # Parameter of BLSURF algo
4155 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4157 ## Sets size of mesh elements to generate.
4158 # @ingroup l3_hypos_blsurf
4159 def SetPhySize(self, theVal):
4160 # Parameter of BLSURF algo
4161 self.Parameters().SetPhySize(theVal)
4163 ## Sets lower boundary of mesh element size (PhySize).
4164 # @ingroup l3_hypos_blsurf
4165 def SetPhyMin(self, theVal=-1):
4166 # Parameter of BLSURF algo
4167 self.Parameters().SetPhyMin(theVal)
4169 ## Sets upper boundary of mesh element size (PhySize).
4170 # @ingroup l3_hypos_blsurf
4171 def SetPhyMax(self, theVal=-1):
4172 # Parameter of BLSURF algo
4173 self.Parameters().SetPhyMax(theVal)
4175 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4176 # @param theGeometricMesh is: DefaultGeom or Custom
4177 # @ingroup l3_hypos_blsurf
4178 def SetGeometricMesh(self, theGeometricMesh=0):
4179 # Parameter of BLSURF algo
4180 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4181 self.params.SetGeometricMesh(theGeometricMesh)
4183 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4184 # @ingroup l3_hypos_blsurf
4185 def SetAngleMeshS(self, theVal=_angleMeshS):
4186 # Parameter of BLSURF algo
4187 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4188 self.params.SetAngleMeshS(theVal)
4190 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4191 # @ingroup l3_hypos_blsurf
4192 def SetAngleMeshC(self, theVal=_angleMeshS):
4193 # Parameter of BLSURF algo
4194 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4195 self.params.SetAngleMeshC(theVal)
4197 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4198 # @ingroup l3_hypos_blsurf
4199 def SetGeoMin(self, theVal=-1):
4200 # Parameter of BLSURF algo
4201 self.Parameters().SetGeoMin(theVal)
4203 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4204 # @ingroup l3_hypos_blsurf
4205 def SetGeoMax(self, theVal=-1):
4206 # Parameter of BLSURF algo
4207 self.Parameters().SetGeoMax(theVal)
4209 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4210 # @ingroup l3_hypos_blsurf
4211 def SetGradation(self, theVal=_gradation):
4212 # Parameter of BLSURF algo
4213 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4214 self.params.SetGradation(theVal)
4216 ## Sets topology usage way.
4217 # @param way defines how mesh conformity is assured <ul>
4218 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4219 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4220 # @ingroup l3_hypos_blsurf
4221 def SetTopology(self, way):
4222 # Parameter of BLSURF algo
4223 self.Parameters().SetTopology(way)
4225 ## To respect geometrical edges or not.
4226 # @ingroup l3_hypos_blsurf
4227 def SetDecimesh(self, toIgnoreEdges=False):
4228 # Parameter of BLSURF algo
4229 self.Parameters().SetDecimesh(toIgnoreEdges)
4231 ## Sets verbosity level in the range 0 to 100.
4232 # @ingroup l3_hypos_blsurf
4233 def SetVerbosity(self, level):
4234 # Parameter of BLSURF algo
4235 self.Parameters().SetVerbosity(level)
4237 ## Sets advanced option value.
4238 # @ingroup l3_hypos_blsurf
4239 def SetOptionValue(self, optionName, level):
4240 # Parameter of BLSURF algo
4241 self.Parameters().SetOptionValue(optionName,level)
4243 ## Sets QuadAllowed flag.
4244 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4245 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4246 def SetQuadAllowed(self, toAllow=True):
4247 if self.algoType == NETGEN_2D:
4248 if toAllow: # add QuadranglePreference
4249 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4250 else: # remove QuadranglePreference
4251 for hyp in self.mesh.GetHypothesisList( self.geom ):
4252 if hyp.GetName() == "QuadranglePreference":
4253 self.mesh.RemoveHypothesis( self.geom, hyp )
4258 if self.Parameters():
4259 self.params.SetQuadAllowed(toAllow)
4262 ## Defines hypothesis having several parameters
4264 # @ingroup l3_hypos_netgen
4265 def Parameters(self, which=SOLE):
4268 if self.algoType == NETGEN:
4270 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4271 "libNETGENEngine.so", UseExisting=0)
4273 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4274 "libNETGENEngine.so", UseExisting=0)
4276 elif self.algoType == MEFISTO:
4277 print "Mefisto algo support no multi-parameter hypothesis"
4279 elif self.algoType == NETGEN_2D:
4280 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4281 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4283 elif self.algoType == BLSURF:
4284 self.params = self.Hypothesis("BLSURF_Parameters", [],
4285 "libBLSURFEngine.so", UseExisting=0)
4288 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4293 # Only for algoType == NETGEN
4294 # @ingroup l3_hypos_netgen
4295 def SetMaxSize(self, theSize):
4296 if self.Parameters():
4297 self.params.SetMaxSize(theSize)
4299 ## Sets SecondOrder flag
4301 # Only for algoType == NETGEN
4302 # @ingroup l3_hypos_netgen
4303 def SetSecondOrder(self, theVal):
4304 if self.Parameters():
4305 self.params.SetSecondOrder(theVal)
4307 ## Sets Optimize flag
4309 # Only for algoType == NETGEN
4310 # @ingroup l3_hypos_netgen
4311 def SetOptimize(self, theVal):
4312 if self.Parameters():
4313 self.params.SetOptimize(theVal)
4316 # @param theFineness is:
4317 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4319 # Only for algoType == NETGEN
4320 # @ingroup l3_hypos_netgen
4321 def SetFineness(self, theFineness):
4322 if self.Parameters():
4323 self.params.SetFineness(theFineness)
4327 # Only for algoType == NETGEN
4328 # @ingroup l3_hypos_netgen
4329 def SetGrowthRate(self, theRate):
4330 if self.Parameters():
4331 self.params.SetGrowthRate(theRate)
4333 ## Sets NbSegPerEdge
4335 # Only for algoType == NETGEN
4336 # @ingroup l3_hypos_netgen
4337 def SetNbSegPerEdge(self, theVal):
4338 if self.Parameters():
4339 self.params.SetNbSegPerEdge(theVal)
4341 ## Sets NbSegPerRadius
4343 # Only for algoType == NETGEN
4344 # @ingroup l3_hypos_netgen
4345 def SetNbSegPerRadius(self, theVal):
4346 if self.Parameters():
4347 self.params.SetNbSegPerRadius(theVal)
4349 ## Sets number of segments overriding value set by SetLocalLength()
4351 # Only for algoType == NETGEN
4352 # @ingroup l3_hypos_netgen
4353 def SetNumberOfSegments(self, theVal):
4354 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4356 ## Sets number of segments overriding value set by SetNumberOfSegments()
4358 # Only for algoType == NETGEN
4359 # @ingroup l3_hypos_netgen
4360 def SetLocalLength(self, theVal):
4361 self.Parameters(SIMPLE).SetLocalLength(theVal)
4366 # Public class: Mesh_Quadrangle
4367 # -----------------------------
4369 ## Defines a quadrangle 2D algorithm
4371 # @ingroup l3_algos_basic
4372 class Mesh_Quadrangle(Mesh_Algorithm):
4374 ## Private constructor.
4375 def __init__(self, mesh, geom=0):
4376 Mesh_Algorithm.__init__(self)
4377 self.Create(mesh, geom, "Quadrangle_2D")
4379 ## Defines "QuadranglePreference" hypothesis, forcing construction
4380 # of quadrangles if the number of nodes on the opposite edges is not the same
4381 # while the total number of nodes on edges is even
4383 # @ingroup l3_hypos_additi
4384 def QuadranglePreference(self):
4385 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4386 CompareMethod=self.CompareEqualHyp)
4389 ## Defines "TrianglePreference" hypothesis, forcing construction
4390 # of triangles in the refinement area if the number of nodes
4391 # on the opposite edges is not the same
4393 # @ingroup l3_hypos_additi
4394 def TrianglePreference(self):
4395 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4396 CompareMethod=self.CompareEqualHyp)
4399 # Public class: Mesh_Tetrahedron
4400 # ------------------------------
4402 ## Defines a tetrahedron 3D algorithm
4404 # @ingroup l3_algos_basic
4405 class Mesh_Tetrahedron(Mesh_Algorithm):
4410 ## Private constructor.
4411 def __init__(self, mesh, algoType, geom=0):
4412 Mesh_Algorithm.__init__(self)
4414 if algoType == NETGEN:
4416 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4419 elif algoType == FULL_NETGEN:
4421 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4424 elif algoType == GHS3D:
4426 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4429 elif algoType == GHS3DPRL:
4430 CheckPlugin(GHS3DPRL)
4431 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4434 self.algoType = algoType
4436 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4437 # @param vol for the maximum volume of each tetrahedron
4438 # @param UseExisting if ==true - searches for the existing hypothesis created with
4439 # the same parameters, else (default) - creates a new one
4440 # @ingroup l3_hypos_maxvol
4441 def MaxElementVolume(self, vol, UseExisting=0):
4442 if self.algoType == NETGEN:
4443 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4444 CompareMethod=self.CompareMaxElementVolume)
4445 hyp.SetMaxElementVolume(vol)
4447 elif self.algoType == FULL_NETGEN:
4448 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4451 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4452 def CompareMaxElementVolume(self, hyp, args):
4453 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4455 ## Defines hypothesis having several parameters
4457 # @ingroup l3_hypos_netgen
4458 def Parameters(self, which=SOLE):
4462 if self.algoType == FULL_NETGEN:
4464 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4465 "libNETGENEngine.so", UseExisting=0)
4467 self.params = self.Hypothesis("NETGEN_Parameters", [],
4468 "libNETGENEngine.so", UseExisting=0)
4471 if self.algoType == GHS3D:
4472 self.params = self.Hypothesis("GHS3D_Parameters", [],
4473 "libGHS3DEngine.so", UseExisting=0)
4476 if self.algoType == GHS3DPRL:
4477 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4478 "libGHS3DPRLEngine.so", UseExisting=0)
4481 print "Algo supports no multi-parameter hypothesis"
4485 # Parameter of FULL_NETGEN
4486 # @ingroup l3_hypos_netgen
4487 def SetMaxSize(self, theSize):
4488 self.Parameters().SetMaxSize(theSize)
4490 ## Sets SecondOrder flag
4491 # Parameter of FULL_NETGEN
4492 # @ingroup l3_hypos_netgen
4493 def SetSecondOrder(self, theVal):
4494 self.Parameters().SetSecondOrder(theVal)
4496 ## Sets Optimize flag
4497 # Parameter of FULL_NETGEN
4498 # @ingroup l3_hypos_netgen
4499 def SetOptimize(self, theVal):
4500 self.Parameters().SetOptimize(theVal)
4503 # @param theFineness is:
4504 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4505 # Parameter of FULL_NETGEN
4506 # @ingroup l3_hypos_netgen
4507 def SetFineness(self, theFineness):
4508 self.Parameters().SetFineness(theFineness)
4511 # Parameter of FULL_NETGEN
4512 # @ingroup l3_hypos_netgen
4513 def SetGrowthRate(self, theRate):
4514 self.Parameters().SetGrowthRate(theRate)
4516 ## Sets NbSegPerEdge
4517 # Parameter of FULL_NETGEN
4518 # @ingroup l3_hypos_netgen
4519 def SetNbSegPerEdge(self, theVal):
4520 self.Parameters().SetNbSegPerEdge(theVal)
4522 ## Sets NbSegPerRadius
4523 # Parameter of FULL_NETGEN
4524 # @ingroup l3_hypos_netgen
4525 def SetNbSegPerRadius(self, theVal):
4526 self.Parameters().SetNbSegPerRadius(theVal)
4528 ## Sets number of segments overriding value set by SetLocalLength()
4529 # Only for algoType == NETGEN_FULL
4530 # @ingroup l3_hypos_netgen
4531 def SetNumberOfSegments(self, theVal):
4532 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4534 ## Sets number of segments overriding value set by SetNumberOfSegments()
4535 # Only for algoType == NETGEN_FULL
4536 # @ingroup l3_hypos_netgen
4537 def SetLocalLength(self, theVal):
4538 self.Parameters(SIMPLE).SetLocalLength(theVal)
4540 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4541 # Overrides value set by LengthFromEdges()
4542 # Only for algoType == NETGEN_FULL
4543 # @ingroup l3_hypos_netgen
4544 def MaxElementArea(self, area):
4545 self.Parameters(SIMPLE).SetMaxElementArea(area)
4547 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4548 # Overrides value set by MaxElementArea()
4549 # Only for algoType == NETGEN_FULL
4550 # @ingroup l3_hypos_netgen
4551 def LengthFromEdges(self):
4552 self.Parameters(SIMPLE).LengthFromEdges()
4554 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4555 # Overrides value set by MaxElementVolume()
4556 # Only for algoType == NETGEN_FULL
4557 # @ingroup l3_hypos_netgen
4558 def LengthFromFaces(self):
4559 self.Parameters(SIMPLE).LengthFromFaces()
4561 ## To mesh "holes" in a solid or not. Default is to mesh.
4562 # @ingroup l3_hypos_ghs3dh
4563 def SetToMeshHoles(self, toMesh):
4564 # Parameter of GHS3D
4565 self.Parameters().SetToMeshHoles(toMesh)
4567 ## Set Optimization level:
4568 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4569 # Strong_Optimization.
4570 # Default is Standard_Optimization
4571 # @ingroup l3_hypos_ghs3dh
4572 def SetOptimizationLevel(self, level):
4573 # Parameter of GHS3D
4574 self.Parameters().SetOptimizationLevel(level)
4576 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4577 # @ingroup l3_hypos_ghs3dh
4578 def SetMaximumMemory(self, MB):
4579 # Advanced parameter of GHS3D
4580 self.Parameters().SetMaximumMemory(MB)
4582 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4583 # automatic memory adjustment mode.
4584 # @ingroup l3_hypos_ghs3dh
4585 def SetInitialMemory(self, MB):
4586 # Advanced parameter of GHS3D
4587 self.Parameters().SetInitialMemory(MB)
4589 ## Path to working directory.
4590 # @ingroup l3_hypos_ghs3dh
4591 def SetWorkingDirectory(self, path):
4592 # Advanced parameter of GHS3D
4593 self.Parameters().SetWorkingDirectory(path)
4595 ## To keep working files or remove them. Log file remains in case of errors anyway.
4596 # @ingroup l3_hypos_ghs3dh
4597 def SetKeepFiles(self, toKeep):
4598 # Advanced parameter of GHS3D and GHS3DPRL
4599 self.Parameters().SetKeepFiles(toKeep)
4601 ## To set verbose level [0-10]. <ul>
4602 #<li> 0 - no standard output,
4603 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4604 # indicates when the final mesh is being saved. In addition the software
4605 # gives indication regarding the CPU time.
4606 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4607 # histogram of the skin mesh, quality statistics histogram together with
4608 # the characteristics of the final mesh.</ul>
4609 # @ingroup l3_hypos_ghs3dh
4610 def SetVerboseLevel(self, level):
4611 # Advanced parameter of GHS3D
4612 self.Parameters().SetVerboseLevel(level)
4614 ## To create new nodes.
4615 # @ingroup l3_hypos_ghs3dh
4616 def SetToCreateNewNodes(self, toCreate):
4617 # Advanced parameter of GHS3D
4618 self.Parameters().SetToCreateNewNodes(toCreate)
4620 ## To use boundary recovery version which tries to create mesh on a very poor
4621 # quality surface mesh.
4622 # @ingroup l3_hypos_ghs3dh
4623 def SetToUseBoundaryRecoveryVersion(self, toUse):
4624 # Advanced parameter of GHS3D
4625 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4627 ## Sets command line option as text.
4628 # @ingroup l3_hypos_ghs3dh
4629 def SetTextOption(self, option):
4630 # Advanced parameter of GHS3D
4631 self.Parameters().SetTextOption(option)
4633 ## Sets MED files name and path.
4634 def SetMEDName(self, value):
4635 self.Parameters().SetMEDName(value)
4637 ## Sets the number of partition of the initial mesh
4638 def SetNbPart(self, value):
4639 self.Parameters().SetNbPart(value)
4641 ## When big mesh, start tepal in background
4642 def SetBackground(self, value):
4643 self.Parameters().SetBackground(value)
4645 # Public class: Mesh_Hexahedron
4646 # ------------------------------
4648 ## Defines a hexahedron 3D algorithm
4650 # @ingroup l3_algos_basic
4651 class Mesh_Hexahedron(Mesh_Algorithm):
4656 ## Private constructor.
4657 def __init__(self, mesh, algoType=Hexa, geom=0):
4658 Mesh_Algorithm.__init__(self)
4660 self.algoType = algoType
4662 if algoType == Hexa:
4663 self.Create(mesh, geom, "Hexa_3D")
4666 elif algoType == Hexotic:
4667 CheckPlugin(Hexotic)
4668 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4671 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4672 # @ingroup l3_hypos_hexotic
4673 def MinMaxQuad(self, min=3, max=8, quad=True):
4674 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4676 self.params.SetHexesMinLevel(min)
4677 self.params.SetHexesMaxLevel(max)
4678 self.params.SetHexoticQuadrangles(quad)
4681 # Deprecated, only for compatibility!
4682 # Public class: Mesh_Netgen
4683 # ------------------------------
4685 ## Defines a NETGEN-based 2D or 3D algorithm
4686 # that needs no discrete boundary (i.e. independent)
4688 # This class is deprecated, only for compatibility!
4691 # @ingroup l3_algos_basic
4692 class Mesh_Netgen(Mesh_Algorithm):
4696 ## Private constructor.
4697 def __init__(self, mesh, is3D, geom=0):
4698 Mesh_Algorithm.__init__(self)
4704 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4708 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4711 ## Defines the hypothesis containing parameters of the algorithm
4712 def Parameters(self):
4714 hyp = self.Hypothesis("NETGEN_Parameters", [],
4715 "libNETGENEngine.so", UseExisting=0)
4717 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4718 "libNETGENEngine.so", UseExisting=0)
4721 # Public class: Mesh_Projection1D
4722 # ------------------------------
4724 ## Defines a projection 1D algorithm
4725 # @ingroup l3_algos_proj
4727 class Mesh_Projection1D(Mesh_Algorithm):
4729 ## Private constructor.
4730 def __init__(self, mesh, geom=0):
4731 Mesh_Algorithm.__init__(self)
4732 self.Create(mesh, geom, "Projection_1D")
4734 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4735 # a mesh pattern is taken, and, optionally, the association of vertices
4736 # between the source edge and a target edge (to which a hypothesis is assigned)
4737 # @param edge from which nodes distribution is taken
4738 # @param mesh from which nodes distribution is taken (optional)
4739 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4740 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4741 # to associate with \a srcV (optional)
4742 # @param UseExisting if ==true - searches for the existing hypothesis created with
4743 # the same parameters, else (default) - creates a new one
4744 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4745 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4747 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4748 hyp.SetSourceEdge( edge )
4749 if not mesh is None and isinstance(mesh, Mesh):
4750 mesh = mesh.GetMesh()
4751 hyp.SetSourceMesh( mesh )
4752 hyp.SetVertexAssociation( srcV, tgtV )
4755 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4756 #def CompareSourceEdge(self, hyp, args):
4757 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4761 # Public class: Mesh_Projection2D
4762 # ------------------------------
4764 ## Defines a projection 2D algorithm
4765 # @ingroup l3_algos_proj
4767 class Mesh_Projection2D(Mesh_Algorithm):
4769 ## Private constructor.
4770 def __init__(self, mesh, geom=0):
4771 Mesh_Algorithm.__init__(self)
4772 self.Create(mesh, geom, "Projection_2D")
4774 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4775 # a mesh pattern is taken, and, optionally, the association of vertices
4776 # between the source face and the target face (to which a hypothesis is assigned)
4777 # @param face from which the mesh pattern is taken
4778 # @param mesh from which the mesh pattern is taken (optional)
4779 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4780 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4781 # to associate with \a srcV1 (optional)
4782 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4783 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4784 # to associate with \a srcV2 (optional)
4785 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4786 # the same parameters, else (default) - forces the creation a new one
4788 # Note: all association vertices must belong to one edge of a face
4789 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4790 srcV2=None, tgtV2=None, UseExisting=0):
4791 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4793 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4794 hyp.SetSourceFace( face )
4795 if not mesh is None and isinstance(mesh, Mesh):
4796 mesh = mesh.GetMesh()
4797 hyp.SetSourceMesh( mesh )
4798 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4801 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4802 #def CompareSourceFace(self, hyp, args):
4803 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4806 # Public class: Mesh_Projection3D
4807 # ------------------------------
4809 ## Defines a projection 3D algorithm
4810 # @ingroup l3_algos_proj
4812 class Mesh_Projection3D(Mesh_Algorithm):
4814 ## Private constructor.
4815 def __init__(self, mesh, geom=0):
4816 Mesh_Algorithm.__init__(self)
4817 self.Create(mesh, geom, "Projection_3D")
4819 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4820 # the mesh pattern is taken, and, optionally, the association of vertices
4821 # between the source and the target solid (to which a hipothesis is assigned)
4822 # @param solid from where the mesh pattern is taken
4823 # @param mesh from where the mesh pattern is taken (optional)
4824 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4825 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4826 # to associate with \a srcV1 (optional)
4827 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4828 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4829 # to associate with \a srcV2 (optional)
4830 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4831 # the same parameters, else (default) - creates a new one
4833 # Note: association vertices must belong to one edge of a solid
4834 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4835 srcV2=0, tgtV2=0, UseExisting=0):
4836 hyp = self.Hypothesis("ProjectionSource3D",
4837 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4839 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4840 hyp.SetSource3DShape( solid )
4841 if not mesh is None and isinstance(mesh, Mesh):
4842 mesh = mesh.GetMesh()
4843 hyp.SetSourceMesh( mesh )
4844 if srcV1 and srcV2 and tgtV1 and tgtV2:
4845 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4846 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4849 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4850 #def CompareSourceShape3D(self, hyp, args):
4851 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4855 # Public class: Mesh_Prism
4856 # ------------------------
4858 ## Defines a 3D extrusion algorithm
4859 # @ingroup l3_algos_3dextr
4861 class Mesh_Prism3D(Mesh_Algorithm):
4863 ## Private constructor.
4864 def __init__(self, mesh, geom=0):
4865 Mesh_Algorithm.__init__(self)
4866 self.Create(mesh, geom, "Prism_3D")
4868 # Public class: Mesh_RadialPrism
4869 # -------------------------------
4871 ## Defines a Radial Prism 3D algorithm
4872 # @ingroup l3_algos_radialp
4874 class Mesh_RadialPrism3D(Mesh_Algorithm):
4876 ## Private constructor.
4877 def __init__(self, mesh, geom=0):
4878 Mesh_Algorithm.__init__(self)
4879 self.Create(mesh, geom, "RadialPrism_3D")
4881 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4882 self.nbLayers = None
4884 ## Return 3D hypothesis holding the 1D one
4885 def Get3DHypothesis(self):
4886 return self.distribHyp
4888 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4889 # hypothesis. Returns the created hypothesis
4890 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4891 #print "OwnHypothesis",hypType
4892 if not self.nbLayers is None:
4893 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4894 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4895 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4896 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4897 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4898 self.distribHyp.SetLayerDistribution( hyp )
4901 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4902 # prisms to build between the inner and outer shells
4903 # @param n number of layers
4904 # @param UseExisting if ==true - searches for the existing hypothesis created with
4905 # the same parameters, else (default) - creates a new one
4906 def NumberOfLayers(self, n, UseExisting=0):
4907 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4908 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4909 CompareMethod=self.CompareNumberOfLayers)
4910 self.nbLayers.SetNumberOfLayers( n )
4911 return self.nbLayers
4913 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4914 def CompareNumberOfLayers(self, hyp, args):
4915 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4917 ## Defines "LocalLength" hypothesis, specifying the segment length
4918 # to build between the inner and the outer shells
4919 # @param l the length of segments
4920 # @param p the precision of rounding
4921 def LocalLength(self, l, p=1e-07):
4922 hyp = self.OwnHypothesis("LocalLength", [l,p])
4927 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4928 # prisms to build between the inner and the outer shells.
4929 # @param n the number of layers
4930 # @param s the scale factor (optional)
4931 def NumberOfSegments(self, n, s=[]):
4933 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4935 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4936 hyp.SetDistrType( 1 )
4937 hyp.SetScaleFactor(s)
4938 hyp.SetNumberOfSegments(n)
4941 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4942 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4943 # @param start the length of the first segment
4944 # @param end the length of the last segment
4945 def Arithmetic1D(self, start, end ):
4946 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4947 hyp.SetLength(start, 1)
4948 hyp.SetLength(end , 0)
4951 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4952 # to build between the inner and the outer shells as geometric length increasing
4953 # @param start for the length of the first segment
4954 # @param end for the length of the last segment
4955 def StartEndLength(self, start, end):
4956 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4957 hyp.SetLength(start, 1)
4958 hyp.SetLength(end , 0)
4961 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4962 # to build between the inner and outer shells
4963 # @param fineness defines the quality of the mesh within the range [0-1]
4964 def AutomaticLength(self, fineness=0):
4965 hyp = self.OwnHypothesis("AutomaticLength")
4966 hyp.SetFineness( fineness )
4969 # Public class: Mesh_RadialQuadrangle1D2D
4970 # -------------------------------
4972 ## Defines a Radial Quadrangle 1D2D algorithm
4973 # @ingroup l2_algos_radialq
4975 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
4977 ## Private constructor.
4978 def __init__(self, mesh, geom=0):
4979 Mesh_Algorithm.__init__(self)
4980 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
4982 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
4983 self.nbLayers = None
4985 ## Return 2D hypothesis holding the 1D one
4986 def Get2DHypothesis(self):
4987 return self.distribHyp
4989 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4990 # hypothesis. Returns the created hypothesis
4991 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4992 #print "OwnHypothesis",hypType
4993 if not self.nbLayers is None:
4994 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4995 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4996 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4997 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4998 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4999 self.distribHyp.SetLayerDistribution( hyp )
5002 ## Defines "NumberOfLayers2D" hypothesis, specifying the number of layers
5003 # @param n number of layers
5004 # @param UseExisting if ==true - searches for the existing hypothesis created with
5005 # the same parameters, else (default) - creates a new one
5006 def NumberOfLayers2D(self, n, UseExisting=0):
5007 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5008 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5009 CompareMethod=self.CompareNumberOfLayers)
5010 self.nbLayers.SetNumberOfLayers( n )
5011 return self.nbLayers
5013 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5014 def CompareNumberOfLayers(self, hyp, args):
5015 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5017 ## Defines "LocalLength" hypothesis, specifying the segment length
5018 # @param l the length of segments
5019 # @param p the precision of rounding
5020 def LocalLength(self, l, p=1e-07):
5021 hyp = self.OwnHypothesis("LocalLength", [l,p])
5026 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5027 # @param n the number of layers
5028 # @param s the scale factor (optional)
5029 def NumberOfSegments(self, n, s=[]):
5031 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5033 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5034 hyp.SetDistrType( 1 )
5035 hyp.SetScaleFactor(s)
5036 hyp.SetNumberOfSegments(n)
5039 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5040 # with a length that changes in arithmetic progression
5041 # @param start the length of the first segment
5042 # @param end the length of the last segment
5043 def Arithmetic1D(self, start, end ):
5044 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5045 hyp.SetLength(start, 1)
5046 hyp.SetLength(end , 0)
5049 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5050 # as geometric length increasing
5051 # @param start for the length of the first segment
5052 # @param end for the length of the last segment
5053 def StartEndLength(self, start, end):
5054 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5055 hyp.SetLength(start, 1)
5056 hyp.SetLength(end , 0)
5059 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5060 # @param fineness defines the quality of the mesh within the range [0-1]
5061 def AutomaticLength(self, fineness=0):
5062 hyp = self.OwnHypothesis("AutomaticLength")
5063 hyp.SetFineness( fineness )
5067 # Private class: Mesh_UseExisting
5068 # -------------------------------
5069 class Mesh_UseExisting(Mesh_Algorithm):
5071 def __init__(self, dim, mesh, geom=0):
5073 self.Create(mesh, geom, "UseExisting_1D")
5075 self.Create(mesh, geom, "UseExisting_2D")
5078 import salome_notebook
5079 notebook = salome_notebook.notebook
5081 ##Return values of the notebook variables
5082 def ParseParameters(last, nbParams,nbParam, value):
5086 listSize = len(last)
5087 for n in range(0,nbParams):
5089 if counter < listSize:
5090 strResult = strResult + last[counter]
5092 strResult = strResult + ""
5094 if isinstance(value, str):
5095 if notebook.isVariable(value):
5096 result = notebook.get(value)
5097 strResult=strResult+value
5099 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5101 strResult=strResult+str(value)
5103 if nbParams - 1 != counter:
5104 strResult=strResult+var_separator #":"
5106 return result, strResult
5108 #Wrapper class for StdMeshers_LocalLength hypothesis
5109 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5111 ## Set Length parameter value
5112 # @param length numerical value or name of variable from notebook
5113 def SetLength(self, length):
5114 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5115 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5116 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5118 ## Set Precision parameter value
5119 # @param precision numerical value or name of variable from notebook
5120 def SetPrecision(self, precision):
5121 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5122 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5123 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5125 #Registering the new proxy for LocalLength
5126 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5129 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5130 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5132 def SetLayerDistribution(self, hypo):
5133 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5134 hypo.ClearParameters();
5135 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5137 #Registering the new proxy for LayerDistribution
5138 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5140 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5141 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5143 ## Set Length parameter value
5144 # @param length numerical value or name of variable from notebook
5145 def SetLength(self, length):
5146 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5147 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5148 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5150 #Registering the new proxy for SegmentLengthAroundVertex
5151 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5154 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5155 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5157 ## Set Length parameter value
5158 # @param length numerical value or name of variable from notebook
5159 # @param isStart true is length is Start Length, otherwise false
5160 def SetLength(self, length, isStart):
5164 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5165 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5166 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5168 #Registering the new proxy for Arithmetic1D
5169 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5171 #Wrapper class for StdMeshers_Deflection1D hypothesis
5172 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5174 ## Set Deflection parameter value
5175 # @param deflection numerical value or name of variable from notebook
5176 def SetDeflection(self, deflection):
5177 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5178 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5179 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5181 #Registering the new proxy for Deflection1D
5182 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5184 #Wrapper class for StdMeshers_StartEndLength hypothesis
5185 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5187 ## Set Length parameter value
5188 # @param length numerical value or name of variable from notebook
5189 # @param isStart true is length is Start Length, otherwise false
5190 def SetLength(self, length, isStart):
5194 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5195 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5196 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5198 #Registering the new proxy for StartEndLength
5199 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5201 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5202 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5204 ## Set Max Element Area parameter value
5205 # @param area numerical value or name of variable from notebook
5206 def SetMaxElementArea(self, area):
5207 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5208 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5209 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5211 #Registering the new proxy for MaxElementArea
5212 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5215 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5216 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5218 ## Set Max Element Volume parameter value
5219 # @param volume numerical value or name of variable from notebook
5220 def SetMaxElementVolume(self, volume):
5221 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5222 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5223 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5225 #Registering the new proxy for MaxElementVolume
5226 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5229 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5230 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5232 ## Set Number Of Layers parameter value
5233 # @param nbLayers numerical value or name of variable from notebook
5234 def SetNumberOfLayers(self, nbLayers):
5235 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5236 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5237 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5239 #Registering the new proxy for NumberOfLayers
5240 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5242 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5243 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5245 ## Set Number Of Segments parameter value
5246 # @param nbSeg numerical value or name of variable from notebook
5247 def SetNumberOfSegments(self, nbSeg):
5248 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5249 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5250 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5251 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5253 ## Set Scale Factor parameter value
5254 # @param factor numerical value or name of variable from notebook
5255 def SetScaleFactor(self, factor):
5256 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5257 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5258 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5260 #Registering the new proxy for NumberOfSegments
5261 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5263 if not noNETGENPlugin:
5264 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5265 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5267 ## Set Max Size parameter value
5268 # @param maxsize numerical value or name of variable from notebook
5269 def SetMaxSize(self, maxsize):
5270 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5271 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5272 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5273 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5275 ## Set Growth Rate parameter value
5276 # @param value numerical value or name of variable from notebook
5277 def SetGrowthRate(self, value):
5278 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5279 value, parameters = ParseParameters(lastParameters,4,2,value)
5280 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5281 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5283 ## Set Number of Segments per Edge parameter value
5284 # @param value numerical value or name of variable from notebook
5285 def SetNbSegPerEdge(self, value):
5286 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5287 value, parameters = ParseParameters(lastParameters,4,3,value)
5288 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5289 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5291 ## Set Number of Segments per Radius parameter value
5292 # @param value numerical value or name of variable from notebook
5293 def SetNbSegPerRadius(self, value):
5294 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5295 value, parameters = ParseParameters(lastParameters,4,4,value)
5296 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5297 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5299 #Registering the new proxy for NETGENPlugin_Hypothesis
5300 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5303 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5304 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5307 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5308 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5310 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5311 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5313 ## Set Number of Segments parameter value
5314 # @param nbSeg numerical value or name of variable from notebook
5315 def SetNumberOfSegments(self, nbSeg):
5316 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5317 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5318 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5319 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5321 ## Set Local Length parameter value
5322 # @param length numerical value or name of variable from notebook
5323 def SetLocalLength(self, length):
5324 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5325 length, parameters = ParseParameters(lastParameters,2,1,length)
5326 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5327 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5329 ## Set Max Element Area parameter value
5330 # @param area numerical value or name of variable from notebook
5331 def SetMaxElementArea(self, area):
5332 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5333 area, parameters = ParseParameters(lastParameters,2,2,area)
5334 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5335 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5337 def LengthFromEdges(self):
5338 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5340 value, parameters = ParseParameters(lastParameters,2,2,value)
5341 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5342 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5344 #Registering the new proxy for NETGEN_SimpleParameters_2D
5345 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5348 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5349 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5350 ## Set Max Element Volume parameter value
5351 # @param volume numerical value or name of variable from notebook
5352 def SetMaxElementVolume(self, volume):
5353 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5354 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5355 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5356 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5358 def LengthFromFaces(self):
5359 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5361 value, parameters = ParseParameters(lastParameters,3,3,value)
5362 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5363 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5365 #Registering the new proxy for NETGEN_SimpleParameters_3D
5366 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5368 pass # if not noNETGENPlugin:
5370 class Pattern(SMESH._objref_SMESH_Pattern):
5372 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5374 if isinstance(theNodeIndexOnKeyPoint1,str):
5376 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5378 theNodeIndexOnKeyPoint1 -= 1
5379 theMesh.SetParameters(Parameters)
5380 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5382 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5385 if isinstance(theNode000Index,str):
5387 if isinstance(theNode001Index,str):
5389 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5391 theNode000Index -= 1
5393 theNode001Index -= 1
5394 theMesh.SetParameters(Parameters)
5395 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5397 #Registering the new proxy for Pattern
5398 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)