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
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 # @ingroup l2_impexp
1324 def ExportToMED(self, f, version, opt=0):
1325 self.mesh.ExportToMED(f, opt, version)
1327 ## Exports the mesh in a file in MED format
1328 # @param f is the file name
1329 # @param auto_groups boolean parameter for creating/not creating
1330 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1331 # the typical use is auto_groups=false.
1332 # @param version MED format version(MED_V2_1 or MED_V2_2)
1333 # @ingroup l2_impexp
1334 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1335 self.mesh.ExportToMED(f, auto_groups, version)
1337 ## Exports the mesh in a file in DAT format
1338 # @param f the file name
1339 # @ingroup l2_impexp
1340 def ExportDAT(self, f):
1341 self.mesh.ExportDAT(f)
1343 ## Exports the mesh in a file in UNV format
1344 # @param f the file name
1345 # @ingroup l2_impexp
1346 def ExportUNV(self, f):
1347 self.mesh.ExportUNV(f)
1349 ## Export the mesh in a file in STL format
1350 # @param f the file name
1351 # @param ascii defines the file encoding
1352 # @ingroup l2_impexp
1353 def ExportSTL(self, f, ascii=1):
1354 self.mesh.ExportSTL(f, ascii)
1357 # Operations with groups:
1358 # ----------------------
1360 ## Creates an empty mesh group
1361 # @param elementType the type of elements in the group
1362 # @param name the name of the mesh group
1363 # @return SMESH_Group
1364 # @ingroup l2_grps_create
1365 def CreateEmptyGroup(self, elementType, name):
1366 return self.mesh.CreateGroup(elementType, name)
1368 ## Creates a mesh group based on the geometrical object \a grp
1369 # and gives a \a name, \n if this parameter is not defined
1370 # the name is the same as the geometrical group name
1371 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1372 # @param name the name of the mesh group
1373 # @param typ the type of elements in the group. If not set, it is
1374 # automatically detected by the type of the geometry
1375 # @return SMESH_GroupOnGeom
1376 # @ingroup l2_grps_create
1377 def GroupOnGeom(self, grp, name="", typ=None):
1379 name = grp.GetName()
1382 tgeo = str(grp.GetShapeType())
1383 if tgeo == "VERTEX":
1385 elif tgeo == "EDGE":
1387 elif tgeo == "FACE":
1389 elif tgeo == "SOLID":
1391 elif tgeo == "SHELL":
1393 elif tgeo == "COMPOUND":
1394 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1395 print "Mesh.Group: empty geometric group", GetName( grp )
1397 tgeo = self.geompyD.GetType(grp)
1398 if tgeo == geompyDC.ShapeType["VERTEX"]:
1400 elif tgeo == geompyDC.ShapeType["EDGE"]:
1402 elif tgeo == geompyDC.ShapeType["FACE"]:
1404 elif tgeo == geompyDC.ShapeType["SOLID"]:
1408 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1411 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1413 ## Creates a mesh group by the given ids of elements
1414 # @param groupName the name of the mesh group
1415 # @param elementType the type of elements in the group
1416 # @param elemIDs the list of ids
1417 # @return SMESH_Group
1418 # @ingroup l2_grps_create
1419 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1420 group = self.mesh.CreateGroup(elementType, groupName)
1424 ## Creates a mesh group by the given conditions
1425 # @param groupName the name of the mesh group
1426 # @param elementType the type of elements in the group
1427 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1428 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1429 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1430 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1431 # @return SMESH_Group
1432 # @ingroup l2_grps_create
1436 CritType=FT_Undefined,
1439 UnaryOp=FT_Undefined):
1440 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1441 group = self.MakeGroupByCriterion(groupName, aCriterion)
1444 ## Creates a mesh group by the given criterion
1445 # @param groupName the name of the mesh group
1446 # @param Criterion the instance of Criterion class
1447 # @return SMESH_Group
1448 # @ingroup l2_grps_create
1449 def MakeGroupByCriterion(self, groupName, Criterion):
1450 aFilterMgr = self.smeshpyD.CreateFilterManager()
1451 aFilter = aFilterMgr.CreateFilter()
1453 aCriteria.append(Criterion)
1454 aFilter.SetCriteria(aCriteria)
1455 group = self.MakeGroupByFilter(groupName, aFilter)
1458 ## Creates a mesh group by the given criteria (list of criteria)
1459 # @param groupName the name of the mesh group
1460 # @param theCriteria the list of criteria
1461 # @return SMESH_Group
1462 # @ingroup l2_grps_create
1463 def MakeGroupByCriteria(self, groupName, theCriteria):
1464 aFilterMgr = self.smeshpyD.CreateFilterManager()
1465 aFilter = aFilterMgr.CreateFilter()
1466 aFilter.SetCriteria(theCriteria)
1467 group = self.MakeGroupByFilter(groupName, aFilter)
1470 ## Creates a mesh group by the given filter
1471 # @param groupName the name of the mesh group
1472 # @param theFilter the instance of Filter class
1473 # @return SMESH_Group
1474 # @ingroup l2_grps_create
1475 def MakeGroupByFilter(self, groupName, theFilter):
1476 anIds = theFilter.GetElementsId(self.mesh)
1477 anElemType = theFilter.GetElementType()
1478 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1481 ## Passes mesh elements through the given filter and return IDs of fitting elements
1482 # @param theFilter SMESH_Filter
1483 # @return a list of ids
1484 # @ingroup l1_controls
1485 def GetIdsFromFilter(self, theFilter):
1486 return theFilter.GetElementsId(self.mesh)
1488 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1489 # Returns a list of special structures (borders).
1490 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1491 # @ingroup l1_controls
1492 def GetFreeBorders(self):
1493 aFilterMgr = self.smeshpyD.CreateFilterManager()
1494 aPredicate = aFilterMgr.CreateFreeEdges()
1495 aPredicate.SetMesh(self.mesh)
1496 aBorders = aPredicate.GetBorders()
1500 # @ingroup l2_grps_delete
1501 def RemoveGroup(self, group):
1502 self.mesh.RemoveGroup(group)
1504 ## Removes a group with its contents
1505 # @ingroup l2_grps_delete
1506 def RemoveGroupWithContents(self, group):
1507 self.mesh.RemoveGroupWithContents(group)
1509 ## Gets the list of groups existing in the mesh
1510 # @return a sequence of SMESH_GroupBase
1511 # @ingroup l2_grps_create
1512 def GetGroups(self):
1513 return self.mesh.GetGroups()
1515 ## Gets the number of groups existing in the mesh
1516 # @return the quantity of groups as an integer value
1517 # @ingroup l2_grps_create
1519 return self.mesh.NbGroups()
1521 ## Gets the list of names of groups existing in the mesh
1522 # @return list of strings
1523 # @ingroup l2_grps_create
1524 def GetGroupNames(self):
1525 groups = self.GetGroups()
1527 for group in groups:
1528 names.append(group.GetName())
1531 ## Produces a union of two groups
1532 # A new group is created. All mesh elements that are
1533 # present in the initial groups are added to the new one
1534 # @return an instance of SMESH_Group
1535 # @ingroup l2_grps_operon
1536 def UnionGroups(self, group1, group2, name):
1537 return self.mesh.UnionGroups(group1, group2, name)
1539 ## Produces a union list of groups
1540 # New group is created. All mesh elements that are present in
1541 # initial groups are added to the new one
1542 # @return an instance of SMESH_Group
1543 # @ingroup l2_grps_operon
1544 def UnionListOfGroups(self, groups, name):
1545 return self.mesh.UnionListOfGroups(groups, name)
1547 ## Prodices an intersection of two groups
1548 # A new group is created. All mesh elements that are common
1549 # for the two initial groups are added to the new one.
1550 # @return an instance of SMESH_Group
1551 # @ingroup l2_grps_operon
1552 def IntersectGroups(self, group1, group2, name):
1553 return self.mesh.IntersectGroups(group1, group2, name)
1555 ## Produces an intersection of groups
1556 # New group is created. All mesh elements that are present in all
1557 # initial groups simultaneously are added to the new one
1558 # @return an instance of SMESH_Group
1559 # @ingroup l2_grps_operon
1560 def IntersectListOfGroups(self, groups, name):
1561 return self.mesh.IntersectListOfGroups(groups, name)
1563 ## Produces a cut of two groups
1564 # A new group is created. All mesh elements that are present in
1565 # the main group but are not present in the tool group are added to the new one
1566 # @return an instance of SMESH_Group
1567 # @ingroup l2_grps_operon
1568 def CutGroups(self, main_group, tool_group, name):
1569 return self.mesh.CutGroups(main_group, tool_group, name)
1571 ## Produces a cut of groups
1572 # A new group is created. All mesh elements that are present in main groups
1573 # but do not present in tool groups are added to the new one
1574 # @return an instance of SMESH_Group
1575 # @ingroup l2_grps_operon
1576 def CutListOfGroups(self, main_groups, tool_groups, name):
1577 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1579 ## Produces a group of elements with specified element type using list of existing groups
1580 # A new group is created. System
1581 # 1) extract all nodes on which groups elements are built
1582 # 2) combine all elements of specified dimension laying on these nodes
1583 # @return an instance of SMESH_Group
1584 # @ingroup l2_grps_operon
1585 def CreateDimGroup(self, groups, elem_type, name):
1586 return self.mesh.CreateDimGroup(groups, elem_type, name)
1589 ## Convert group on geom into standalone group
1590 # @ingroup l2_grps_delete
1591 def ConvertToStandalone(self, group):
1592 return self.mesh.ConvertToStandalone(group)
1594 # Get some info about mesh:
1595 # ------------------------
1597 ## Returns the log of nodes and elements added or removed
1598 # since the previous clear of the log.
1599 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1600 # @return list of log_block structures:
1605 # @ingroup l1_auxiliary
1606 def GetLog(self, clearAfterGet):
1607 return self.mesh.GetLog(clearAfterGet)
1609 ## Clears the log of nodes and elements added or removed since the previous
1610 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1611 # @ingroup l1_auxiliary
1613 self.mesh.ClearLog()
1615 ## Toggles auto color mode on the object.
1616 # @param theAutoColor the flag which toggles auto color mode.
1617 # @ingroup l1_auxiliary
1618 def SetAutoColor(self, theAutoColor):
1619 self.mesh.SetAutoColor(theAutoColor)
1621 ## Gets flag of object auto color mode.
1622 # @return True or False
1623 # @ingroup l1_auxiliary
1624 def GetAutoColor(self):
1625 return self.mesh.GetAutoColor()
1627 ## Gets the internal ID
1628 # @return integer value, which is the internal Id of the mesh
1629 # @ingroup l1_auxiliary
1631 return self.mesh.GetId()
1634 # @return integer value, which is the study Id of the mesh
1635 # @ingroup l1_auxiliary
1636 def GetStudyId(self):
1637 return self.mesh.GetStudyId()
1639 ## Checks the group names for duplications.
1640 # Consider the maximum group name length stored in MED file.
1641 # @return True or False
1642 # @ingroup l1_auxiliary
1643 def HasDuplicatedGroupNamesMED(self):
1644 return self.mesh.HasDuplicatedGroupNamesMED()
1646 ## Obtains the mesh editor tool
1647 # @return an instance of SMESH_MeshEditor
1648 # @ingroup l1_modifying
1649 def GetMeshEditor(self):
1650 return self.mesh.GetMeshEditor()
1653 # @return an instance of SALOME_MED::MESH
1654 # @ingroup l1_auxiliary
1655 def GetMEDMesh(self):
1656 return self.mesh.GetMEDMesh()
1659 # Get informations about mesh contents:
1660 # ------------------------------------
1662 ## Gets the mesh stattistic
1663 # @return dictionary type element - count of elements
1664 # @ingroup l1_meshinfo
1665 def GetMeshInfo(self, obj = None):
1666 if not obj: obj = self.mesh
1667 return self.smeshpyD.GetMeshInfo(obj)
1669 ## Returns the number of nodes in the mesh
1670 # @return an integer value
1671 # @ingroup l1_meshinfo
1673 return self.mesh.NbNodes()
1675 ## Returns the number of elements in the mesh
1676 # @return an integer value
1677 # @ingroup l1_meshinfo
1678 def NbElements(self):
1679 return self.mesh.NbElements()
1681 ## Returns the number of 0d elements in the mesh
1682 # @return an integer value
1683 # @ingroup l1_meshinfo
1684 def Nb0DElements(self):
1685 return self.mesh.Nb0DElements()
1687 ## Returns the number of edges in the mesh
1688 # @return an integer value
1689 # @ingroup l1_meshinfo
1691 return self.mesh.NbEdges()
1693 ## Returns the number of edges with the given order in the mesh
1694 # @param elementOrder the order of elements:
1695 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1696 # @return an integer value
1697 # @ingroup l1_meshinfo
1698 def NbEdgesOfOrder(self, elementOrder):
1699 return self.mesh.NbEdgesOfOrder(elementOrder)
1701 ## Returns the number of faces in the mesh
1702 # @return an integer value
1703 # @ingroup l1_meshinfo
1705 return self.mesh.NbFaces()
1707 ## Returns the number of faces with the given order in the mesh
1708 # @param elementOrder the order of elements:
1709 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1710 # @return an integer value
1711 # @ingroup l1_meshinfo
1712 def NbFacesOfOrder(self, elementOrder):
1713 return self.mesh.NbFacesOfOrder(elementOrder)
1715 ## Returns the number of triangles in the mesh
1716 # @return an integer value
1717 # @ingroup l1_meshinfo
1718 def NbTriangles(self):
1719 return self.mesh.NbTriangles()
1721 ## Returns the number of triangles with the given order in the mesh
1722 # @param elementOrder is the order of elements:
1723 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1724 # @return an integer value
1725 # @ingroup l1_meshinfo
1726 def NbTrianglesOfOrder(self, elementOrder):
1727 return self.mesh.NbTrianglesOfOrder(elementOrder)
1729 ## Returns the number of quadrangles in the mesh
1730 # @return an integer value
1731 # @ingroup l1_meshinfo
1732 def NbQuadrangles(self):
1733 return self.mesh.NbQuadrangles()
1735 ## Returns the number of quadrangles with the given order in the mesh
1736 # @param elementOrder the order of elements:
1737 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1738 # @return an integer value
1739 # @ingroup l1_meshinfo
1740 def NbQuadranglesOfOrder(self, elementOrder):
1741 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1743 ## Returns the number of polygons in the mesh
1744 # @return an integer value
1745 # @ingroup l1_meshinfo
1746 def NbPolygons(self):
1747 return self.mesh.NbPolygons()
1749 ## Returns the number of volumes in the mesh
1750 # @return an integer value
1751 # @ingroup l1_meshinfo
1752 def NbVolumes(self):
1753 return self.mesh.NbVolumes()
1755 ## Returns the number of volumes 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 NbVolumesOfOrder(self, elementOrder):
1761 return self.mesh.NbVolumesOfOrder(elementOrder)
1763 ## Returns the number of tetrahedrons in the mesh
1764 # @return an integer value
1765 # @ingroup l1_meshinfo
1767 return self.mesh.NbTetras()
1769 ## Returns the number of tetrahedrons with the given order in the mesh
1770 # @param elementOrder the order of elements:
1771 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1772 # @return an integer value
1773 # @ingroup l1_meshinfo
1774 def NbTetrasOfOrder(self, elementOrder):
1775 return self.mesh.NbTetrasOfOrder(elementOrder)
1777 ## Returns the number of hexahedrons in the mesh
1778 # @return an integer value
1779 # @ingroup l1_meshinfo
1781 return self.mesh.NbHexas()
1783 ## Returns the number of hexahedrons with the given order in the mesh
1784 # @param elementOrder the order of elements:
1785 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1786 # @return an integer value
1787 # @ingroup l1_meshinfo
1788 def NbHexasOfOrder(self, elementOrder):
1789 return self.mesh.NbHexasOfOrder(elementOrder)
1791 ## Returns the number of pyramids in the mesh
1792 # @return an integer value
1793 # @ingroup l1_meshinfo
1794 def NbPyramids(self):
1795 return self.mesh.NbPyramids()
1797 ## Returns the number of pyramids with the given order in the mesh
1798 # @param elementOrder the order of elements:
1799 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1800 # @return an integer value
1801 # @ingroup l1_meshinfo
1802 def NbPyramidsOfOrder(self, elementOrder):
1803 return self.mesh.NbPyramidsOfOrder(elementOrder)
1805 ## Returns the number of prisms in the mesh
1806 # @return an integer value
1807 # @ingroup l1_meshinfo
1809 return self.mesh.NbPrisms()
1811 ## Returns the number of prisms with the given order in the mesh
1812 # @param elementOrder the order of elements:
1813 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1814 # @return an integer value
1815 # @ingroup l1_meshinfo
1816 def NbPrismsOfOrder(self, elementOrder):
1817 return self.mesh.NbPrismsOfOrder(elementOrder)
1819 ## Returns the number of polyhedrons in the mesh
1820 # @return an integer value
1821 # @ingroup l1_meshinfo
1822 def NbPolyhedrons(self):
1823 return self.mesh.NbPolyhedrons()
1825 ## Returns the number of submeshes in the mesh
1826 # @return an integer value
1827 # @ingroup l1_meshinfo
1828 def NbSubMesh(self):
1829 return self.mesh.NbSubMesh()
1831 ## Returns the list of mesh elements IDs
1832 # @return the list of integer values
1833 # @ingroup l1_meshinfo
1834 def GetElementsId(self):
1835 return self.mesh.GetElementsId()
1837 ## Returns the list of IDs of mesh elements with the given type
1838 # @param elementType the required type of elements
1839 # @return list of integer values
1840 # @ingroup l1_meshinfo
1841 def GetElementsByType(self, elementType):
1842 return self.mesh.GetElementsByType(elementType)
1844 ## Returns the list of mesh nodes IDs
1845 # @return the list of integer values
1846 # @ingroup l1_meshinfo
1847 def GetNodesId(self):
1848 return self.mesh.GetNodesId()
1850 # Get the information about mesh elements:
1851 # ------------------------------------
1853 ## Returns the type of mesh element
1854 # @return the value from SMESH::ElementType enumeration
1855 # @ingroup l1_meshinfo
1856 def GetElementType(self, id, iselem):
1857 return self.mesh.GetElementType(id, iselem)
1859 ## Returns the list of submesh elements IDs
1860 # @param Shape a geom object(subshape) IOR
1861 # Shape must be the subshape of a ShapeToMesh()
1862 # @return the list of integer values
1863 # @ingroup l1_meshinfo
1864 def GetSubMeshElementsId(self, Shape):
1865 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1866 ShapeID = Shape.GetSubShapeIndices()[0]
1869 return self.mesh.GetSubMeshElementsId(ShapeID)
1871 ## Returns the list of submesh nodes IDs
1872 # @param Shape a geom object(subshape) IOR
1873 # Shape must be the subshape of a ShapeToMesh()
1874 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1875 # @return the list of integer values
1876 # @ingroup l1_meshinfo
1877 def GetSubMeshNodesId(self, Shape, all):
1878 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1879 ShapeID = Shape.GetSubShapeIndices()[0]
1882 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1884 ## Returns type of elements on given shape
1885 # @param Shape a geom object(subshape) IOR
1886 # Shape must be a subshape of a ShapeToMesh()
1887 # @return element type
1888 # @ingroup l1_meshinfo
1889 def GetSubMeshElementType(self, Shape):
1890 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1891 ShapeID = Shape.GetSubShapeIndices()[0]
1894 return self.mesh.GetSubMeshElementType(ShapeID)
1896 ## Gets the mesh description
1897 # @return string value
1898 # @ingroup l1_meshinfo
1900 return self.mesh.Dump()
1903 # Get the information about nodes and elements of a mesh by its IDs:
1904 # -----------------------------------------------------------
1906 ## Gets XYZ coordinates of a node
1907 # \n If there is no nodes for the given ID - returns an empty list
1908 # @return a list of double precision values
1909 # @ingroup l1_meshinfo
1910 def GetNodeXYZ(self, id):
1911 return self.mesh.GetNodeXYZ(id)
1913 ## Returns list of IDs of inverse elements for the given node
1914 # \n If there is no node for the given ID - returns an empty list
1915 # @return a list of integer values
1916 # @ingroup l1_meshinfo
1917 def GetNodeInverseElements(self, id):
1918 return self.mesh.GetNodeInverseElements(id)
1920 ## @brief Returns the position of a node on the shape
1921 # @return SMESH::NodePosition
1922 # @ingroup l1_meshinfo
1923 def GetNodePosition(self,NodeID):
1924 return self.mesh.GetNodePosition(NodeID)
1926 ## If the given element is a node, returns the ID of shape
1927 # \n If there is no node for the given ID - returns -1
1928 # @return an integer value
1929 # @ingroup l1_meshinfo
1930 def GetShapeID(self, id):
1931 return self.mesh.GetShapeID(id)
1933 ## Returns the ID of the result shape after
1934 # FindShape() from SMESH_MeshEditor for the given element
1935 # \n If there is no element for the given ID - returns -1
1936 # @return an integer value
1937 # @ingroup l1_meshinfo
1938 def GetShapeIDForElem(self,id):
1939 return self.mesh.GetShapeIDForElem(id)
1941 ## Returns the number of nodes for the given element
1942 # \n If there is no element for the given ID - returns -1
1943 # @return an integer value
1944 # @ingroup l1_meshinfo
1945 def GetElemNbNodes(self, id):
1946 return self.mesh.GetElemNbNodes(id)
1948 ## Returns the node ID the given index for the given element
1949 # \n If there is no element for the given ID - returns -1
1950 # \n If there is no node for the given index - returns -2
1951 # @return an integer value
1952 # @ingroup l1_meshinfo
1953 def GetElemNode(self, id, index):
1954 return self.mesh.GetElemNode(id, index)
1956 ## Returns the IDs of nodes of the given element
1957 # @return a list of integer values
1958 # @ingroup l1_meshinfo
1959 def GetElemNodes(self, id):
1960 return self.mesh.GetElemNodes(id)
1962 ## Returns true if the given node is the medium node in the given quadratic element
1963 # @ingroup l1_meshinfo
1964 def IsMediumNode(self, elementID, nodeID):
1965 return self.mesh.IsMediumNode(elementID, nodeID)
1967 ## Returns true if the given node is the medium node in one of quadratic elements
1968 # @ingroup l1_meshinfo
1969 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1970 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1972 ## Returns the number of edges for the given element
1973 # @ingroup l1_meshinfo
1974 def ElemNbEdges(self, id):
1975 return self.mesh.ElemNbEdges(id)
1977 ## Returns the number of faces for the given element
1978 # @ingroup l1_meshinfo
1979 def ElemNbFaces(self, id):
1980 return self.mesh.ElemNbFaces(id)
1982 ## Returns true if the given element is a polygon
1983 # @ingroup l1_meshinfo
1984 def IsPoly(self, id):
1985 return self.mesh.IsPoly(id)
1987 ## Returns true if the given element is quadratic
1988 # @ingroup l1_meshinfo
1989 def IsQuadratic(self, id):
1990 return self.mesh.IsQuadratic(id)
1992 ## Returns XYZ coordinates of the barycenter of the given element
1993 # \n If there is no element for the given ID - returns an empty list
1994 # @return a list of three double values
1995 # @ingroup l1_meshinfo
1996 def BaryCenter(self, id):
1997 return self.mesh.BaryCenter(id)
2000 # Mesh edition (SMESH_MeshEditor functionality):
2001 # ---------------------------------------------
2003 ## Removes the elements from the mesh by ids
2004 # @param IDsOfElements is a list of ids of elements to remove
2005 # @return True or False
2006 # @ingroup l2_modif_del
2007 def RemoveElements(self, IDsOfElements):
2008 return self.editor.RemoveElements(IDsOfElements)
2010 ## Removes nodes from mesh by ids
2011 # @param IDsOfNodes is a list of ids of nodes to remove
2012 # @return True or False
2013 # @ingroup l2_modif_del
2014 def RemoveNodes(self, IDsOfNodes):
2015 return self.editor.RemoveNodes(IDsOfNodes)
2017 ## Add a node to the mesh by coordinates
2018 # @return Id of the new node
2019 # @ingroup l2_modif_add
2020 def AddNode(self, x, y, z):
2021 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2022 self.mesh.SetParameters(Parameters)
2023 return self.editor.AddNode( x, y, z)
2025 ## Creates a 0D element on a node with given number.
2026 # @param IDOfNode the ID of node for creation of the element.
2027 # @return the Id of the new 0D element
2028 # @ingroup l2_modif_add
2029 def Add0DElement(self, IDOfNode):
2030 return self.editor.Add0DElement(IDOfNode)
2032 ## Creates a linear or quadratic edge (this is determined
2033 # by the number of given nodes).
2034 # @param IDsOfNodes the list of node IDs for creation of the element.
2035 # The order of nodes in this list should correspond to the description
2036 # of MED. \n This description is located by the following link:
2037 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2038 # @return the Id of the new edge
2039 # @ingroup l2_modif_add
2040 def AddEdge(self, IDsOfNodes):
2041 return self.editor.AddEdge(IDsOfNodes)
2043 ## Creates a linear or quadratic face (this is determined
2044 # by the number of given nodes).
2045 # @param IDsOfNodes the list of node IDs for creation of the element.
2046 # The order of nodes in this list should correspond to the description
2047 # of MED. \n This description is located by the following link:
2048 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2049 # @return the Id of the new face
2050 # @ingroup l2_modif_add
2051 def AddFace(self, IDsOfNodes):
2052 return self.editor.AddFace(IDsOfNodes)
2054 ## Adds a polygonal face to the mesh by the list of node IDs
2055 # @param IdsOfNodes the list of node IDs for creation of the element.
2056 # @return the Id of the new face
2057 # @ingroup l2_modif_add
2058 def AddPolygonalFace(self, IdsOfNodes):
2059 return self.editor.AddPolygonalFace(IdsOfNodes)
2061 ## Creates both simple and quadratic volume (this is determined
2062 # by the number of given nodes).
2063 # @param IDsOfNodes the list of node IDs for creation of the element.
2064 # The order of nodes in this list should correspond to the description
2065 # of MED. \n This description is located by the following link:
2066 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2067 # @return the Id of the new volumic element
2068 # @ingroup l2_modif_add
2069 def AddVolume(self, IDsOfNodes):
2070 return self.editor.AddVolume(IDsOfNodes)
2072 ## Creates a volume of many faces, giving nodes for each face.
2073 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2074 # @param Quantities the list of integer values, Quantities[i]
2075 # gives the quantity of nodes in face number i.
2076 # @return the Id of the new volumic element
2077 # @ingroup l2_modif_add
2078 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2079 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2081 ## Creates a volume of many faces, giving the IDs of the existing faces.
2082 # @param IdsOfFaces the list of face IDs for volume creation.
2084 # Note: The created volume will refer only to the nodes
2085 # of the given faces, not to the faces themselves.
2086 # @return the Id of the new volumic element
2087 # @ingroup l2_modif_add
2088 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2089 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2092 ## @brief Binds a node to a vertex
2093 # @param NodeID a node ID
2094 # @param Vertex a vertex or vertex ID
2095 # @return True if succeed else raises an exception
2096 # @ingroup l2_modif_add
2097 def SetNodeOnVertex(self, NodeID, Vertex):
2098 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2099 VertexID = Vertex.GetSubShapeIndices()[0]
2103 self.editor.SetNodeOnVertex(NodeID, VertexID)
2104 except SALOME.SALOME_Exception, inst:
2105 raise ValueError, inst.details.text
2109 ## @brief Stores the node position on an edge
2110 # @param NodeID a node ID
2111 # @param Edge an edge or edge ID
2112 # @param paramOnEdge a parameter on the edge where the node is located
2113 # @return True if succeed else raises an exception
2114 # @ingroup l2_modif_add
2115 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2116 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2117 EdgeID = Edge.GetSubShapeIndices()[0]
2121 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2122 except SALOME.SALOME_Exception, inst:
2123 raise ValueError, inst.details.text
2126 ## @brief Stores node position on a face
2127 # @param NodeID a node ID
2128 # @param Face a face or face ID
2129 # @param u U parameter on the face where the node is located
2130 # @param v V parameter on the face where the node is located
2131 # @return True if succeed else raises an exception
2132 # @ingroup l2_modif_add
2133 def SetNodeOnFace(self, NodeID, Face, u, v):
2134 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2135 FaceID = Face.GetSubShapeIndices()[0]
2139 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2140 except SALOME.SALOME_Exception, inst:
2141 raise ValueError, inst.details.text
2144 ## @brief Binds a node to a solid
2145 # @param NodeID a node ID
2146 # @param Solid a solid or solid ID
2147 # @return True if succeed else raises an exception
2148 # @ingroup l2_modif_add
2149 def SetNodeInVolume(self, NodeID, Solid):
2150 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2151 SolidID = Solid.GetSubShapeIndices()[0]
2155 self.editor.SetNodeInVolume(NodeID, SolidID)
2156 except SALOME.SALOME_Exception, inst:
2157 raise ValueError, inst.details.text
2160 ## @brief Bind an element to a shape
2161 # @param ElementID an element ID
2162 # @param Shape a shape or shape ID
2163 # @return True if succeed else raises an exception
2164 # @ingroup l2_modif_add
2165 def SetMeshElementOnShape(self, ElementID, Shape):
2166 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2167 ShapeID = Shape.GetSubShapeIndices()[0]
2171 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2172 except SALOME.SALOME_Exception, inst:
2173 raise ValueError, inst.details.text
2177 ## Moves the node with the given id
2178 # @param NodeID the id of the node
2179 # @param x a new X coordinate
2180 # @param y a new Y coordinate
2181 # @param z a new Z coordinate
2182 # @return True if succeed else False
2183 # @ingroup l2_modif_movenode
2184 def MoveNode(self, NodeID, x, y, z):
2185 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2186 self.mesh.SetParameters(Parameters)
2187 return self.editor.MoveNode(NodeID, x, y, z)
2189 ## Finds the node closest to a point and moves it to a point location
2190 # @param x the X coordinate of a point
2191 # @param y the Y coordinate of a point
2192 # @param z the Z coordinate of a point
2193 # @return the ID of a node
2194 # @ingroup l2_modif_throughp
2195 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2196 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2197 self.mesh.SetParameters(Parameters)
2198 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2200 ## Finds the node closest to a point
2201 # @param x the X coordinate of a point
2202 # @param y the Y coordinate of a point
2203 # @param z the Z coordinate of a point
2204 # @return the ID of a node
2205 # @ingroup l2_modif_throughp
2206 def FindNodeClosestTo(self, x, y, z):
2207 #preview = self.mesh.GetMeshEditPreviewer()
2208 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2209 return self.editor.FindNodeClosestTo(x, y, z)
2211 ## Finds the elements where a point lays IN or ON
2212 # @param x the X coordinate of a point
2213 # @param y the Y coordinate of a point
2214 # @param z the Z coordinate of a point
2215 # @param elementType type of elements to find (SMESH.ALL type
2216 # means elements of any type excluding nodes and 0D elements)
2217 # @return list of IDs of found elements
2218 # @ingroup l2_modif_throughp
2219 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2220 return self.editor.FindElementsByPoint(x, y, z, elementType)
2223 ## Finds the node closest to a point and moves it to a point location
2224 # @param x the X coordinate of a point
2225 # @param y the Y coordinate of a point
2226 # @param z the Z coordinate of a point
2227 # @return the ID of a moved node
2228 # @ingroup l2_modif_throughp
2229 def MeshToPassThroughAPoint(self, x, y, z):
2230 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2232 ## Replaces two neighbour triangles sharing Node1-Node2 link
2233 # with the triangles built on the same 4 nodes but having other common link.
2234 # @param NodeID1 the ID of the first node
2235 # @param NodeID2 the ID of the second node
2236 # @return false if proper faces were not found
2237 # @ingroup l2_modif_invdiag
2238 def InverseDiag(self, NodeID1, NodeID2):
2239 return self.editor.InverseDiag(NodeID1, NodeID2)
2241 ## Replaces two neighbour triangles sharing Node1-Node2 link
2242 # with a quadrangle built on the same 4 nodes.
2243 # @param NodeID1 the ID of the first node
2244 # @param NodeID2 the ID of the second node
2245 # @return false if proper faces were not found
2246 # @ingroup l2_modif_unitetri
2247 def DeleteDiag(self, NodeID1, NodeID2):
2248 return self.editor.DeleteDiag(NodeID1, NodeID2)
2250 ## Reorients elements by ids
2251 # @param IDsOfElements if undefined reorients all mesh elements
2252 # @return True if succeed else False
2253 # @ingroup l2_modif_changori
2254 def Reorient(self, IDsOfElements=None):
2255 if IDsOfElements == None:
2256 IDsOfElements = self.GetElementsId()
2257 return self.editor.Reorient(IDsOfElements)
2259 ## Reorients all elements of the object
2260 # @param theObject mesh, submesh or group
2261 # @return True if succeed else False
2262 # @ingroup l2_modif_changori
2263 def ReorientObject(self, theObject):
2264 if ( isinstance( theObject, Mesh )):
2265 theObject = theObject.GetMesh()
2266 return self.editor.ReorientObject(theObject)
2268 ## Fuses the neighbouring triangles into quadrangles.
2269 # @param IDsOfElements The triangles to be fused,
2270 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2271 # @param MaxAngle is the maximum angle between element normals at which the fusion
2272 # is still performed; theMaxAngle is mesured in radians.
2273 # Also it could be a name of variable which defines angle in degrees.
2274 # @return TRUE in case of success, FALSE otherwise.
2275 # @ingroup l2_modif_unitetri
2276 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2278 if isinstance(MaxAngle,str):
2280 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2282 MaxAngle = DegreesToRadians(MaxAngle)
2283 if IDsOfElements == []:
2284 IDsOfElements = self.GetElementsId()
2285 self.mesh.SetParameters(Parameters)
2287 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2288 Functor = theCriterion
2290 Functor = self.smeshpyD.GetFunctor(theCriterion)
2291 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2293 ## Fuses the neighbouring triangles of the object into quadrangles
2294 # @param theObject is mesh, submesh or group
2295 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2296 # @param MaxAngle a max angle between element normals at which the fusion
2297 # is still performed; theMaxAngle is mesured in radians.
2298 # @return TRUE in case of success, FALSE otherwise.
2299 # @ingroup l2_modif_unitetri
2300 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2301 if ( isinstance( theObject, Mesh )):
2302 theObject = theObject.GetMesh()
2303 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2305 ## Splits quadrangles into triangles.
2306 # @param IDsOfElements the faces to be splitted.
2307 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2308 # @return TRUE in case of success, FALSE otherwise.
2309 # @ingroup l2_modif_cutquadr
2310 def QuadToTri (self, IDsOfElements, theCriterion):
2311 if IDsOfElements == []:
2312 IDsOfElements = self.GetElementsId()
2313 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2315 ## Splits quadrangles into triangles.
2316 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2317 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2318 # @return TRUE in case of success, FALSE otherwise.
2319 # @ingroup l2_modif_cutquadr
2320 def QuadToTriObject (self, theObject, theCriterion):
2321 if ( isinstance( theObject, Mesh )):
2322 theObject = theObject.GetMesh()
2323 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2325 ## Splits quadrangles into triangles.
2326 # @param IDsOfElements the faces to be splitted
2327 # @param Diag13 is used to choose a diagonal for splitting.
2328 # @return TRUE in case of success, FALSE otherwise.
2329 # @ingroup l2_modif_cutquadr
2330 def SplitQuad (self, IDsOfElements, Diag13):
2331 if IDsOfElements == []:
2332 IDsOfElements = self.GetElementsId()
2333 return self.editor.SplitQuad(IDsOfElements, Diag13)
2335 ## Splits quadrangles into triangles.
2336 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2337 # @param Diag13 is used to choose a diagonal for splitting.
2338 # @return TRUE in case of success, FALSE otherwise.
2339 # @ingroup l2_modif_cutquadr
2340 def SplitQuadObject (self, theObject, Diag13):
2341 if ( isinstance( theObject, Mesh )):
2342 theObject = theObject.GetMesh()
2343 return self.editor.SplitQuadObject(theObject, Diag13)
2345 ## Finds a better splitting of the given quadrangle.
2346 # @param IDOfQuad the ID of the quadrangle to be splitted.
2347 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2348 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2349 # diagonal is better, 0 if error occurs.
2350 # @ingroup l2_modif_cutquadr
2351 def BestSplit (self, IDOfQuad, theCriterion):
2352 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2354 ## Splits quadrangle faces near triangular facets of volumes
2356 # @ingroup l1_auxiliary
2357 def SplitQuadsNearTriangularFacets(self):
2358 faces_array = self.GetElementsByType(SMESH.FACE)
2359 for face_id in faces_array:
2360 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2361 quad_nodes = self.mesh.GetElemNodes(face_id)
2362 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2363 isVolumeFound = False
2364 for node1_elem in node1_elems:
2365 if not isVolumeFound:
2366 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2367 nb_nodes = self.GetElemNbNodes(node1_elem)
2368 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2369 volume_elem = node1_elem
2370 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2371 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2372 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2373 isVolumeFound = True
2374 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2375 self.SplitQuad([face_id], False) # diagonal 2-4
2376 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2377 isVolumeFound = True
2378 self.SplitQuad([face_id], True) # diagonal 1-3
2379 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2380 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2381 isVolumeFound = True
2382 self.SplitQuad([face_id], True) # diagonal 1-3
2384 ## @brief Splits hexahedrons into tetrahedrons.
2386 # This operation uses pattern mapping functionality for splitting.
2387 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2388 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2389 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2390 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2391 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2392 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2393 # @return TRUE in case of success, FALSE otherwise.
2394 # @ingroup l1_auxiliary
2395 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2396 # Pattern: 5.---------.6
2401 # (0,0,1) 4.---------.7 * |
2408 # (0,0,0) 0.---------.3
2409 pattern_tetra = "!!! Nb of points: \n 8 \n\
2419 !!! Indices of points of 6 tetras: \n\
2427 pattern = self.smeshpyD.GetPattern()
2428 isDone = pattern.LoadFromFile(pattern_tetra)
2430 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2433 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2434 isDone = pattern.MakeMesh(self.mesh, False, False)
2435 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2437 # split quafrangle faces near triangular facets of volumes
2438 self.SplitQuadsNearTriangularFacets()
2442 ## @brief Split hexahedrons into prisms.
2444 # Uses the pattern mapping functionality for splitting.
2445 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2446 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2447 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2448 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2449 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2450 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2451 # @return TRUE in case of success, FALSE otherwise.
2452 # @ingroup l1_auxiliary
2453 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2454 # Pattern: 5.---------.6
2459 # (0,0,1) 4.---------.7 |
2466 # (0,0,0) 0.---------.3
2467 pattern_prism = "!!! Nb of points: \n 8 \n\
2477 !!! Indices of points of 2 prisms: \n\
2481 pattern = self.smeshpyD.GetPattern()
2482 isDone = pattern.LoadFromFile(pattern_prism)
2484 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2487 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2488 isDone = pattern.MakeMesh(self.mesh, False, False)
2489 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2491 # Splits quafrangle faces near triangular facets of volumes
2492 self.SplitQuadsNearTriangularFacets()
2496 ## Smoothes elements
2497 # @param IDsOfElements the list if ids of elements to smooth
2498 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2499 # Note that nodes built on edges and boundary nodes are always fixed.
2500 # @param MaxNbOfIterations the maximum number of iterations
2501 # @param MaxAspectRatio varies in range [1.0, inf]
2502 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2503 # @return TRUE in case of success, FALSE otherwise.
2504 # @ingroup l2_modif_smooth
2505 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2506 MaxNbOfIterations, MaxAspectRatio, Method):
2507 if IDsOfElements == []:
2508 IDsOfElements = self.GetElementsId()
2509 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2510 self.mesh.SetParameters(Parameters)
2511 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2512 MaxNbOfIterations, MaxAspectRatio, Method)
2514 ## Smoothes elements which belong to the given object
2515 # @param theObject the object to smooth
2516 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2517 # Note that nodes built on edges and boundary nodes are always fixed.
2518 # @param MaxNbOfIterations the maximum number of iterations
2519 # @param MaxAspectRatio varies in range [1.0, inf]
2520 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2521 # @return TRUE in case of success, FALSE otherwise.
2522 # @ingroup l2_modif_smooth
2523 def SmoothObject(self, theObject, IDsOfFixedNodes,
2524 MaxNbOfIterations, MaxAspectRatio, Method):
2525 if ( isinstance( theObject, Mesh )):
2526 theObject = theObject.GetMesh()
2527 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2528 MaxNbOfIterations, MaxAspectRatio, Method)
2530 ## Parametrically smoothes the given elements
2531 # @param IDsOfElements the list if ids of elements to smooth
2532 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2533 # Note that nodes built on edges and boundary nodes are always fixed.
2534 # @param MaxNbOfIterations the maximum number of iterations
2535 # @param MaxAspectRatio varies in range [1.0, inf]
2536 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2537 # @return TRUE in case of success, FALSE otherwise.
2538 # @ingroup l2_modif_smooth
2539 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2540 MaxNbOfIterations, MaxAspectRatio, Method):
2541 if IDsOfElements == []:
2542 IDsOfElements = self.GetElementsId()
2543 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2544 self.mesh.SetParameters(Parameters)
2545 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2546 MaxNbOfIterations, MaxAspectRatio, Method)
2548 ## Parametrically smoothes the elements which belong to the given object
2549 # @param theObject the object to smooth
2550 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2551 # Note that nodes built on edges and boundary nodes are always fixed.
2552 # @param MaxNbOfIterations the maximum number of iterations
2553 # @param MaxAspectRatio varies in range [1.0, inf]
2554 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2555 # @return TRUE in case of success, FALSE otherwise.
2556 # @ingroup l2_modif_smooth
2557 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2558 MaxNbOfIterations, MaxAspectRatio, Method):
2559 if ( isinstance( theObject, Mesh )):
2560 theObject = theObject.GetMesh()
2561 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2562 MaxNbOfIterations, MaxAspectRatio, Method)
2564 ## Converts the mesh to quadratic, deletes old elements, replacing
2565 # them with quadratic with the same id.
2566 # @ingroup l2_modif_tofromqu
2567 def ConvertToQuadratic(self, theForce3d):
2568 self.editor.ConvertToQuadratic(theForce3d)
2570 ## Converts the mesh from quadratic to ordinary,
2571 # deletes old quadratic elements, \n replacing
2572 # them with ordinary mesh elements with the same id.
2573 # @return TRUE in case of success, FALSE otherwise.
2574 # @ingroup l2_modif_tofromqu
2575 def ConvertFromQuadratic(self):
2576 return self.editor.ConvertFromQuadratic()
2578 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2579 # @return TRUE if operation has been completed successfully, FALSE otherwise
2580 # @ingroup l2_modif_edit
2581 def Make2DMeshFrom3D(self):
2582 return self.editor. Make2DMeshFrom3D()
2584 ## Renumber mesh nodes
2585 # @ingroup l2_modif_renumber
2586 def RenumberNodes(self):
2587 self.editor.RenumberNodes()
2589 ## Renumber mesh elements
2590 # @ingroup l2_modif_renumber
2591 def RenumberElements(self):
2592 self.editor.RenumberElements()
2594 ## Generates new elements by rotation of the elements around the axis
2595 # @param IDsOfElements the list of ids of elements to sweep
2596 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2597 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2598 # @param NbOfSteps the number of steps
2599 # @param Tolerance tolerance
2600 # @param MakeGroups forces the generation of new groups from existing ones
2601 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2602 # of all steps, else - size of each step
2603 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2604 # @ingroup l2_modif_extrurev
2605 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2606 MakeGroups=False, TotalAngle=False):
2608 if isinstance(AngleInRadians,str):
2610 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2612 AngleInRadians = DegreesToRadians(AngleInRadians)
2613 if IDsOfElements == []:
2614 IDsOfElements = self.GetElementsId()
2615 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2616 Axis = self.smeshpyD.GetAxisStruct(Axis)
2617 Axis,AxisParameters = ParseAxisStruct(Axis)
2618 if TotalAngle and NbOfSteps:
2619 AngleInRadians /= NbOfSteps
2620 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2621 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2622 self.mesh.SetParameters(Parameters)
2624 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2625 AngleInRadians, NbOfSteps, Tolerance)
2626 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2629 ## Generates new elements by rotation of the elements of object around the axis
2630 # @param theObject object which elements should be sweeped
2631 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2632 # @param AngleInRadians the angle of Rotation
2633 # @param NbOfSteps number of steps
2634 # @param Tolerance tolerance
2635 # @param MakeGroups forces the generation of new groups from existing ones
2636 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2637 # of all steps, else - size of each step
2638 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2639 # @ingroup l2_modif_extrurev
2640 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2641 MakeGroups=False, TotalAngle=False):
2643 if isinstance(AngleInRadians,str):
2645 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2647 AngleInRadians = DegreesToRadians(AngleInRadians)
2648 if ( isinstance( theObject, Mesh )):
2649 theObject = theObject.GetMesh()
2650 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2651 Axis = self.smeshpyD.GetAxisStruct(Axis)
2652 Axis,AxisParameters = ParseAxisStruct(Axis)
2653 if TotalAngle and NbOfSteps:
2654 AngleInRadians /= NbOfSteps
2655 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2656 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2657 self.mesh.SetParameters(Parameters)
2659 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2660 NbOfSteps, Tolerance)
2661 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2664 ## Generates new elements by rotation of the elements of object around the axis
2665 # @param theObject object which elements should be sweeped
2666 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2667 # @param AngleInRadians the angle of Rotation
2668 # @param NbOfSteps number of steps
2669 # @param Tolerance tolerance
2670 # @param MakeGroups forces the generation of new groups from existing ones
2671 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2672 # of all steps, else - size of each step
2673 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2674 # @ingroup l2_modif_extrurev
2675 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2676 MakeGroups=False, TotalAngle=False):
2678 if isinstance(AngleInRadians,str):
2680 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2682 AngleInRadians = DegreesToRadians(AngleInRadians)
2683 if ( isinstance( theObject, Mesh )):
2684 theObject = theObject.GetMesh()
2685 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2686 Axis = self.smeshpyD.GetAxisStruct(Axis)
2687 Axis,AxisParameters = ParseAxisStruct(Axis)
2688 if TotalAngle and NbOfSteps:
2689 AngleInRadians /= NbOfSteps
2690 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2691 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2692 self.mesh.SetParameters(Parameters)
2694 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2695 NbOfSteps, Tolerance)
2696 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2699 ## Generates new elements by rotation of the elements of object around the axis
2700 # @param theObject object which elements should be sweeped
2701 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2702 # @param AngleInRadians the angle of Rotation
2703 # @param NbOfSteps number of steps
2704 # @param Tolerance tolerance
2705 # @param MakeGroups forces the generation of new groups from existing ones
2706 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2707 # of all steps, else - size of each step
2708 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2709 # @ingroup l2_modif_extrurev
2710 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2711 MakeGroups=False, TotalAngle=False):
2713 if isinstance(AngleInRadians,str):
2715 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2717 AngleInRadians = DegreesToRadians(AngleInRadians)
2718 if ( isinstance( theObject, Mesh )):
2719 theObject = theObject.GetMesh()
2720 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2721 Axis = self.smeshpyD.GetAxisStruct(Axis)
2722 Axis,AxisParameters = ParseAxisStruct(Axis)
2723 if TotalAngle and NbOfSteps:
2724 AngleInRadians /= NbOfSteps
2725 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2726 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2727 self.mesh.SetParameters(Parameters)
2729 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2730 NbOfSteps, Tolerance)
2731 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2734 ## Generates new elements by extrusion of the elements with given ids
2735 # @param IDsOfElements the list of elements ids for extrusion
2736 # @param StepVector vector, defining the direction and value of extrusion
2737 # @param NbOfSteps the number of steps
2738 # @param MakeGroups forces the generation of new groups from existing ones
2739 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2740 # @ingroup l2_modif_extrurev
2741 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2742 if IDsOfElements == []:
2743 IDsOfElements = self.GetElementsId()
2744 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2745 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2746 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2747 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2748 Parameters = StepVectorParameters + var_separator + Parameters
2749 self.mesh.SetParameters(Parameters)
2751 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2752 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2755 ## Generates new elements by extrusion of the elements with given ids
2756 # @param IDsOfElements is ids of elements
2757 # @param StepVector vector, defining the direction and value of extrusion
2758 # @param NbOfSteps the number of steps
2759 # @param ExtrFlags sets flags for extrusion
2760 # @param SewTolerance uses for comparing locations of nodes if flag
2761 # EXTRUSION_FLAG_SEW is set
2762 # @param MakeGroups forces the generation of new groups from existing ones
2763 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2764 # @ingroup l2_modif_extrurev
2765 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2766 ExtrFlags, SewTolerance, MakeGroups=False):
2767 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2768 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2770 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2771 ExtrFlags, SewTolerance)
2772 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2773 ExtrFlags, SewTolerance)
2776 ## Generates new elements by extrusion of the elements which belong to the object
2777 # @param theObject the object which elements should be processed
2778 # @param StepVector vector, defining the direction and value of extrusion
2779 # @param NbOfSteps the number of steps
2780 # @param MakeGroups forces the generation of new groups from existing ones
2781 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2782 # @ingroup l2_modif_extrurev
2783 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2784 if ( isinstance( theObject, Mesh )):
2785 theObject = theObject.GetMesh()
2786 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2787 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2788 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2789 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2790 Parameters = StepVectorParameters + var_separator + Parameters
2791 self.mesh.SetParameters(Parameters)
2793 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2794 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2797 ## Generates new elements by extrusion of the elements which belong to the object
2798 # @param theObject object which elements should be processed
2799 # @param StepVector vector, defining the direction and value of extrusion
2800 # @param NbOfSteps the number of steps
2801 # @param MakeGroups to generate new groups from existing ones
2802 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2803 # @ingroup l2_modif_extrurev
2804 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2805 if ( isinstance( theObject, Mesh )):
2806 theObject = theObject.GetMesh()
2807 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2808 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2809 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2810 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2811 Parameters = StepVectorParameters + var_separator + Parameters
2812 self.mesh.SetParameters(Parameters)
2814 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2815 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2818 ## Generates new elements by extrusion of the elements which belong to the object
2819 # @param theObject object which elements should be processed
2820 # @param StepVector vector, defining the direction and value of extrusion
2821 # @param NbOfSteps the number of steps
2822 # @param MakeGroups forces the generation of new groups from existing ones
2823 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2824 # @ingroup l2_modif_extrurev
2825 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2826 if ( isinstance( theObject, Mesh )):
2827 theObject = theObject.GetMesh()
2828 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2829 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2830 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2831 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2832 Parameters = StepVectorParameters + var_separator + Parameters
2833 self.mesh.SetParameters(Parameters)
2835 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2836 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2841 ## Generates new elements by extrusion of the given elements
2842 # The path of extrusion must be a meshed edge.
2843 # @param Base mesh or list of ids of elements for extrusion
2844 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2845 # @param NodeStart the start node from Path. Defines the direction of extrusion
2846 # @param HasAngles allows the shape to be rotated around the path
2847 # to get the resulting mesh in a helical fashion
2848 # @param Angles list of angles in radians
2849 # @param LinearVariation forces the computation of rotation angles as linear
2850 # variation of the given Angles along path steps
2851 # @param HasRefPoint allows using the reference point
2852 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2853 # The User can specify any point as the Reference Point.
2854 # @param MakeGroups forces the generation of new groups from existing ones
2855 # @param ElemType type of elements for extrusion (if param Base is a mesh)
2856 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2857 # only SMESH::Extrusion_Error otherwise
2858 # @ingroup l2_modif_extrurev
2859 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2860 HasAngles, Angles, LinearVariation,
2861 HasRefPoint, RefPoint, MakeGroups, ElemType):
2862 Angles,AnglesParameters = ParseAngles(Angles)
2863 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2864 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2865 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2867 Parameters = AnglesParameters + var_separator + RefPointParameters
2868 self.mesh.SetParameters(Parameters)
2870 if isinstance(Base,list):
2872 if Base == []: IDsOfElements = self.GetElementsId()
2873 else: IDsOfElements = Base
2874 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2875 HasAngles, Angles, LinearVariation,
2876 HasRefPoint, RefPoint, MakeGroups, ElemType)
2878 if isinstance(Base,Mesh):
2879 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
2880 HasAngles, Angles, LinearVariation,
2881 HasRefPoint, RefPoint, MakeGroups, ElemType)
2883 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2886 ## Generates new elements by extrusion of the given elements
2887 # The path of extrusion must be a meshed edge.
2888 # @param IDsOfElements ids of elements
2889 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2890 # @param PathShape shape(edge) defines the sub-mesh for the path
2891 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2892 # @param HasAngles allows the shape to be rotated around the path
2893 # to get the resulting mesh in a helical fashion
2894 # @param Angles list of angles in radians
2895 # @param HasRefPoint allows using the reference point
2896 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2897 # The User can specify any point as the Reference Point.
2898 # @param MakeGroups forces the generation of new groups from existing ones
2899 # @param LinearVariation forces the computation of rotation angles as linear
2900 # variation of the given Angles along path steps
2901 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2902 # only SMESH::Extrusion_Error otherwise
2903 # @ingroup l2_modif_extrurev
2904 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2905 HasAngles, Angles, HasRefPoint, RefPoint,
2906 MakeGroups=False, LinearVariation=False):
2907 Angles,AnglesParameters = ParseAngles(Angles)
2908 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2909 if IDsOfElements == []:
2910 IDsOfElements = self.GetElementsId()
2911 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2912 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2914 if ( isinstance( PathMesh, Mesh )):
2915 PathMesh = PathMesh.GetMesh()
2916 if HasAngles and Angles and LinearVariation:
2917 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2919 Parameters = AnglesParameters + var_separator + RefPointParameters
2920 self.mesh.SetParameters(Parameters)
2922 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2923 PathShape, NodeStart, HasAngles,
2924 Angles, HasRefPoint, RefPoint)
2925 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2926 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2928 ## Generates new elements by extrusion of the elements which belong to the object
2929 # The path of extrusion must be a meshed edge.
2930 # @param theObject the object which elements should be processed
2931 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2932 # @param PathShape shape(edge) defines the sub-mesh for the path
2933 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2934 # @param HasAngles allows the shape to be rotated around the path
2935 # to get the resulting mesh in a helical fashion
2936 # @param Angles list of angles
2937 # @param HasRefPoint allows using the reference point
2938 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2939 # The User can specify any point as the Reference Point.
2940 # @param MakeGroups forces the generation of new groups from existing ones
2941 # @param LinearVariation forces the computation of rotation angles as linear
2942 # variation of the given Angles along path steps
2943 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2944 # only SMESH::Extrusion_Error otherwise
2945 # @ingroup l2_modif_extrurev
2946 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2947 HasAngles, Angles, HasRefPoint, RefPoint,
2948 MakeGroups=False, LinearVariation=False):
2949 Angles,AnglesParameters = ParseAngles(Angles)
2950 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2951 if ( isinstance( theObject, Mesh )):
2952 theObject = theObject.GetMesh()
2953 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2954 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2955 if ( isinstance( PathMesh, Mesh )):
2956 PathMesh = PathMesh.GetMesh()
2957 if HasAngles and Angles and LinearVariation:
2958 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2960 Parameters = AnglesParameters + var_separator + RefPointParameters
2961 self.mesh.SetParameters(Parameters)
2963 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2964 PathShape, NodeStart, HasAngles,
2965 Angles, HasRefPoint, RefPoint)
2966 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2967 NodeStart, HasAngles, Angles, HasRefPoint,
2970 ## Generates new elements by extrusion of the elements which belong to the object
2971 # The path of extrusion must be a meshed edge.
2972 # @param theObject the object which elements should be processed
2973 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2974 # @param PathShape shape(edge) defines the sub-mesh for the path
2975 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2976 # @param HasAngles allows the shape to be rotated around the path
2977 # to get the resulting mesh in a helical fashion
2978 # @param Angles list of angles
2979 # @param HasRefPoint allows using the reference point
2980 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2981 # The User can specify any point as the Reference Point.
2982 # @param MakeGroups forces the generation of new groups from existing ones
2983 # @param LinearVariation forces the computation of rotation angles as linear
2984 # variation of the given Angles along path steps
2985 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2986 # only SMESH::Extrusion_Error otherwise
2987 # @ingroup l2_modif_extrurev
2988 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
2989 HasAngles, Angles, HasRefPoint, RefPoint,
2990 MakeGroups=False, LinearVariation=False):
2991 Angles,AnglesParameters = ParseAngles(Angles)
2992 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2993 if ( isinstance( theObject, Mesh )):
2994 theObject = theObject.GetMesh()
2995 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2996 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2997 if ( isinstance( PathMesh, Mesh )):
2998 PathMesh = PathMesh.GetMesh()
2999 if HasAngles and Angles and LinearVariation:
3000 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3002 Parameters = AnglesParameters + var_separator + RefPointParameters
3003 self.mesh.SetParameters(Parameters)
3005 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3006 PathShape, NodeStart, HasAngles,
3007 Angles, HasRefPoint, RefPoint)
3008 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3009 NodeStart, HasAngles, Angles, HasRefPoint,
3012 ## Generates new elements by extrusion of the elements which belong to the object
3013 # The path of extrusion must be a meshed edge.
3014 # @param theObject the object which elements should be processed
3015 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3016 # @param PathShape shape(edge) defines the sub-mesh for the path
3017 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3018 # @param HasAngles allows the shape to be rotated around the path
3019 # to get the resulting mesh in a helical fashion
3020 # @param Angles list of angles
3021 # @param HasRefPoint allows using the reference point
3022 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3023 # The User can specify any point as the Reference Point.
3024 # @param MakeGroups forces the generation of new groups from existing ones
3025 # @param LinearVariation forces the computation of rotation angles as linear
3026 # variation of the given Angles along path steps
3027 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3028 # only SMESH::Extrusion_Error otherwise
3029 # @ingroup l2_modif_extrurev
3030 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3031 HasAngles, Angles, HasRefPoint, RefPoint,
3032 MakeGroups=False, LinearVariation=False):
3033 Angles,AnglesParameters = ParseAngles(Angles)
3034 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3035 if ( isinstance( theObject, Mesh )):
3036 theObject = theObject.GetMesh()
3037 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3038 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3039 if ( isinstance( PathMesh, Mesh )):
3040 PathMesh = PathMesh.GetMesh()
3041 if HasAngles and Angles and LinearVariation:
3042 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3044 Parameters = AnglesParameters + var_separator + RefPointParameters
3045 self.mesh.SetParameters(Parameters)
3047 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3048 PathShape, NodeStart, HasAngles,
3049 Angles, HasRefPoint, RefPoint)
3050 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3051 NodeStart, HasAngles, Angles, HasRefPoint,
3054 ## Creates a symmetrical copy of mesh elements
3055 # @param IDsOfElements list of elements ids
3056 # @param Mirror is AxisStruct or geom object(point, line, plane)
3057 # @param theMirrorType is POINT, AXIS or PLANE
3058 # If the Mirror is a geom object this parameter is unnecessary
3059 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3060 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3061 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3062 # @ingroup l2_modif_trsf
3063 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3064 if IDsOfElements == []:
3065 IDsOfElements = self.GetElementsId()
3066 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3067 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3068 Mirror,Parameters = ParseAxisStruct(Mirror)
3069 self.mesh.SetParameters(Parameters)
3070 if Copy and MakeGroups:
3071 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3072 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3075 ## Creates a new mesh by a symmetrical copy of mesh elements
3076 # @param IDsOfElements the list of elements ids
3077 # @param Mirror is AxisStruct or geom object (point, line, plane)
3078 # @param theMirrorType is POINT, AXIS or PLANE
3079 # If the Mirror is a geom object this parameter is unnecessary
3080 # @param MakeGroups to generate new groups from existing ones
3081 # @param NewMeshName a name of the new mesh to create
3082 # @return instance of Mesh class
3083 # @ingroup l2_modif_trsf
3084 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3085 if IDsOfElements == []:
3086 IDsOfElements = self.GetElementsId()
3087 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3088 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3089 Mirror,Parameters = ParseAxisStruct(Mirror)
3090 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3091 MakeGroups, NewMeshName)
3092 mesh.SetParameters(Parameters)
3093 return Mesh(self.smeshpyD,self.geompyD,mesh)
3095 ## Creates a symmetrical copy of the object
3096 # @param theObject mesh, submesh or group
3097 # @param Mirror AxisStruct or geom object (point, line, plane)
3098 # @param theMirrorType is POINT, AXIS or PLANE
3099 # If the Mirror is a geom object this parameter is unnecessary
3100 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3101 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3102 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3103 # @ingroup l2_modif_trsf
3104 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3105 if ( isinstance( theObject, Mesh )):
3106 theObject = theObject.GetMesh()
3107 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3108 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3109 Mirror,Parameters = ParseAxisStruct(Mirror)
3110 self.mesh.SetParameters(Parameters)
3111 if Copy and MakeGroups:
3112 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3113 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3116 ## Creates a new mesh by a symmetrical copy of the object
3117 # @param theObject mesh, submesh or group
3118 # @param Mirror AxisStruct or geom object (point, line, plane)
3119 # @param theMirrorType POINT, AXIS or PLANE
3120 # If the Mirror is a geom object this parameter is unnecessary
3121 # @param MakeGroups forces the generation of new groups from existing ones
3122 # @param NewMeshName the name of the new mesh to create
3123 # @return instance of Mesh class
3124 # @ingroup l2_modif_trsf
3125 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3126 if ( isinstance( theObject, Mesh )):
3127 theObject = theObject.GetMesh()
3128 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3129 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3130 Mirror,Parameters = ParseAxisStruct(Mirror)
3131 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3132 MakeGroups, NewMeshName)
3133 mesh.SetParameters(Parameters)
3134 return Mesh( self.smeshpyD,self.geompyD,mesh )
3136 ## Translates the elements
3137 # @param IDsOfElements list of elements ids
3138 # @param Vector the direction of translation (DirStruct or vector)
3139 # @param Copy allows copying the translated elements
3140 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3141 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3142 # @ingroup l2_modif_trsf
3143 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3144 if IDsOfElements == []:
3145 IDsOfElements = self.GetElementsId()
3146 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3147 Vector = self.smeshpyD.GetDirStruct(Vector)
3148 Vector,Parameters = ParseDirStruct(Vector)
3149 self.mesh.SetParameters(Parameters)
3150 if Copy and MakeGroups:
3151 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3152 self.editor.Translate(IDsOfElements, Vector, Copy)
3155 ## Creates a new mesh of translated elements
3156 # @param IDsOfElements list of elements ids
3157 # @param Vector the direction of translation (DirStruct or vector)
3158 # @param MakeGroups forces the generation of new groups from existing ones
3159 # @param NewMeshName the name of the newly created mesh
3160 # @return instance of Mesh class
3161 # @ingroup l2_modif_trsf
3162 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3163 if IDsOfElements == []:
3164 IDsOfElements = self.GetElementsId()
3165 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3166 Vector = self.smeshpyD.GetDirStruct(Vector)
3167 Vector,Parameters = ParseDirStruct(Vector)
3168 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3169 mesh.SetParameters(Parameters)
3170 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3172 ## Translates the object
3173 # @param theObject the object to translate (mesh, submesh, or group)
3174 # @param Vector direction of translation (DirStruct or geom vector)
3175 # @param Copy allows copying the translated elements
3176 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3177 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3178 # @ingroup l2_modif_trsf
3179 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3180 if ( isinstance( theObject, Mesh )):
3181 theObject = theObject.GetMesh()
3182 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3183 Vector = self.smeshpyD.GetDirStruct(Vector)
3184 Vector,Parameters = ParseDirStruct(Vector)
3185 self.mesh.SetParameters(Parameters)
3186 if Copy and MakeGroups:
3187 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3188 self.editor.TranslateObject(theObject, Vector, Copy)
3191 ## Creates a new mesh from the translated object
3192 # @param theObject the object to translate (mesh, submesh, or group)
3193 # @param Vector the direction of translation (DirStruct or geom vector)
3194 # @param MakeGroups forces the generation of new groups from existing ones
3195 # @param NewMeshName the name of the newly created mesh
3196 # @return instance of Mesh class
3197 # @ingroup l2_modif_trsf
3198 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3199 if (isinstance(theObject, Mesh)):
3200 theObject = theObject.GetMesh()
3201 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3202 Vector = self.smeshpyD.GetDirStruct(Vector)
3203 Vector,Parameters = ParseDirStruct(Vector)
3204 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3205 mesh.SetParameters(Parameters)
3206 return Mesh( self.smeshpyD, self.geompyD, mesh )
3208 ## Rotates the elements
3209 # @param IDsOfElements list of elements ids
3210 # @param Axis the axis of rotation (AxisStruct or geom line)
3211 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3212 # @param Copy allows copying the rotated elements
3213 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3214 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3215 # @ingroup l2_modif_trsf
3216 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3218 if isinstance(AngleInRadians,str):
3220 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3222 AngleInRadians = DegreesToRadians(AngleInRadians)
3223 if IDsOfElements == []:
3224 IDsOfElements = self.GetElementsId()
3225 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3226 Axis = self.smeshpyD.GetAxisStruct(Axis)
3227 Axis,AxisParameters = ParseAxisStruct(Axis)
3228 Parameters = AxisParameters + var_separator + Parameters
3229 self.mesh.SetParameters(Parameters)
3230 if Copy and MakeGroups:
3231 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3232 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3235 ## Creates a new mesh of rotated elements
3236 # @param IDsOfElements list of element ids
3237 # @param Axis the axis of rotation (AxisStruct or geom line)
3238 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3239 # @param MakeGroups forces the generation of new groups from existing ones
3240 # @param NewMeshName the name of the newly created mesh
3241 # @return instance of Mesh class
3242 # @ingroup l2_modif_trsf
3243 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3245 if isinstance(AngleInRadians,str):
3247 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3249 AngleInRadians = DegreesToRadians(AngleInRadians)
3250 if IDsOfElements == []:
3251 IDsOfElements = self.GetElementsId()
3252 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3253 Axis = self.smeshpyD.GetAxisStruct(Axis)
3254 Axis,AxisParameters = ParseAxisStruct(Axis)
3255 Parameters = AxisParameters + var_separator + Parameters
3256 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3257 MakeGroups, NewMeshName)
3258 mesh.SetParameters(Parameters)
3259 return Mesh( self.smeshpyD, self.geompyD, mesh )
3261 ## Rotates the object
3262 # @param theObject the object to rotate( mesh, submesh, or group)
3263 # @param Axis the axis of rotation (AxisStruct or geom line)
3264 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3265 # @param Copy allows copying the rotated elements
3266 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3267 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3268 # @ingroup l2_modif_trsf
3269 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3271 if isinstance(AngleInRadians,str):
3273 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3275 AngleInRadians = DegreesToRadians(AngleInRadians)
3276 if (isinstance(theObject, Mesh)):
3277 theObject = theObject.GetMesh()
3278 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3279 Axis = self.smeshpyD.GetAxisStruct(Axis)
3280 Axis,AxisParameters = ParseAxisStruct(Axis)
3281 Parameters = AxisParameters + ":" + Parameters
3282 self.mesh.SetParameters(Parameters)
3283 if Copy and MakeGroups:
3284 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3285 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3288 ## Creates a new mesh from the rotated object
3289 # @param theObject the object to rotate (mesh, submesh, or group)
3290 # @param Axis the axis of rotation (AxisStruct or geom line)
3291 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3292 # @param MakeGroups forces the generation of new groups from existing ones
3293 # @param NewMeshName the name of the newly created mesh
3294 # @return instance of Mesh class
3295 # @ingroup l2_modif_trsf
3296 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3298 if isinstance(AngleInRadians,str):
3300 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3302 AngleInRadians = DegreesToRadians(AngleInRadians)
3303 if (isinstance( theObject, Mesh )):
3304 theObject = theObject.GetMesh()
3305 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3306 Axis = self.smeshpyD.GetAxisStruct(Axis)
3307 Axis,AxisParameters = ParseAxisStruct(Axis)
3308 Parameters = AxisParameters + ":" + Parameters
3309 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3310 MakeGroups, NewMeshName)
3311 mesh.SetParameters(Parameters)
3312 return Mesh( self.smeshpyD, self.geompyD, mesh )
3314 ## Finds groups of ajacent nodes within Tolerance.
3315 # @param Tolerance the value of tolerance
3316 # @return the list of groups of nodes
3317 # @ingroup l2_modif_trsf
3318 def FindCoincidentNodes (self, Tolerance):
3319 return self.editor.FindCoincidentNodes(Tolerance)
3321 ## Finds groups of ajacent nodes within Tolerance.
3322 # @param Tolerance the value of tolerance
3323 # @param SubMeshOrGroup SubMesh or Group
3324 # @return the list of groups of nodes
3325 # @ingroup l2_modif_trsf
3326 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3327 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3330 # @param GroupsOfNodes the list of groups of nodes
3331 # @ingroup l2_modif_trsf
3332 def MergeNodes (self, GroupsOfNodes):
3333 self.editor.MergeNodes(GroupsOfNodes)
3335 ## Finds the elements built on the same nodes.
3336 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3337 # @return a list of groups of equal elements
3338 # @ingroup l2_modif_trsf
3339 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3340 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3341 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3342 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3344 ## Merges elements in each given group.
3345 # @param GroupsOfElementsID groups of elements for merging
3346 # @ingroup l2_modif_trsf
3347 def MergeElements(self, GroupsOfElementsID):
3348 self.editor.MergeElements(GroupsOfElementsID)
3350 ## Leaves one element and removes all other elements built on the same nodes.
3351 # @ingroup l2_modif_trsf
3352 def MergeEqualElements(self):
3353 self.editor.MergeEqualElements()
3355 ## Sews free borders
3356 # @return SMESH::Sew_Error
3357 # @ingroup l2_modif_trsf
3358 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3359 FirstNodeID2, SecondNodeID2, LastNodeID2,
3360 CreatePolygons, CreatePolyedrs):
3361 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3362 FirstNodeID2, SecondNodeID2, LastNodeID2,
3363 CreatePolygons, CreatePolyedrs)
3365 ## Sews conform free borders
3366 # @return SMESH::Sew_Error
3367 # @ingroup l2_modif_trsf
3368 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3369 FirstNodeID2, SecondNodeID2):
3370 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3371 FirstNodeID2, SecondNodeID2)
3373 ## Sews border to side
3374 # @return SMESH::Sew_Error
3375 # @ingroup l2_modif_trsf
3376 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3377 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3378 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3379 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3381 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3382 # merged with the nodes of elements of Side2.
3383 # The number of elements in theSide1 and in theSide2 must be
3384 # equal and they should have similar nodal connectivity.
3385 # The nodes to merge should belong to side borders and
3386 # the first node should be linked to the second.
3387 # @return SMESH::Sew_Error
3388 # @ingroup l2_modif_trsf
3389 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3390 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3391 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3392 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3393 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3394 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3396 ## Sets new nodes for the given element.
3397 # @param ide the element id
3398 # @param newIDs nodes ids
3399 # @return If the number of nodes does not correspond to the type of element - returns false
3400 # @ingroup l2_modif_edit
3401 def ChangeElemNodes(self, ide, newIDs):
3402 return self.editor.ChangeElemNodes(ide, newIDs)
3404 ## If during the last operation of MeshEditor some nodes were
3405 # created, this method returns the list of their IDs, \n
3406 # if new nodes were not created - returns empty list
3407 # @return the list of integer values (can be empty)
3408 # @ingroup l1_auxiliary
3409 def GetLastCreatedNodes(self):
3410 return self.editor.GetLastCreatedNodes()
3412 ## If during the last operation of MeshEditor some elements were
3413 # created this method returns the list of their IDs, \n
3414 # if new elements were not created - returns empty list
3415 # @return the list of integer values (can be empty)
3416 # @ingroup l1_auxiliary
3417 def GetLastCreatedElems(self):
3418 return self.editor.GetLastCreatedElems()
3420 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3421 # @param theElems - the list of elements (edges or faces) to be replicated
3422 # The nodes for duplication could be found from these elements
3423 # @param theNodesNot - list of nodes to NOT replicate
3424 # @param theAffectedElems - the list of elements (cells and edges) to which the
3425 # replicated nodes should be associated to.
3426 # @return TRUE if operation has been completed successfully, FALSE otherwise
3427 # @ingroup l2_modif_edit
3428 def DoubleNodes(self, theElems, theNodesNot, theAffectedElems):
3429 return self.editor.DoubleNodes(theElems, theNodesNot, theAffectedElems)
3431 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3432 # @param theElems - the list of elements (edges or faces) to be replicated
3433 # The nodes for duplication could be found from these elements
3434 # @param theNodesNot - list of nodes to NOT replicate
3435 # @param theShape - shape to detect affected elements (element which geometric center
3436 # located on or inside shape).
3437 # The replicated nodes should be associated to affected elements.
3438 # @return TRUE if operation has been completed successfully, FALSE otherwise
3439 # @ingroup l2_modif_edit
3440 def DoubleNodesInRegion(self, theElems, theNodesNot, theShape):
3441 return self.editor.DoubleNodesInRegion(theElems, theNodesNot, theShape)
3443 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3444 # This method provided for convenience works as DoubleNodes() described above.
3445 # @param theElems - group of of elements (edges or faces) to be replicated
3446 # @param theNodesNot - group of nodes not to replicated
3447 # @param theAffectedElems - group of elements to which the replicated nodes
3448 # should be associated to.
3449 # @ingroup l2_modif_edit
3450 def DoubleNodeGroup(self, theElems, theNodesNot, theAffectedElems):
3451 return self.editor.DoubleNodeGroup(theElems, theNodesNot, theAffectedElems)
3453 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3454 # This method provided for convenience works as DoubleNodes() described above.
3455 # @param theElems - group of of elements (edges or faces) to be replicated
3456 # @param theNodesNot - group of nodes not to replicated
3457 # @param theShape - shape to detect affected elements (element which geometric center
3458 # located on or inside shape).
3459 # The replicated nodes should be associated to affected elements.
3460 # @ingroup l2_modif_edit
3461 def DoubleNodeGroupInRegion(self, theElems, theNodesNot, theShape):
3462 return self.editor.DoubleNodeGroup(theElems, theNodesNot, theShape)
3464 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3465 # This method provided for convenience works as DoubleNodes() described above.
3466 # @param theElems - list of groups of elements (edges or faces) to be replicated
3467 # @param theNodesNot - list of groups of nodes not to replicated
3468 # @param theAffectedElems - group of elements to which the replicated nodes
3469 # should be associated to.
3470 # @return TRUE if operation has been completed successfully, FALSE otherwise
3471 # @ingroup l2_modif_edit
3472 def DoubleNodeGroups(self, theElems, theNodesNot, theAffectedElems):
3473 return self.editor.DoubleNodeGroups(theElems, theNodesNot, theAffectedElems)
3475 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3476 # This method provided for convenience works as DoubleNodes() described above.
3477 # @param theElems - list of groups of elements (edges or faces) to be replicated
3478 # @param theNodesNot - list of groups of nodes not to replicated
3479 # @param theShape - shape to detect affected elements (element which geometric center
3480 # located on or inside shape).
3481 # The replicated nodes should be associated to affected elements.
3482 # @return TRUE if operation has been completed successfully, FALSE otherwise
3483 # @ingroup l2_modif_edit
3484 def DoubleNodeGroupsInRegion(self, theElems, theNodesNot, theShape):
3485 return self.editor.DoubleNodeGroupsInRegion(theElems, theNodesNot, theShape)
3487 ## The mother class to define algorithm, it is not recommended to use it directly.
3490 # @ingroup l2_algorithms
3491 class Mesh_Algorithm:
3492 # @class Mesh_Algorithm
3493 # @brief Class Mesh_Algorithm
3495 #def __init__(self,smesh):
3503 ## Finds a hypothesis in the study by its type name and parameters.
3504 # Finds only the hypotheses created in smeshpyD engine.
3505 # @return SMESH.SMESH_Hypothesis
3506 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3507 study = smeshpyD.GetCurrentStudy()
3508 #to do: find component by smeshpyD object, not by its data type
3509 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3510 if scomp is not None:
3511 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3512 # Check if the root label of the hypotheses exists
3513 if res and hypRoot is not None:
3514 iter = study.NewChildIterator(hypRoot)
3515 # Check all published hypotheses
3517 hypo_so_i = iter.Value()
3518 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3519 if attr is not None:
3520 anIOR = attr.Value()
3521 hypo_o_i = salome.orb.string_to_object(anIOR)
3522 if hypo_o_i is not None:
3523 # Check if this is a hypothesis
3524 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3525 if hypo_i is not None:
3526 # Check if the hypothesis belongs to current engine
3527 if smeshpyD.GetObjectId(hypo_i) > 0:
3528 # Check if this is the required hypothesis
3529 if hypo_i.GetName() == hypname:
3531 if CompareMethod(hypo_i, args):
3545 ## Finds the algorithm in the study by its type name.
3546 # Finds only the algorithms, which have been created in smeshpyD engine.
3547 # @return SMESH.SMESH_Algo
3548 def FindAlgorithm (self, algoname, smeshpyD):
3549 study = smeshpyD.GetCurrentStudy()
3550 #to do: find component by smeshpyD object, not by its data type
3551 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3552 if scomp is not None:
3553 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3554 # Check if the root label of the algorithms exists
3555 if res and hypRoot is not None:
3556 iter = study.NewChildIterator(hypRoot)
3557 # Check all published algorithms
3559 algo_so_i = iter.Value()
3560 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3561 if attr is not None:
3562 anIOR = attr.Value()
3563 algo_o_i = salome.orb.string_to_object(anIOR)
3564 if algo_o_i is not None:
3565 # Check if this is an algorithm
3566 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3567 if algo_i is not None:
3568 # Checks if the algorithm belongs to the current engine
3569 if smeshpyD.GetObjectId(algo_i) > 0:
3570 # Check if this is the required algorithm
3571 if algo_i.GetName() == algoname:
3584 ## If the algorithm is global, returns 0; \n
3585 # else returns the submesh associated to this algorithm.
3586 def GetSubMesh(self):
3589 ## Returns the wrapped mesher.
3590 def GetAlgorithm(self):
3593 ## Gets the list of hypothesis that can be used with this algorithm
3594 def GetCompatibleHypothesis(self):
3597 mylist = self.algo.GetCompatibleHypothesis()
3600 ## Gets the name of the algorithm
3604 ## Sets the name to the algorithm
3605 def SetName(self, name):
3606 self.mesh.smeshpyD.SetName(self.algo, name)
3608 ## Gets the id of the algorithm
3610 return self.algo.GetId()
3613 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3615 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3616 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3618 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3620 self.Assign(algo, mesh, geom)
3624 def Assign(self, algo, mesh, geom):
3626 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3633 name = GetName(geom)
3635 name = mesh.geompyD.SubShapeName(geom, piece)
3636 mesh.geompyD.addToStudyInFather(piece, geom, name)
3637 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3640 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3641 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3643 def CompareHyp (self, hyp, args):
3644 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3647 def CompareEqualHyp (self, hyp, args):
3651 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3652 UseExisting=0, CompareMethod=""):
3655 if CompareMethod == "": CompareMethod = self.CompareHyp
3656 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3659 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3665 a = a + s + str(args[i])
3669 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3671 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3672 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3675 ## Returns entry of the shape to mesh in the study
3676 def MainShapeEntry(self):
3678 if not self.mesh or not self.mesh.GetMesh(): return entry
3679 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3680 study = self.mesh.smeshpyD.GetCurrentStudy()
3681 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3682 sobj = study.FindObjectIOR(ior)
3683 if sobj: entry = sobj.GetID()
3684 if not entry: return ""
3687 # Public class: Mesh_Segment
3688 # --------------------------
3690 ## Class to define a segment 1D algorithm for discretization
3693 # @ingroup l3_algos_basic
3694 class Mesh_Segment(Mesh_Algorithm):
3696 ## Private constructor.
3697 def __init__(self, mesh, geom=0):
3698 Mesh_Algorithm.__init__(self)
3699 self.Create(mesh, geom, "Regular_1D")
3701 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3702 # @param l for the length of segments that cut an edge
3703 # @param UseExisting if ==true - searches for an existing hypothesis created with
3704 # the same parameters, else (default) - creates a new one
3705 # @param p precision, used for calculation of the number of segments.
3706 # The precision should be a positive, meaningful value within the range [0,1].
3707 # In general, the number of segments is calculated with the formula:
3708 # nb = ceil((edge_length / l) - p)
3709 # Function ceil rounds its argument to the higher integer.
3710 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3711 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3712 # p=1 means rounding of (edge_length / l) to the lower integer.
3713 # Default value is 1e-07.
3714 # @return an instance of StdMeshers_LocalLength hypothesis
3715 # @ingroup l3_hypos_1dhyps
3716 def LocalLength(self, l, UseExisting=0, p=1e-07):
3717 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3718 CompareMethod=self.CompareLocalLength)
3724 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3725 def CompareLocalLength(self, hyp, args):
3726 if IsEqual(hyp.GetLength(), args[0]):
3727 return IsEqual(hyp.GetPrecision(), args[1])
3730 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3731 # @param length is optional maximal allowed length of segment, if it is omitted
3732 # the preestimated length is used that depends on geometry size
3733 # @param UseExisting if ==true - searches for an existing hypothesis created with
3734 # the same parameters, else (default) - create a new one
3735 # @return an instance of StdMeshers_MaxLength hypothesis
3736 # @ingroup l3_hypos_1dhyps
3737 def MaxSize(self, length=0.0, UseExisting=0):
3738 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3741 hyp.SetLength(length)
3743 # set preestimated length
3744 gen = self.mesh.smeshpyD
3745 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3746 self.mesh.GetMesh(), self.mesh.GetShape(),
3748 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3750 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3753 hyp.SetUsePreestimatedLength( length == 0.0 )
3756 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3757 # @param n for the number of segments that cut an edge
3758 # @param s for the scale factor (optional)
3759 # @param reversedEdges is a list of edges to mesh using reversed orientation
3760 # @param UseExisting if ==true - searches for an existing hypothesis created with
3761 # the same parameters, else (default) - create a new one
3762 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3763 # @ingroup l3_hypos_1dhyps
3764 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3765 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3766 reversedEdges, UseExisting = [], reversedEdges
3767 entry = self.MainShapeEntry()
3769 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3770 UseExisting=UseExisting,
3771 CompareMethod=self.CompareNumberOfSegments)
3773 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3774 UseExisting=UseExisting,
3775 CompareMethod=self.CompareNumberOfSegments)
3776 hyp.SetDistrType( 1 )
3777 hyp.SetScaleFactor(s)
3778 hyp.SetNumberOfSegments(n)
3779 hyp.SetReversedEdges( reversedEdges )
3780 hyp.SetObjectEntry( entry )
3784 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3785 def CompareNumberOfSegments(self, hyp, args):
3786 if hyp.GetNumberOfSegments() == args[0]:
3788 if hyp.GetReversedEdges() == args[1]:
3789 if not args[1] or hyp.GetObjectEntry() == args[2]:
3792 if hyp.GetReversedEdges() == args[2]:
3793 if not args[2] or hyp.GetObjectEntry() == args[3]:
3794 if hyp.GetDistrType() == 1:
3795 if IsEqual(hyp.GetScaleFactor(), args[1]):
3799 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3800 # @param start defines the length of the first segment
3801 # @param end defines the length of the last segment
3802 # @param reversedEdges is a list of edges to mesh using reversed orientation
3803 # @param UseExisting if ==true - searches for an existing hypothesis created with
3804 # the same parameters, else (default) - creates a new one
3805 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3806 # @ingroup l3_hypos_1dhyps
3807 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3808 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3809 reversedEdges, UseExisting = [], reversedEdges
3810 entry = self.MainShapeEntry()
3811 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
3812 UseExisting=UseExisting,
3813 CompareMethod=self.CompareArithmetic1D)
3814 hyp.SetStartLength(start)
3815 hyp.SetEndLength(end)
3816 hyp.SetReversedEdges( reversedEdges )
3817 hyp.SetObjectEntry( entry )
3821 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3822 def CompareArithmetic1D(self, hyp, args):
3823 if IsEqual(hyp.GetLength(1), args[0]):
3824 if IsEqual(hyp.GetLength(0), args[1]):
3825 if hyp.GetReversedEdges() == args[2]:
3826 if not args[2] or hyp.GetObjectEntry() == args[3]:
3831 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
3832 # on curve from 0 to 1 (additionally it is neecessary to check
3833 # orientation of edges and create list of reversed edges if it is
3834 # needed) and sets numbers of segments between given points (default
3835 # values are equals 1
3836 # @param points defines the list of parameters on curve
3837 # @param nbSegs defines the list of numbers of segments
3838 # @param reversedEdges is a list of edges to mesh using reversed orientation
3839 # @param UseExisting if ==true - searches for an existing hypothesis created with
3840 # the same parameters, else (default) - creates a new one
3841 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3842 # @ingroup l3_hypos_1dhyps
3843 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
3844 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3845 reversedEdges, UseExisting = [], reversedEdges
3846 entry = self.MainShapeEntry()
3847 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
3848 UseExisting=UseExisting,
3849 CompareMethod=self.CompareArithmetic1D)
3850 hyp.SetPoints(points)
3851 hyp.SetNbSegments(nbSegs)
3852 hyp.SetReversedEdges(reversedEdges)
3853 hyp.SetObjectEntry(entry)
3857 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
3858 ## as the given arguments
3859 def CompareFixedPoints1D(self, hyp, args):
3860 if hyp.GetPoints() == args[0]:
3861 if hyp.GetNbSegments() == args[1]:
3862 if hyp.GetReversedEdges() == args[2]:
3863 if not args[2] or hyp.GetObjectEntry() == args[3]:
3869 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3870 # @param start defines the length of the first segment
3871 # @param end defines the length of the last segment
3872 # @param reversedEdges is a list of edges to mesh using reversed orientation
3873 # @param UseExisting if ==true - searches for an existing hypothesis created with
3874 # the same parameters, else (default) - creates a new one
3875 # @return an instance of StdMeshers_StartEndLength hypothesis
3876 # @ingroup l3_hypos_1dhyps
3877 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3878 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3879 reversedEdges, UseExisting = [], reversedEdges
3880 entry = self.MainShapeEntry()
3881 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3882 UseExisting=UseExisting,
3883 CompareMethod=self.CompareStartEndLength)
3884 hyp.SetStartLength(start)
3885 hyp.SetEndLength(end)
3886 hyp.SetReversedEdges( reversedEdges )
3887 hyp.SetObjectEntry( entry )
3890 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3891 def CompareStartEndLength(self, hyp, args):
3892 if IsEqual(hyp.GetLength(1), args[0]):
3893 if IsEqual(hyp.GetLength(0), args[1]):
3894 if hyp.GetReversedEdges() == args[2]:
3895 if not args[2] or hyp.GetObjectEntry() == args[3]:
3899 ## Defines "Deflection1D" hypothesis
3900 # @param d for the deflection
3901 # @param UseExisting if ==true - searches for an existing hypothesis created with
3902 # the same parameters, else (default) - create a new one
3903 # @ingroup l3_hypos_1dhyps
3904 def Deflection1D(self, d, UseExisting=0):
3905 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3906 CompareMethod=self.CompareDeflection1D)
3907 hyp.SetDeflection(d)
3910 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3911 def CompareDeflection1D(self, hyp, args):
3912 return IsEqual(hyp.GetDeflection(), args[0])
3914 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3915 # the opposite side in case of quadrangular faces
3916 # @ingroup l3_hypos_additi
3917 def Propagation(self):
3918 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3920 ## Defines "AutomaticLength" hypothesis
3921 # @param fineness for the fineness [0-1]
3922 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3923 # same parameters, else (default) - create a new one
3924 # @ingroup l3_hypos_1dhyps
3925 def AutomaticLength(self, fineness=0, UseExisting=0):
3926 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3927 CompareMethod=self.CompareAutomaticLength)
3928 hyp.SetFineness( fineness )
3931 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3932 def CompareAutomaticLength(self, hyp, args):
3933 return IsEqual(hyp.GetFineness(), args[0])
3935 ## Defines "SegmentLengthAroundVertex" hypothesis
3936 # @param length for the segment length
3937 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3938 # Any other integer value means that the hypothesis will be set on the
3939 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3940 # @param UseExisting if ==true - searches for an existing hypothesis created with
3941 # the same parameters, else (default) - creates a new one
3942 # @ingroup l3_algos_segmarv
3943 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3945 store_geom = self.geom
3946 if type(vertex) is types.IntType:
3947 if vertex == 0 or vertex == 1:
3948 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3956 if self.geom is None:
3957 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3958 name = GetName(self.geom)
3960 piece = self.mesh.geom
3961 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3962 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3963 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3965 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3967 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3968 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3970 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3971 CompareMethod=self.CompareLengthNearVertex)
3972 self.geom = store_geom
3973 hyp.SetLength( length )
3976 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3977 # @ingroup l3_algos_segmarv
3978 def CompareLengthNearVertex(self, hyp, args):
3979 return IsEqual(hyp.GetLength(), args[0])
3981 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3982 # If the 2D mesher sees that all boundary edges are quadratic,
3983 # it generates quadratic faces, else it generates linear faces using
3984 # medium nodes as if they are vertices.
3985 # The 3D mesher generates quadratic volumes only if all boundary faces
3986 # are quadratic, else it fails.
3988 # @ingroup l3_hypos_additi
3989 def QuadraticMesh(self):
3990 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3993 # Public class: Mesh_CompositeSegment
3994 # --------------------------
3996 ## Defines a segment 1D algorithm for discretization
3998 # @ingroup l3_algos_basic
3999 class Mesh_CompositeSegment(Mesh_Segment):
4001 ## Private constructor.
4002 def __init__(self, mesh, geom=0):
4003 self.Create(mesh, geom, "CompositeSegment_1D")
4006 # Public class: Mesh_Segment_Python
4007 # ---------------------------------
4009 ## Defines a segment 1D algorithm for discretization with python function
4011 # @ingroup l3_algos_basic
4012 class Mesh_Segment_Python(Mesh_Segment):
4014 ## Private constructor.
4015 def __init__(self, mesh, geom=0):
4016 import Python1dPlugin
4017 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4019 ## Defines "PythonSplit1D" hypothesis
4020 # @param n for the number of segments that cut an edge
4021 # @param func for the python function that calculates the length of all segments
4022 # @param UseExisting if ==true - searches for the existing hypothesis created with
4023 # the same parameters, else (default) - creates a new one
4024 # @ingroup l3_hypos_1dhyps
4025 def PythonSplit1D(self, n, func, UseExisting=0):
4026 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4027 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4028 hyp.SetNumberOfSegments(n)
4029 hyp.SetPythonLog10RatioFunction(func)
4032 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4033 def ComparePythonSplit1D(self, hyp, args):
4034 #if hyp.GetNumberOfSegments() == args[0]:
4035 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4039 # Public class: Mesh_Triangle
4040 # ---------------------------
4042 ## Defines a triangle 2D algorithm
4044 # @ingroup l3_algos_basic
4045 class Mesh_Triangle(Mesh_Algorithm):
4054 ## Private constructor.
4055 def __init__(self, mesh, algoType, geom=0):
4056 Mesh_Algorithm.__init__(self)
4058 self.algoType = algoType
4059 if algoType == MEFISTO:
4060 self.Create(mesh, geom, "MEFISTO_2D")
4062 elif algoType == BLSURF:
4064 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4065 #self.SetPhysicalMesh() - PAL19680
4066 elif algoType == NETGEN:
4068 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4070 elif algoType == NETGEN_2D:
4072 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4075 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4076 # @param area for the maximum area of each triangle
4077 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4078 # same parameters, else (default) - creates a new one
4080 # Only for algoType == MEFISTO || NETGEN_2D
4081 # @ingroup l3_hypos_2dhyps
4082 def MaxElementArea(self, area, UseExisting=0):
4083 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4084 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4085 CompareMethod=self.CompareMaxElementArea)
4086 elif self.algoType == NETGEN:
4087 hyp = self.Parameters(SIMPLE)
4088 hyp.SetMaxElementArea(area)
4091 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4092 def CompareMaxElementArea(self, hyp, args):
4093 return IsEqual(hyp.GetMaxElementArea(), args[0])
4095 ## Defines "LengthFromEdges" hypothesis to build triangles
4096 # based on the length of the edges taken from the wire
4098 # Only for algoType == MEFISTO || NETGEN_2D
4099 # @ingroup l3_hypos_2dhyps
4100 def LengthFromEdges(self):
4101 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4102 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4104 elif self.algoType == NETGEN:
4105 hyp = self.Parameters(SIMPLE)
4106 hyp.LengthFromEdges()
4109 ## Sets a way to define size of mesh elements to generate.
4110 # @param thePhysicalMesh is: DefaultSize or Custom.
4111 # @ingroup l3_hypos_blsurf
4112 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4113 # Parameter of BLSURF algo
4114 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4116 ## Sets size of mesh elements to generate.
4117 # @ingroup l3_hypos_blsurf
4118 def SetPhySize(self, theVal):
4119 # Parameter of BLSURF algo
4120 self.Parameters().SetPhySize(theVal)
4122 ## Sets lower boundary of mesh element size (PhySize).
4123 # @ingroup l3_hypos_blsurf
4124 def SetPhyMin(self, theVal=-1):
4125 # Parameter of BLSURF algo
4126 self.Parameters().SetPhyMin(theVal)
4128 ## Sets upper boundary of mesh element size (PhySize).
4129 # @ingroup l3_hypos_blsurf
4130 def SetPhyMax(self, theVal=-1):
4131 # Parameter of BLSURF algo
4132 self.Parameters().SetPhyMax(theVal)
4134 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4135 # @param theGeometricMesh is: DefaultGeom or Custom
4136 # @ingroup l3_hypos_blsurf
4137 def SetGeometricMesh(self, theGeometricMesh=0):
4138 # Parameter of BLSURF algo
4139 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4140 self.params.SetGeometricMesh(theGeometricMesh)
4142 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4143 # @ingroup l3_hypos_blsurf
4144 def SetAngleMeshS(self, theVal=_angleMeshS):
4145 # Parameter of BLSURF algo
4146 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4147 self.params.SetAngleMeshS(theVal)
4149 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4150 # @ingroup l3_hypos_blsurf
4151 def SetAngleMeshC(self, theVal=_angleMeshS):
4152 # Parameter of BLSURF algo
4153 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4154 self.params.SetAngleMeshC(theVal)
4156 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4157 # @ingroup l3_hypos_blsurf
4158 def SetGeoMin(self, theVal=-1):
4159 # Parameter of BLSURF algo
4160 self.Parameters().SetGeoMin(theVal)
4162 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4163 # @ingroup l3_hypos_blsurf
4164 def SetGeoMax(self, theVal=-1):
4165 # Parameter of BLSURF algo
4166 self.Parameters().SetGeoMax(theVal)
4168 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4169 # @ingroup l3_hypos_blsurf
4170 def SetGradation(self, theVal=_gradation):
4171 # Parameter of BLSURF algo
4172 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4173 self.params.SetGradation(theVal)
4175 ## Sets topology usage way.
4176 # @param way defines how mesh conformity is assured <ul>
4177 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4178 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4179 # @ingroup l3_hypos_blsurf
4180 def SetTopology(self, way):
4181 # Parameter of BLSURF algo
4182 self.Parameters().SetTopology(way)
4184 ## To respect geometrical edges or not.
4185 # @ingroup l3_hypos_blsurf
4186 def SetDecimesh(self, toIgnoreEdges=False):
4187 # Parameter of BLSURF algo
4188 self.Parameters().SetDecimesh(toIgnoreEdges)
4190 ## Sets verbosity level in the range 0 to 100.
4191 # @ingroup l3_hypos_blsurf
4192 def SetVerbosity(self, level):
4193 # Parameter of BLSURF algo
4194 self.Parameters().SetVerbosity(level)
4196 ## Sets advanced option value.
4197 # @ingroup l3_hypos_blsurf
4198 def SetOptionValue(self, optionName, level):
4199 # Parameter of BLSURF algo
4200 self.Parameters().SetOptionValue(optionName,level)
4202 ## Sets QuadAllowed flag.
4203 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4204 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4205 def SetQuadAllowed(self, toAllow=True):
4206 if self.algoType == NETGEN_2D:
4207 if toAllow: # add QuadranglePreference
4208 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4209 else: # remove QuadranglePreference
4210 for hyp in self.mesh.GetHypothesisList( self.geom ):
4211 if hyp.GetName() == "QuadranglePreference":
4212 self.mesh.RemoveHypothesis( self.geom, hyp )
4217 if self.Parameters():
4218 self.params.SetQuadAllowed(toAllow)
4221 ## Defines hypothesis having several parameters
4223 # @ingroup l3_hypos_netgen
4224 def Parameters(self, which=SOLE):
4227 if self.algoType == NETGEN:
4229 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4230 "libNETGENEngine.so", UseExisting=0)
4232 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4233 "libNETGENEngine.so", UseExisting=0)
4235 elif self.algoType == MEFISTO:
4236 print "Mefisto algo support no multi-parameter hypothesis"
4238 elif self.algoType == NETGEN_2D:
4239 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4240 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4242 elif self.algoType == BLSURF:
4243 self.params = self.Hypothesis("BLSURF_Parameters", [],
4244 "libBLSURFEngine.so", UseExisting=0)
4247 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4252 # Only for algoType == NETGEN
4253 # @ingroup l3_hypos_netgen
4254 def SetMaxSize(self, theSize):
4255 if self.Parameters():
4256 self.params.SetMaxSize(theSize)
4258 ## Sets SecondOrder flag
4260 # Only for algoType == NETGEN
4261 # @ingroup l3_hypos_netgen
4262 def SetSecondOrder(self, theVal):
4263 if self.Parameters():
4264 self.params.SetSecondOrder(theVal)
4266 ## Sets Optimize flag
4268 # Only for algoType == NETGEN
4269 # @ingroup l3_hypos_netgen
4270 def SetOptimize(self, theVal):
4271 if self.Parameters():
4272 self.params.SetOptimize(theVal)
4275 # @param theFineness is:
4276 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4278 # Only for algoType == NETGEN
4279 # @ingroup l3_hypos_netgen
4280 def SetFineness(self, theFineness):
4281 if self.Parameters():
4282 self.params.SetFineness(theFineness)
4286 # Only for algoType == NETGEN
4287 # @ingroup l3_hypos_netgen
4288 def SetGrowthRate(self, theRate):
4289 if self.Parameters():
4290 self.params.SetGrowthRate(theRate)
4292 ## Sets NbSegPerEdge
4294 # Only for algoType == NETGEN
4295 # @ingroup l3_hypos_netgen
4296 def SetNbSegPerEdge(self, theVal):
4297 if self.Parameters():
4298 self.params.SetNbSegPerEdge(theVal)
4300 ## Sets NbSegPerRadius
4302 # Only for algoType == NETGEN
4303 # @ingroup l3_hypos_netgen
4304 def SetNbSegPerRadius(self, theVal):
4305 if self.Parameters():
4306 self.params.SetNbSegPerRadius(theVal)
4308 ## Sets number of segments overriding value set by SetLocalLength()
4310 # Only for algoType == NETGEN
4311 # @ingroup l3_hypos_netgen
4312 def SetNumberOfSegments(self, theVal):
4313 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4315 ## Sets number of segments overriding value set by SetNumberOfSegments()
4317 # Only for algoType == NETGEN
4318 # @ingroup l3_hypos_netgen
4319 def SetLocalLength(self, theVal):
4320 self.Parameters(SIMPLE).SetLocalLength(theVal)
4325 # Public class: Mesh_Quadrangle
4326 # -----------------------------
4328 ## Defines a quadrangle 2D algorithm
4330 # @ingroup l3_algos_basic
4331 class Mesh_Quadrangle(Mesh_Algorithm):
4333 ## Private constructor.
4334 def __init__(self, mesh, geom=0):
4335 Mesh_Algorithm.__init__(self)
4336 self.Create(mesh, geom, "Quadrangle_2D")
4338 ## Defines "QuadranglePreference" hypothesis, forcing construction
4339 # of quadrangles if the number of nodes on the opposite edges is not the same
4340 # while the total number of nodes on edges is even
4342 # @ingroup l3_hypos_additi
4343 def QuadranglePreference(self):
4344 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4345 CompareMethod=self.CompareEqualHyp)
4348 ## Defines "TrianglePreference" hypothesis, forcing construction
4349 # of triangles in the refinement area if the number of nodes
4350 # on the opposite edges is not the same
4352 # @ingroup l3_hypos_additi
4353 def TrianglePreference(self):
4354 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4355 CompareMethod=self.CompareEqualHyp)
4358 # Public class: Mesh_Tetrahedron
4359 # ------------------------------
4361 ## Defines a tetrahedron 3D algorithm
4363 # @ingroup l3_algos_basic
4364 class Mesh_Tetrahedron(Mesh_Algorithm):
4369 ## Private constructor.
4370 def __init__(self, mesh, algoType, geom=0):
4371 Mesh_Algorithm.__init__(self)
4373 if algoType == NETGEN:
4375 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4378 elif algoType == FULL_NETGEN:
4380 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4383 elif algoType == GHS3D:
4385 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4388 elif algoType == GHS3DPRL:
4389 CheckPlugin(GHS3DPRL)
4390 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4393 self.algoType = algoType
4395 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4396 # @param vol for the maximum volume of each tetrahedron
4397 # @param UseExisting if ==true - searches for the existing hypothesis created with
4398 # the same parameters, else (default) - creates a new one
4399 # @ingroup l3_hypos_maxvol
4400 def MaxElementVolume(self, vol, UseExisting=0):
4401 if self.algoType == NETGEN:
4402 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4403 CompareMethod=self.CompareMaxElementVolume)
4404 hyp.SetMaxElementVolume(vol)
4406 elif self.algoType == FULL_NETGEN:
4407 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4410 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4411 def CompareMaxElementVolume(self, hyp, args):
4412 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4414 ## Defines hypothesis having several parameters
4416 # @ingroup l3_hypos_netgen
4417 def Parameters(self, which=SOLE):
4421 if self.algoType == FULL_NETGEN:
4423 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4424 "libNETGENEngine.so", UseExisting=0)
4426 self.params = self.Hypothesis("NETGEN_Parameters", [],
4427 "libNETGENEngine.so", UseExisting=0)
4430 if self.algoType == GHS3D:
4431 self.params = self.Hypothesis("GHS3D_Parameters", [],
4432 "libGHS3DEngine.so", UseExisting=0)
4435 if self.algoType == GHS3DPRL:
4436 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4437 "libGHS3DPRLEngine.so", UseExisting=0)
4440 print "Algo supports no multi-parameter hypothesis"
4444 # Parameter of FULL_NETGEN
4445 # @ingroup l3_hypos_netgen
4446 def SetMaxSize(self, theSize):
4447 self.Parameters().SetMaxSize(theSize)
4449 ## Sets SecondOrder flag
4450 # Parameter of FULL_NETGEN
4451 # @ingroup l3_hypos_netgen
4452 def SetSecondOrder(self, theVal):
4453 self.Parameters().SetSecondOrder(theVal)
4455 ## Sets Optimize flag
4456 # Parameter of FULL_NETGEN
4457 # @ingroup l3_hypos_netgen
4458 def SetOptimize(self, theVal):
4459 self.Parameters().SetOptimize(theVal)
4462 # @param theFineness is:
4463 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4464 # Parameter of FULL_NETGEN
4465 # @ingroup l3_hypos_netgen
4466 def SetFineness(self, theFineness):
4467 self.Parameters().SetFineness(theFineness)
4470 # Parameter of FULL_NETGEN
4471 # @ingroup l3_hypos_netgen
4472 def SetGrowthRate(self, theRate):
4473 self.Parameters().SetGrowthRate(theRate)
4475 ## Sets NbSegPerEdge
4476 # Parameter of FULL_NETGEN
4477 # @ingroup l3_hypos_netgen
4478 def SetNbSegPerEdge(self, theVal):
4479 self.Parameters().SetNbSegPerEdge(theVal)
4481 ## Sets NbSegPerRadius
4482 # Parameter of FULL_NETGEN
4483 # @ingroup l3_hypos_netgen
4484 def SetNbSegPerRadius(self, theVal):
4485 self.Parameters().SetNbSegPerRadius(theVal)
4487 ## Sets number of segments overriding value set by SetLocalLength()
4488 # Only for algoType == NETGEN_FULL
4489 # @ingroup l3_hypos_netgen
4490 def SetNumberOfSegments(self, theVal):
4491 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4493 ## Sets number of segments overriding value set by SetNumberOfSegments()
4494 # Only for algoType == NETGEN_FULL
4495 # @ingroup l3_hypos_netgen
4496 def SetLocalLength(self, theVal):
4497 self.Parameters(SIMPLE).SetLocalLength(theVal)
4499 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4500 # Overrides value set by LengthFromEdges()
4501 # Only for algoType == NETGEN_FULL
4502 # @ingroup l3_hypos_netgen
4503 def MaxElementArea(self, area):
4504 self.Parameters(SIMPLE).SetMaxElementArea(area)
4506 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4507 # Overrides value set by MaxElementArea()
4508 # Only for algoType == NETGEN_FULL
4509 # @ingroup l3_hypos_netgen
4510 def LengthFromEdges(self):
4511 self.Parameters(SIMPLE).LengthFromEdges()
4513 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4514 # Overrides value set by MaxElementVolume()
4515 # Only for algoType == NETGEN_FULL
4516 # @ingroup l3_hypos_netgen
4517 def LengthFromFaces(self):
4518 self.Parameters(SIMPLE).LengthFromFaces()
4520 ## To mesh "holes" in a solid or not. Default is to mesh.
4521 # @ingroup l3_hypos_ghs3dh
4522 def SetToMeshHoles(self, toMesh):
4523 # Parameter of GHS3D
4524 self.Parameters().SetToMeshHoles(toMesh)
4526 ## Set Optimization level:
4527 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4528 # Strong_Optimization.
4529 # Default is Standard_Optimization
4530 # @ingroup l3_hypos_ghs3dh
4531 def SetOptimizationLevel(self, level):
4532 # Parameter of GHS3D
4533 self.Parameters().SetOptimizationLevel(level)
4535 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4536 # @ingroup l3_hypos_ghs3dh
4537 def SetMaximumMemory(self, MB):
4538 # Advanced parameter of GHS3D
4539 self.Parameters().SetMaximumMemory(MB)
4541 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4542 # automatic memory adjustment mode.
4543 # @ingroup l3_hypos_ghs3dh
4544 def SetInitialMemory(self, MB):
4545 # Advanced parameter of GHS3D
4546 self.Parameters().SetInitialMemory(MB)
4548 ## Path to working directory.
4549 # @ingroup l3_hypos_ghs3dh
4550 def SetWorkingDirectory(self, path):
4551 # Advanced parameter of GHS3D
4552 self.Parameters().SetWorkingDirectory(path)
4554 ## To keep working files or remove them. Log file remains in case of errors anyway.
4555 # @ingroup l3_hypos_ghs3dh
4556 def SetKeepFiles(self, toKeep):
4557 # Advanced parameter of GHS3D and GHS3DPRL
4558 self.Parameters().SetKeepFiles(toKeep)
4560 ## To set verbose level [0-10]. <ul>
4561 #<li> 0 - no standard output,
4562 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4563 # indicates when the final mesh is being saved. In addition the software
4564 # gives indication regarding the CPU time.
4565 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4566 # histogram of the skin mesh, quality statistics histogram together with
4567 # the characteristics of the final mesh.</ul>
4568 # @ingroup l3_hypos_ghs3dh
4569 def SetVerboseLevel(self, level):
4570 # Advanced parameter of GHS3D
4571 self.Parameters().SetVerboseLevel(level)
4573 ## To create new nodes.
4574 # @ingroup l3_hypos_ghs3dh
4575 def SetToCreateNewNodes(self, toCreate):
4576 # Advanced parameter of GHS3D
4577 self.Parameters().SetToCreateNewNodes(toCreate)
4579 ## To use boundary recovery version which tries to create mesh on a very poor
4580 # quality surface mesh.
4581 # @ingroup l3_hypos_ghs3dh
4582 def SetToUseBoundaryRecoveryVersion(self, toUse):
4583 # Advanced parameter of GHS3D
4584 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4586 ## Sets command line option as text.
4587 # @ingroup l3_hypos_ghs3dh
4588 def SetTextOption(self, option):
4589 # Advanced parameter of GHS3D
4590 self.Parameters().SetTextOption(option)
4592 ## Sets MED files name and path.
4593 def SetMEDName(self, value):
4594 self.Parameters().SetMEDName(value)
4596 ## Sets the number of partition of the initial mesh
4597 def SetNbPart(self, value):
4598 self.Parameters().SetNbPart(value)
4600 ## When big mesh, start tepal in background
4601 def SetBackground(self, value):
4602 self.Parameters().SetBackground(value)
4604 # Public class: Mesh_Hexahedron
4605 # ------------------------------
4607 ## Defines a hexahedron 3D algorithm
4609 # @ingroup l3_algos_basic
4610 class Mesh_Hexahedron(Mesh_Algorithm):
4615 ## Private constructor.
4616 def __init__(self, mesh, algoType=Hexa, geom=0):
4617 Mesh_Algorithm.__init__(self)
4619 self.algoType = algoType
4621 if algoType == Hexa:
4622 self.Create(mesh, geom, "Hexa_3D")
4625 elif algoType == Hexotic:
4626 CheckPlugin(Hexotic)
4627 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4630 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4631 # @ingroup l3_hypos_hexotic
4632 def MinMaxQuad(self, min=3, max=8, quad=True):
4633 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4635 self.params.SetHexesMinLevel(min)
4636 self.params.SetHexesMaxLevel(max)
4637 self.params.SetHexoticQuadrangles(quad)
4640 # Deprecated, only for compatibility!
4641 # Public class: Mesh_Netgen
4642 # ------------------------------
4644 ## Defines a NETGEN-based 2D or 3D algorithm
4645 # that needs no discrete boundary (i.e. independent)
4647 # This class is deprecated, only for compatibility!
4650 # @ingroup l3_algos_basic
4651 class Mesh_Netgen(Mesh_Algorithm):
4655 ## Private constructor.
4656 def __init__(self, mesh, is3D, geom=0):
4657 Mesh_Algorithm.__init__(self)
4663 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4667 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4670 ## Defines the hypothesis containing parameters of the algorithm
4671 def Parameters(self):
4673 hyp = self.Hypothesis("NETGEN_Parameters", [],
4674 "libNETGENEngine.so", UseExisting=0)
4676 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4677 "libNETGENEngine.so", UseExisting=0)
4680 # Public class: Mesh_Projection1D
4681 # ------------------------------
4683 ## Defines a projection 1D algorithm
4684 # @ingroup l3_algos_proj
4686 class Mesh_Projection1D(Mesh_Algorithm):
4688 ## Private constructor.
4689 def __init__(self, mesh, geom=0):
4690 Mesh_Algorithm.__init__(self)
4691 self.Create(mesh, geom, "Projection_1D")
4693 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4694 # a mesh pattern is taken, and, optionally, the association of vertices
4695 # between the source edge and a target edge (to which a hypothesis is assigned)
4696 # @param edge from which nodes distribution is taken
4697 # @param mesh from which nodes distribution is taken (optional)
4698 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4699 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4700 # to associate with \a srcV (optional)
4701 # @param UseExisting if ==true - searches for the existing hypothesis created with
4702 # the same parameters, else (default) - creates a new one
4703 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4704 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4706 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4707 hyp.SetSourceEdge( edge )
4708 if not mesh is None and isinstance(mesh, Mesh):
4709 mesh = mesh.GetMesh()
4710 hyp.SetSourceMesh( mesh )
4711 hyp.SetVertexAssociation( srcV, tgtV )
4714 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4715 #def CompareSourceEdge(self, hyp, args):
4716 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4720 # Public class: Mesh_Projection2D
4721 # ------------------------------
4723 ## Defines a projection 2D algorithm
4724 # @ingroup l3_algos_proj
4726 class Mesh_Projection2D(Mesh_Algorithm):
4728 ## Private constructor.
4729 def __init__(self, mesh, geom=0):
4730 Mesh_Algorithm.__init__(self)
4731 self.Create(mesh, geom, "Projection_2D")
4733 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4734 # a mesh pattern is taken, and, optionally, the association of vertices
4735 # between the source face and the target face (to which a hypothesis is assigned)
4736 # @param face from which the mesh pattern is taken
4737 # @param mesh from which the mesh pattern is taken (optional)
4738 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4739 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4740 # to associate with \a srcV1 (optional)
4741 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4742 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4743 # to associate with \a srcV2 (optional)
4744 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4745 # the same parameters, else (default) - forces the creation a new one
4747 # Note: all association vertices must belong to one edge of a face
4748 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4749 srcV2=None, tgtV2=None, UseExisting=0):
4750 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4752 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4753 hyp.SetSourceFace( face )
4754 if not mesh is None and isinstance(mesh, Mesh):
4755 mesh = mesh.GetMesh()
4756 hyp.SetSourceMesh( mesh )
4757 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4760 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4761 #def CompareSourceFace(self, hyp, args):
4762 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4765 # Public class: Mesh_Projection3D
4766 # ------------------------------
4768 ## Defines a projection 3D algorithm
4769 # @ingroup l3_algos_proj
4771 class Mesh_Projection3D(Mesh_Algorithm):
4773 ## Private constructor.
4774 def __init__(self, mesh, geom=0):
4775 Mesh_Algorithm.__init__(self)
4776 self.Create(mesh, geom, "Projection_3D")
4778 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4779 # the mesh pattern is taken, and, optionally, the association of vertices
4780 # between the source and the target solid (to which a hipothesis is assigned)
4781 # @param solid from where the mesh pattern is taken
4782 # @param mesh from where the mesh pattern is taken (optional)
4783 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4784 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4785 # to associate with \a srcV1 (optional)
4786 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4787 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4788 # to associate with \a srcV2 (optional)
4789 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4790 # the same parameters, else (default) - creates a new one
4792 # Note: association vertices must belong to one edge of a solid
4793 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4794 srcV2=0, tgtV2=0, UseExisting=0):
4795 hyp = self.Hypothesis("ProjectionSource3D",
4796 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4798 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4799 hyp.SetSource3DShape( solid )
4800 if not mesh is None and isinstance(mesh, Mesh):
4801 mesh = mesh.GetMesh()
4802 hyp.SetSourceMesh( mesh )
4803 if srcV1 and srcV2 and tgtV1 and tgtV2:
4804 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4805 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4808 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4809 #def CompareSourceShape3D(self, hyp, args):
4810 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4814 # Public class: Mesh_Prism
4815 # ------------------------
4817 ## Defines a 3D extrusion algorithm
4818 # @ingroup l3_algos_3dextr
4820 class Mesh_Prism3D(Mesh_Algorithm):
4822 ## Private constructor.
4823 def __init__(self, mesh, geom=0):
4824 Mesh_Algorithm.__init__(self)
4825 self.Create(mesh, geom, "Prism_3D")
4827 # Public class: Mesh_RadialPrism
4828 # -------------------------------
4830 ## Defines a Radial Prism 3D algorithm
4831 # @ingroup l3_algos_radialp
4833 class Mesh_RadialPrism3D(Mesh_Algorithm):
4835 ## Private constructor.
4836 def __init__(self, mesh, geom=0):
4837 Mesh_Algorithm.__init__(self)
4838 self.Create(mesh, geom, "RadialPrism_3D")
4840 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4841 self.nbLayers = None
4843 ## Return 3D hypothesis holding the 1D one
4844 def Get3DHypothesis(self):
4845 return self.distribHyp
4847 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4848 # hypothesis. Returns the created hypothesis
4849 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4850 #print "OwnHypothesis",hypType
4851 if not self.nbLayers is None:
4852 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4853 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4854 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4855 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4856 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4857 self.distribHyp.SetLayerDistribution( hyp )
4860 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4861 # prisms to build between the inner and outer shells
4862 # @param n number of layers
4863 # @param UseExisting if ==true - searches for the existing hypothesis created with
4864 # the same parameters, else (default) - creates a new one
4865 def NumberOfLayers(self, n, UseExisting=0):
4866 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4867 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4868 CompareMethod=self.CompareNumberOfLayers)
4869 self.nbLayers.SetNumberOfLayers( n )
4870 return self.nbLayers
4872 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4873 def CompareNumberOfLayers(self, hyp, args):
4874 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4876 ## Defines "LocalLength" hypothesis, specifying the segment length
4877 # to build between the inner and the outer shells
4878 # @param l the length of segments
4879 # @param p the precision of rounding
4880 def LocalLength(self, l, p=1e-07):
4881 hyp = self.OwnHypothesis("LocalLength", [l,p])
4886 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4887 # prisms to build between the inner and the outer shells.
4888 # @param n the number of layers
4889 # @param s the scale factor (optional)
4890 def NumberOfSegments(self, n, s=[]):
4892 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4894 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4895 hyp.SetDistrType( 1 )
4896 hyp.SetScaleFactor(s)
4897 hyp.SetNumberOfSegments(n)
4900 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4901 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4902 # @param start the length of the first segment
4903 # @param end the length of the last segment
4904 def Arithmetic1D(self, start, end ):
4905 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4906 hyp.SetLength(start, 1)
4907 hyp.SetLength(end , 0)
4910 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4911 # to build between the inner and the outer shells as geometric length increasing
4912 # @param start for the length of the first segment
4913 # @param end for the length of the last segment
4914 def StartEndLength(self, start, end):
4915 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4916 hyp.SetLength(start, 1)
4917 hyp.SetLength(end , 0)
4920 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4921 # to build between the inner and outer shells
4922 # @param fineness defines the quality of the mesh within the range [0-1]
4923 def AutomaticLength(self, fineness=0):
4924 hyp = self.OwnHypothesis("AutomaticLength")
4925 hyp.SetFineness( fineness )
4928 # Public class: Mesh_RadialQuadrangle1D2D
4929 # -------------------------------
4931 ## Defines a Radial Quadrangle 1D2D algorithm
4932 # @ingroup l2_algos_radialq
4934 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
4936 ## Private constructor.
4937 def __init__(self, mesh, geom=0):
4938 Mesh_Algorithm.__init__(self)
4939 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
4941 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
4942 self.nbLayers = None
4944 ## Return 2D hypothesis holding the 1D one
4945 def Get2DHypothesis(self):
4946 return self.distribHyp
4948 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4949 # hypothesis. Returns the created hypothesis
4950 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4951 #print "OwnHypothesis",hypType
4952 if not self.nbLayers is None:
4953 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4954 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4955 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4956 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4957 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4958 self.distribHyp.SetLayerDistribution( hyp )
4961 ## Defines "NumberOfLayers2D" hypothesis, specifying the number of layers
4962 # @param n number of layers
4963 # @param UseExisting if ==true - searches for the existing hypothesis created with
4964 # the same parameters, else (default) - creates a new one
4965 def NumberOfLayers2D(self, n, UseExisting=0):
4966 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4967 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
4968 CompareMethod=self.CompareNumberOfLayers)
4969 self.nbLayers.SetNumberOfLayers( n )
4970 return self.nbLayers
4972 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4973 def CompareNumberOfLayers(self, hyp, args):
4974 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4976 ## Defines "LocalLength" hypothesis, specifying the segment length
4977 # @param l the length of segments
4978 # @param p the precision of rounding
4979 def LocalLength(self, l, p=1e-07):
4980 hyp = self.OwnHypothesis("LocalLength", [l,p])
4985 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
4986 # @param n the number of layers
4987 # @param s the scale factor (optional)
4988 def NumberOfSegments(self, n, s=[]):
4990 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4992 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4993 hyp.SetDistrType( 1 )
4994 hyp.SetScaleFactor(s)
4995 hyp.SetNumberOfSegments(n)
4998 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4999 # with a length that changes in arithmetic progression
5000 # @param start the length of the first segment
5001 # @param end the length of the last segment
5002 def Arithmetic1D(self, start, end ):
5003 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5004 hyp.SetLength(start, 1)
5005 hyp.SetLength(end , 0)
5008 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5009 # as geometric length increasing
5010 # @param start for the length of the first segment
5011 # @param end for the length of the last segment
5012 def StartEndLength(self, start, end):
5013 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5014 hyp.SetLength(start, 1)
5015 hyp.SetLength(end , 0)
5018 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5019 # @param fineness defines the quality of the mesh within the range [0-1]
5020 def AutomaticLength(self, fineness=0):
5021 hyp = self.OwnHypothesis("AutomaticLength")
5022 hyp.SetFineness( fineness )
5026 # Private class: Mesh_UseExisting
5027 # -------------------------------
5028 class Mesh_UseExisting(Mesh_Algorithm):
5030 def __init__(self, dim, mesh, geom=0):
5032 self.Create(mesh, geom, "UseExisting_1D")
5034 self.Create(mesh, geom, "UseExisting_2D")
5037 import salome_notebook
5038 notebook = salome_notebook.notebook
5040 ##Return values of the notebook variables
5041 def ParseParameters(last, nbParams,nbParam, value):
5045 listSize = len(last)
5046 for n in range(0,nbParams):
5048 if counter < listSize:
5049 strResult = strResult + last[counter]
5051 strResult = strResult + ""
5053 if isinstance(value, str):
5054 if notebook.isVariable(value):
5055 result = notebook.get(value)
5056 strResult=strResult+value
5058 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5060 strResult=strResult+str(value)
5062 if nbParams - 1 != counter:
5063 strResult=strResult+var_separator #":"
5065 return result, strResult
5067 #Wrapper class for StdMeshers_LocalLength hypothesis
5068 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5070 ## Set Length parameter value
5071 # @param length numerical value or name of variable from notebook
5072 def SetLength(self, length):
5073 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5074 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5075 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5077 ## Set Precision parameter value
5078 # @param precision numerical value or name of variable from notebook
5079 def SetPrecision(self, precision):
5080 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5081 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5082 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5084 #Registering the new proxy for LocalLength
5085 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5088 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5089 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5091 def SetLayerDistribution(self, hypo):
5092 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5093 hypo.ClearParameters();
5094 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5096 #Registering the new proxy for LayerDistribution
5097 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5099 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5100 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5102 ## Set Length parameter value
5103 # @param length numerical value or name of variable from notebook
5104 def SetLength(self, length):
5105 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5106 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5107 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5109 #Registering the new proxy for SegmentLengthAroundVertex
5110 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5113 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5114 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5116 ## Set Length parameter value
5117 # @param length numerical value or name of variable from notebook
5118 # @param isStart true is length is Start Length, otherwise false
5119 def SetLength(self, length, isStart):
5123 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5124 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5125 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5127 #Registering the new proxy for Arithmetic1D
5128 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5130 #Wrapper class for StdMeshers_Deflection1D hypothesis
5131 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5133 ## Set Deflection parameter value
5134 # @param deflection numerical value or name of variable from notebook
5135 def SetDeflection(self, deflection):
5136 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5137 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5138 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5140 #Registering the new proxy for Deflection1D
5141 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5143 #Wrapper class for StdMeshers_StartEndLength hypothesis
5144 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5146 ## Set Length parameter value
5147 # @param length numerical value or name of variable from notebook
5148 # @param isStart true is length is Start Length, otherwise false
5149 def SetLength(self, length, isStart):
5153 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5154 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5155 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5157 #Registering the new proxy for StartEndLength
5158 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5160 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5161 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5163 ## Set Max Element Area parameter value
5164 # @param area numerical value or name of variable from notebook
5165 def SetMaxElementArea(self, area):
5166 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5167 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5168 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5170 #Registering the new proxy for MaxElementArea
5171 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5174 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5175 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5177 ## Set Max Element Volume parameter value
5178 # @param area numerical value or name of variable from notebook
5179 def SetMaxElementVolume(self, volume):
5180 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5181 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5182 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5184 #Registering the new proxy for MaxElementVolume
5185 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5188 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5189 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5191 ## Set Number Of Layers parameter value
5192 # @param nbLayers numerical value or name of variable from notebook
5193 def SetNumberOfLayers(self, nbLayers):
5194 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5195 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5196 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5198 #Registering the new proxy for NumberOfLayers
5199 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5201 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5202 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5204 ## Set Number Of Segments parameter value
5205 # @param nbSeg numerical value or name of variable from notebook
5206 def SetNumberOfSegments(self, nbSeg):
5207 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5208 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5209 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5210 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5212 ## Set Scale Factor parameter value
5213 # @param factor numerical value or name of variable from notebook
5214 def SetScaleFactor(self, factor):
5215 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5216 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5217 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5219 #Registering the new proxy for NumberOfSegments
5220 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5222 if not noNETGENPlugin:
5223 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5224 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5226 ## Set Max Size parameter value
5227 # @param maxsize numerical value or name of variable from notebook
5228 def SetMaxSize(self, maxsize):
5229 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5230 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5231 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5232 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5234 ## Set Growth Rate parameter value
5235 # @param value numerical value or name of variable from notebook
5236 def SetGrowthRate(self, value):
5237 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5238 value, parameters = ParseParameters(lastParameters,4,2,value)
5239 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5240 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5242 ## Set Number of Segments per Edge parameter value
5243 # @param value numerical value or name of variable from notebook
5244 def SetNbSegPerEdge(self, value):
5245 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5246 value, parameters = ParseParameters(lastParameters,4,3,value)
5247 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5248 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5250 ## Set Number of Segments per Radius parameter value
5251 # @param value numerical value or name of variable from notebook
5252 def SetNbSegPerRadius(self, value):
5253 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5254 value, parameters = ParseParameters(lastParameters,4,4,value)
5255 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5256 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5258 #Registering the new proxy for NETGENPlugin_Hypothesis
5259 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5262 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5263 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5266 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5267 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5269 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5270 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5272 ## Set Number of Segments parameter value
5273 # @param nbSeg numerical value or name of variable from notebook
5274 def SetNumberOfSegments(self, nbSeg):
5275 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5276 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5277 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5278 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5280 ## Set Local Length parameter value
5281 # @param length numerical value or name of variable from notebook
5282 def SetLocalLength(self, length):
5283 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5284 length, parameters = ParseParameters(lastParameters,2,1,length)
5285 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5286 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5288 ## Set Max Element Area parameter value
5289 # @param area numerical value or name of variable from notebook
5290 def SetMaxElementArea(self, area):
5291 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5292 area, parameters = ParseParameters(lastParameters,2,2,area)
5293 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5294 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5296 def LengthFromEdges(self):
5297 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5299 value, parameters = ParseParameters(lastParameters,2,2,value)
5300 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5301 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5303 #Registering the new proxy for NETGEN_SimpleParameters_2D
5304 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5307 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5308 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5309 ## Set Max Element Volume parameter value
5310 # @param volume numerical value or name of variable from notebook
5311 def SetMaxElementVolume(self, volume):
5312 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5313 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5314 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5315 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5317 def LengthFromFaces(self):
5318 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5320 value, parameters = ParseParameters(lastParameters,3,3,value)
5321 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5322 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5324 #Registering the new proxy for NETGEN_SimpleParameters_3D
5325 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5327 pass # if not noNETGENPlugin:
5329 class Pattern(SMESH._objref_SMESH_Pattern):
5331 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5333 if isinstance(theNodeIndexOnKeyPoint1,str):
5335 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5337 theNodeIndexOnKeyPoint1 -= 1
5338 theMesh.SetParameters(Parameters)
5339 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5341 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5344 if isinstance(theNode000Index,str):
5346 if isinstance(theNode001Index,str):
5348 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5350 theNode000Index -= 1
5352 theNode001Index -= 1
5353 theMesh.SetParameters(Parameters)
5354 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5356 #Registering the new proxy for Pattern
5357 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)