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 try: # it raises on a compound of compounds
1397 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1398 print "Mesh.Group: empty geometric group", GetName( grp )
1403 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1405 tgeo = self.geompyD.GetType(grp)
1406 if tgeo == geompyDC.ShapeType["VERTEX"]:
1408 elif tgeo == geompyDC.ShapeType["EDGE"]:
1410 elif tgeo == geompyDC.ShapeType["FACE"]:
1412 elif tgeo == geompyDC.ShapeType["SOLID"]:
1418 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1419 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1420 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1428 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1431 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1433 ## Creates a mesh group by the given ids of elements
1434 # @param groupName the name of the mesh group
1435 # @param elementType the type of elements in the group
1436 # @param elemIDs the list of ids
1437 # @return SMESH_Group
1438 # @ingroup l2_grps_create
1439 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1440 group = self.mesh.CreateGroup(elementType, groupName)
1444 ## Creates a mesh group by the given conditions
1445 # @param groupName the name of the mesh group
1446 # @param elementType the type of elements in the group
1447 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1448 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1449 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1450 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1451 # @return SMESH_Group
1452 # @ingroup l2_grps_create
1456 CritType=FT_Undefined,
1459 UnaryOp=FT_Undefined):
1460 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1461 group = self.MakeGroupByCriterion(groupName, aCriterion)
1464 ## Creates a mesh group by the given criterion
1465 # @param groupName the name of the mesh group
1466 # @param Criterion the instance of Criterion class
1467 # @return SMESH_Group
1468 # @ingroup l2_grps_create
1469 def MakeGroupByCriterion(self, groupName, Criterion):
1470 aFilterMgr = self.smeshpyD.CreateFilterManager()
1471 aFilter = aFilterMgr.CreateFilter()
1473 aCriteria.append(Criterion)
1474 aFilter.SetCriteria(aCriteria)
1475 group = self.MakeGroupByFilter(groupName, aFilter)
1478 ## Creates a mesh group by the given criteria (list of criteria)
1479 # @param groupName the name of the mesh group
1480 # @param theCriteria the list of criteria
1481 # @return SMESH_Group
1482 # @ingroup l2_grps_create
1483 def MakeGroupByCriteria(self, groupName, theCriteria):
1484 aFilterMgr = self.smeshpyD.CreateFilterManager()
1485 aFilter = aFilterMgr.CreateFilter()
1486 aFilter.SetCriteria(theCriteria)
1487 group = self.MakeGroupByFilter(groupName, aFilter)
1490 ## Creates a mesh group by the given filter
1491 # @param groupName the name of the mesh group
1492 # @param theFilter the instance of Filter class
1493 # @return SMESH_Group
1494 # @ingroup l2_grps_create
1495 def MakeGroupByFilter(self, groupName, theFilter):
1496 anIds = theFilter.GetElementsId(self.mesh)
1497 anElemType = theFilter.GetElementType()
1498 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1501 ## Passes mesh elements through the given filter and return IDs of fitting elements
1502 # @param theFilter SMESH_Filter
1503 # @return a list of ids
1504 # @ingroup l1_controls
1505 def GetIdsFromFilter(self, theFilter):
1506 return theFilter.GetElementsId(self.mesh)
1508 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1509 # Returns a list of special structures (borders).
1510 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1511 # @ingroup l1_controls
1512 def GetFreeBorders(self):
1513 aFilterMgr = self.smeshpyD.CreateFilterManager()
1514 aPredicate = aFilterMgr.CreateFreeEdges()
1515 aPredicate.SetMesh(self.mesh)
1516 aBorders = aPredicate.GetBorders()
1520 # @ingroup l2_grps_delete
1521 def RemoveGroup(self, group):
1522 self.mesh.RemoveGroup(group)
1524 ## Removes a group with its contents
1525 # @ingroup l2_grps_delete
1526 def RemoveGroupWithContents(self, group):
1527 self.mesh.RemoveGroupWithContents(group)
1529 ## Gets the list of groups existing in the mesh
1530 # @return a sequence of SMESH_GroupBase
1531 # @ingroup l2_grps_create
1532 def GetGroups(self):
1533 return self.mesh.GetGroups()
1535 ## Gets the number of groups existing in the mesh
1536 # @return the quantity of groups as an integer value
1537 # @ingroup l2_grps_create
1539 return self.mesh.NbGroups()
1541 ## Gets the list of names of groups existing in the mesh
1542 # @return list of strings
1543 # @ingroup l2_grps_create
1544 def GetGroupNames(self):
1545 groups = self.GetGroups()
1547 for group in groups:
1548 names.append(group.GetName())
1551 ## Produces a union of two groups
1552 # A new group is created. All mesh elements that are
1553 # present in the initial groups are added to the new one
1554 # @return an instance of SMESH_Group
1555 # @ingroup l2_grps_operon
1556 def UnionGroups(self, group1, group2, name):
1557 return self.mesh.UnionGroups(group1, group2, name)
1559 ## Produces a union list of groups
1560 # New group is created. All mesh elements that are present in
1561 # initial groups are added to the new one
1562 # @return an instance of SMESH_Group
1563 # @ingroup l2_grps_operon
1564 def UnionListOfGroups(self, groups, name):
1565 return self.mesh.UnionListOfGroups(groups, name)
1567 ## Prodices an intersection of two groups
1568 # A new group is created. All mesh elements that are common
1569 # for the two initial groups are added to the new one.
1570 # @return an instance of SMESH_Group
1571 # @ingroup l2_grps_operon
1572 def IntersectGroups(self, group1, group2, name):
1573 return self.mesh.IntersectGroups(group1, group2, name)
1575 ## Produces an intersection of groups
1576 # New group is created. All mesh elements that are present in all
1577 # initial groups simultaneously are added to the new one
1578 # @return an instance of SMESH_Group
1579 # @ingroup l2_grps_operon
1580 def IntersectListOfGroups(self, groups, name):
1581 return self.mesh.IntersectListOfGroups(groups, name)
1583 ## Produces a cut of two groups
1584 # A new group is created. All mesh elements that are present in
1585 # the main group but are not present in the tool group are added to the new one
1586 # @return an instance of SMESH_Group
1587 # @ingroup l2_grps_operon
1588 def CutGroups(self, main_group, tool_group, name):
1589 return self.mesh.CutGroups(main_group, tool_group, name)
1591 ## Produces a cut of groups
1592 # A new group is created. All mesh elements that are present in main groups
1593 # but do not present in tool groups are added to the new one
1594 # @return an instance of SMESH_Group
1595 # @ingroup l2_grps_operon
1596 def CutListOfGroups(self, main_groups, tool_groups, name):
1597 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1599 ## Produces a group of elements with specified element type using list of existing groups
1600 # A new group is created. System
1601 # 1) extract all nodes on which groups elements are built
1602 # 2) combine all elements of specified dimension laying on these nodes
1603 # @return an instance of SMESH_Group
1604 # @ingroup l2_grps_operon
1605 def CreateDimGroup(self, groups, elem_type, name):
1606 return self.mesh.CreateDimGroup(groups, elem_type, name)
1609 ## Convert group on geom into standalone group
1610 # @ingroup l2_grps_delete
1611 def ConvertToStandalone(self, group):
1612 return self.mesh.ConvertToStandalone(group)
1614 # Get some info about mesh:
1615 # ------------------------
1617 ## Returns the log of nodes and elements added or removed
1618 # since the previous clear of the log.
1619 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1620 # @return list of log_block structures:
1625 # @ingroup l1_auxiliary
1626 def GetLog(self, clearAfterGet):
1627 return self.mesh.GetLog(clearAfterGet)
1629 ## Clears the log of nodes and elements added or removed since the previous
1630 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1631 # @ingroup l1_auxiliary
1633 self.mesh.ClearLog()
1635 ## Toggles auto color mode on the object.
1636 # @param theAutoColor the flag which toggles auto color mode.
1637 # @ingroup l1_auxiliary
1638 def SetAutoColor(self, theAutoColor):
1639 self.mesh.SetAutoColor(theAutoColor)
1641 ## Gets flag of object auto color mode.
1642 # @return True or False
1643 # @ingroup l1_auxiliary
1644 def GetAutoColor(self):
1645 return self.mesh.GetAutoColor()
1647 ## Gets the internal ID
1648 # @return integer value, which is the internal Id of the mesh
1649 # @ingroup l1_auxiliary
1651 return self.mesh.GetId()
1654 # @return integer value, which is the study Id of the mesh
1655 # @ingroup l1_auxiliary
1656 def GetStudyId(self):
1657 return self.mesh.GetStudyId()
1659 ## Checks the group names for duplications.
1660 # Consider the maximum group name length stored in MED file.
1661 # @return True or False
1662 # @ingroup l1_auxiliary
1663 def HasDuplicatedGroupNamesMED(self):
1664 return self.mesh.HasDuplicatedGroupNamesMED()
1666 ## Obtains the mesh editor tool
1667 # @return an instance of SMESH_MeshEditor
1668 # @ingroup l1_modifying
1669 def GetMeshEditor(self):
1670 return self.mesh.GetMeshEditor()
1673 # @return an instance of SALOME_MED::MESH
1674 # @ingroup l1_auxiliary
1675 def GetMEDMesh(self):
1676 return self.mesh.GetMEDMesh()
1679 # Get informations about mesh contents:
1680 # ------------------------------------
1682 ## Gets the mesh stattistic
1683 # @return dictionary type element - count of elements
1684 # @ingroup l1_meshinfo
1685 def GetMeshInfo(self, obj = None):
1686 if not obj: obj = self.mesh
1687 return self.smeshpyD.GetMeshInfo(obj)
1689 ## Returns the number of nodes in the mesh
1690 # @return an integer value
1691 # @ingroup l1_meshinfo
1693 return self.mesh.NbNodes()
1695 ## Returns the number of elements in the mesh
1696 # @return an integer value
1697 # @ingroup l1_meshinfo
1698 def NbElements(self):
1699 return self.mesh.NbElements()
1701 ## Returns the number of 0d elements in the mesh
1702 # @return an integer value
1703 # @ingroup l1_meshinfo
1704 def Nb0DElements(self):
1705 return self.mesh.Nb0DElements()
1707 ## Returns the number of edges in the mesh
1708 # @return an integer value
1709 # @ingroup l1_meshinfo
1711 return self.mesh.NbEdges()
1713 ## Returns the number of edges with the given order in the mesh
1714 # @param elementOrder the order of elements:
1715 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1716 # @return an integer value
1717 # @ingroup l1_meshinfo
1718 def NbEdgesOfOrder(self, elementOrder):
1719 return self.mesh.NbEdgesOfOrder(elementOrder)
1721 ## Returns the number of faces in the mesh
1722 # @return an integer value
1723 # @ingroup l1_meshinfo
1725 return self.mesh.NbFaces()
1727 ## Returns the number of faces with the given order in the mesh
1728 # @param elementOrder the order of elements:
1729 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1730 # @return an integer value
1731 # @ingroup l1_meshinfo
1732 def NbFacesOfOrder(self, elementOrder):
1733 return self.mesh.NbFacesOfOrder(elementOrder)
1735 ## Returns the number of triangles in the mesh
1736 # @return an integer value
1737 # @ingroup l1_meshinfo
1738 def NbTriangles(self):
1739 return self.mesh.NbTriangles()
1741 ## Returns the number of triangles with the given order in the mesh
1742 # @param elementOrder is the order of elements:
1743 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1744 # @return an integer value
1745 # @ingroup l1_meshinfo
1746 def NbTrianglesOfOrder(self, elementOrder):
1747 return self.mesh.NbTrianglesOfOrder(elementOrder)
1749 ## Returns the number of quadrangles in the mesh
1750 # @return an integer value
1751 # @ingroup l1_meshinfo
1752 def NbQuadrangles(self):
1753 return self.mesh.NbQuadrangles()
1755 ## Returns the number of quadrangles with the given order in the mesh
1756 # @param elementOrder the order of elements:
1757 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1758 # @return an integer value
1759 # @ingroup l1_meshinfo
1760 def NbQuadranglesOfOrder(self, elementOrder):
1761 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1763 ## Returns the number of polygons in the mesh
1764 # @return an integer value
1765 # @ingroup l1_meshinfo
1766 def NbPolygons(self):
1767 return self.mesh.NbPolygons()
1769 ## Returns the number of volumes in the mesh
1770 # @return an integer value
1771 # @ingroup l1_meshinfo
1772 def NbVolumes(self):
1773 return self.mesh.NbVolumes()
1775 ## Returns the number of volumes with the given order in the mesh
1776 # @param elementOrder the order of elements:
1777 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1778 # @return an integer value
1779 # @ingroup l1_meshinfo
1780 def NbVolumesOfOrder(self, elementOrder):
1781 return self.mesh.NbVolumesOfOrder(elementOrder)
1783 ## Returns the number of tetrahedrons in the mesh
1784 # @return an integer value
1785 # @ingroup l1_meshinfo
1787 return self.mesh.NbTetras()
1789 ## Returns the number of tetrahedrons with the given order in the mesh
1790 # @param elementOrder the order of elements:
1791 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1792 # @return an integer value
1793 # @ingroup l1_meshinfo
1794 def NbTetrasOfOrder(self, elementOrder):
1795 return self.mesh.NbTetrasOfOrder(elementOrder)
1797 ## Returns the number of hexahedrons in the mesh
1798 # @return an integer value
1799 # @ingroup l1_meshinfo
1801 return self.mesh.NbHexas()
1803 ## Returns the number of hexahedrons with the given order in the mesh
1804 # @param elementOrder the order of elements:
1805 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1806 # @return an integer value
1807 # @ingroup l1_meshinfo
1808 def NbHexasOfOrder(self, elementOrder):
1809 return self.mesh.NbHexasOfOrder(elementOrder)
1811 ## Returns the number of pyramids in the mesh
1812 # @return an integer value
1813 # @ingroup l1_meshinfo
1814 def NbPyramids(self):
1815 return self.mesh.NbPyramids()
1817 ## Returns the number of pyramids with the given order in the mesh
1818 # @param elementOrder the order of elements:
1819 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1820 # @return an integer value
1821 # @ingroup l1_meshinfo
1822 def NbPyramidsOfOrder(self, elementOrder):
1823 return self.mesh.NbPyramidsOfOrder(elementOrder)
1825 ## Returns the number of prisms in the mesh
1826 # @return an integer value
1827 # @ingroup l1_meshinfo
1829 return self.mesh.NbPrisms()
1831 ## Returns the number of prisms with the given order in the mesh
1832 # @param elementOrder the order of elements:
1833 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1834 # @return an integer value
1835 # @ingroup l1_meshinfo
1836 def NbPrismsOfOrder(self, elementOrder):
1837 return self.mesh.NbPrismsOfOrder(elementOrder)
1839 ## Returns the number of polyhedrons in the mesh
1840 # @return an integer value
1841 # @ingroup l1_meshinfo
1842 def NbPolyhedrons(self):
1843 return self.mesh.NbPolyhedrons()
1845 ## Returns the number of submeshes in the mesh
1846 # @return an integer value
1847 # @ingroup l1_meshinfo
1848 def NbSubMesh(self):
1849 return self.mesh.NbSubMesh()
1851 ## Returns the list of mesh elements IDs
1852 # @return the list of integer values
1853 # @ingroup l1_meshinfo
1854 def GetElementsId(self):
1855 return self.mesh.GetElementsId()
1857 ## Returns the list of IDs of mesh elements with the given type
1858 # @param elementType the required type of elements
1859 # @return list of integer values
1860 # @ingroup l1_meshinfo
1861 def GetElementsByType(self, elementType):
1862 return self.mesh.GetElementsByType(elementType)
1864 ## Returns the list of mesh nodes IDs
1865 # @return the list of integer values
1866 # @ingroup l1_meshinfo
1867 def GetNodesId(self):
1868 return self.mesh.GetNodesId()
1870 # Get the information about mesh elements:
1871 # ------------------------------------
1873 ## Returns the type of mesh element
1874 # @return the value from SMESH::ElementType enumeration
1875 # @ingroup l1_meshinfo
1876 def GetElementType(self, id, iselem):
1877 return self.mesh.GetElementType(id, iselem)
1879 ## Returns the list of submesh elements IDs
1880 # @param Shape a geom object(subshape) IOR
1881 # Shape must be the subshape of a ShapeToMesh()
1882 # @return the list of integer values
1883 # @ingroup l1_meshinfo
1884 def GetSubMeshElementsId(self, Shape):
1885 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1886 ShapeID = Shape.GetSubShapeIndices()[0]
1889 return self.mesh.GetSubMeshElementsId(ShapeID)
1891 ## Returns the list of submesh nodes IDs
1892 # @param Shape a geom object(subshape) IOR
1893 # Shape must be the subshape of a ShapeToMesh()
1894 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1895 # @return the list of integer values
1896 # @ingroup l1_meshinfo
1897 def GetSubMeshNodesId(self, Shape, all):
1898 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1899 ShapeID = Shape.GetSubShapeIndices()[0]
1902 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1904 ## Returns type of elements on given shape
1905 # @param Shape a geom object(subshape) IOR
1906 # Shape must be a subshape of a ShapeToMesh()
1907 # @return element type
1908 # @ingroup l1_meshinfo
1909 def GetSubMeshElementType(self, Shape):
1910 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1911 ShapeID = Shape.GetSubShapeIndices()[0]
1914 return self.mesh.GetSubMeshElementType(ShapeID)
1916 ## Gets the mesh description
1917 # @return string value
1918 # @ingroup l1_meshinfo
1920 return self.mesh.Dump()
1923 # Get the information about nodes and elements of a mesh by its IDs:
1924 # -----------------------------------------------------------
1926 ## Gets XYZ coordinates of a node
1927 # \n If there is no nodes for the given ID - returns an empty list
1928 # @return a list of double precision values
1929 # @ingroup l1_meshinfo
1930 def GetNodeXYZ(self, id):
1931 return self.mesh.GetNodeXYZ(id)
1933 ## Returns list of IDs of inverse elements for the given node
1934 # \n If there is no node for the given ID - returns an empty list
1935 # @return a list of integer values
1936 # @ingroup l1_meshinfo
1937 def GetNodeInverseElements(self, id):
1938 return self.mesh.GetNodeInverseElements(id)
1940 ## @brief Returns the position of a node on the shape
1941 # @return SMESH::NodePosition
1942 # @ingroup l1_meshinfo
1943 def GetNodePosition(self,NodeID):
1944 return self.mesh.GetNodePosition(NodeID)
1946 ## If the given element is a node, returns the ID of shape
1947 # \n If there is no node for the given ID - returns -1
1948 # @return an integer value
1949 # @ingroup l1_meshinfo
1950 def GetShapeID(self, id):
1951 return self.mesh.GetShapeID(id)
1953 ## Returns the ID of the result shape after
1954 # FindShape() from SMESH_MeshEditor for the given element
1955 # \n If there is no element for the given ID - returns -1
1956 # @return an integer value
1957 # @ingroup l1_meshinfo
1958 def GetShapeIDForElem(self,id):
1959 return self.mesh.GetShapeIDForElem(id)
1961 ## Returns the number of nodes for the given element
1962 # \n If there is no element for the given ID - returns -1
1963 # @return an integer value
1964 # @ingroup l1_meshinfo
1965 def GetElemNbNodes(self, id):
1966 return self.mesh.GetElemNbNodes(id)
1968 ## Returns the node ID the given index for the given element
1969 # \n If there is no element for the given ID - returns -1
1970 # \n If there is no node for the given index - returns -2
1971 # @return an integer value
1972 # @ingroup l1_meshinfo
1973 def GetElemNode(self, id, index):
1974 return self.mesh.GetElemNode(id, index)
1976 ## Returns the IDs of nodes of the given element
1977 # @return a list of integer values
1978 # @ingroup l1_meshinfo
1979 def GetElemNodes(self, id):
1980 return self.mesh.GetElemNodes(id)
1982 ## Returns true if the given node is the medium node in the given quadratic element
1983 # @ingroup l1_meshinfo
1984 def IsMediumNode(self, elementID, nodeID):
1985 return self.mesh.IsMediumNode(elementID, nodeID)
1987 ## Returns true if the given node is the medium node in one of quadratic elements
1988 # @ingroup l1_meshinfo
1989 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1990 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1992 ## Returns the number of edges for the given element
1993 # @ingroup l1_meshinfo
1994 def ElemNbEdges(self, id):
1995 return self.mesh.ElemNbEdges(id)
1997 ## Returns the number of faces for the given element
1998 # @ingroup l1_meshinfo
1999 def ElemNbFaces(self, id):
2000 return self.mesh.ElemNbFaces(id)
2002 ## Returns true if the given element is a polygon
2003 # @ingroup l1_meshinfo
2004 def IsPoly(self, id):
2005 return self.mesh.IsPoly(id)
2007 ## Returns true if the given element is quadratic
2008 # @ingroup l1_meshinfo
2009 def IsQuadratic(self, id):
2010 return self.mesh.IsQuadratic(id)
2012 ## Returns XYZ coordinates of the barycenter of the given element
2013 # \n If there is no element for the given ID - returns an empty list
2014 # @return a list of three double values
2015 # @ingroup l1_meshinfo
2016 def BaryCenter(self, id):
2017 return self.mesh.BaryCenter(id)
2020 # Mesh edition (SMESH_MeshEditor functionality):
2021 # ---------------------------------------------
2023 ## Removes the elements from the mesh by ids
2024 # @param IDsOfElements is a list of ids of elements to remove
2025 # @return True or False
2026 # @ingroup l2_modif_del
2027 def RemoveElements(self, IDsOfElements):
2028 return self.editor.RemoveElements(IDsOfElements)
2030 ## Removes nodes from mesh by ids
2031 # @param IDsOfNodes is a list of ids of nodes to remove
2032 # @return True or False
2033 # @ingroup l2_modif_del
2034 def RemoveNodes(self, IDsOfNodes):
2035 return self.editor.RemoveNodes(IDsOfNodes)
2037 ## Add a node to the mesh by coordinates
2038 # @return Id of the new node
2039 # @ingroup l2_modif_add
2040 def AddNode(self, x, y, z):
2041 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2042 self.mesh.SetParameters(Parameters)
2043 return self.editor.AddNode( x, y, z)
2045 ## Creates a 0D element on a node with given number.
2046 # @param IDOfNode the ID of node for creation of the element.
2047 # @return the Id of the new 0D element
2048 # @ingroup l2_modif_add
2049 def Add0DElement(self, IDOfNode):
2050 return self.editor.Add0DElement(IDOfNode)
2052 ## Creates a linear or quadratic edge (this is determined
2053 # by the number of given nodes).
2054 # @param IDsOfNodes the list of node IDs for creation of the element.
2055 # The order of nodes in this list should correspond to the description
2056 # of MED. \n This description is located by the following link:
2057 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2058 # @return the Id of the new edge
2059 # @ingroup l2_modif_add
2060 def AddEdge(self, IDsOfNodes):
2061 return self.editor.AddEdge(IDsOfNodes)
2063 ## Creates a linear or quadratic face (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 face
2070 # @ingroup l2_modif_add
2071 def AddFace(self, IDsOfNodes):
2072 return self.editor.AddFace(IDsOfNodes)
2074 ## Adds a polygonal face to the mesh by the list of node IDs
2075 # @param IdsOfNodes the list of node IDs for creation of the element.
2076 # @return the Id of the new face
2077 # @ingroup l2_modif_add
2078 def AddPolygonalFace(self, IdsOfNodes):
2079 return self.editor.AddPolygonalFace(IdsOfNodes)
2081 ## Creates both simple and quadratic volume (this is determined
2082 # by the number of given nodes).
2083 # @param IDsOfNodes the list of node IDs for creation of the element.
2084 # The order of nodes in this list should correspond to the description
2085 # of MED. \n This description is located by the following link:
2086 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2087 # @return the Id of the new volumic element
2088 # @ingroup l2_modif_add
2089 def AddVolume(self, IDsOfNodes):
2090 return self.editor.AddVolume(IDsOfNodes)
2092 ## Creates a volume of many faces, giving nodes for each face.
2093 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2094 # @param Quantities the list of integer values, Quantities[i]
2095 # gives the quantity of nodes in face number i.
2096 # @return the Id of the new volumic element
2097 # @ingroup l2_modif_add
2098 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2099 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2101 ## Creates a volume of many faces, giving the IDs of the existing faces.
2102 # @param IdsOfFaces the list of face IDs for volume creation.
2104 # Note: The created volume will refer only to the nodes
2105 # of the given faces, not to the faces themselves.
2106 # @return the Id of the new volumic element
2107 # @ingroup l2_modif_add
2108 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2109 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2112 ## @brief Binds a node to a vertex
2113 # @param NodeID a node ID
2114 # @param Vertex a vertex or vertex ID
2115 # @return True if succeed else raises an exception
2116 # @ingroup l2_modif_add
2117 def SetNodeOnVertex(self, NodeID, Vertex):
2118 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2119 VertexID = Vertex.GetSubShapeIndices()[0]
2123 self.editor.SetNodeOnVertex(NodeID, VertexID)
2124 except SALOME.SALOME_Exception, inst:
2125 raise ValueError, inst.details.text
2129 ## @brief Stores the node position on an edge
2130 # @param NodeID a node ID
2131 # @param Edge an edge or edge ID
2132 # @param paramOnEdge a parameter on the edge where the node is located
2133 # @return True if succeed else raises an exception
2134 # @ingroup l2_modif_add
2135 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2136 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2137 EdgeID = Edge.GetSubShapeIndices()[0]
2141 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2142 except SALOME.SALOME_Exception, inst:
2143 raise ValueError, inst.details.text
2146 ## @brief Stores node position on a face
2147 # @param NodeID a node ID
2148 # @param Face a face or face ID
2149 # @param u U parameter on the face where the node is located
2150 # @param v V parameter on the face where the node is located
2151 # @return True if succeed else raises an exception
2152 # @ingroup l2_modif_add
2153 def SetNodeOnFace(self, NodeID, Face, u, v):
2154 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2155 FaceID = Face.GetSubShapeIndices()[0]
2159 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2160 except SALOME.SALOME_Exception, inst:
2161 raise ValueError, inst.details.text
2164 ## @brief Binds a node to a solid
2165 # @param NodeID a node ID
2166 # @param Solid a solid or solid ID
2167 # @return True if succeed else raises an exception
2168 # @ingroup l2_modif_add
2169 def SetNodeInVolume(self, NodeID, Solid):
2170 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2171 SolidID = Solid.GetSubShapeIndices()[0]
2175 self.editor.SetNodeInVolume(NodeID, SolidID)
2176 except SALOME.SALOME_Exception, inst:
2177 raise ValueError, inst.details.text
2180 ## @brief Bind an element to a shape
2181 # @param ElementID an element ID
2182 # @param Shape a shape or shape ID
2183 # @return True if succeed else raises an exception
2184 # @ingroup l2_modif_add
2185 def SetMeshElementOnShape(self, ElementID, Shape):
2186 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2187 ShapeID = Shape.GetSubShapeIndices()[0]
2191 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2192 except SALOME.SALOME_Exception, inst:
2193 raise ValueError, inst.details.text
2197 ## Moves the node with the given id
2198 # @param NodeID the id of the node
2199 # @param x a new X coordinate
2200 # @param y a new Y coordinate
2201 # @param z a new Z coordinate
2202 # @return True if succeed else False
2203 # @ingroup l2_modif_movenode
2204 def MoveNode(self, NodeID, x, y, z):
2205 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2206 self.mesh.SetParameters(Parameters)
2207 return self.editor.MoveNode(NodeID, x, y, z)
2209 ## Finds the node closest to a point and moves it to a point location
2210 # @param x the X coordinate of a point
2211 # @param y the Y coordinate of a point
2212 # @param z the Z coordinate of a point
2213 # @param NodeID if specified (>0), the node with this ID is moved,
2214 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2215 # @return the ID of a node
2216 # @ingroup l2_modif_throughp
2217 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2218 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2219 self.mesh.SetParameters(Parameters)
2220 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2222 ## Finds the node closest to a point
2223 # @param x the X coordinate of a point
2224 # @param y the Y coordinate of a point
2225 # @param z the Z coordinate of a point
2226 # @return the ID of a node
2227 # @ingroup l2_modif_throughp
2228 def FindNodeClosestTo(self, x, y, z):
2229 #preview = self.mesh.GetMeshEditPreviewer()
2230 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2231 return self.editor.FindNodeClosestTo(x, y, z)
2233 ## Finds the elements where a point lays IN or ON
2234 # @param x the X coordinate of a point
2235 # @param y the Y coordinate of a point
2236 # @param z the Z coordinate of a point
2237 # @param elementType type of elements to find (SMESH.ALL type
2238 # means elements of any type excluding nodes and 0D elements)
2239 # @return list of IDs of found elements
2240 # @ingroup l2_modif_throughp
2241 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2242 return self.editor.FindElementsByPoint(x, y, z, elementType)
2245 ## Finds the node closest to a point and moves it to a point location
2246 # @param x the X coordinate of a point
2247 # @param y the Y coordinate of a point
2248 # @param z the Z coordinate of a point
2249 # @return the ID of a moved node
2250 # @ingroup l2_modif_throughp
2251 def MeshToPassThroughAPoint(self, x, y, z):
2252 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2254 ## Replaces two neighbour triangles sharing Node1-Node2 link
2255 # with the triangles built on the same 4 nodes but having other common link.
2256 # @param NodeID1 the ID of the first node
2257 # @param NodeID2 the ID of the second node
2258 # @return false if proper faces were not found
2259 # @ingroup l2_modif_invdiag
2260 def InverseDiag(self, NodeID1, NodeID2):
2261 return self.editor.InverseDiag(NodeID1, NodeID2)
2263 ## Replaces two neighbour triangles sharing Node1-Node2 link
2264 # with a quadrangle built on the same 4 nodes.
2265 # @param NodeID1 the ID of the first node
2266 # @param NodeID2 the ID of the second node
2267 # @return false if proper faces were not found
2268 # @ingroup l2_modif_unitetri
2269 def DeleteDiag(self, NodeID1, NodeID2):
2270 return self.editor.DeleteDiag(NodeID1, NodeID2)
2272 ## Reorients elements by ids
2273 # @param IDsOfElements if undefined reorients all mesh elements
2274 # @return True if succeed else False
2275 # @ingroup l2_modif_changori
2276 def Reorient(self, IDsOfElements=None):
2277 if IDsOfElements == None:
2278 IDsOfElements = self.GetElementsId()
2279 return self.editor.Reorient(IDsOfElements)
2281 ## Reorients all elements of the object
2282 # @param theObject mesh, submesh or group
2283 # @return True if succeed else False
2284 # @ingroup l2_modif_changori
2285 def ReorientObject(self, theObject):
2286 if ( isinstance( theObject, Mesh )):
2287 theObject = theObject.GetMesh()
2288 return self.editor.ReorientObject(theObject)
2290 ## Fuses the neighbouring triangles into quadrangles.
2291 # @param IDsOfElements The triangles to be fused,
2292 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2293 # @param MaxAngle is the maximum angle between element normals at which the fusion
2294 # is still performed; theMaxAngle is mesured in radians.
2295 # Also it could be a name of variable which defines angle in degrees.
2296 # @return TRUE in case of success, FALSE otherwise.
2297 # @ingroup l2_modif_unitetri
2298 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2300 if isinstance(MaxAngle,str):
2302 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2304 MaxAngle = DegreesToRadians(MaxAngle)
2305 if IDsOfElements == []:
2306 IDsOfElements = self.GetElementsId()
2307 self.mesh.SetParameters(Parameters)
2309 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2310 Functor = theCriterion
2312 Functor = self.smeshpyD.GetFunctor(theCriterion)
2313 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2315 ## Fuses the neighbouring triangles of the object into quadrangles
2316 # @param theObject is mesh, submesh or group
2317 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2318 # @param MaxAngle a max angle between element normals at which the fusion
2319 # is still performed; theMaxAngle is mesured in radians.
2320 # @return TRUE in case of success, FALSE otherwise.
2321 # @ingroup l2_modif_unitetri
2322 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2323 if ( isinstance( theObject, Mesh )):
2324 theObject = theObject.GetMesh()
2325 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2327 ## Splits quadrangles into triangles.
2328 # @param IDsOfElements the faces to be splitted.
2329 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2330 # @return TRUE in case of success, FALSE otherwise.
2331 # @ingroup l2_modif_cutquadr
2332 def QuadToTri (self, IDsOfElements, theCriterion):
2333 if IDsOfElements == []:
2334 IDsOfElements = self.GetElementsId()
2335 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2337 ## Splits quadrangles into triangles.
2338 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2339 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2340 # @return TRUE in case of success, FALSE otherwise.
2341 # @ingroup l2_modif_cutquadr
2342 def QuadToTriObject (self, theObject, theCriterion):
2343 if ( isinstance( theObject, Mesh )):
2344 theObject = theObject.GetMesh()
2345 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2347 ## Splits quadrangles into triangles.
2348 # @param IDsOfElements the faces to be splitted
2349 # @param Diag13 is used to choose a diagonal for splitting.
2350 # @return TRUE in case of success, FALSE otherwise.
2351 # @ingroup l2_modif_cutquadr
2352 def SplitQuad (self, IDsOfElements, Diag13):
2353 if IDsOfElements == []:
2354 IDsOfElements = self.GetElementsId()
2355 return self.editor.SplitQuad(IDsOfElements, Diag13)
2357 ## Splits quadrangles into triangles.
2358 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2359 # @param Diag13 is used to choose a diagonal for splitting.
2360 # @return TRUE in case of success, FALSE otherwise.
2361 # @ingroup l2_modif_cutquadr
2362 def SplitQuadObject (self, theObject, Diag13):
2363 if ( isinstance( theObject, Mesh )):
2364 theObject = theObject.GetMesh()
2365 return self.editor.SplitQuadObject(theObject, Diag13)
2367 ## Finds a better splitting of the given quadrangle.
2368 # @param IDOfQuad the ID of the quadrangle to be splitted.
2369 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2370 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2371 # diagonal is better, 0 if error occurs.
2372 # @ingroup l2_modif_cutquadr
2373 def BestSplit (self, IDOfQuad, theCriterion):
2374 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2376 ## Splits quadrangle faces near triangular facets of volumes
2378 # @ingroup l1_auxiliary
2379 def SplitQuadsNearTriangularFacets(self):
2380 faces_array = self.GetElementsByType(SMESH.FACE)
2381 for face_id in faces_array:
2382 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2383 quad_nodes = self.mesh.GetElemNodes(face_id)
2384 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2385 isVolumeFound = False
2386 for node1_elem in node1_elems:
2387 if not isVolumeFound:
2388 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2389 nb_nodes = self.GetElemNbNodes(node1_elem)
2390 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2391 volume_elem = node1_elem
2392 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2393 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2394 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2395 isVolumeFound = True
2396 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2397 self.SplitQuad([face_id], False) # diagonal 2-4
2398 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2399 isVolumeFound = True
2400 self.SplitQuad([face_id], True) # diagonal 1-3
2401 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2402 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2403 isVolumeFound = True
2404 self.SplitQuad([face_id], True) # diagonal 1-3
2406 ## @brief Splits hexahedrons into tetrahedrons.
2408 # This operation uses pattern mapping functionality for splitting.
2409 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2410 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2411 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2412 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2413 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2414 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2415 # @return TRUE in case of success, FALSE otherwise.
2416 # @ingroup l1_auxiliary
2417 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2418 # Pattern: 5.---------.6
2423 # (0,0,1) 4.---------.7 * |
2430 # (0,0,0) 0.---------.3
2431 pattern_tetra = "!!! Nb of points: \n 8 \n\
2441 !!! Indices of points of 6 tetras: \n\
2449 pattern = self.smeshpyD.GetPattern()
2450 isDone = pattern.LoadFromFile(pattern_tetra)
2452 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2455 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2456 isDone = pattern.MakeMesh(self.mesh, False, False)
2457 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2459 # split quafrangle faces near triangular facets of volumes
2460 self.SplitQuadsNearTriangularFacets()
2464 ## @brief Split hexahedrons into prisms.
2466 # Uses the pattern mapping functionality for splitting.
2467 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2468 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2469 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2470 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2471 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2472 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2473 # @return TRUE in case of success, FALSE otherwise.
2474 # @ingroup l1_auxiliary
2475 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2476 # Pattern: 5.---------.6
2481 # (0,0,1) 4.---------.7 |
2488 # (0,0,0) 0.---------.3
2489 pattern_prism = "!!! Nb of points: \n 8 \n\
2499 !!! Indices of points of 2 prisms: \n\
2503 pattern = self.smeshpyD.GetPattern()
2504 isDone = pattern.LoadFromFile(pattern_prism)
2506 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2509 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2510 isDone = pattern.MakeMesh(self.mesh, False, False)
2511 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2513 # Splits quafrangle faces near triangular facets of volumes
2514 self.SplitQuadsNearTriangularFacets()
2518 ## Smoothes elements
2519 # @param IDsOfElements the list if ids of elements 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 Smooth(self, IDsOfElements, IDsOfFixedNodes,
2528 MaxNbOfIterations, MaxAspectRatio, Method):
2529 if IDsOfElements == []:
2530 IDsOfElements = self.GetElementsId()
2531 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2532 self.mesh.SetParameters(Parameters)
2533 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2534 MaxNbOfIterations, MaxAspectRatio, Method)
2536 ## Smoothes elements which belong to the given object
2537 # @param theObject the object to smooth
2538 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2539 # Note that nodes built on edges and boundary nodes are always fixed.
2540 # @param MaxNbOfIterations the maximum number of iterations
2541 # @param MaxAspectRatio varies in range [1.0, inf]
2542 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2543 # @return TRUE in case of success, FALSE otherwise.
2544 # @ingroup l2_modif_smooth
2545 def SmoothObject(self, theObject, IDsOfFixedNodes,
2546 MaxNbOfIterations, MaxAspectRatio, Method):
2547 if ( isinstance( theObject, Mesh )):
2548 theObject = theObject.GetMesh()
2549 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2550 MaxNbOfIterations, MaxAspectRatio, Method)
2552 ## Parametrically smoothes the given elements
2553 # @param IDsOfElements the list if ids of elements 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 is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2559 # @return TRUE in case of success, FALSE otherwise.
2560 # @ingroup l2_modif_smooth
2561 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2562 MaxNbOfIterations, MaxAspectRatio, Method):
2563 if IDsOfElements == []:
2564 IDsOfElements = self.GetElementsId()
2565 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2566 self.mesh.SetParameters(Parameters)
2567 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2568 MaxNbOfIterations, MaxAspectRatio, Method)
2570 ## Parametrically smoothes the elements which belong to the given object
2571 # @param theObject the object to smooth
2572 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2573 # Note that nodes built on edges and boundary nodes are always fixed.
2574 # @param MaxNbOfIterations the maximum number of iterations
2575 # @param MaxAspectRatio varies in range [1.0, inf]
2576 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2577 # @return TRUE in case of success, FALSE otherwise.
2578 # @ingroup l2_modif_smooth
2579 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2580 MaxNbOfIterations, MaxAspectRatio, Method):
2581 if ( isinstance( theObject, Mesh )):
2582 theObject = theObject.GetMesh()
2583 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2584 MaxNbOfIterations, MaxAspectRatio, Method)
2586 ## Converts the mesh to quadratic, deletes old elements, replacing
2587 # them with quadratic with the same id.
2588 # @ingroup l2_modif_tofromqu
2589 def ConvertToQuadratic(self, theForce3d):
2590 self.editor.ConvertToQuadratic(theForce3d)
2592 ## Converts the mesh from quadratic to ordinary,
2593 # deletes old quadratic elements, \n replacing
2594 # them with ordinary mesh elements with the same id.
2595 # @return TRUE in case of success, FALSE otherwise.
2596 # @ingroup l2_modif_tofromqu
2597 def ConvertFromQuadratic(self):
2598 return self.editor.ConvertFromQuadratic()
2600 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2601 # @return TRUE if operation has been completed successfully, FALSE otherwise
2602 # @ingroup l2_modif_edit
2603 def Make2DMeshFrom3D(self):
2604 return self.editor. Make2DMeshFrom3D()
2606 ## Renumber mesh nodes
2607 # @ingroup l2_modif_renumber
2608 def RenumberNodes(self):
2609 self.editor.RenumberNodes()
2611 ## Renumber mesh elements
2612 # @ingroup l2_modif_renumber
2613 def RenumberElements(self):
2614 self.editor.RenumberElements()
2616 ## Generates new elements by rotation of the elements around the axis
2617 # @param IDsOfElements the list of ids of elements to sweep
2618 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2619 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2620 # @param NbOfSteps the number of steps
2621 # @param Tolerance tolerance
2622 # @param MakeGroups forces the generation of new groups from existing ones
2623 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2624 # of all steps, else - size of each step
2625 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2626 # @ingroup l2_modif_extrurev
2627 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2628 MakeGroups=False, TotalAngle=False):
2630 if isinstance(AngleInRadians,str):
2632 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2634 AngleInRadians = DegreesToRadians(AngleInRadians)
2635 if IDsOfElements == []:
2636 IDsOfElements = self.GetElementsId()
2637 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2638 Axis = self.smeshpyD.GetAxisStruct(Axis)
2639 Axis,AxisParameters = ParseAxisStruct(Axis)
2640 if TotalAngle and NbOfSteps:
2641 AngleInRadians /= NbOfSteps
2642 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2643 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2644 self.mesh.SetParameters(Parameters)
2646 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2647 AngleInRadians, NbOfSteps, Tolerance)
2648 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2651 ## Generates new elements by rotation of the elements of object around the axis
2652 # @param theObject object which elements should be sweeped
2653 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2654 # @param AngleInRadians the angle of Rotation
2655 # @param NbOfSteps number of steps
2656 # @param Tolerance tolerance
2657 # @param MakeGroups forces the generation of new groups from existing ones
2658 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2659 # of all steps, else - size of each step
2660 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2661 # @ingroup l2_modif_extrurev
2662 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2663 MakeGroups=False, TotalAngle=False):
2665 if isinstance(AngleInRadians,str):
2667 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2669 AngleInRadians = DegreesToRadians(AngleInRadians)
2670 if ( isinstance( theObject, Mesh )):
2671 theObject = theObject.GetMesh()
2672 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2673 Axis = self.smeshpyD.GetAxisStruct(Axis)
2674 Axis,AxisParameters = ParseAxisStruct(Axis)
2675 if TotalAngle and NbOfSteps:
2676 AngleInRadians /= NbOfSteps
2677 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2678 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2679 self.mesh.SetParameters(Parameters)
2681 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2682 NbOfSteps, Tolerance)
2683 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2686 ## Generates new elements by rotation of the elements of object around the axis
2687 # @param theObject object which elements should be sweeped
2688 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2689 # @param AngleInRadians the angle of Rotation
2690 # @param NbOfSteps number of steps
2691 # @param Tolerance tolerance
2692 # @param MakeGroups forces the generation of new groups from existing ones
2693 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2694 # of all steps, else - size of each step
2695 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2696 # @ingroup l2_modif_extrurev
2697 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2698 MakeGroups=False, TotalAngle=False):
2700 if isinstance(AngleInRadians,str):
2702 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2704 AngleInRadians = DegreesToRadians(AngleInRadians)
2705 if ( isinstance( theObject, Mesh )):
2706 theObject = theObject.GetMesh()
2707 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2708 Axis = self.smeshpyD.GetAxisStruct(Axis)
2709 Axis,AxisParameters = ParseAxisStruct(Axis)
2710 if TotalAngle and NbOfSteps:
2711 AngleInRadians /= NbOfSteps
2712 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2713 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2714 self.mesh.SetParameters(Parameters)
2716 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2717 NbOfSteps, Tolerance)
2718 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2721 ## Generates new elements by rotation of the elements of object around the axis
2722 # @param theObject object which elements should be sweeped
2723 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2724 # @param AngleInRadians the angle of Rotation
2725 # @param NbOfSteps number of steps
2726 # @param Tolerance tolerance
2727 # @param MakeGroups forces the generation of new groups from existing ones
2728 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2729 # of all steps, else - size of each step
2730 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2731 # @ingroup l2_modif_extrurev
2732 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2733 MakeGroups=False, TotalAngle=False):
2735 if isinstance(AngleInRadians,str):
2737 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2739 AngleInRadians = DegreesToRadians(AngleInRadians)
2740 if ( isinstance( theObject, Mesh )):
2741 theObject = theObject.GetMesh()
2742 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2743 Axis = self.smeshpyD.GetAxisStruct(Axis)
2744 Axis,AxisParameters = ParseAxisStruct(Axis)
2745 if TotalAngle and NbOfSteps:
2746 AngleInRadians /= NbOfSteps
2747 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2748 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2749 self.mesh.SetParameters(Parameters)
2751 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2752 NbOfSteps, Tolerance)
2753 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2756 ## Generates new elements by extrusion of the elements with given ids
2757 # @param IDsOfElements the list of elements ids for extrusion
2758 # @param StepVector vector, defining the direction and value of extrusion
2759 # @param NbOfSteps the number of steps
2760 # @param MakeGroups forces the generation of new groups from existing ones
2761 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2762 # @ingroup l2_modif_extrurev
2763 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2764 if IDsOfElements == []:
2765 IDsOfElements = self.GetElementsId()
2766 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2767 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2768 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2769 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2770 Parameters = StepVectorParameters + var_separator + Parameters
2771 self.mesh.SetParameters(Parameters)
2773 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2774 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2777 ## Generates new elements by extrusion of the elements with given ids
2778 # @param IDsOfElements is ids of elements
2779 # @param StepVector vector, defining the direction and value of extrusion
2780 # @param NbOfSteps the number of steps
2781 # @param ExtrFlags sets flags for extrusion
2782 # @param SewTolerance uses for comparing locations of nodes if flag
2783 # EXTRUSION_FLAG_SEW is set
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 AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2788 ExtrFlags, SewTolerance, MakeGroups=False):
2789 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2790 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2792 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2793 ExtrFlags, SewTolerance)
2794 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2795 ExtrFlags, SewTolerance)
2798 ## Generates new elements by extrusion of the elements which belong to the object
2799 # @param theObject the object which elements should be processed
2800 # @param StepVector vector, defining the direction and value of extrusion
2801 # @param NbOfSteps the number of steps
2802 # @param MakeGroups forces the generation of new groups from existing ones
2803 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2804 # @ingroup l2_modif_extrurev
2805 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2806 if ( isinstance( theObject, Mesh )):
2807 theObject = theObject.GetMesh()
2808 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2809 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2810 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2811 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2812 Parameters = StepVectorParameters + var_separator + Parameters
2813 self.mesh.SetParameters(Parameters)
2815 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2816 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2819 ## Generates new elements by extrusion of the elements which belong to the object
2820 # @param theObject object which elements should be processed
2821 # @param StepVector vector, defining the direction and value of extrusion
2822 # @param NbOfSteps the number of steps
2823 # @param MakeGroups to generate new groups from existing ones
2824 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2825 # @ingroup l2_modif_extrurev
2826 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2827 if ( isinstance( theObject, Mesh )):
2828 theObject = theObject.GetMesh()
2829 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2830 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2831 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2832 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2833 Parameters = StepVectorParameters + var_separator + Parameters
2834 self.mesh.SetParameters(Parameters)
2836 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2837 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2840 ## Generates new elements by extrusion of the elements which belong to the object
2841 # @param theObject object which elements should be processed
2842 # @param StepVector vector, defining the direction and value of extrusion
2843 # @param NbOfSteps the number of steps
2844 # @param MakeGroups forces the generation of new groups from existing ones
2845 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2846 # @ingroup l2_modif_extrurev
2847 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2848 if ( isinstance( theObject, Mesh )):
2849 theObject = theObject.GetMesh()
2850 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2851 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2852 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2853 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2854 Parameters = StepVectorParameters + var_separator + Parameters
2855 self.mesh.SetParameters(Parameters)
2857 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2858 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2863 ## Generates new elements by extrusion of the given elements
2864 # The path of extrusion must be a meshed edge.
2865 # @param Base mesh or list of ids of elements for extrusion
2866 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2867 # @param NodeStart the start node from Path. Defines the direction of extrusion
2868 # @param HasAngles allows the shape to be rotated around the path
2869 # to get the resulting mesh in a helical fashion
2870 # @param Angles list of angles in radians
2871 # @param LinearVariation forces the computation of rotation angles as linear
2872 # variation of the given Angles along path steps
2873 # @param HasRefPoint allows using the reference point
2874 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2875 # The User can specify any point as the Reference Point.
2876 # @param MakeGroups forces the generation of new groups from existing ones
2877 # @param ElemType type of elements for extrusion (if param Base is a mesh)
2878 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2879 # only SMESH::Extrusion_Error otherwise
2880 # @ingroup l2_modif_extrurev
2881 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2882 HasAngles, Angles, LinearVariation,
2883 HasRefPoint, RefPoint, MakeGroups, ElemType):
2884 Angles,AnglesParameters = ParseAngles(Angles)
2885 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2886 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2887 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2889 Parameters = AnglesParameters + var_separator + RefPointParameters
2890 self.mesh.SetParameters(Parameters)
2892 if isinstance(Base,list):
2894 if Base == []: IDsOfElements = self.GetElementsId()
2895 else: IDsOfElements = Base
2896 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2897 HasAngles, Angles, LinearVariation,
2898 HasRefPoint, RefPoint, MakeGroups, ElemType)
2900 if isinstance(Base,Mesh):
2901 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
2902 HasAngles, Angles, LinearVariation,
2903 HasRefPoint, RefPoint, MakeGroups, ElemType)
2905 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2908 ## Generates new elements by extrusion of the given elements
2909 # The path of extrusion must be a meshed edge.
2910 # @param IDsOfElements ids of elements
2911 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2912 # @param PathShape shape(edge) defines the sub-mesh for the path
2913 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2914 # @param HasAngles allows the shape to be rotated around the path
2915 # to get the resulting mesh in a helical fashion
2916 # @param Angles list of angles in radians
2917 # @param HasRefPoint allows using the reference point
2918 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2919 # The User can specify any point as the Reference Point.
2920 # @param MakeGroups forces the generation of new groups from existing ones
2921 # @param LinearVariation forces the computation of rotation angles as linear
2922 # variation of the given Angles along path steps
2923 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2924 # only SMESH::Extrusion_Error otherwise
2925 # @ingroup l2_modif_extrurev
2926 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2927 HasAngles, Angles, HasRefPoint, RefPoint,
2928 MakeGroups=False, LinearVariation=False):
2929 Angles,AnglesParameters = ParseAngles(Angles)
2930 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2931 if IDsOfElements == []:
2932 IDsOfElements = self.GetElementsId()
2933 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2934 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2936 if ( isinstance( PathMesh, Mesh )):
2937 PathMesh = PathMesh.GetMesh()
2938 if HasAngles and Angles and LinearVariation:
2939 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2941 Parameters = AnglesParameters + var_separator + RefPointParameters
2942 self.mesh.SetParameters(Parameters)
2944 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2945 PathShape, NodeStart, HasAngles,
2946 Angles, HasRefPoint, RefPoint)
2947 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2948 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2950 ## Generates new elements by extrusion of the elements which belong to the object
2951 # The path of extrusion must be a meshed edge.
2952 # @param theObject the object which elements should be processed
2953 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2954 # @param PathShape shape(edge) defines the sub-mesh for the path
2955 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2956 # @param HasAngles allows the shape to be rotated around the path
2957 # to get the resulting mesh in a helical fashion
2958 # @param Angles list of angles
2959 # @param HasRefPoint allows using the reference point
2960 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2961 # The User can specify any point as the Reference Point.
2962 # @param MakeGroups forces the generation of new groups from existing ones
2963 # @param LinearVariation forces the computation of rotation angles as linear
2964 # variation of the given Angles along path steps
2965 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2966 # only SMESH::Extrusion_Error otherwise
2967 # @ingroup l2_modif_extrurev
2968 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2969 HasAngles, Angles, HasRefPoint, RefPoint,
2970 MakeGroups=False, LinearVariation=False):
2971 Angles,AnglesParameters = ParseAngles(Angles)
2972 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2973 if ( isinstance( theObject, Mesh )):
2974 theObject = theObject.GetMesh()
2975 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2976 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2977 if ( isinstance( PathMesh, Mesh )):
2978 PathMesh = PathMesh.GetMesh()
2979 if HasAngles and Angles and LinearVariation:
2980 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2982 Parameters = AnglesParameters + var_separator + RefPointParameters
2983 self.mesh.SetParameters(Parameters)
2985 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2986 PathShape, NodeStart, HasAngles,
2987 Angles, HasRefPoint, RefPoint)
2988 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2989 NodeStart, HasAngles, Angles, HasRefPoint,
2992 ## Generates new elements by extrusion of the elements which belong to the object
2993 # The path of extrusion must be a meshed edge.
2994 # @param theObject the object which elements should be processed
2995 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2996 # @param PathShape shape(edge) defines the sub-mesh for the path
2997 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2998 # @param HasAngles allows the shape to be rotated around the path
2999 # to get the resulting mesh in a helical fashion
3000 # @param Angles list of angles
3001 # @param HasRefPoint allows using the reference point
3002 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3003 # The User can specify any point as the Reference Point.
3004 # @param MakeGroups forces the generation of new groups from existing ones
3005 # @param LinearVariation forces the computation of rotation angles as linear
3006 # variation of the given Angles along path steps
3007 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3008 # only SMESH::Extrusion_Error otherwise
3009 # @ingroup l2_modif_extrurev
3010 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3011 HasAngles, Angles, HasRefPoint, RefPoint,
3012 MakeGroups=False, LinearVariation=False):
3013 Angles,AnglesParameters = ParseAngles(Angles)
3014 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3015 if ( isinstance( theObject, Mesh )):
3016 theObject = theObject.GetMesh()
3017 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3018 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3019 if ( isinstance( PathMesh, Mesh )):
3020 PathMesh = PathMesh.GetMesh()
3021 if HasAngles and Angles and LinearVariation:
3022 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3024 Parameters = AnglesParameters + var_separator + RefPointParameters
3025 self.mesh.SetParameters(Parameters)
3027 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3028 PathShape, NodeStart, HasAngles,
3029 Angles, HasRefPoint, RefPoint)
3030 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3031 NodeStart, HasAngles, Angles, HasRefPoint,
3034 ## Generates new elements by extrusion of the elements which belong to the object
3035 # The path of extrusion must be a meshed edge.
3036 # @param theObject the object which elements should be processed
3037 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3038 # @param PathShape shape(edge) defines the sub-mesh for the path
3039 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3040 # @param HasAngles allows the shape to be rotated around the path
3041 # to get the resulting mesh in a helical fashion
3042 # @param Angles list of angles
3043 # @param HasRefPoint allows using the reference point
3044 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3045 # The User can specify any point as the Reference Point.
3046 # @param MakeGroups forces the generation of new groups from existing ones
3047 # @param LinearVariation forces the computation of rotation angles as linear
3048 # variation of the given Angles along path steps
3049 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3050 # only SMESH::Extrusion_Error otherwise
3051 # @ingroup l2_modif_extrurev
3052 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3053 HasAngles, Angles, HasRefPoint, RefPoint,
3054 MakeGroups=False, LinearVariation=False):
3055 Angles,AnglesParameters = ParseAngles(Angles)
3056 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3057 if ( isinstance( theObject, Mesh )):
3058 theObject = theObject.GetMesh()
3059 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3060 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3061 if ( isinstance( PathMesh, Mesh )):
3062 PathMesh = PathMesh.GetMesh()
3063 if HasAngles and Angles and LinearVariation:
3064 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3066 Parameters = AnglesParameters + var_separator + RefPointParameters
3067 self.mesh.SetParameters(Parameters)
3069 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3070 PathShape, NodeStart, HasAngles,
3071 Angles, HasRefPoint, RefPoint)
3072 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3073 NodeStart, HasAngles, Angles, HasRefPoint,
3076 ## Creates a symmetrical copy of mesh elements
3077 # @param IDsOfElements list of elements ids
3078 # @param Mirror is AxisStruct or geom object(point, line, plane)
3079 # @param theMirrorType is POINT, AXIS or PLANE
3080 # If the Mirror is a geom object this parameter is unnecessary
3081 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3082 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3083 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3084 # @ingroup l2_modif_trsf
3085 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3086 if IDsOfElements == []:
3087 IDsOfElements = self.GetElementsId()
3088 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3089 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3090 Mirror,Parameters = ParseAxisStruct(Mirror)
3091 self.mesh.SetParameters(Parameters)
3092 if Copy and MakeGroups:
3093 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3094 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3097 ## Creates a new mesh by a symmetrical copy of mesh elements
3098 # @param IDsOfElements the list of elements ids
3099 # @param Mirror is AxisStruct or geom object (point, line, plane)
3100 # @param theMirrorType is POINT, AXIS or PLANE
3101 # If the Mirror is a geom object this parameter is unnecessary
3102 # @param MakeGroups to generate new groups from existing ones
3103 # @param NewMeshName a name of the new mesh to create
3104 # @return instance of Mesh class
3105 # @ingroup l2_modif_trsf
3106 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3107 if IDsOfElements == []:
3108 IDsOfElements = self.GetElementsId()
3109 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3110 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3111 Mirror,Parameters = ParseAxisStruct(Mirror)
3112 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3113 MakeGroups, NewMeshName)
3114 mesh.SetParameters(Parameters)
3115 return Mesh(self.smeshpyD,self.geompyD,mesh)
3117 ## Creates a symmetrical copy of the object
3118 # @param theObject mesh, submesh or group
3119 # @param Mirror AxisStruct or geom object (point, line, plane)
3120 # @param theMirrorType is POINT, AXIS or PLANE
3121 # If the Mirror is a geom object this parameter is unnecessary
3122 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3123 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3124 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3125 # @ingroup l2_modif_trsf
3126 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3127 if ( isinstance( theObject, Mesh )):
3128 theObject = theObject.GetMesh()
3129 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3130 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3131 Mirror,Parameters = ParseAxisStruct(Mirror)
3132 self.mesh.SetParameters(Parameters)
3133 if Copy and MakeGroups:
3134 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3135 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3138 ## Creates a new mesh by a symmetrical copy of the object
3139 # @param theObject mesh, submesh or group
3140 # @param Mirror AxisStruct or geom object (point, line, plane)
3141 # @param theMirrorType POINT, AXIS or PLANE
3142 # If the Mirror is a geom object this parameter is unnecessary
3143 # @param MakeGroups forces the generation of new groups from existing ones
3144 # @param NewMeshName the name of the new mesh to create
3145 # @return instance of Mesh class
3146 # @ingroup l2_modif_trsf
3147 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3148 if ( isinstance( theObject, Mesh )):
3149 theObject = theObject.GetMesh()
3150 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3151 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3152 Mirror,Parameters = ParseAxisStruct(Mirror)
3153 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3154 MakeGroups, NewMeshName)
3155 mesh.SetParameters(Parameters)
3156 return Mesh( self.smeshpyD,self.geompyD,mesh )
3158 ## Translates the elements
3159 # @param IDsOfElements list of elements ids
3160 # @param Vector the direction of translation (DirStruct or vector)
3161 # @param Copy allows copying the translated elements
3162 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3163 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3164 # @ingroup l2_modif_trsf
3165 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3166 if IDsOfElements == []:
3167 IDsOfElements = self.GetElementsId()
3168 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3169 Vector = self.smeshpyD.GetDirStruct(Vector)
3170 Vector,Parameters = ParseDirStruct(Vector)
3171 self.mesh.SetParameters(Parameters)
3172 if Copy and MakeGroups:
3173 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3174 self.editor.Translate(IDsOfElements, Vector, Copy)
3177 ## Creates a new mesh of translated elements
3178 # @param IDsOfElements list of elements ids
3179 # @param Vector the direction of translation (DirStruct or vector)
3180 # @param MakeGroups forces the generation of new groups from existing ones
3181 # @param NewMeshName the name of the newly created mesh
3182 # @return instance of Mesh class
3183 # @ingroup l2_modif_trsf
3184 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3185 if IDsOfElements == []:
3186 IDsOfElements = self.GetElementsId()
3187 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3188 Vector = self.smeshpyD.GetDirStruct(Vector)
3189 Vector,Parameters = ParseDirStruct(Vector)
3190 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3191 mesh.SetParameters(Parameters)
3192 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3194 ## Translates the object
3195 # @param theObject the object to translate (mesh, submesh, or group)
3196 # @param Vector direction of translation (DirStruct or geom vector)
3197 # @param Copy allows copying the translated elements
3198 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3199 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3200 # @ingroup l2_modif_trsf
3201 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3202 if ( isinstance( theObject, Mesh )):
3203 theObject = theObject.GetMesh()
3204 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3205 Vector = self.smeshpyD.GetDirStruct(Vector)
3206 Vector,Parameters = ParseDirStruct(Vector)
3207 self.mesh.SetParameters(Parameters)
3208 if Copy and MakeGroups:
3209 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3210 self.editor.TranslateObject(theObject, Vector, Copy)
3213 ## Creates a new mesh from the translated object
3214 # @param theObject the object to translate (mesh, submesh, or group)
3215 # @param Vector the direction of translation (DirStruct or geom vector)
3216 # @param MakeGroups forces the generation of new groups from existing ones
3217 # @param NewMeshName the name of the newly created mesh
3218 # @return instance of Mesh class
3219 # @ingroup l2_modif_trsf
3220 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3221 if (isinstance(theObject, Mesh)):
3222 theObject = theObject.GetMesh()
3223 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3224 Vector = self.smeshpyD.GetDirStruct(Vector)
3225 Vector,Parameters = ParseDirStruct(Vector)
3226 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3227 mesh.SetParameters(Parameters)
3228 return Mesh( self.smeshpyD, self.geompyD, mesh )
3230 ## Rotates the elements
3231 # @param IDsOfElements list of elements ids
3232 # @param Axis the axis of rotation (AxisStruct or geom line)
3233 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3234 # @param Copy allows copying the rotated elements
3235 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3236 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3237 # @ingroup l2_modif_trsf
3238 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3240 if isinstance(AngleInRadians,str):
3242 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3244 AngleInRadians = DegreesToRadians(AngleInRadians)
3245 if IDsOfElements == []:
3246 IDsOfElements = self.GetElementsId()
3247 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3248 Axis = self.smeshpyD.GetAxisStruct(Axis)
3249 Axis,AxisParameters = ParseAxisStruct(Axis)
3250 Parameters = AxisParameters + var_separator + Parameters
3251 self.mesh.SetParameters(Parameters)
3252 if Copy and MakeGroups:
3253 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3254 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3257 ## Creates a new mesh of rotated elements
3258 # @param IDsOfElements list of element ids
3259 # @param Axis the axis of rotation (AxisStruct or geom line)
3260 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3261 # @param MakeGroups forces the generation of new groups from existing ones
3262 # @param NewMeshName the name of the newly created mesh
3263 # @return instance of Mesh class
3264 # @ingroup l2_modif_trsf
3265 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3267 if isinstance(AngleInRadians,str):
3269 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3271 AngleInRadians = DegreesToRadians(AngleInRadians)
3272 if IDsOfElements == []:
3273 IDsOfElements = self.GetElementsId()
3274 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3275 Axis = self.smeshpyD.GetAxisStruct(Axis)
3276 Axis,AxisParameters = ParseAxisStruct(Axis)
3277 Parameters = AxisParameters + var_separator + Parameters
3278 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3279 MakeGroups, NewMeshName)
3280 mesh.SetParameters(Parameters)
3281 return Mesh( self.smeshpyD, self.geompyD, mesh )
3283 ## Rotates the object
3284 # @param theObject the object to rotate( mesh, submesh, or group)
3285 # @param Axis the axis of rotation (AxisStruct or geom line)
3286 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3287 # @param Copy allows copying the rotated elements
3288 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3289 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3290 # @ingroup l2_modif_trsf
3291 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3293 if isinstance(AngleInRadians,str):
3295 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3297 AngleInRadians = DegreesToRadians(AngleInRadians)
3298 if (isinstance(theObject, Mesh)):
3299 theObject = theObject.GetMesh()
3300 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3301 Axis = self.smeshpyD.GetAxisStruct(Axis)
3302 Axis,AxisParameters = ParseAxisStruct(Axis)
3303 Parameters = AxisParameters + ":" + Parameters
3304 self.mesh.SetParameters(Parameters)
3305 if Copy and MakeGroups:
3306 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3307 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3310 ## Creates a new mesh from the rotated object
3311 # @param theObject the object to rotate (mesh, submesh, or group)
3312 # @param Axis the axis of rotation (AxisStruct or geom line)
3313 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3314 # @param MakeGroups forces the generation of new groups from existing ones
3315 # @param NewMeshName the name of the newly created mesh
3316 # @return instance of Mesh class
3317 # @ingroup l2_modif_trsf
3318 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3320 if isinstance(AngleInRadians,str):
3322 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3324 AngleInRadians = DegreesToRadians(AngleInRadians)
3325 if (isinstance( theObject, Mesh )):
3326 theObject = theObject.GetMesh()
3327 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3328 Axis = self.smeshpyD.GetAxisStruct(Axis)
3329 Axis,AxisParameters = ParseAxisStruct(Axis)
3330 Parameters = AxisParameters + ":" + Parameters
3331 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3332 MakeGroups, NewMeshName)
3333 mesh.SetParameters(Parameters)
3334 return Mesh( self.smeshpyD, self.geompyD, mesh )
3336 ## Finds groups of ajacent nodes within Tolerance.
3337 # @param Tolerance the value of tolerance
3338 # @return the list of groups of nodes
3339 # @ingroup l2_modif_trsf
3340 def FindCoincidentNodes (self, Tolerance):
3341 return self.editor.FindCoincidentNodes(Tolerance)
3343 ## Finds groups of ajacent nodes within Tolerance.
3344 # @param Tolerance the value of tolerance
3345 # @param SubMeshOrGroup SubMesh or Group
3346 # @return the list of groups of nodes
3347 # @ingroup l2_modif_trsf
3348 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3349 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3352 # @param GroupsOfNodes the list of groups of nodes
3353 # @ingroup l2_modif_trsf
3354 def MergeNodes (self, GroupsOfNodes):
3355 self.editor.MergeNodes(GroupsOfNodes)
3357 ## Finds the elements built on the same nodes.
3358 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3359 # @return a list of groups of equal elements
3360 # @ingroup l2_modif_trsf
3361 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3362 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3363 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3364 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3366 ## Merges elements in each given group.
3367 # @param GroupsOfElementsID groups of elements for merging
3368 # @ingroup l2_modif_trsf
3369 def MergeElements(self, GroupsOfElementsID):
3370 self.editor.MergeElements(GroupsOfElementsID)
3372 ## Leaves one element and removes all other elements built on the same nodes.
3373 # @ingroup l2_modif_trsf
3374 def MergeEqualElements(self):
3375 self.editor.MergeEqualElements()
3377 ## Sews free borders
3378 # @return SMESH::Sew_Error
3379 # @ingroup l2_modif_trsf
3380 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3381 FirstNodeID2, SecondNodeID2, LastNodeID2,
3382 CreatePolygons, CreatePolyedrs):
3383 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3384 FirstNodeID2, SecondNodeID2, LastNodeID2,
3385 CreatePolygons, CreatePolyedrs)
3387 ## Sews conform free borders
3388 # @return SMESH::Sew_Error
3389 # @ingroup l2_modif_trsf
3390 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3391 FirstNodeID2, SecondNodeID2):
3392 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3393 FirstNodeID2, SecondNodeID2)
3395 ## Sews border to side
3396 # @return SMESH::Sew_Error
3397 # @ingroup l2_modif_trsf
3398 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3399 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3400 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3401 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3403 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3404 # merged with the nodes of elements of Side2.
3405 # The number of elements in theSide1 and in theSide2 must be
3406 # equal and they should have similar nodal connectivity.
3407 # The nodes to merge should belong to side borders and
3408 # the first node should be linked to the second.
3409 # @return SMESH::Sew_Error
3410 # @ingroup l2_modif_trsf
3411 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3412 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3413 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3414 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3415 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3416 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3418 ## Sets new nodes for the given element.
3419 # @param ide the element id
3420 # @param newIDs nodes ids
3421 # @return If the number of nodes does not correspond to the type of element - returns false
3422 # @ingroup l2_modif_edit
3423 def ChangeElemNodes(self, ide, newIDs):
3424 return self.editor.ChangeElemNodes(ide, newIDs)
3426 ## If during the last operation of MeshEditor some nodes were
3427 # created, this method returns the list of their IDs, \n
3428 # if new nodes were not created - returns empty list
3429 # @return the list of integer values (can be empty)
3430 # @ingroup l1_auxiliary
3431 def GetLastCreatedNodes(self):
3432 return self.editor.GetLastCreatedNodes()
3434 ## If during the last operation of MeshEditor some elements were
3435 # created this method returns the list of their IDs, \n
3436 # if new elements were not created - returns empty list
3437 # @return the list of integer values (can be empty)
3438 # @ingroup l1_auxiliary
3439 def GetLastCreatedElems(self):
3440 return self.editor.GetLastCreatedElems()
3442 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3443 # @param theNodes identifiers of nodes to be doubled
3444 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3445 # nodes. If list of element identifiers is empty then nodes are doubled but
3446 # they not assigned to elements
3447 # @return TRUE if operation has been completed successfully, FALSE otherwise
3448 # @ingroup l2_modif_edit
3449 def DoubleNodes(self, theNodes, theModifiedElems):
3450 return self.editor.DoubleNodes(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 identifiers of node to be doubled
3455 # @param theModifiedElems identifiers of elements to be updated
3456 # @return TRUE if operation has been completed successfully, FALSE otherwise
3457 # @ingroup l2_modif_edit
3458 def DoubleNode(self, theNodeId, theModifiedElems):
3459 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3461 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3462 # This method provided for convenience works as DoubleNodes() described above.
3463 # @param theNodes group of nodes to be doubled
3464 # @param theModifiedElems group of elements to be updated.
3465 # @return TRUE if operation has been completed successfully, FALSE otherwise
3466 # @ingroup l2_modif_edit
3467 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3468 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3470 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3471 # This method provided for convenience works as DoubleNodes() described above.
3472 # @param theNodes list of groups of nodes to be doubled
3473 # @param theModifiedElems list of groups of elements to be updated.
3474 # @return TRUE if operation has been completed successfully, FALSE otherwise
3475 # @ingroup l2_modif_edit
3476 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3477 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3479 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3480 # @param theElems - the list of elements (edges or faces) to be replicated
3481 # The nodes for duplication could be found from these elements
3482 # @param theNodesNot - list of nodes to NOT replicate
3483 # @param theAffectedElems - the list of elements (cells and edges) to which the
3484 # replicated nodes should be associated to.
3485 # @return TRUE if operation has been completed successfully, FALSE otherwise
3486 # @ingroup l2_modif_edit
3487 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3488 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3490 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3491 # @param theElems - the list of elements (edges or faces) to be replicated
3492 # The nodes for duplication could be found from these elements
3493 # @param theNodesNot - list of nodes to NOT replicate
3494 # @param theShape - shape to detect affected elements (element which geometric center
3495 # located on or inside shape).
3496 # The replicated nodes should be associated to affected elements.
3497 # @return TRUE if operation has been completed successfully, FALSE otherwise
3498 # @ingroup l2_modif_edit
3499 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3500 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3502 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3503 # This method provided for convenience works as DoubleNodes() described above.
3504 # @param theElems - group of of elements (edges or faces) to be replicated
3505 # @param theNodesNot - group of nodes not to replicated
3506 # @param theAffectedElems - group of elements to which the replicated nodes
3507 # should be associated to.
3508 # @ingroup l2_modif_edit
3509 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
3510 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3512 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3513 # This method provided for convenience works as DoubleNodes() described above.
3514 # @param theElems - group of of elements (edges or faces) to be replicated
3515 # @param theNodesNot - group of nodes not to replicated
3516 # @param theShape - shape to detect affected elements (element which geometric center
3517 # located on or inside shape).
3518 # The replicated nodes should be associated to affected elements.
3519 # @ingroup l2_modif_edit
3520 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3521 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theShape)
3523 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3524 # This method provided for convenience works as DoubleNodes() described above.
3525 # @param theElems - list of groups of elements (edges or faces) to be replicated
3526 # @param theNodesNot - list of groups of nodes not to replicated
3527 # @param theAffectedElems - group of elements to which the replicated nodes
3528 # should be associated to.
3529 # @return TRUE if operation has been completed successfully, FALSE otherwise
3530 # @ingroup l2_modif_edit
3531 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3532 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3534 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3535 # This method provided for convenience works as DoubleNodes() described above.
3536 # @param theElems - list of groups of elements (edges or faces) to be replicated
3537 # @param theNodesNot - list of groups of nodes not to replicated
3538 # @param theShape - shape to detect affected elements (element which geometric center
3539 # located on or inside shape).
3540 # The replicated nodes should be associated to affected elements.
3541 # @return TRUE if operation has been completed successfully, FALSE otherwise
3542 # @ingroup l2_modif_edit
3543 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3544 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3546 ## The mother class to define algorithm, it is not recommended to use it directly.
3549 # @ingroup l2_algorithms
3550 class Mesh_Algorithm:
3551 # @class Mesh_Algorithm
3552 # @brief Class Mesh_Algorithm
3554 #def __init__(self,smesh):
3562 ## Finds a hypothesis in the study by its type name and parameters.
3563 # Finds only the hypotheses created in smeshpyD engine.
3564 # @return SMESH.SMESH_Hypothesis
3565 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3566 study = smeshpyD.GetCurrentStudy()
3567 #to do: find component by smeshpyD object, not by its data type
3568 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3569 if scomp is not None:
3570 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3571 # Check if the root label of the hypotheses exists
3572 if res and hypRoot is not None:
3573 iter = study.NewChildIterator(hypRoot)
3574 # Check all published hypotheses
3576 hypo_so_i = iter.Value()
3577 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3578 if attr is not None:
3579 anIOR = attr.Value()
3580 hypo_o_i = salome.orb.string_to_object(anIOR)
3581 if hypo_o_i is not None:
3582 # Check if this is a hypothesis
3583 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3584 if hypo_i is not None:
3585 # Check if the hypothesis belongs to current engine
3586 if smeshpyD.GetObjectId(hypo_i) > 0:
3587 # Check if this is the required hypothesis
3588 if hypo_i.GetName() == hypname:
3590 if CompareMethod(hypo_i, args):
3604 ## Finds the algorithm in the study by its type name.
3605 # Finds only the algorithms, which have been created in smeshpyD engine.
3606 # @return SMESH.SMESH_Algo
3607 def FindAlgorithm (self, algoname, smeshpyD):
3608 study = smeshpyD.GetCurrentStudy()
3609 #to do: find component by smeshpyD object, not by its data type
3610 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3611 if scomp is not None:
3612 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3613 # Check if the root label of the algorithms exists
3614 if res and hypRoot is not None:
3615 iter = study.NewChildIterator(hypRoot)
3616 # Check all published algorithms
3618 algo_so_i = iter.Value()
3619 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3620 if attr is not None:
3621 anIOR = attr.Value()
3622 algo_o_i = salome.orb.string_to_object(anIOR)
3623 if algo_o_i is not None:
3624 # Check if this is an algorithm
3625 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3626 if algo_i is not None:
3627 # Checks if the algorithm belongs to the current engine
3628 if smeshpyD.GetObjectId(algo_i) > 0:
3629 # Check if this is the required algorithm
3630 if algo_i.GetName() == algoname:
3643 ## If the algorithm is global, returns 0; \n
3644 # else returns the submesh associated to this algorithm.
3645 def GetSubMesh(self):
3648 ## Returns the wrapped mesher.
3649 def GetAlgorithm(self):
3652 ## Gets the list of hypothesis that can be used with this algorithm
3653 def GetCompatibleHypothesis(self):
3656 mylist = self.algo.GetCompatibleHypothesis()
3659 ## Gets the name of the algorithm
3663 ## Sets the name to the algorithm
3664 def SetName(self, name):
3665 self.mesh.smeshpyD.SetName(self.algo, name)
3667 ## Gets the id of the algorithm
3669 return self.algo.GetId()
3672 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3674 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3675 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3677 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3679 self.Assign(algo, mesh, geom)
3683 def Assign(self, algo, mesh, geom):
3685 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3692 name = GetName(geom)
3694 name = mesh.geompyD.SubShapeName(geom, piece)
3695 mesh.geompyD.addToStudyInFather(piece, geom, name)
3696 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3699 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3700 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3702 def CompareHyp (self, hyp, args):
3703 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3706 def CompareEqualHyp (self, hyp, args):
3710 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3711 UseExisting=0, CompareMethod=""):
3714 if CompareMethod == "": CompareMethod = self.CompareHyp
3715 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3718 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3724 a = a + s + str(args[i])
3728 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3730 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3731 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3734 ## Returns entry of the shape to mesh in the study
3735 def MainShapeEntry(self):
3737 if not self.mesh or not self.mesh.GetMesh(): return entry
3738 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3739 study = self.mesh.smeshpyD.GetCurrentStudy()
3740 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3741 sobj = study.FindObjectIOR(ior)
3742 if sobj: entry = sobj.GetID()
3743 if not entry: return ""
3746 # Public class: Mesh_Segment
3747 # --------------------------
3749 ## Class to define a segment 1D algorithm for discretization
3752 # @ingroup l3_algos_basic
3753 class Mesh_Segment(Mesh_Algorithm):
3755 ## Private constructor.
3756 def __init__(self, mesh, geom=0):
3757 Mesh_Algorithm.__init__(self)
3758 self.Create(mesh, geom, "Regular_1D")
3760 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3761 # @param l for the length of segments that cut an edge
3762 # @param UseExisting if ==true - searches for an existing hypothesis created with
3763 # the same parameters, else (default) - creates a new one
3764 # @param p precision, used for calculation of the number of segments.
3765 # The precision should be a positive, meaningful value within the range [0,1].
3766 # In general, the number of segments is calculated with the formula:
3767 # nb = ceil((edge_length / l) - p)
3768 # Function ceil rounds its argument to the higher integer.
3769 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3770 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3771 # p=1 means rounding of (edge_length / l) to the lower integer.
3772 # Default value is 1e-07.
3773 # @return an instance of StdMeshers_LocalLength hypothesis
3774 # @ingroup l3_hypos_1dhyps
3775 def LocalLength(self, l, UseExisting=0, p=1e-07):
3776 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3777 CompareMethod=self.CompareLocalLength)
3783 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3784 def CompareLocalLength(self, hyp, args):
3785 if IsEqual(hyp.GetLength(), args[0]):
3786 return IsEqual(hyp.GetPrecision(), args[1])
3789 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3790 # @param length is optional maximal allowed length of segment, if it is omitted
3791 # the preestimated length is used that depends on geometry size
3792 # @param UseExisting if ==true - searches for an existing hypothesis created with
3793 # the same parameters, else (default) - create a new one
3794 # @return an instance of StdMeshers_MaxLength hypothesis
3795 # @ingroup l3_hypos_1dhyps
3796 def MaxSize(self, length=0.0, UseExisting=0):
3797 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3800 hyp.SetLength(length)
3802 # set preestimated length
3803 gen = self.mesh.smeshpyD
3804 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3805 self.mesh.GetMesh(), self.mesh.GetShape(),
3807 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3809 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3812 hyp.SetUsePreestimatedLength( length == 0.0 )
3815 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3816 # @param n for the number of segments that cut an edge
3817 # @param s for the scale factor (optional)
3818 # @param reversedEdges is a list of edges to mesh using reversed orientation
3819 # @param UseExisting if ==true - searches for an existing hypothesis created with
3820 # the same parameters, else (default) - create a new one
3821 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3822 # @ingroup l3_hypos_1dhyps
3823 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3824 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3825 reversedEdges, UseExisting = [], reversedEdges
3826 entry = self.MainShapeEntry()
3828 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3829 UseExisting=UseExisting,
3830 CompareMethod=self.CompareNumberOfSegments)
3832 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3833 UseExisting=UseExisting,
3834 CompareMethod=self.CompareNumberOfSegments)
3835 hyp.SetDistrType( 1 )
3836 hyp.SetScaleFactor(s)
3837 hyp.SetNumberOfSegments(n)
3838 hyp.SetReversedEdges( reversedEdges )
3839 hyp.SetObjectEntry( entry )
3843 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3844 def CompareNumberOfSegments(self, hyp, args):
3845 if hyp.GetNumberOfSegments() == args[0]:
3847 if hyp.GetReversedEdges() == args[1]:
3848 if not args[1] or hyp.GetObjectEntry() == args[2]:
3851 if hyp.GetReversedEdges() == args[2]:
3852 if not args[2] or hyp.GetObjectEntry() == args[3]:
3853 if hyp.GetDistrType() == 1:
3854 if IsEqual(hyp.GetScaleFactor(), args[1]):
3858 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3859 # @param start defines the length of the first segment
3860 # @param end defines the length of the last segment
3861 # @param reversedEdges is a list of edges to mesh using reversed orientation
3862 # @param UseExisting if ==true - searches for an existing hypothesis created with
3863 # the same parameters, else (default) - creates a new one
3864 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3865 # @ingroup l3_hypos_1dhyps
3866 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3867 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3868 reversedEdges, UseExisting = [], reversedEdges
3869 entry = self.MainShapeEntry()
3870 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
3871 UseExisting=UseExisting,
3872 CompareMethod=self.CompareArithmetic1D)
3873 hyp.SetStartLength(start)
3874 hyp.SetEndLength(end)
3875 hyp.SetReversedEdges( reversedEdges )
3876 hyp.SetObjectEntry( entry )
3880 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3881 def CompareArithmetic1D(self, hyp, args):
3882 if IsEqual(hyp.GetLength(1), args[0]):
3883 if IsEqual(hyp.GetLength(0), args[1]):
3884 if hyp.GetReversedEdges() == args[2]:
3885 if not args[2] or hyp.GetObjectEntry() == args[3]:
3890 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
3891 # on curve from 0 to 1 (additionally it is neecessary to check
3892 # orientation of edges and create list of reversed edges if it is
3893 # needed) and sets numbers of segments between given points (default
3894 # values are equals 1
3895 # @param points defines the list of parameters on curve
3896 # @param nbSegs defines the list of numbers of segments
3897 # @param reversedEdges is a list of edges to mesh using reversed orientation
3898 # @param UseExisting if ==true - searches for an existing hypothesis created with
3899 # the same parameters, else (default) - creates a new one
3900 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3901 # @ingroup l3_hypos_1dhyps
3902 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
3903 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3904 reversedEdges, UseExisting = [], reversedEdges
3905 entry = self.MainShapeEntry()
3906 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
3907 UseExisting=UseExisting,
3908 CompareMethod=self.CompareArithmetic1D)
3909 hyp.SetPoints(points)
3910 hyp.SetNbSegments(nbSegs)
3911 hyp.SetReversedEdges(reversedEdges)
3912 hyp.SetObjectEntry(entry)
3916 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
3917 ## as the given arguments
3918 def CompareFixedPoints1D(self, hyp, args):
3919 if hyp.GetPoints() == args[0]:
3920 if hyp.GetNbSegments() == args[1]:
3921 if hyp.GetReversedEdges() == args[2]:
3922 if not args[2] or hyp.GetObjectEntry() == args[3]:
3928 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3929 # @param start defines the length of the first segment
3930 # @param end defines the length of the last segment
3931 # @param reversedEdges is a list of edges to mesh using reversed orientation
3932 # @param UseExisting if ==true - searches for an existing hypothesis created with
3933 # the same parameters, else (default) - creates a new one
3934 # @return an instance of StdMeshers_StartEndLength hypothesis
3935 # @ingroup l3_hypos_1dhyps
3936 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3937 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3938 reversedEdges, UseExisting = [], reversedEdges
3939 entry = self.MainShapeEntry()
3940 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3941 UseExisting=UseExisting,
3942 CompareMethod=self.CompareStartEndLength)
3943 hyp.SetStartLength(start)
3944 hyp.SetEndLength(end)
3945 hyp.SetReversedEdges( reversedEdges )
3946 hyp.SetObjectEntry( entry )
3949 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3950 def CompareStartEndLength(self, hyp, args):
3951 if IsEqual(hyp.GetLength(1), args[0]):
3952 if IsEqual(hyp.GetLength(0), args[1]):
3953 if hyp.GetReversedEdges() == args[2]:
3954 if not args[2] or hyp.GetObjectEntry() == args[3]:
3958 ## Defines "Deflection1D" hypothesis
3959 # @param d for the deflection
3960 # @param UseExisting if ==true - searches for an existing hypothesis created with
3961 # the same parameters, else (default) - create a new one
3962 # @ingroup l3_hypos_1dhyps
3963 def Deflection1D(self, d, UseExisting=0):
3964 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3965 CompareMethod=self.CompareDeflection1D)
3966 hyp.SetDeflection(d)
3969 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3970 def CompareDeflection1D(self, hyp, args):
3971 return IsEqual(hyp.GetDeflection(), args[0])
3973 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3974 # the opposite side in case of quadrangular faces
3975 # @ingroup l3_hypos_additi
3976 def Propagation(self):
3977 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3979 ## Defines "AutomaticLength" hypothesis
3980 # @param fineness for the fineness [0-1]
3981 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3982 # same parameters, else (default) - create a new one
3983 # @ingroup l3_hypos_1dhyps
3984 def AutomaticLength(self, fineness=0, UseExisting=0):
3985 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3986 CompareMethod=self.CompareAutomaticLength)
3987 hyp.SetFineness( fineness )
3990 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3991 def CompareAutomaticLength(self, hyp, args):
3992 return IsEqual(hyp.GetFineness(), args[0])
3994 ## Defines "SegmentLengthAroundVertex" hypothesis
3995 # @param length for the segment length
3996 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3997 # Any other integer value means that the hypothesis will be set on the
3998 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3999 # @param UseExisting if ==true - searches for an existing hypothesis created with
4000 # the same parameters, else (default) - creates a new one
4001 # @ingroup l3_algos_segmarv
4002 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4004 store_geom = self.geom
4005 if type(vertex) is types.IntType:
4006 if vertex == 0 or vertex == 1:
4007 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4015 if self.geom is None:
4016 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4017 name = GetName(self.geom)
4019 piece = self.mesh.geom
4020 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4021 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4022 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4024 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4026 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4027 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4029 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4030 CompareMethod=self.CompareLengthNearVertex)
4031 self.geom = store_geom
4032 hyp.SetLength( length )
4035 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4036 # @ingroup l3_algos_segmarv
4037 def CompareLengthNearVertex(self, hyp, args):
4038 return IsEqual(hyp.GetLength(), args[0])
4040 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4041 # If the 2D mesher sees that all boundary edges are quadratic,
4042 # it generates quadratic faces, else it generates linear faces using
4043 # medium nodes as if they are vertices.
4044 # The 3D mesher generates quadratic volumes only if all boundary faces
4045 # are quadratic, else it fails.
4047 # @ingroup l3_hypos_additi
4048 def QuadraticMesh(self):
4049 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4052 # Public class: Mesh_CompositeSegment
4053 # --------------------------
4055 ## Defines a segment 1D algorithm for discretization
4057 # @ingroup l3_algos_basic
4058 class Mesh_CompositeSegment(Mesh_Segment):
4060 ## Private constructor.
4061 def __init__(self, mesh, geom=0):
4062 self.Create(mesh, geom, "CompositeSegment_1D")
4065 # Public class: Mesh_Segment_Python
4066 # ---------------------------------
4068 ## Defines a segment 1D algorithm for discretization with python function
4070 # @ingroup l3_algos_basic
4071 class Mesh_Segment_Python(Mesh_Segment):
4073 ## Private constructor.
4074 def __init__(self, mesh, geom=0):
4075 import Python1dPlugin
4076 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4078 ## Defines "PythonSplit1D" hypothesis
4079 # @param n for the number of segments that cut an edge
4080 # @param func for the python function that calculates the length of all segments
4081 # @param UseExisting if ==true - searches for the existing hypothesis created with
4082 # the same parameters, else (default) - creates a new one
4083 # @ingroup l3_hypos_1dhyps
4084 def PythonSplit1D(self, n, func, UseExisting=0):
4085 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4086 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4087 hyp.SetNumberOfSegments(n)
4088 hyp.SetPythonLog10RatioFunction(func)
4091 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4092 def ComparePythonSplit1D(self, hyp, args):
4093 #if hyp.GetNumberOfSegments() == args[0]:
4094 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4098 # Public class: Mesh_Triangle
4099 # ---------------------------
4101 ## Defines a triangle 2D algorithm
4103 # @ingroup l3_algos_basic
4104 class Mesh_Triangle(Mesh_Algorithm):
4113 ## Private constructor.
4114 def __init__(self, mesh, algoType, geom=0):
4115 Mesh_Algorithm.__init__(self)
4117 self.algoType = algoType
4118 if algoType == MEFISTO:
4119 self.Create(mesh, geom, "MEFISTO_2D")
4121 elif algoType == BLSURF:
4123 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4124 #self.SetPhysicalMesh() - PAL19680
4125 elif algoType == NETGEN:
4127 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4129 elif algoType == NETGEN_2D:
4131 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4134 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4135 # @param area for the maximum area of each triangle
4136 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4137 # same parameters, else (default) - creates a new one
4139 # Only for algoType == MEFISTO || NETGEN_2D
4140 # @ingroup l3_hypos_2dhyps
4141 def MaxElementArea(self, area, UseExisting=0):
4142 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4143 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4144 CompareMethod=self.CompareMaxElementArea)
4145 elif self.algoType == NETGEN:
4146 hyp = self.Parameters(SIMPLE)
4147 hyp.SetMaxElementArea(area)
4150 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4151 def CompareMaxElementArea(self, hyp, args):
4152 return IsEqual(hyp.GetMaxElementArea(), args[0])
4154 ## Defines "LengthFromEdges" hypothesis to build triangles
4155 # based on the length of the edges taken from the wire
4157 # Only for algoType == MEFISTO || NETGEN_2D
4158 # @ingroup l3_hypos_2dhyps
4159 def LengthFromEdges(self):
4160 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4161 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4163 elif self.algoType == NETGEN:
4164 hyp = self.Parameters(SIMPLE)
4165 hyp.LengthFromEdges()
4168 ## Sets a way to define size of mesh elements to generate.
4169 # @param thePhysicalMesh is: DefaultSize or Custom.
4170 # @ingroup l3_hypos_blsurf
4171 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4172 # Parameter of BLSURF algo
4173 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4175 ## Sets size of mesh elements to generate.
4176 # @ingroup l3_hypos_blsurf
4177 def SetPhySize(self, theVal):
4178 # Parameter of BLSURF algo
4179 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4180 self.Parameters().SetPhySize(theVal)
4182 ## Sets lower boundary of mesh element size (PhySize).
4183 # @ingroup l3_hypos_blsurf
4184 def SetPhyMin(self, theVal=-1):
4185 # Parameter of BLSURF algo
4186 self.Parameters().SetPhyMin(theVal)
4188 ## Sets upper boundary of mesh element size (PhySize).
4189 # @ingroup l3_hypos_blsurf
4190 def SetPhyMax(self, theVal=-1):
4191 # Parameter of BLSURF algo
4192 self.Parameters().SetPhyMax(theVal)
4194 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4195 # @param theGeometricMesh is: DefaultGeom or Custom
4196 # @ingroup l3_hypos_blsurf
4197 def SetGeometricMesh(self, theGeometricMesh=0):
4198 # Parameter of BLSURF algo
4199 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4200 self.params.SetGeometricMesh(theGeometricMesh)
4202 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4203 # @ingroup l3_hypos_blsurf
4204 def SetAngleMeshS(self, theVal=_angleMeshS):
4205 # Parameter of BLSURF algo
4206 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4207 self.params.SetAngleMeshS(theVal)
4209 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4210 # @ingroup l3_hypos_blsurf
4211 def SetAngleMeshC(self, theVal=_angleMeshS):
4212 # Parameter of BLSURF algo
4213 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4214 self.params.SetAngleMeshC(theVal)
4216 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4217 # @ingroup l3_hypos_blsurf
4218 def SetGeoMin(self, theVal=-1):
4219 # Parameter of BLSURF algo
4220 self.Parameters().SetGeoMin(theVal)
4222 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4223 # @ingroup l3_hypos_blsurf
4224 def SetGeoMax(self, theVal=-1):
4225 # Parameter of BLSURF algo
4226 self.Parameters().SetGeoMax(theVal)
4228 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4229 # @ingroup l3_hypos_blsurf
4230 def SetGradation(self, theVal=_gradation):
4231 # Parameter of BLSURF algo
4232 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4233 self.params.SetGradation(theVal)
4235 ## Sets topology usage way.
4236 # @param way defines how mesh conformity is assured <ul>
4237 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4238 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4239 # @ingroup l3_hypos_blsurf
4240 def SetTopology(self, way):
4241 # Parameter of BLSURF algo
4242 self.Parameters().SetTopology(way)
4244 ## To respect geometrical edges or not.
4245 # @ingroup l3_hypos_blsurf
4246 def SetDecimesh(self, toIgnoreEdges=False):
4247 # Parameter of BLSURF algo
4248 self.Parameters().SetDecimesh(toIgnoreEdges)
4250 ## Sets verbosity level in the range 0 to 100.
4251 # @ingroup l3_hypos_blsurf
4252 def SetVerbosity(self, level):
4253 # Parameter of BLSURF algo
4254 self.Parameters().SetVerbosity(level)
4256 ## Sets advanced option value.
4257 # @ingroup l3_hypos_blsurf
4258 def SetOptionValue(self, optionName, level):
4259 # Parameter of BLSURF algo
4260 self.Parameters().SetOptionValue(optionName,level)
4262 ## Sets QuadAllowed flag.
4263 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4264 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4265 def SetQuadAllowed(self, toAllow=True):
4266 if self.algoType == NETGEN_2D:
4267 if toAllow: # add QuadranglePreference
4268 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4269 else: # remove QuadranglePreference
4270 for hyp in self.mesh.GetHypothesisList( self.geom ):
4271 if hyp.GetName() == "QuadranglePreference":
4272 self.mesh.RemoveHypothesis( self.geom, hyp )
4277 if self.Parameters():
4278 self.params.SetQuadAllowed(toAllow)
4281 ## Defines hypothesis having several parameters
4283 # @ingroup l3_hypos_netgen
4284 def Parameters(self, which=SOLE):
4287 if self.algoType == NETGEN:
4289 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4290 "libNETGENEngine.so", UseExisting=0)
4292 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4293 "libNETGENEngine.so", UseExisting=0)
4295 elif self.algoType == MEFISTO:
4296 print "Mefisto algo support no multi-parameter hypothesis"
4298 elif self.algoType == NETGEN_2D:
4299 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4300 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4302 elif self.algoType == BLSURF:
4303 self.params = self.Hypothesis("BLSURF_Parameters", [],
4304 "libBLSURFEngine.so", UseExisting=0)
4307 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4312 # Only for algoType == NETGEN
4313 # @ingroup l3_hypos_netgen
4314 def SetMaxSize(self, theSize):
4315 if self.Parameters():
4316 self.params.SetMaxSize(theSize)
4318 ## Sets SecondOrder flag
4320 # Only for algoType == NETGEN
4321 # @ingroup l3_hypos_netgen
4322 def SetSecondOrder(self, theVal):
4323 if self.Parameters():
4324 self.params.SetSecondOrder(theVal)
4326 ## Sets Optimize flag
4328 # Only for algoType == NETGEN
4329 # @ingroup l3_hypos_netgen
4330 def SetOptimize(self, theVal):
4331 if self.Parameters():
4332 self.params.SetOptimize(theVal)
4335 # @param theFineness is:
4336 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4338 # Only for algoType == NETGEN
4339 # @ingroup l3_hypos_netgen
4340 def SetFineness(self, theFineness):
4341 if self.Parameters():
4342 self.params.SetFineness(theFineness)
4346 # Only for algoType == NETGEN
4347 # @ingroup l3_hypos_netgen
4348 def SetGrowthRate(self, theRate):
4349 if self.Parameters():
4350 self.params.SetGrowthRate(theRate)
4352 ## Sets NbSegPerEdge
4354 # Only for algoType == NETGEN
4355 # @ingroup l3_hypos_netgen
4356 def SetNbSegPerEdge(self, theVal):
4357 if self.Parameters():
4358 self.params.SetNbSegPerEdge(theVal)
4360 ## Sets NbSegPerRadius
4362 # Only for algoType == NETGEN
4363 # @ingroup l3_hypos_netgen
4364 def SetNbSegPerRadius(self, theVal):
4365 if self.Parameters():
4366 self.params.SetNbSegPerRadius(theVal)
4368 ## Sets number of segments overriding value set by SetLocalLength()
4370 # Only for algoType == NETGEN
4371 # @ingroup l3_hypos_netgen
4372 def SetNumberOfSegments(self, theVal):
4373 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4375 ## Sets number of segments overriding value set by SetNumberOfSegments()
4377 # Only for algoType == NETGEN
4378 # @ingroup l3_hypos_netgen
4379 def SetLocalLength(self, theVal):
4380 self.Parameters(SIMPLE).SetLocalLength(theVal)
4385 # Public class: Mesh_Quadrangle
4386 # -----------------------------
4388 ## Defines a quadrangle 2D algorithm
4390 # @ingroup l3_algos_basic
4391 class Mesh_Quadrangle(Mesh_Algorithm):
4393 ## Private constructor.
4394 def __init__(self, mesh, geom=0):
4395 Mesh_Algorithm.__init__(self)
4396 self.Create(mesh, geom, "Quadrangle_2D")
4398 ## Defines "QuadranglePreference" hypothesis, forcing construction
4399 # of quadrangles if the number of nodes on the opposite edges is not the same
4400 # while the total number of nodes on edges is even
4402 # @ingroup l3_hypos_additi
4403 def QuadranglePreference(self):
4404 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4405 CompareMethod=self.CompareEqualHyp)
4408 ## Defines "TrianglePreference" hypothesis, forcing construction
4409 # of triangles in the refinement area if the number of nodes
4410 # on the opposite edges is not the same
4412 # @ingroup l3_hypos_additi
4413 def TrianglePreference(self):
4414 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4415 CompareMethod=self.CompareEqualHyp)
4418 # Public class: Mesh_Tetrahedron
4419 # ------------------------------
4421 ## Defines a tetrahedron 3D algorithm
4423 # @ingroup l3_algos_basic
4424 class Mesh_Tetrahedron(Mesh_Algorithm):
4429 ## Private constructor.
4430 def __init__(self, mesh, algoType, geom=0):
4431 Mesh_Algorithm.__init__(self)
4433 if algoType == NETGEN:
4435 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4438 elif algoType == FULL_NETGEN:
4440 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4443 elif algoType == GHS3D:
4445 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4448 elif algoType == GHS3DPRL:
4449 CheckPlugin(GHS3DPRL)
4450 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4453 self.algoType = algoType
4455 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4456 # @param vol for the maximum volume of each tetrahedron
4457 # @param UseExisting if ==true - searches for the existing hypothesis created with
4458 # the same parameters, else (default) - creates a new one
4459 # @ingroup l3_hypos_maxvol
4460 def MaxElementVolume(self, vol, UseExisting=0):
4461 if self.algoType == NETGEN:
4462 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4463 CompareMethod=self.CompareMaxElementVolume)
4464 hyp.SetMaxElementVolume(vol)
4466 elif self.algoType == FULL_NETGEN:
4467 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4470 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4471 def CompareMaxElementVolume(self, hyp, args):
4472 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4474 ## Defines hypothesis having several parameters
4476 # @ingroup l3_hypos_netgen
4477 def Parameters(self, which=SOLE):
4481 if self.algoType == FULL_NETGEN:
4483 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4484 "libNETGENEngine.so", UseExisting=0)
4486 self.params = self.Hypothesis("NETGEN_Parameters", [],
4487 "libNETGENEngine.so", UseExisting=0)
4490 if self.algoType == GHS3D:
4491 self.params = self.Hypothesis("GHS3D_Parameters", [],
4492 "libGHS3DEngine.so", UseExisting=0)
4495 if self.algoType == GHS3DPRL:
4496 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4497 "libGHS3DPRLEngine.so", UseExisting=0)
4500 print "Algo supports no multi-parameter hypothesis"
4504 # Parameter of FULL_NETGEN
4505 # @ingroup l3_hypos_netgen
4506 def SetMaxSize(self, theSize):
4507 self.Parameters().SetMaxSize(theSize)
4509 ## Sets SecondOrder flag
4510 # Parameter of FULL_NETGEN
4511 # @ingroup l3_hypos_netgen
4512 def SetSecondOrder(self, theVal):
4513 self.Parameters().SetSecondOrder(theVal)
4515 ## Sets Optimize flag
4516 # Parameter of FULL_NETGEN
4517 # @ingroup l3_hypos_netgen
4518 def SetOptimize(self, theVal):
4519 self.Parameters().SetOptimize(theVal)
4522 # @param theFineness is:
4523 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4524 # Parameter of FULL_NETGEN
4525 # @ingroup l3_hypos_netgen
4526 def SetFineness(self, theFineness):
4527 self.Parameters().SetFineness(theFineness)
4530 # Parameter of FULL_NETGEN
4531 # @ingroup l3_hypos_netgen
4532 def SetGrowthRate(self, theRate):
4533 self.Parameters().SetGrowthRate(theRate)
4535 ## Sets NbSegPerEdge
4536 # Parameter of FULL_NETGEN
4537 # @ingroup l3_hypos_netgen
4538 def SetNbSegPerEdge(self, theVal):
4539 self.Parameters().SetNbSegPerEdge(theVal)
4541 ## Sets NbSegPerRadius
4542 # Parameter of FULL_NETGEN
4543 # @ingroup l3_hypos_netgen
4544 def SetNbSegPerRadius(self, theVal):
4545 self.Parameters().SetNbSegPerRadius(theVal)
4547 ## Sets number of segments overriding value set by SetLocalLength()
4548 # Only for algoType == NETGEN_FULL
4549 # @ingroup l3_hypos_netgen
4550 def SetNumberOfSegments(self, theVal):
4551 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4553 ## Sets number of segments overriding value set by SetNumberOfSegments()
4554 # Only for algoType == NETGEN_FULL
4555 # @ingroup l3_hypos_netgen
4556 def SetLocalLength(self, theVal):
4557 self.Parameters(SIMPLE).SetLocalLength(theVal)
4559 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4560 # Overrides value set by LengthFromEdges()
4561 # Only for algoType == NETGEN_FULL
4562 # @ingroup l3_hypos_netgen
4563 def MaxElementArea(self, area):
4564 self.Parameters(SIMPLE).SetMaxElementArea(area)
4566 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4567 # Overrides value set by MaxElementArea()
4568 # Only for algoType == NETGEN_FULL
4569 # @ingroup l3_hypos_netgen
4570 def LengthFromEdges(self):
4571 self.Parameters(SIMPLE).LengthFromEdges()
4573 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4574 # Overrides value set by MaxElementVolume()
4575 # Only for algoType == NETGEN_FULL
4576 # @ingroup l3_hypos_netgen
4577 def LengthFromFaces(self):
4578 self.Parameters(SIMPLE).LengthFromFaces()
4580 ## To mesh "holes" in a solid or not. Default is to mesh.
4581 # @ingroup l3_hypos_ghs3dh
4582 def SetToMeshHoles(self, toMesh):
4583 # Parameter of GHS3D
4584 self.Parameters().SetToMeshHoles(toMesh)
4586 ## Set Optimization level:
4587 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4588 # Strong_Optimization.
4589 # Default is Standard_Optimization
4590 # @ingroup l3_hypos_ghs3dh
4591 def SetOptimizationLevel(self, level):
4592 # Parameter of GHS3D
4593 self.Parameters().SetOptimizationLevel(level)
4595 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4596 # @ingroup l3_hypos_ghs3dh
4597 def SetMaximumMemory(self, MB):
4598 # Advanced parameter of GHS3D
4599 self.Parameters().SetMaximumMemory(MB)
4601 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4602 # automatic memory adjustment mode.
4603 # @ingroup l3_hypos_ghs3dh
4604 def SetInitialMemory(self, MB):
4605 # Advanced parameter of GHS3D
4606 self.Parameters().SetInitialMemory(MB)
4608 ## Path to working directory.
4609 # @ingroup l3_hypos_ghs3dh
4610 def SetWorkingDirectory(self, path):
4611 # Advanced parameter of GHS3D
4612 self.Parameters().SetWorkingDirectory(path)
4614 ## To keep working files or remove them. Log file remains in case of errors anyway.
4615 # @ingroup l3_hypos_ghs3dh
4616 def SetKeepFiles(self, toKeep):
4617 # Advanced parameter of GHS3D and GHS3DPRL
4618 self.Parameters().SetKeepFiles(toKeep)
4620 ## To set verbose level [0-10]. <ul>
4621 #<li> 0 - no standard output,
4622 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4623 # indicates when the final mesh is being saved. In addition the software
4624 # gives indication regarding the CPU time.
4625 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4626 # histogram of the skin mesh, quality statistics histogram together with
4627 # the characteristics of the final mesh.</ul>
4628 # @ingroup l3_hypos_ghs3dh
4629 def SetVerboseLevel(self, level):
4630 # Advanced parameter of GHS3D
4631 self.Parameters().SetVerboseLevel(level)
4633 ## To create new nodes.
4634 # @ingroup l3_hypos_ghs3dh
4635 def SetToCreateNewNodes(self, toCreate):
4636 # Advanced parameter of GHS3D
4637 self.Parameters().SetToCreateNewNodes(toCreate)
4639 ## To use boundary recovery version which tries to create mesh on a very poor
4640 # quality surface mesh.
4641 # @ingroup l3_hypos_ghs3dh
4642 def SetToUseBoundaryRecoveryVersion(self, toUse):
4643 # Advanced parameter of GHS3D
4644 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4646 ## Sets command line option as text.
4647 # @ingroup l3_hypos_ghs3dh
4648 def SetTextOption(self, option):
4649 # Advanced parameter of GHS3D
4650 self.Parameters().SetTextOption(option)
4652 ## Sets MED files name and path.
4653 def SetMEDName(self, value):
4654 self.Parameters().SetMEDName(value)
4656 ## Sets the number of partition of the initial mesh
4657 def SetNbPart(self, value):
4658 self.Parameters().SetNbPart(value)
4660 ## When big mesh, start tepal in background
4661 def SetBackground(self, value):
4662 self.Parameters().SetBackground(value)
4664 # Public class: Mesh_Hexahedron
4665 # ------------------------------
4667 ## Defines a hexahedron 3D algorithm
4669 # @ingroup l3_algos_basic
4670 class Mesh_Hexahedron(Mesh_Algorithm):
4675 ## Private constructor.
4676 def __init__(self, mesh, algoType=Hexa, geom=0):
4677 Mesh_Algorithm.__init__(self)
4679 self.algoType = algoType
4681 if algoType == Hexa:
4682 self.Create(mesh, geom, "Hexa_3D")
4685 elif algoType == Hexotic:
4686 CheckPlugin(Hexotic)
4687 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4690 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4691 # @ingroup l3_hypos_hexotic
4692 def MinMaxQuad(self, min=3, max=8, quad=True):
4693 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4695 self.params.SetHexesMinLevel(min)
4696 self.params.SetHexesMaxLevel(max)
4697 self.params.SetHexoticQuadrangles(quad)
4700 # Deprecated, only for compatibility!
4701 # Public class: Mesh_Netgen
4702 # ------------------------------
4704 ## Defines a NETGEN-based 2D or 3D algorithm
4705 # that needs no discrete boundary (i.e. independent)
4707 # This class is deprecated, only for compatibility!
4710 # @ingroup l3_algos_basic
4711 class Mesh_Netgen(Mesh_Algorithm):
4715 ## Private constructor.
4716 def __init__(self, mesh, is3D, geom=0):
4717 Mesh_Algorithm.__init__(self)
4723 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4727 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4730 ## Defines the hypothesis containing parameters of the algorithm
4731 def Parameters(self):
4733 hyp = self.Hypothesis("NETGEN_Parameters", [],
4734 "libNETGENEngine.so", UseExisting=0)
4736 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4737 "libNETGENEngine.so", UseExisting=0)
4740 # Public class: Mesh_Projection1D
4741 # ------------------------------
4743 ## Defines a projection 1D algorithm
4744 # @ingroup l3_algos_proj
4746 class Mesh_Projection1D(Mesh_Algorithm):
4748 ## Private constructor.
4749 def __init__(self, mesh, geom=0):
4750 Mesh_Algorithm.__init__(self)
4751 self.Create(mesh, geom, "Projection_1D")
4753 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4754 # a mesh pattern is taken, and, optionally, the association of vertices
4755 # between the source edge and a target edge (to which a hypothesis is assigned)
4756 # @param edge from which nodes distribution is taken
4757 # @param mesh from which nodes distribution is taken (optional)
4758 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4759 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4760 # to associate with \a srcV (optional)
4761 # @param UseExisting if ==true - searches for the existing hypothesis created with
4762 # the same parameters, else (default) - creates a new one
4763 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4764 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4766 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4767 hyp.SetSourceEdge( edge )
4768 if not mesh is None and isinstance(mesh, Mesh):
4769 mesh = mesh.GetMesh()
4770 hyp.SetSourceMesh( mesh )
4771 hyp.SetVertexAssociation( srcV, tgtV )
4774 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4775 #def CompareSourceEdge(self, hyp, args):
4776 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4780 # Public class: Mesh_Projection2D
4781 # ------------------------------
4783 ## Defines a projection 2D algorithm
4784 # @ingroup l3_algos_proj
4786 class Mesh_Projection2D(Mesh_Algorithm):
4788 ## Private constructor.
4789 def __init__(self, mesh, geom=0):
4790 Mesh_Algorithm.__init__(self)
4791 self.Create(mesh, geom, "Projection_2D")
4793 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4794 # a mesh pattern is taken, and, optionally, the association of vertices
4795 # between the source face and the target face (to which a hypothesis is assigned)
4796 # @param face from which the mesh pattern is taken
4797 # @param mesh from which the mesh pattern is taken (optional)
4798 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4799 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4800 # to associate with \a srcV1 (optional)
4801 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4802 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4803 # to associate with \a srcV2 (optional)
4804 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4805 # the same parameters, else (default) - forces the creation a new one
4807 # Note: all association vertices must belong to one edge of a face
4808 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4809 srcV2=None, tgtV2=None, UseExisting=0):
4810 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4812 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4813 hyp.SetSourceFace( face )
4814 if not mesh is None and isinstance(mesh, Mesh):
4815 mesh = mesh.GetMesh()
4816 hyp.SetSourceMesh( mesh )
4817 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4820 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4821 #def CompareSourceFace(self, hyp, args):
4822 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4825 # Public class: Mesh_Projection3D
4826 # ------------------------------
4828 ## Defines a projection 3D algorithm
4829 # @ingroup l3_algos_proj
4831 class Mesh_Projection3D(Mesh_Algorithm):
4833 ## Private constructor.
4834 def __init__(self, mesh, geom=0):
4835 Mesh_Algorithm.__init__(self)
4836 self.Create(mesh, geom, "Projection_3D")
4838 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4839 # the mesh pattern is taken, and, optionally, the association of vertices
4840 # between the source and the target solid (to which a hipothesis is assigned)
4841 # @param solid from where the mesh pattern is taken
4842 # @param mesh from where the mesh pattern is taken (optional)
4843 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4844 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4845 # to associate with \a srcV1 (optional)
4846 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4847 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4848 # to associate with \a srcV2 (optional)
4849 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4850 # the same parameters, else (default) - creates a new one
4852 # Note: association vertices must belong to one edge of a solid
4853 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4854 srcV2=0, tgtV2=0, UseExisting=0):
4855 hyp = self.Hypothesis("ProjectionSource3D",
4856 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4858 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4859 hyp.SetSource3DShape( solid )
4860 if not mesh is None and isinstance(mesh, Mesh):
4861 mesh = mesh.GetMesh()
4862 hyp.SetSourceMesh( mesh )
4863 if srcV1 and srcV2 and tgtV1 and tgtV2:
4864 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4865 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4868 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4869 #def CompareSourceShape3D(self, hyp, args):
4870 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4874 # Public class: Mesh_Prism
4875 # ------------------------
4877 ## Defines a 3D extrusion algorithm
4878 # @ingroup l3_algos_3dextr
4880 class Mesh_Prism3D(Mesh_Algorithm):
4882 ## Private constructor.
4883 def __init__(self, mesh, geom=0):
4884 Mesh_Algorithm.__init__(self)
4885 self.Create(mesh, geom, "Prism_3D")
4887 # Public class: Mesh_RadialPrism
4888 # -------------------------------
4890 ## Defines a Radial Prism 3D algorithm
4891 # @ingroup l3_algos_radialp
4893 class Mesh_RadialPrism3D(Mesh_Algorithm):
4895 ## Private constructor.
4896 def __init__(self, mesh, geom=0):
4897 Mesh_Algorithm.__init__(self)
4898 self.Create(mesh, geom, "RadialPrism_3D")
4900 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4901 self.nbLayers = None
4903 ## Return 3D hypothesis holding the 1D one
4904 def Get3DHypothesis(self):
4905 return self.distribHyp
4907 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4908 # hypothesis. Returns the created hypothesis
4909 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4910 #print "OwnHypothesis",hypType
4911 if not self.nbLayers is None:
4912 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4913 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4914 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4915 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4916 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4917 self.distribHyp.SetLayerDistribution( hyp )
4920 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4921 # prisms to build between the inner and outer shells
4922 # @param n number of layers
4923 # @param UseExisting if ==true - searches for the existing hypothesis created with
4924 # the same parameters, else (default) - creates a new one
4925 def NumberOfLayers(self, n, UseExisting=0):
4926 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4927 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4928 CompareMethod=self.CompareNumberOfLayers)
4929 self.nbLayers.SetNumberOfLayers( n )
4930 return self.nbLayers
4932 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4933 def CompareNumberOfLayers(self, hyp, args):
4934 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4936 ## Defines "LocalLength" hypothesis, specifying the segment length
4937 # to build between the inner and the outer shells
4938 # @param l the length of segments
4939 # @param p the precision of rounding
4940 def LocalLength(self, l, p=1e-07):
4941 hyp = self.OwnHypothesis("LocalLength", [l,p])
4946 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4947 # prisms to build between the inner and the outer shells.
4948 # @param n the number of layers
4949 # @param s the scale factor (optional)
4950 def NumberOfSegments(self, n, s=[]):
4952 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4954 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4955 hyp.SetDistrType( 1 )
4956 hyp.SetScaleFactor(s)
4957 hyp.SetNumberOfSegments(n)
4960 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4961 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4962 # @param start the length of the first segment
4963 # @param end the length of the last segment
4964 def Arithmetic1D(self, start, end ):
4965 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4966 hyp.SetLength(start, 1)
4967 hyp.SetLength(end , 0)
4970 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4971 # to build between the inner and the outer shells as geometric length increasing
4972 # @param start for the length of the first segment
4973 # @param end for the length of the last segment
4974 def StartEndLength(self, start, end):
4975 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4976 hyp.SetLength(start, 1)
4977 hyp.SetLength(end , 0)
4980 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4981 # to build between the inner and outer shells
4982 # @param fineness defines the quality of the mesh within the range [0-1]
4983 def AutomaticLength(self, fineness=0):
4984 hyp = self.OwnHypothesis("AutomaticLength")
4985 hyp.SetFineness( fineness )
4988 # Public class: Mesh_RadialQuadrangle1D2D
4989 # -------------------------------
4991 ## Defines a Radial Quadrangle 1D2D algorithm
4992 # @ingroup l2_algos_radialq
4994 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
4996 ## Private constructor.
4997 def __init__(self, mesh, geom=0):
4998 Mesh_Algorithm.__init__(self)
4999 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5001 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5002 self.nbLayers = None
5004 ## Return 2D hypothesis holding the 1D one
5005 def Get2DHypothesis(self):
5006 return self.distribHyp
5008 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5009 # hypothesis. Returns the created hypothesis
5010 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5011 #print "OwnHypothesis",hypType
5012 if not self.nbLayers is None:
5013 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5014 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5015 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5016 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5017 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5018 self.distribHyp.SetLayerDistribution( hyp )
5021 ## Defines "NumberOfLayers2D" hypothesis, specifying the number of layers
5022 # @param n number of layers
5023 # @param UseExisting if ==true - searches for the existing hypothesis created with
5024 # the same parameters, else (default) - creates a new one
5025 def NumberOfLayers2D(self, n, UseExisting=0):
5026 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5027 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5028 CompareMethod=self.CompareNumberOfLayers)
5029 self.nbLayers.SetNumberOfLayers( n )
5030 return self.nbLayers
5032 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5033 def CompareNumberOfLayers(self, hyp, args):
5034 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5036 ## Defines "LocalLength" hypothesis, specifying the segment length
5037 # @param l the length of segments
5038 # @param p the precision of rounding
5039 def LocalLength(self, l, p=1e-07):
5040 hyp = self.OwnHypothesis("LocalLength", [l,p])
5045 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5046 # @param n the number of layers
5047 # @param s the scale factor (optional)
5048 def NumberOfSegments(self, n, s=[]):
5050 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5052 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5053 hyp.SetDistrType( 1 )
5054 hyp.SetScaleFactor(s)
5055 hyp.SetNumberOfSegments(n)
5058 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5059 # with a length that changes in arithmetic progression
5060 # @param start the length of the first segment
5061 # @param end the length of the last segment
5062 def Arithmetic1D(self, start, end ):
5063 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5064 hyp.SetLength(start, 1)
5065 hyp.SetLength(end , 0)
5068 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5069 # as geometric length increasing
5070 # @param start for the length of the first segment
5071 # @param end for the length of the last segment
5072 def StartEndLength(self, start, end):
5073 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5074 hyp.SetLength(start, 1)
5075 hyp.SetLength(end , 0)
5078 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5079 # @param fineness defines the quality of the mesh within the range [0-1]
5080 def AutomaticLength(self, fineness=0):
5081 hyp = self.OwnHypothesis("AutomaticLength")
5082 hyp.SetFineness( fineness )
5086 # Private class: Mesh_UseExisting
5087 # -------------------------------
5088 class Mesh_UseExisting(Mesh_Algorithm):
5090 def __init__(self, dim, mesh, geom=0):
5092 self.Create(mesh, geom, "UseExisting_1D")
5094 self.Create(mesh, geom, "UseExisting_2D")
5097 import salome_notebook
5098 notebook = salome_notebook.notebook
5100 ##Return values of the notebook variables
5101 def ParseParameters(last, nbParams,nbParam, value):
5105 listSize = len(last)
5106 for n in range(0,nbParams):
5108 if counter < listSize:
5109 strResult = strResult + last[counter]
5111 strResult = strResult + ""
5113 if isinstance(value, str):
5114 if notebook.isVariable(value):
5115 result = notebook.get(value)
5116 strResult=strResult+value
5118 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5120 strResult=strResult+str(value)
5122 if nbParams - 1 != counter:
5123 strResult=strResult+var_separator #":"
5125 return result, strResult
5127 #Wrapper class for StdMeshers_LocalLength hypothesis
5128 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5130 ## Set Length parameter value
5131 # @param length numerical value or name of variable from notebook
5132 def SetLength(self, length):
5133 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5134 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5135 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5137 ## Set Precision parameter value
5138 # @param precision numerical value or name of variable from notebook
5139 def SetPrecision(self, precision):
5140 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5141 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5142 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5144 #Registering the new proxy for LocalLength
5145 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5148 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5149 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5151 def SetLayerDistribution(self, hypo):
5152 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5153 hypo.ClearParameters();
5154 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5156 #Registering the new proxy for LayerDistribution
5157 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5159 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5160 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5162 ## Set Length parameter value
5163 # @param length numerical value or name of variable from notebook
5164 def SetLength(self, length):
5165 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5166 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5167 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5169 #Registering the new proxy for SegmentLengthAroundVertex
5170 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5173 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5174 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5176 ## Set Length parameter value
5177 # @param length numerical value or name of variable from notebook
5178 # @param isStart true is length is Start Length, otherwise false
5179 def SetLength(self, length, isStart):
5183 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5184 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5185 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5187 #Registering the new proxy for Arithmetic1D
5188 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5190 #Wrapper class for StdMeshers_Deflection1D hypothesis
5191 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5193 ## Set Deflection parameter value
5194 # @param deflection numerical value or name of variable from notebook
5195 def SetDeflection(self, deflection):
5196 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5197 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5198 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5200 #Registering the new proxy for Deflection1D
5201 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5203 #Wrapper class for StdMeshers_StartEndLength hypothesis
5204 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5206 ## Set Length parameter value
5207 # @param length numerical value or name of variable from notebook
5208 # @param isStart true is length is Start Length, otherwise false
5209 def SetLength(self, length, isStart):
5213 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5214 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5215 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5217 #Registering the new proxy for StartEndLength
5218 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5220 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5221 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5223 ## Set Max Element Area parameter value
5224 # @param area numerical value or name of variable from notebook
5225 def SetMaxElementArea(self, area):
5226 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5227 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5228 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5230 #Registering the new proxy for MaxElementArea
5231 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5234 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5235 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5237 ## Set Max Element Volume parameter value
5238 # @param volume numerical value or name of variable from notebook
5239 def SetMaxElementVolume(self, volume):
5240 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5241 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5242 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5244 #Registering the new proxy for MaxElementVolume
5245 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5248 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5249 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5251 ## Set Number Of Layers parameter value
5252 # @param nbLayers numerical value or name of variable from notebook
5253 def SetNumberOfLayers(self, nbLayers):
5254 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5255 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5256 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5258 #Registering the new proxy for NumberOfLayers
5259 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5261 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5262 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5264 ## Set Number Of Segments parameter value
5265 # @param nbSeg numerical value or name of variable from notebook
5266 def SetNumberOfSegments(self, nbSeg):
5267 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5268 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5269 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5270 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5272 ## Set Scale Factor parameter value
5273 # @param factor numerical value or name of variable from notebook
5274 def SetScaleFactor(self, factor):
5275 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5276 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5277 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5279 #Registering the new proxy for NumberOfSegments
5280 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5282 if not noNETGENPlugin:
5283 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5284 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5286 ## Set Max Size parameter value
5287 # @param maxsize numerical value or name of variable from notebook
5288 def SetMaxSize(self, maxsize):
5289 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5290 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5291 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5292 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5294 ## Set Growth Rate parameter value
5295 # @param value numerical value or name of variable from notebook
5296 def SetGrowthRate(self, value):
5297 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5298 value, parameters = ParseParameters(lastParameters,4,2,value)
5299 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5300 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5302 ## Set Number of Segments per Edge parameter value
5303 # @param value numerical value or name of variable from notebook
5304 def SetNbSegPerEdge(self, value):
5305 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5306 value, parameters = ParseParameters(lastParameters,4,3,value)
5307 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5308 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5310 ## Set Number of Segments per Radius parameter value
5311 # @param value numerical value or name of variable from notebook
5312 def SetNbSegPerRadius(self, value):
5313 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5314 value, parameters = ParseParameters(lastParameters,4,4,value)
5315 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5316 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5318 #Registering the new proxy for NETGENPlugin_Hypothesis
5319 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5322 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5323 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5326 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5327 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5329 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5330 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5332 ## Set Number of Segments parameter value
5333 # @param nbSeg numerical value or name of variable from notebook
5334 def SetNumberOfSegments(self, nbSeg):
5335 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5336 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5337 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5338 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5340 ## Set Local Length parameter value
5341 # @param length numerical value or name of variable from notebook
5342 def SetLocalLength(self, length):
5343 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5344 length, parameters = ParseParameters(lastParameters,2,1,length)
5345 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5346 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5348 ## Set Max Element Area parameter value
5349 # @param area numerical value or name of variable from notebook
5350 def SetMaxElementArea(self, area):
5351 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5352 area, parameters = ParseParameters(lastParameters,2,2,area)
5353 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5354 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5356 def LengthFromEdges(self):
5357 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5359 value, parameters = ParseParameters(lastParameters,2,2,value)
5360 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5361 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5363 #Registering the new proxy for NETGEN_SimpleParameters_2D
5364 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5367 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5368 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5369 ## Set Max Element Volume parameter value
5370 # @param volume numerical value or name of variable from notebook
5371 def SetMaxElementVolume(self, volume):
5372 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5373 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5374 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5375 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5377 def LengthFromFaces(self):
5378 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5380 value, parameters = ParseParameters(lastParameters,3,3,value)
5381 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5382 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5384 #Registering the new proxy for NETGEN_SimpleParameters_3D
5385 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5387 pass # if not noNETGENPlugin:
5389 class Pattern(SMESH._objref_SMESH_Pattern):
5391 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5393 if isinstance(theNodeIndexOnKeyPoint1,str):
5395 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5397 theNodeIndexOnKeyPoint1 -= 1
5398 theMesh.SetParameters(Parameters)
5399 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5401 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5404 if isinstance(theNode000Index,str):
5406 if isinstance(theNode001Index,str):
5408 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5410 theNode000Index -= 1
5412 theNode001Index -= 1
5413 theMesh.SetParameters(Parameters)
5414 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5416 #Registering the new proxy for Pattern
5417 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)