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 )
820 #Registering the new proxy for SMESH_Gen
821 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
827 ## This class allows defining and managing a mesh.
828 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
829 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
830 # new nodes and elements and by changing the existing entities), to get information
831 # about a mesh and to export a mesh into different formats.
840 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
841 # sets the GUI name of this mesh to \a name.
842 # @param smeshpyD an instance of smeshDC class
843 # @param geompyD an instance of geompyDC class
844 # @param obj Shape to be meshed or SMESH_Mesh object
845 # @param name Study name of the mesh
846 # @ingroup l2_construct
847 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
848 self.smeshpyD=smeshpyD
853 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
855 self.mesh = self.smeshpyD.CreateMesh(self.geom)
856 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
859 self.mesh = self.smeshpyD.CreateEmptyMesh()
861 self.smeshpyD.SetName(self.mesh, name)
863 self.smeshpyD.SetName(self.mesh, GetName(obj))
866 self.geom = self.mesh.GetShapeToMesh()
868 self.editor = self.mesh.GetMeshEditor()
870 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
871 # @param theMesh a SMESH_Mesh object
872 # @ingroup l2_construct
873 def SetMesh(self, theMesh):
875 self.geom = self.mesh.GetShapeToMesh()
877 ## Returns the mesh, that is an instance of SMESH_Mesh interface
878 # @return a SMESH_Mesh object
879 # @ingroup l2_construct
883 ## Gets the name of the mesh
884 # @return the name of the mesh as a string
885 # @ingroup l2_construct
887 name = GetName(self.GetMesh())
890 ## Sets a name to the mesh
891 # @param name a new name of the mesh
892 # @ingroup l2_construct
893 def SetName(self, name):
894 self.smeshpyD.SetName(self.GetMesh(), name)
896 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
897 # The subMesh object gives access to the IDs of nodes and elements.
898 # @param theSubObject a geometrical object (shape)
899 # @param theName a name for the submesh
900 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
901 # @ingroup l2_submeshes
902 def GetSubMesh(self, theSubObject, theName):
903 submesh = self.mesh.GetSubMesh(theSubObject, theName)
906 ## Returns the shape associated to the mesh
907 # @return a GEOM_Object
908 # @ingroup l2_construct
912 ## Associates the given shape to the mesh (entails the recreation of the mesh)
913 # @param geom the shape to be meshed (GEOM_Object)
914 # @ingroup l2_construct
915 def SetShape(self, geom):
916 self.mesh = self.smeshpyD.CreateMesh(geom)
918 ## Returns true if the hypotheses are defined well
919 # @param theSubObject a subshape of a mesh shape
920 # @return True or False
921 # @ingroup l2_construct
922 def IsReadyToCompute(self, theSubObject):
923 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
925 ## Returns errors of hypotheses definition.
926 # The list of errors is empty if everything is OK.
927 # @param theSubObject a subshape of a mesh shape
928 # @return a list of errors
929 # @ingroup l2_construct
930 def GetAlgoState(self, theSubObject):
931 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
933 ## Returns a geometrical object on which the given element was built.
934 # The returned geometrical object, if not nil, is either found in the
935 # study or published by this method with the given name
936 # @param theElementID the id of the mesh element
937 # @param theGeomName the user-defined name of the geometrical object
938 # @return GEOM::GEOM_Object instance
939 # @ingroup l2_construct
940 def GetGeometryByMeshElement(self, theElementID, theGeomName):
941 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
943 ## Returns the mesh dimension depending on the dimension of the underlying shape
944 # @return mesh dimension as an integer value [0,3]
945 # @ingroup l1_auxiliary
946 def MeshDimension(self):
947 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
948 if len( shells ) > 0 :
950 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
952 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
958 ## Creates a segment discretization 1D algorithm.
959 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
960 # \n If the optional \a geom parameter is not set, this algorithm is global.
961 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
962 # @param algo the type of the required algorithm. Possible values are:
964 # - smesh.PYTHON for discretization via a python function,
965 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
966 # @param geom If defined is the subshape to be meshed
967 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
968 # @ingroup l3_algos_basic
969 def Segment(self, algo=REGULAR, geom=0):
970 ## if Segment(geom) is called by mistake
971 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
972 algo, geom = geom, algo
973 if not algo: algo = REGULAR
976 return Mesh_Segment(self, geom)
978 return Mesh_Segment_Python(self, geom)
979 elif algo == COMPOSITE:
980 return Mesh_CompositeSegment(self, geom)
982 return Mesh_Segment(self, geom)
984 ## Enables creation of nodes and segments usable by 2D algoritms.
985 # The added nodes and segments must be bound to edges and vertices by
986 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
987 # If the optional \a geom parameter is not set, this algorithm is global.
988 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
989 # @param geom the subshape to be manually meshed
990 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
991 # @ingroup l3_algos_basic
992 def UseExistingSegments(self, geom=0):
993 algo = Mesh_UseExisting(1,self,geom)
994 return algo.GetAlgorithm()
996 ## Enables creation of nodes and faces usable by 3D algoritms.
997 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
998 # and SetMeshElementOnShape()
999 # If the optional \a geom parameter is not set, this algorithm is global.
1000 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1001 # @param geom the subshape to be manually meshed
1002 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1003 # @ingroup l3_algos_basic
1004 def UseExistingFaces(self, geom=0):
1005 algo = Mesh_UseExisting(2,self,geom)
1006 return algo.GetAlgorithm()
1008 ## Creates a triangle 2D algorithm for faces.
1009 # If the optional \a geom parameter is not set, this algorithm is global.
1010 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1011 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1012 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1013 # @return an instance of Mesh_Triangle algorithm
1014 # @ingroup l3_algos_basic
1015 def Triangle(self, algo=MEFISTO, geom=0):
1016 ## if Triangle(geom) is called by mistake
1017 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1021 return Mesh_Triangle(self, algo, geom)
1023 ## Creates a quadrangle 2D algorithm for faces.
1024 # If the optional \a geom parameter is not set, this algorithm is global.
1025 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1026 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1027 # @return an instance of Mesh_Quadrangle algorithm
1028 # @ingroup l3_algos_basic
1029 def Quadrangle(self, geom=0):
1030 return Mesh_Quadrangle(self, geom)
1032 ## Creates a tetrahedron 3D algorithm for solids.
1033 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1034 # If the optional \a geom parameter is not set, this algorithm is global.
1035 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1036 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1037 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1038 # @return an instance of Mesh_Tetrahedron algorithm
1039 # @ingroup l3_algos_basic
1040 def Tetrahedron(self, algo=NETGEN, geom=0):
1041 ## if Tetrahedron(geom) is called by mistake
1042 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1043 algo, geom = geom, algo
1044 if not algo: algo = NETGEN
1046 return Mesh_Tetrahedron(self, algo, geom)
1048 ## Creates a hexahedron 3D algorithm for solids.
1049 # If the optional \a geom parameter is not set, this algorithm is global.
1050 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1051 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1052 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1053 # @return an instance of Mesh_Hexahedron algorithm
1054 # @ingroup l3_algos_basic
1055 def Hexahedron(self, algo=Hexa, geom=0):
1056 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1057 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1058 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1059 elif geom == 0: algo, geom = Hexa, algo
1060 return Mesh_Hexahedron(self, algo, geom)
1062 ## Deprecated, used only for compatibility!
1063 # @return an instance of Mesh_Netgen algorithm
1064 # @ingroup l3_algos_basic
1065 def Netgen(self, is3D, geom=0):
1066 return Mesh_Netgen(self, is3D, geom)
1068 ## Creates a projection 1D algorithm for edges.
1069 # If the optional \a geom parameter is not set, this algorithm is global.
1070 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1071 # @param geom If defined, the subshape to be meshed
1072 # @return an instance of Mesh_Projection1D algorithm
1073 # @ingroup l3_algos_proj
1074 def Projection1D(self, geom=0):
1075 return Mesh_Projection1D(self, geom)
1077 ## Creates a projection 2D algorithm for faces.
1078 # If the optional \a geom parameter is not set, this algorithm is global.
1079 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1080 # @param geom If defined, the subshape to be meshed
1081 # @return an instance of Mesh_Projection2D algorithm
1082 # @ingroup l3_algos_proj
1083 def Projection2D(self, geom=0):
1084 return Mesh_Projection2D(self, geom)
1086 ## Creates a projection 3D algorithm for solids.
1087 # If the optional \a geom parameter is not set, this algorithm is global.
1088 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1089 # @param geom If defined, the subshape to be meshed
1090 # @return an instance of Mesh_Projection3D algorithm
1091 # @ingroup l3_algos_proj
1092 def Projection3D(self, geom=0):
1093 return Mesh_Projection3D(self, geom)
1095 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1096 # If the optional \a geom parameter is not set, this algorithm is global.
1097 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1098 # @param geom If defined, the subshape to be meshed
1099 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1100 # @ingroup l3_algos_radialp l3_algos_3dextr
1101 def Prism(self, geom=0):
1105 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1106 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1107 if nbSolids == 0 or nbSolids == nbShells:
1108 return Mesh_Prism3D(self, geom)
1109 return Mesh_RadialPrism3D(self, geom)
1111 ## Evaluates size of prospective mesh on a shape
1112 # @return True or False
1113 def Evaluate(self, geom=0):
1114 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1116 geom = self.mesh.GetShapeToMesh()
1119 return self.smeshpyD.Evaluate(self.mesh, geom)
1122 ## Computes the mesh and returns the status of the computation
1123 # @return True or False
1124 # @ingroup l2_construct
1125 def Compute(self, geom=0):
1126 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1128 geom = self.mesh.GetShapeToMesh()
1133 ok = self.smeshpyD.Compute(self.mesh, geom)
1134 except SALOME.SALOME_Exception, ex:
1135 print "Mesh computation failed, exception caught:"
1136 print " ", ex.details.text
1139 print "Mesh computation failed, exception caught:"
1140 traceback.print_exc()
1142 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1145 if err.isGlobalAlgo:
1153 reason = '%s %sD algorithm is missing' % (glob, dim)
1154 elif err.state == HYP_MISSING:
1155 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1156 % (glob, dim, name, dim))
1157 elif err.state == HYP_NOTCONFORM:
1158 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1159 elif err.state == HYP_BAD_PARAMETER:
1160 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1161 % ( glob, dim, name ))
1162 elif err.state == HYP_BAD_GEOMETRY:
1163 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1164 'geometry' % ( glob, dim, name ))
1166 reason = "For unknown reason."+\
1167 " Revise Mesh.Compute() implementation in smeshDC.py!"
1169 if allReasons != "":
1172 allReasons += reason
1174 if allReasons != "":
1175 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1179 print '"' + GetName(self.mesh) + '"',"has not been computed."
1182 if salome.sg.hasDesktop():
1183 smeshgui = salome.ImportComponentGUI("SMESH")
1184 smeshgui.Init(self.mesh.GetStudyId())
1185 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1186 salome.sg.updateObjBrowser(1)
1190 ## Removes all nodes and elements
1191 # @ingroup l2_construct
1194 if salome.sg.hasDesktop():
1195 smeshgui = salome.ImportComponentGUI("SMESH")
1196 smeshgui.Init(self.mesh.GetStudyId())
1197 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1198 salome.sg.updateObjBrowser(1)
1200 ## Removes all nodes and elements of indicated shape
1201 # @ingroup l2_construct
1202 def ClearSubMesh(self, geomId):
1203 self.mesh.ClearSubMesh(geomId)
1204 if salome.sg.hasDesktop():
1205 smeshgui = salome.ImportComponentGUI("SMESH")
1206 smeshgui.Init(self.mesh.GetStudyId())
1207 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1208 salome.sg.updateObjBrowser(1)
1210 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1211 # @param fineness [0,-1] defines mesh fineness
1212 # @return True or False
1213 # @ingroup l3_algos_basic
1214 def AutomaticTetrahedralization(self, fineness=0):
1215 dim = self.MeshDimension()
1217 self.RemoveGlobalHypotheses()
1218 self.Segment().AutomaticLength(fineness)
1220 self.Triangle().LengthFromEdges()
1223 self.Tetrahedron(NETGEN)
1225 return self.Compute()
1227 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1228 # @param fineness [0,-1] defines mesh fineness
1229 # @return True or False
1230 # @ingroup l3_algos_basic
1231 def AutomaticHexahedralization(self, fineness=0):
1232 dim = self.MeshDimension()
1233 # assign the hypotheses
1234 self.RemoveGlobalHypotheses()
1235 self.Segment().AutomaticLength(fineness)
1242 return self.Compute()
1244 ## Assigns a hypothesis
1245 # @param hyp a hypothesis to assign
1246 # @param geom a subhape of mesh geometry
1247 # @return SMESH.Hypothesis_Status
1248 # @ingroup l2_hypotheses
1249 def AddHypothesis(self, hyp, geom=0):
1250 if isinstance( hyp, Mesh_Algorithm ):
1251 hyp = hyp.GetAlgorithm()
1256 geom = self.mesh.GetShapeToMesh()
1258 status = self.mesh.AddHypothesis(geom, hyp)
1259 isAlgo = hyp._narrow( SMESH_Algo )
1260 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1263 ## Unassigns a hypothesis
1264 # @param hyp a hypothesis to unassign
1265 # @param geom a subshape of mesh geometry
1266 # @return SMESH.Hypothesis_Status
1267 # @ingroup l2_hypotheses
1268 def RemoveHypothesis(self, hyp, geom=0):
1269 if isinstance( hyp, Mesh_Algorithm ):
1270 hyp = hyp.GetAlgorithm()
1275 status = self.mesh.RemoveHypothesis(geom, hyp)
1278 ## Gets the list of hypotheses added on a geometry
1279 # @param geom a subshape of mesh geometry
1280 # @return the sequence of SMESH_Hypothesis
1281 # @ingroup l2_hypotheses
1282 def GetHypothesisList(self, geom):
1283 return self.mesh.GetHypothesisList( geom )
1285 ## Removes all global hypotheses
1286 # @ingroup l2_hypotheses
1287 def RemoveGlobalHypotheses(self):
1288 current_hyps = self.mesh.GetHypothesisList( self.geom )
1289 for hyp in current_hyps:
1290 self.mesh.RemoveHypothesis( self.geom, hyp )
1294 ## Creates a mesh group based on the geometric object \a grp
1295 # and gives a \a name, \n if this parameter is not defined
1296 # the name is the same as the geometric group name \n
1297 # Note: Works like GroupOnGeom().
1298 # @param grp a geometric group, a vertex, an edge, a face or a solid
1299 # @param name the name of the mesh group
1300 # @return SMESH_GroupOnGeom
1301 # @ingroup l2_grps_create
1302 def Group(self, grp, name=""):
1303 return self.GroupOnGeom(grp, name)
1305 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1306 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1307 # @param f the file name
1308 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1309 # @ingroup l2_impexp
1310 def ExportToMED(self, f, version, opt=0):
1311 self.mesh.ExportToMED(f, opt, version)
1313 ## Exports the mesh in a file in MED format
1314 # @param f is the file name
1315 # @param auto_groups boolean parameter for creating/not creating
1316 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1317 # the typical use is auto_groups=false.
1318 # @param version MED format version(MED_V2_1 or MED_V2_2)
1319 # @ingroup l2_impexp
1320 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1321 self.mesh.ExportToMED(f, auto_groups, version)
1323 ## Exports the mesh in a file in DAT format
1324 # @param f the file name
1325 # @ingroup l2_impexp
1326 def ExportDAT(self, f):
1327 self.mesh.ExportDAT(f)
1329 ## Exports the mesh in a file in UNV format
1330 # @param f the file name
1331 # @ingroup l2_impexp
1332 def ExportUNV(self, f):
1333 self.mesh.ExportUNV(f)
1335 ## Export the mesh in a file in STL format
1336 # @param f the file name
1337 # @param ascii defines the file encoding
1338 # @ingroup l2_impexp
1339 def ExportSTL(self, f, ascii=1):
1340 self.mesh.ExportSTL(f, ascii)
1343 # Operations with groups:
1344 # ----------------------
1346 ## Creates an empty mesh group
1347 # @param elementType the type of elements in the group
1348 # @param name the name of the mesh group
1349 # @return SMESH_Group
1350 # @ingroup l2_grps_create
1351 def CreateEmptyGroup(self, elementType, name):
1352 return self.mesh.CreateGroup(elementType, name)
1354 ## Creates a mesh group based on the geometrical object \a grp
1355 # and gives a \a name, \n if this parameter is not defined
1356 # the name is the same as the geometrical group name
1357 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1358 # @param name the name of the mesh group
1359 # @param typ the type of elements in the group. If not set, it is
1360 # automatically detected by the type of the geometry
1361 # @return SMESH_GroupOnGeom
1362 # @ingroup l2_grps_create
1363 def GroupOnGeom(self, grp, name="", typ=None):
1365 name = grp.GetName()
1368 tgeo = str(grp.GetShapeType())
1369 if tgeo == "VERTEX":
1371 elif tgeo == "EDGE":
1373 elif tgeo == "FACE":
1375 elif tgeo == "SOLID":
1377 elif tgeo == "SHELL":
1379 elif tgeo == "COMPOUND":
1380 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1381 print "Mesh.Group: empty geometric group", GetName( grp )
1383 tgeo = self.geompyD.GetType(grp)
1384 if tgeo == geompyDC.ShapeType["VERTEX"]:
1386 elif tgeo == geompyDC.ShapeType["EDGE"]:
1388 elif tgeo == geompyDC.ShapeType["FACE"]:
1390 elif tgeo == geompyDC.ShapeType["SOLID"]:
1394 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1397 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1399 ## Creates a mesh group by the given ids of elements
1400 # @param groupName the name of the mesh group
1401 # @param elementType the type of elements in the group
1402 # @param elemIDs the list of ids
1403 # @return SMESH_Group
1404 # @ingroup l2_grps_create
1405 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1406 group = self.mesh.CreateGroup(elementType, groupName)
1410 ## Creates a mesh group by the given conditions
1411 # @param groupName the name of the mesh group
1412 # @param elementType the type of elements in the group
1413 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1414 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1415 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1416 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1417 # @return SMESH_Group
1418 # @ingroup l2_grps_create
1422 CritType=FT_Undefined,
1425 UnaryOp=FT_Undefined):
1426 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1427 group = self.MakeGroupByCriterion(groupName, aCriterion)
1430 ## Creates a mesh group by the given criterion
1431 # @param groupName the name of the mesh group
1432 # @param Criterion the instance of Criterion class
1433 # @return SMESH_Group
1434 # @ingroup l2_grps_create
1435 def MakeGroupByCriterion(self, groupName, Criterion):
1436 aFilterMgr = self.smeshpyD.CreateFilterManager()
1437 aFilter = aFilterMgr.CreateFilter()
1439 aCriteria.append(Criterion)
1440 aFilter.SetCriteria(aCriteria)
1441 group = self.MakeGroupByFilter(groupName, aFilter)
1444 ## Creates a mesh group by the given criteria (list of criteria)
1445 # @param groupName the name of the mesh group
1446 # @param theCriteria the list of criteria
1447 # @return SMESH_Group
1448 # @ingroup l2_grps_create
1449 def MakeGroupByCriteria(self, groupName, theCriteria):
1450 aFilterMgr = self.smeshpyD.CreateFilterManager()
1451 aFilter = aFilterMgr.CreateFilter()
1452 aFilter.SetCriteria(theCriteria)
1453 group = self.MakeGroupByFilter(groupName, aFilter)
1456 ## Creates a mesh group by the given filter
1457 # @param groupName the name of the mesh group
1458 # @param theFilter the instance of Filter class
1459 # @return SMESH_Group
1460 # @ingroup l2_grps_create
1461 def MakeGroupByFilter(self, groupName, theFilter):
1462 anIds = theFilter.GetElementsId(self.mesh)
1463 anElemType = theFilter.GetElementType()
1464 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1467 ## Passes mesh elements through the given filter and return IDs of fitting elements
1468 # @param theFilter SMESH_Filter
1469 # @return a list of ids
1470 # @ingroup l1_controls
1471 def GetIdsFromFilter(self, theFilter):
1472 return theFilter.GetElementsId(self.mesh)
1474 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1475 # Returns a list of special structures (borders).
1476 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1477 # @ingroup l1_controls
1478 def GetFreeBorders(self):
1479 aFilterMgr = self.smeshpyD.CreateFilterManager()
1480 aPredicate = aFilterMgr.CreateFreeEdges()
1481 aPredicate.SetMesh(self.mesh)
1482 aBorders = aPredicate.GetBorders()
1486 # @ingroup l2_grps_delete
1487 def RemoveGroup(self, group):
1488 self.mesh.RemoveGroup(group)
1490 ## Removes a group with its contents
1491 # @ingroup l2_grps_delete
1492 def RemoveGroupWithContents(self, group):
1493 self.mesh.RemoveGroupWithContents(group)
1495 ## Gets the list of groups existing in the mesh
1496 # @return a sequence of SMESH_GroupBase
1497 # @ingroup l2_grps_create
1498 def GetGroups(self):
1499 return self.mesh.GetGroups()
1501 ## Gets the number of groups existing in the mesh
1502 # @return the quantity of groups as an integer value
1503 # @ingroup l2_grps_create
1505 return self.mesh.NbGroups()
1507 ## Gets the list of names of groups existing in the mesh
1508 # @return list of strings
1509 # @ingroup l2_grps_create
1510 def GetGroupNames(self):
1511 groups = self.GetGroups()
1513 for group in groups:
1514 names.append(group.GetName())
1517 ## Produces a union of two groups
1518 # A new group is created. All mesh elements that are
1519 # present in the initial groups are added to the new one
1520 # @return an instance of SMESH_Group
1521 # @ingroup l2_grps_operon
1522 def UnionGroups(self, group1, group2, name):
1523 return self.mesh.UnionGroups(group1, group2, name)
1525 ## Produces a union list of groups
1526 # New group is created. All mesh elements that are present in
1527 # initial groups are added to the new one
1528 # @return an instance of SMESH_Group
1529 # @ingroup l2_grps_operon
1530 def UnionListOfGroups(self, groups, name):
1531 return self.mesh.UnionListOfGroups(groups, name)
1533 ## Prodices an intersection of two groups
1534 # A new group is created. All mesh elements that are common
1535 # for the two initial groups are added to the new one.
1536 # @return an instance of SMESH_Group
1537 # @ingroup l2_grps_operon
1538 def IntersectGroups(self, group1, group2, name):
1539 return self.mesh.IntersectGroups(group1, group2, name)
1541 ## Produces an intersection of groups
1542 # New group is created. All mesh elements that are present in all
1543 # initial groups simultaneously are added to the new one
1544 # @return an instance of SMESH_Group
1545 # @ingroup l2_grps_operon
1546 def IntersectListOfGroups(self, groups, name):
1547 return self.mesh.IntersectListOfGroups(groups, name)
1549 ## Produces a cut of two groups
1550 # A new group is created. All mesh elements that are present in
1551 # the main group but are not present in the tool group are added to the new one
1552 # @return an instance of SMESH_Group
1553 # @ingroup l2_grps_operon
1554 def CutGroups(self, main_group, tool_group, name):
1555 return self.mesh.CutGroups(main_group, tool_group, name)
1557 ## Produces a cut of groups
1558 # A new group is created. All mesh elements that are present in main groups
1559 # but do not present in tool groups are added to the new one
1560 # @return an instance of SMESH_Group
1561 # @ingroup l2_grps_operon
1562 def CutListOfGroups(self, main_groups, tool_groups, name):
1563 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1565 ## Produces a group of elements with specified element type using list of existing groups
1566 # A new group is created. System
1567 # 1) extract all nodes on which groups elements are built
1568 # 2) combine all elements of specified dimension laying on these nodes
1569 # @return an instance of SMESH_Group
1570 # @ingroup l2_grps_operon
1571 def CreateDimGroup(self, groups, elem_type, name):
1572 return self.mesh.CreateDimGroup(groups, elem_type, name)
1575 ## Convert group on geom into standalone group
1576 # @ingroup l2_grps_delete
1577 def ConvertToStandalone(self, group):
1578 return self.mesh.ConvertToStandalone(group)
1580 # Get some info about mesh:
1581 # ------------------------
1583 ## Returns the log of nodes and elements added or removed
1584 # since the previous clear of the log.
1585 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1586 # @return list of log_block structures:
1591 # @ingroup l1_auxiliary
1592 def GetLog(self, clearAfterGet):
1593 return self.mesh.GetLog(clearAfterGet)
1595 ## Clears the log of nodes and elements added or removed since the previous
1596 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1597 # @ingroup l1_auxiliary
1599 self.mesh.ClearLog()
1601 ## Toggles auto color mode on the object.
1602 # @param theAutoColor the flag which toggles auto color mode.
1603 # @ingroup l1_auxiliary
1604 def SetAutoColor(self, theAutoColor):
1605 self.mesh.SetAutoColor(theAutoColor)
1607 ## Gets flag of object auto color mode.
1608 # @return True or False
1609 # @ingroup l1_auxiliary
1610 def GetAutoColor(self):
1611 return self.mesh.GetAutoColor()
1613 ## Gets the internal ID
1614 # @return integer value, which is the internal Id of the mesh
1615 # @ingroup l1_auxiliary
1617 return self.mesh.GetId()
1620 # @return integer value, which is the study Id of the mesh
1621 # @ingroup l1_auxiliary
1622 def GetStudyId(self):
1623 return self.mesh.GetStudyId()
1625 ## Checks the group names for duplications.
1626 # Consider the maximum group name length stored in MED file.
1627 # @return True or False
1628 # @ingroup l1_auxiliary
1629 def HasDuplicatedGroupNamesMED(self):
1630 return self.mesh.HasDuplicatedGroupNamesMED()
1632 ## Obtains the mesh editor tool
1633 # @return an instance of SMESH_MeshEditor
1634 # @ingroup l1_modifying
1635 def GetMeshEditor(self):
1636 return self.mesh.GetMeshEditor()
1639 # @return an instance of SALOME_MED::MESH
1640 # @ingroup l1_auxiliary
1641 def GetMEDMesh(self):
1642 return self.mesh.GetMEDMesh()
1645 # Get informations about mesh contents:
1646 # ------------------------------------
1648 ## Gets the mesh stattistic
1649 # @return dictionary type element - count of elements
1650 # @ingroup l1_meshinfo
1651 def GetMeshInfo(self, obj = None):
1652 if not obj: obj = self.mesh
1654 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
1655 values = obj.GetMeshInfo()
1656 for i in range(SMESH.Entity_Last._v):
1657 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
1661 ## Returns the number of nodes in the mesh
1662 # @return an integer value
1663 # @ingroup l1_meshinfo
1665 return self.mesh.NbNodes()
1667 ## Returns the number of elements in the mesh
1668 # @return an integer value
1669 # @ingroup l1_meshinfo
1670 def NbElements(self):
1671 return self.mesh.NbElements()
1673 ## Returns the number of 0d elements in the mesh
1674 # @return an integer value
1675 # @ingroup l1_meshinfo
1676 def Nb0DElements(self):
1677 return self.mesh.Nb0DElements()
1679 ## Returns the number of edges in the mesh
1680 # @return an integer value
1681 # @ingroup l1_meshinfo
1683 return self.mesh.NbEdges()
1685 ## Returns the number of edges with the given order in the mesh
1686 # @param elementOrder the order of elements:
1687 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1688 # @return an integer value
1689 # @ingroup l1_meshinfo
1690 def NbEdgesOfOrder(self, elementOrder):
1691 return self.mesh.NbEdgesOfOrder(elementOrder)
1693 ## Returns the number of faces in the mesh
1694 # @return an integer value
1695 # @ingroup l1_meshinfo
1697 return self.mesh.NbFaces()
1699 ## Returns the number of faces with the given order in the mesh
1700 # @param elementOrder the order of elements:
1701 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1702 # @return an integer value
1703 # @ingroup l1_meshinfo
1704 def NbFacesOfOrder(self, elementOrder):
1705 return self.mesh.NbFacesOfOrder(elementOrder)
1707 ## Returns the number of triangles in the mesh
1708 # @return an integer value
1709 # @ingroup l1_meshinfo
1710 def NbTriangles(self):
1711 return self.mesh.NbTriangles()
1713 ## Returns the number of triangles with the given order in the mesh
1714 # @param elementOrder is the order of elements:
1715 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1716 # @return an integer value
1717 # @ingroup l1_meshinfo
1718 def NbTrianglesOfOrder(self, elementOrder):
1719 return self.mesh.NbTrianglesOfOrder(elementOrder)
1721 ## Returns the number of quadrangles in the mesh
1722 # @return an integer value
1723 # @ingroup l1_meshinfo
1724 def NbQuadrangles(self):
1725 return self.mesh.NbQuadrangles()
1727 ## Returns the number of quadrangles with the given order in the mesh
1728 # @param elementOrder the order of elements:
1729 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1730 # @return an integer value
1731 # @ingroup l1_meshinfo
1732 def NbQuadranglesOfOrder(self, elementOrder):
1733 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1735 ## Returns the number of polygons in the mesh
1736 # @return an integer value
1737 # @ingroup l1_meshinfo
1738 def NbPolygons(self):
1739 return self.mesh.NbPolygons()
1741 ## Returns the number of volumes in the mesh
1742 # @return an integer value
1743 # @ingroup l1_meshinfo
1744 def NbVolumes(self):
1745 return self.mesh.NbVolumes()
1747 ## Returns the number of volumes with the given order in the mesh
1748 # @param elementOrder the order of elements:
1749 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1750 # @return an integer value
1751 # @ingroup l1_meshinfo
1752 def NbVolumesOfOrder(self, elementOrder):
1753 return self.mesh.NbVolumesOfOrder(elementOrder)
1755 ## Returns the number of tetrahedrons in the mesh
1756 # @return an integer value
1757 # @ingroup l1_meshinfo
1759 return self.mesh.NbTetras()
1761 ## Returns the number of tetrahedrons with the given order in the mesh
1762 # @param elementOrder the order of elements:
1763 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1764 # @return an integer value
1765 # @ingroup l1_meshinfo
1766 def NbTetrasOfOrder(self, elementOrder):
1767 return self.mesh.NbTetrasOfOrder(elementOrder)
1769 ## Returns the number of hexahedrons in the mesh
1770 # @return an integer value
1771 # @ingroup l1_meshinfo
1773 return self.mesh.NbHexas()
1775 ## Returns the number of hexahedrons with the given order in the mesh
1776 # @param elementOrder the order of elements:
1777 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1778 # @return an integer value
1779 # @ingroup l1_meshinfo
1780 def NbHexasOfOrder(self, elementOrder):
1781 return self.mesh.NbHexasOfOrder(elementOrder)
1783 ## Returns the number of pyramids in the mesh
1784 # @return an integer value
1785 # @ingroup l1_meshinfo
1786 def NbPyramids(self):
1787 return self.mesh.NbPyramids()
1789 ## Returns the number of pyramids with the given order in the mesh
1790 # @param elementOrder the order of elements:
1791 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1792 # @return an integer value
1793 # @ingroup l1_meshinfo
1794 def NbPyramidsOfOrder(self, elementOrder):
1795 return self.mesh.NbPyramidsOfOrder(elementOrder)
1797 ## Returns the number of prisms in the mesh
1798 # @return an integer value
1799 # @ingroup l1_meshinfo
1801 return self.mesh.NbPrisms()
1803 ## Returns the number of prisms with the given order in the mesh
1804 # @param elementOrder the order of elements:
1805 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1806 # @return an integer value
1807 # @ingroup l1_meshinfo
1808 def NbPrismsOfOrder(self, elementOrder):
1809 return self.mesh.NbPrismsOfOrder(elementOrder)
1811 ## Returns the number of polyhedrons in the mesh
1812 # @return an integer value
1813 # @ingroup l1_meshinfo
1814 def NbPolyhedrons(self):
1815 return self.mesh.NbPolyhedrons()
1817 ## Returns the number of submeshes in the mesh
1818 # @return an integer value
1819 # @ingroup l1_meshinfo
1820 def NbSubMesh(self):
1821 return self.mesh.NbSubMesh()
1823 ## Returns the list of mesh elements IDs
1824 # @return the list of integer values
1825 # @ingroup l1_meshinfo
1826 def GetElementsId(self):
1827 return self.mesh.GetElementsId()
1829 ## Returns the list of IDs of mesh elements with the given type
1830 # @param elementType the required type of elements
1831 # @return list of integer values
1832 # @ingroup l1_meshinfo
1833 def GetElementsByType(self, elementType):
1834 return self.mesh.GetElementsByType(elementType)
1836 ## Returns the list of mesh nodes IDs
1837 # @return the list of integer values
1838 # @ingroup l1_meshinfo
1839 def GetNodesId(self):
1840 return self.mesh.GetNodesId()
1842 # Get the information about mesh elements:
1843 # ------------------------------------
1845 ## Returns the type of mesh element
1846 # @return the value from SMESH::ElementType enumeration
1847 # @ingroup l1_meshinfo
1848 def GetElementType(self, id, iselem):
1849 return self.mesh.GetElementType(id, iselem)
1851 ## Returns the list of submesh elements IDs
1852 # @param Shape a geom object(subshape) IOR
1853 # Shape must be the subshape of a ShapeToMesh()
1854 # @return the list of integer values
1855 # @ingroup l1_meshinfo
1856 def GetSubMeshElementsId(self, Shape):
1857 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1858 ShapeID = Shape.GetSubShapeIndices()[0]
1861 return self.mesh.GetSubMeshElementsId(ShapeID)
1863 ## Returns the list of submesh nodes IDs
1864 # @param Shape a geom object(subshape) IOR
1865 # Shape must be the subshape of a ShapeToMesh()
1866 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1867 # @return the list of integer values
1868 # @ingroup l1_meshinfo
1869 def GetSubMeshNodesId(self, Shape, all):
1870 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1871 ShapeID = Shape.GetSubShapeIndices()[0]
1874 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1876 ## Returns type of elements on given shape
1877 # @param Shape a geom object(subshape) IOR
1878 # Shape must be a subshape of a ShapeToMesh()
1879 # @return element type
1880 # @ingroup l1_meshinfo
1881 def GetSubMeshElementType(self, Shape):
1882 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1883 ShapeID = Shape.GetSubShapeIndices()[0]
1886 return self.mesh.GetSubMeshElementType(ShapeID)
1888 ## Gets the mesh description
1889 # @return string value
1890 # @ingroup l1_meshinfo
1892 return self.mesh.Dump()
1895 # Get the information about nodes and elements of a mesh by its IDs:
1896 # -----------------------------------------------------------
1898 ## Gets XYZ coordinates of a node
1899 # \n If there is no nodes for the given ID - returns an empty list
1900 # @return a list of double precision values
1901 # @ingroup l1_meshinfo
1902 def GetNodeXYZ(self, id):
1903 return self.mesh.GetNodeXYZ(id)
1905 ## Returns list of IDs of inverse elements for the given node
1906 # \n If there is no node for the given ID - returns an empty list
1907 # @return a list of integer values
1908 # @ingroup l1_meshinfo
1909 def GetNodeInverseElements(self, id):
1910 return self.mesh.GetNodeInverseElements(id)
1912 ## @brief Returns the position of a node on the shape
1913 # @return SMESH::NodePosition
1914 # @ingroup l1_meshinfo
1915 def GetNodePosition(self,NodeID):
1916 return self.mesh.GetNodePosition(NodeID)
1918 ## If the given element is a node, returns the ID of shape
1919 # \n If there is no node for the given ID - returns -1
1920 # @return an integer value
1921 # @ingroup l1_meshinfo
1922 def GetShapeID(self, id):
1923 return self.mesh.GetShapeID(id)
1925 ## Returns the ID of the result shape after
1926 # FindShape() from SMESH_MeshEditor for the given element
1927 # \n If there is no element for the given ID - returns -1
1928 # @return an integer value
1929 # @ingroup l1_meshinfo
1930 def GetShapeIDForElem(self,id):
1931 return self.mesh.GetShapeIDForElem(id)
1933 ## Returns the number of nodes for the given element
1934 # \n If there is no element for the given ID - returns -1
1935 # @return an integer value
1936 # @ingroup l1_meshinfo
1937 def GetElemNbNodes(self, id):
1938 return self.mesh.GetElemNbNodes(id)
1940 ## Returns the node ID the given index for the given element
1941 # \n If there is no element for the given ID - returns -1
1942 # \n If there is no node for the given index - returns -2
1943 # @return an integer value
1944 # @ingroup l1_meshinfo
1945 def GetElemNode(self, id, index):
1946 return self.mesh.GetElemNode(id, index)
1948 ## Returns the IDs of nodes of the given element
1949 # @return a list of integer values
1950 # @ingroup l1_meshinfo
1951 def GetElemNodes(self, id):
1952 return self.mesh.GetElemNodes(id)
1954 ## Returns true if the given node is the medium node in the given quadratic element
1955 # @ingroup l1_meshinfo
1956 def IsMediumNode(self, elementID, nodeID):
1957 return self.mesh.IsMediumNode(elementID, nodeID)
1959 ## Returns true if the given node is the medium node in one of quadratic elements
1960 # @ingroup l1_meshinfo
1961 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1962 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1964 ## Returns the number of edges for the given element
1965 # @ingroup l1_meshinfo
1966 def ElemNbEdges(self, id):
1967 return self.mesh.ElemNbEdges(id)
1969 ## Returns the number of faces for the given element
1970 # @ingroup l1_meshinfo
1971 def ElemNbFaces(self, id):
1972 return self.mesh.ElemNbFaces(id)
1974 ## Returns true if the given element is a polygon
1975 # @ingroup l1_meshinfo
1976 def IsPoly(self, id):
1977 return self.mesh.IsPoly(id)
1979 ## Returns true if the given element is quadratic
1980 # @ingroup l1_meshinfo
1981 def IsQuadratic(self, id):
1982 return self.mesh.IsQuadratic(id)
1984 ## Returns XYZ coordinates of the barycenter of the given element
1985 # \n If there is no element for the given ID - returns an empty list
1986 # @return a list of three double values
1987 # @ingroup l1_meshinfo
1988 def BaryCenter(self, id):
1989 return self.mesh.BaryCenter(id)
1992 # Mesh edition (SMESH_MeshEditor functionality):
1993 # ---------------------------------------------
1995 ## Removes the elements from the mesh by ids
1996 # @param IDsOfElements is a list of ids of elements to remove
1997 # @return True or False
1998 # @ingroup l2_modif_del
1999 def RemoveElements(self, IDsOfElements):
2000 return self.editor.RemoveElements(IDsOfElements)
2002 ## Removes nodes from mesh by ids
2003 # @param IDsOfNodes is a list of ids of nodes to remove
2004 # @return True or False
2005 # @ingroup l2_modif_del
2006 def RemoveNodes(self, IDsOfNodes):
2007 return self.editor.RemoveNodes(IDsOfNodes)
2009 ## Add a node to the mesh by coordinates
2010 # @return Id of the new node
2011 # @ingroup l2_modif_add
2012 def AddNode(self, x, y, z):
2013 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2014 self.mesh.SetParameters(Parameters)
2015 return self.editor.AddNode( x, y, z)
2017 ## Creates a 0D element on a node with given number.
2018 # @param IDOfNode the ID of node for creation of the element.
2019 # @return the Id of the new 0D element
2020 # @ingroup l2_modif_add
2021 def Add0DElement(self, IDOfNode):
2022 return self.editor.Add0DElement(IDOfNode)
2024 ## Creates a linear or quadratic edge (this is determined
2025 # by the number of given nodes).
2026 # @param IDsOfNodes the list of node IDs for creation of the element.
2027 # The order of nodes in this list should correspond to the description
2028 # of MED. \n This description is located by the following link:
2029 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2030 # @return the Id of the new edge
2031 # @ingroup l2_modif_add
2032 def AddEdge(self, IDsOfNodes):
2033 return self.editor.AddEdge(IDsOfNodes)
2035 ## Creates a linear or quadratic face (this is determined
2036 # by the number of given nodes).
2037 # @param IDsOfNodes the list of node IDs for creation of the element.
2038 # The order of nodes in this list should correspond to the description
2039 # of MED. \n This description is located by the following link:
2040 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2041 # @return the Id of the new face
2042 # @ingroup l2_modif_add
2043 def AddFace(self, IDsOfNodes):
2044 return self.editor.AddFace(IDsOfNodes)
2046 ## Adds a polygonal face to the mesh by the list of node IDs
2047 # @param IdsOfNodes the list of node IDs for creation of the element.
2048 # @return the Id of the new face
2049 # @ingroup l2_modif_add
2050 def AddPolygonalFace(self, IdsOfNodes):
2051 return self.editor.AddPolygonalFace(IdsOfNodes)
2053 ## Creates both simple and quadratic volume (this is determined
2054 # by the number of given nodes).
2055 # @param IDsOfNodes the list of node IDs for creation of the element.
2056 # The order of nodes in this list should correspond to the description
2057 # of MED. \n This description is located by the following link:
2058 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2059 # @return the Id of the new volumic element
2060 # @ingroup l2_modif_add
2061 def AddVolume(self, IDsOfNodes):
2062 return self.editor.AddVolume(IDsOfNodes)
2064 ## Creates a volume of many faces, giving nodes for each face.
2065 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2066 # @param Quantities the list of integer values, Quantities[i]
2067 # gives the quantity of nodes in face number i.
2068 # @return the Id of the new volumic element
2069 # @ingroup l2_modif_add
2070 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2071 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2073 ## Creates a volume of many faces, giving the IDs of the existing faces.
2074 # @param IdsOfFaces the list of face IDs for volume creation.
2076 # Note: The created volume will refer only to the nodes
2077 # of the given faces, not to the faces themselves.
2078 # @return the Id of the new volumic element
2079 # @ingroup l2_modif_add
2080 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2081 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2084 ## @brief Binds a node to a vertex
2085 # @param NodeID a node ID
2086 # @param Vertex a vertex or vertex ID
2087 # @return True if succeed else raises an exception
2088 # @ingroup l2_modif_add
2089 def SetNodeOnVertex(self, NodeID, Vertex):
2090 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2091 VertexID = Vertex.GetSubShapeIndices()[0]
2095 self.editor.SetNodeOnVertex(NodeID, VertexID)
2096 except SALOME.SALOME_Exception, inst:
2097 raise ValueError, inst.details.text
2101 ## @brief Stores the node position on an edge
2102 # @param NodeID a node ID
2103 # @param Edge an edge or edge ID
2104 # @param paramOnEdge a parameter on the edge where the node is located
2105 # @return True if succeed else raises an exception
2106 # @ingroup l2_modif_add
2107 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2108 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2109 EdgeID = Edge.GetSubShapeIndices()[0]
2113 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2114 except SALOME.SALOME_Exception, inst:
2115 raise ValueError, inst.details.text
2118 ## @brief Stores node position on a face
2119 # @param NodeID a node ID
2120 # @param Face a face or face ID
2121 # @param u U parameter on the face where the node is located
2122 # @param v V parameter on the face where the node is located
2123 # @return True if succeed else raises an exception
2124 # @ingroup l2_modif_add
2125 def SetNodeOnFace(self, NodeID, Face, u, v):
2126 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2127 FaceID = Face.GetSubShapeIndices()[0]
2131 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2132 except SALOME.SALOME_Exception, inst:
2133 raise ValueError, inst.details.text
2136 ## @brief Binds a node to a solid
2137 # @param NodeID a node ID
2138 # @param Solid a solid or solid ID
2139 # @return True if succeed else raises an exception
2140 # @ingroup l2_modif_add
2141 def SetNodeInVolume(self, NodeID, Solid):
2142 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2143 SolidID = Solid.GetSubShapeIndices()[0]
2147 self.editor.SetNodeInVolume(NodeID, SolidID)
2148 except SALOME.SALOME_Exception, inst:
2149 raise ValueError, inst.details.text
2152 ## @brief Bind an element to a shape
2153 # @param ElementID an element ID
2154 # @param Shape a shape or shape ID
2155 # @return True if succeed else raises an exception
2156 # @ingroup l2_modif_add
2157 def SetMeshElementOnShape(self, ElementID, Shape):
2158 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2159 ShapeID = Shape.GetSubShapeIndices()[0]
2163 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2164 except SALOME.SALOME_Exception, inst:
2165 raise ValueError, inst.details.text
2169 ## Moves the node with the given id
2170 # @param NodeID the id of the node
2171 # @param x a new X coordinate
2172 # @param y a new Y coordinate
2173 # @param z a new Z coordinate
2174 # @return True if succeed else False
2175 # @ingroup l2_modif_movenode
2176 def MoveNode(self, NodeID, x, y, z):
2177 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2178 self.mesh.SetParameters(Parameters)
2179 return self.editor.MoveNode(NodeID, x, y, z)
2181 ## Finds the node closest to a point and moves it to a point location
2182 # @param x the X coordinate of a point
2183 # @param y the Y coordinate of a point
2184 # @param z the Z coordinate of a point
2185 # @return the ID of a node
2186 # @ingroup l2_modif_throughp
2187 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2188 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2189 self.mesh.SetParameters(Parameters)
2190 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2192 ## Finds the node closest to a point
2193 # @param x the X coordinate of a point
2194 # @param y the Y coordinate of a point
2195 # @param z the Z coordinate of a point
2196 # @return the ID of a node
2197 # @ingroup l2_modif_throughp
2198 def FindNodeClosestTo(self, x, y, z):
2199 #preview = self.mesh.GetMeshEditPreviewer()
2200 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2201 return self.editor.FindNodeClosestTo(x, y, z)
2203 ## Finds the elements where a point lays IN or ON
2204 # @param x the X coordinate of a point
2205 # @param y the Y coordinate of a point
2206 # @param z the Z coordinate of a point
2207 # @param elementType type of elements to find (SMESH.ALL type
2208 # means elements of any type excluding nodes and 0D elements)
2209 # @return list of IDs of found elements
2210 # @ingroup l2_modif_throughp
2211 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2212 return self.editor.FindElementsByPoint(x, y, z, elementType)
2215 ## Finds the node closest to a point and moves it to a point location
2216 # @param x the X coordinate of a point
2217 # @param y the Y coordinate of a point
2218 # @param z the Z coordinate of a point
2219 # @return the ID of a moved node
2220 # @ingroup l2_modif_throughp
2221 def MeshToPassThroughAPoint(self, x, y, z):
2222 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2224 ## Replaces two neighbour triangles sharing Node1-Node2 link
2225 # with the triangles built on the same 4 nodes but having other common link.
2226 # @param NodeID1 the ID of the first node
2227 # @param NodeID2 the ID of the second node
2228 # @return false if proper faces were not found
2229 # @ingroup l2_modif_invdiag
2230 def InverseDiag(self, NodeID1, NodeID2):
2231 return self.editor.InverseDiag(NodeID1, NodeID2)
2233 ## Replaces two neighbour triangles sharing Node1-Node2 link
2234 # with a quadrangle built on the same 4 nodes.
2235 # @param NodeID1 the ID of the first node
2236 # @param NodeID2 the ID of the second node
2237 # @return false if proper faces were not found
2238 # @ingroup l2_modif_unitetri
2239 def DeleteDiag(self, NodeID1, NodeID2):
2240 return self.editor.DeleteDiag(NodeID1, NodeID2)
2242 ## Reorients elements by ids
2243 # @param IDsOfElements if undefined reorients all mesh elements
2244 # @return True if succeed else False
2245 # @ingroup l2_modif_changori
2246 def Reorient(self, IDsOfElements=None):
2247 if IDsOfElements == None:
2248 IDsOfElements = self.GetElementsId()
2249 return self.editor.Reorient(IDsOfElements)
2251 ## Reorients all elements of the object
2252 # @param theObject mesh, submesh or group
2253 # @return True if succeed else False
2254 # @ingroup l2_modif_changori
2255 def ReorientObject(self, theObject):
2256 if ( isinstance( theObject, Mesh )):
2257 theObject = theObject.GetMesh()
2258 return self.editor.ReorientObject(theObject)
2260 ## Fuses the neighbouring triangles into quadrangles.
2261 # @param IDsOfElements The triangles to be fused,
2262 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2263 # @param MaxAngle is the maximum angle between element normals at which the fusion
2264 # is still performed; theMaxAngle is mesured in radians.
2265 # Also it could be a name of variable which defines angle in degrees.
2266 # @return TRUE in case of success, FALSE otherwise.
2267 # @ingroup l2_modif_unitetri
2268 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2270 if isinstance(MaxAngle,str):
2272 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2274 MaxAngle = DegreesToRadians(MaxAngle)
2275 if IDsOfElements == []:
2276 IDsOfElements = self.GetElementsId()
2277 self.mesh.SetParameters(Parameters)
2279 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2280 Functor = theCriterion
2282 Functor = self.smeshpyD.GetFunctor(theCriterion)
2283 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2285 ## Fuses the neighbouring triangles of the object into quadrangles
2286 # @param theObject is mesh, submesh or group
2287 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2288 # @param MaxAngle a max angle between element normals at which the fusion
2289 # is still performed; theMaxAngle is mesured in radians.
2290 # @return TRUE in case of success, FALSE otherwise.
2291 # @ingroup l2_modif_unitetri
2292 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2293 if ( isinstance( theObject, Mesh )):
2294 theObject = theObject.GetMesh()
2295 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2297 ## Splits quadrangles into triangles.
2298 # @param IDsOfElements the faces to be splitted.
2299 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2300 # @return TRUE in case of success, FALSE otherwise.
2301 # @ingroup l2_modif_cutquadr
2302 def QuadToTri (self, IDsOfElements, theCriterion):
2303 if IDsOfElements == []:
2304 IDsOfElements = self.GetElementsId()
2305 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2307 ## Splits quadrangles into triangles.
2308 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2309 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2310 # @return TRUE in case of success, FALSE otherwise.
2311 # @ingroup l2_modif_cutquadr
2312 def QuadToTriObject (self, theObject, theCriterion):
2313 if ( isinstance( theObject, Mesh )):
2314 theObject = theObject.GetMesh()
2315 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2317 ## Splits quadrangles into triangles.
2318 # @param IDsOfElements the faces to be splitted
2319 # @param Diag13 is used to choose a diagonal for splitting.
2320 # @return TRUE in case of success, FALSE otherwise.
2321 # @ingroup l2_modif_cutquadr
2322 def SplitQuad (self, IDsOfElements, Diag13):
2323 if IDsOfElements == []:
2324 IDsOfElements = self.GetElementsId()
2325 return self.editor.SplitQuad(IDsOfElements, Diag13)
2327 ## Splits quadrangles into triangles.
2328 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2329 # @param Diag13 is used to choose a diagonal for splitting.
2330 # @return TRUE in case of success, FALSE otherwise.
2331 # @ingroup l2_modif_cutquadr
2332 def SplitQuadObject (self, theObject, Diag13):
2333 if ( isinstance( theObject, Mesh )):
2334 theObject = theObject.GetMesh()
2335 return self.editor.SplitQuadObject(theObject, Diag13)
2337 ## Finds a better splitting of the given quadrangle.
2338 # @param IDOfQuad the ID of the quadrangle to be splitted.
2339 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2340 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2341 # diagonal is better, 0 if error occurs.
2342 # @ingroup l2_modif_cutquadr
2343 def BestSplit (self, IDOfQuad, theCriterion):
2344 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2346 ## Splits quadrangle faces near triangular facets of volumes
2348 # @ingroup l1_auxiliary
2349 def SplitQuadsNearTriangularFacets(self):
2350 faces_array = self.GetElementsByType(SMESH.FACE)
2351 for face_id in faces_array:
2352 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2353 quad_nodes = self.mesh.GetElemNodes(face_id)
2354 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2355 isVolumeFound = False
2356 for node1_elem in node1_elems:
2357 if not isVolumeFound:
2358 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2359 nb_nodes = self.GetElemNbNodes(node1_elem)
2360 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2361 volume_elem = node1_elem
2362 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2363 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2364 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2365 isVolumeFound = True
2366 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2367 self.SplitQuad([face_id], False) # diagonal 2-4
2368 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2369 isVolumeFound = True
2370 self.SplitQuad([face_id], True) # diagonal 1-3
2371 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2372 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2373 isVolumeFound = True
2374 self.SplitQuad([face_id], True) # diagonal 1-3
2376 ## @brief Splits hexahedrons into tetrahedrons.
2378 # This operation uses pattern mapping functionality for splitting.
2379 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2380 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2381 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2382 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2383 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2384 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2385 # @return TRUE in case of success, FALSE otherwise.
2386 # @ingroup l1_auxiliary
2387 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2388 # Pattern: 5.---------.6
2393 # (0,0,1) 4.---------.7 * |
2400 # (0,0,0) 0.---------.3
2401 pattern_tetra = "!!! Nb of points: \n 8 \n\
2411 !!! Indices of points of 6 tetras: \n\
2419 pattern = self.smeshpyD.GetPattern()
2420 isDone = pattern.LoadFromFile(pattern_tetra)
2422 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2425 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2426 isDone = pattern.MakeMesh(self.mesh, False, False)
2427 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2429 # split quafrangle faces near triangular facets of volumes
2430 self.SplitQuadsNearTriangularFacets()
2434 ## @brief Split hexahedrons into prisms.
2436 # Uses the pattern mapping functionality for splitting.
2437 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2438 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2439 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2440 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2441 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2442 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2443 # @return TRUE in case of success, FALSE otherwise.
2444 # @ingroup l1_auxiliary
2445 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2446 # Pattern: 5.---------.6
2451 # (0,0,1) 4.---------.7 |
2458 # (0,0,0) 0.---------.3
2459 pattern_prism = "!!! Nb of points: \n 8 \n\
2469 !!! Indices of points of 2 prisms: \n\
2473 pattern = self.smeshpyD.GetPattern()
2474 isDone = pattern.LoadFromFile(pattern_prism)
2476 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2479 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2480 isDone = pattern.MakeMesh(self.mesh, False, False)
2481 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2483 # Splits quafrangle faces near triangular facets of volumes
2484 self.SplitQuadsNearTriangularFacets()
2488 ## Smoothes elements
2489 # @param IDsOfElements the list if ids of elements to smooth
2490 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2491 # Note that nodes built on edges and boundary nodes are always fixed.
2492 # @param MaxNbOfIterations the maximum number of iterations
2493 # @param MaxAspectRatio varies in range [1.0, inf]
2494 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2495 # @return TRUE in case of success, FALSE otherwise.
2496 # @ingroup l2_modif_smooth
2497 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2498 MaxNbOfIterations, MaxAspectRatio, Method):
2499 if IDsOfElements == []:
2500 IDsOfElements = self.GetElementsId()
2501 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2502 self.mesh.SetParameters(Parameters)
2503 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2504 MaxNbOfIterations, MaxAspectRatio, Method)
2506 ## Smoothes elements which belong to the given object
2507 # @param theObject the object to smooth
2508 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2509 # Note that nodes built on edges and boundary nodes are always fixed.
2510 # @param MaxNbOfIterations the maximum number of iterations
2511 # @param MaxAspectRatio varies in range [1.0, inf]
2512 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2513 # @return TRUE in case of success, FALSE otherwise.
2514 # @ingroup l2_modif_smooth
2515 def SmoothObject(self, theObject, IDsOfFixedNodes,
2516 MaxNbOfIterations, MaxAspectRatio, Method):
2517 if ( isinstance( theObject, Mesh )):
2518 theObject = theObject.GetMesh()
2519 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2520 MaxNbOfIterations, MaxAspectRatio, Method)
2522 ## Parametrically smoothes the given elements
2523 # @param IDsOfElements the list if ids of elements to smooth
2524 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2525 # Note that nodes built on edges and boundary nodes are always fixed.
2526 # @param MaxNbOfIterations the maximum number of iterations
2527 # @param MaxAspectRatio varies in range [1.0, inf]
2528 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2529 # @return TRUE in case of success, FALSE otherwise.
2530 # @ingroup l2_modif_smooth
2531 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2532 MaxNbOfIterations, MaxAspectRatio, Method):
2533 if IDsOfElements == []:
2534 IDsOfElements = self.GetElementsId()
2535 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2536 self.mesh.SetParameters(Parameters)
2537 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2538 MaxNbOfIterations, MaxAspectRatio, Method)
2540 ## Parametrically smoothes the elements which belong to the given object
2541 # @param theObject the object to smooth
2542 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2543 # Note that nodes built on edges and boundary nodes are always fixed.
2544 # @param MaxNbOfIterations the maximum number of iterations
2545 # @param MaxAspectRatio varies in range [1.0, inf]
2546 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2547 # @return TRUE in case of success, FALSE otherwise.
2548 # @ingroup l2_modif_smooth
2549 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2550 MaxNbOfIterations, MaxAspectRatio, Method):
2551 if ( isinstance( theObject, Mesh )):
2552 theObject = theObject.GetMesh()
2553 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2554 MaxNbOfIterations, MaxAspectRatio, Method)
2556 ## Converts the mesh to quadratic, deletes old elements, replacing
2557 # them with quadratic with the same id.
2558 # @ingroup l2_modif_tofromqu
2559 def ConvertToQuadratic(self, theForce3d):
2560 self.editor.ConvertToQuadratic(theForce3d)
2562 ## Converts the mesh from quadratic to ordinary,
2563 # deletes old quadratic elements, \n replacing
2564 # them with ordinary mesh elements with the same id.
2565 # @return TRUE in case of success, FALSE otherwise.
2566 # @ingroup l2_modif_tofromqu
2567 def ConvertFromQuadratic(self):
2568 return self.editor.ConvertFromQuadratic()
2570 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2571 # @return TRUE if operation has been completed successfully, FALSE otherwise
2572 # @ingroup l2_modif_edit
2573 def Make2DMeshFrom3D(self):
2574 return self.editor. Make2DMeshFrom3D()
2576 ## Renumber mesh nodes
2577 # @ingroup l2_modif_renumber
2578 def RenumberNodes(self):
2579 self.editor.RenumberNodes()
2581 ## Renumber mesh elements
2582 # @ingroup l2_modif_renumber
2583 def RenumberElements(self):
2584 self.editor.RenumberElements()
2586 ## Generates new elements by rotation of the elements around the axis
2587 # @param IDsOfElements the list of ids of elements to sweep
2588 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2589 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2590 # @param NbOfSteps the number of steps
2591 # @param Tolerance tolerance
2592 # @param MakeGroups forces the generation of new groups from existing ones
2593 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2594 # of all steps, else - size of each step
2595 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2596 # @ingroup l2_modif_extrurev
2597 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2598 MakeGroups=False, TotalAngle=False):
2600 if isinstance(AngleInRadians,str):
2602 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2604 AngleInRadians = DegreesToRadians(AngleInRadians)
2605 if IDsOfElements == []:
2606 IDsOfElements = self.GetElementsId()
2607 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2608 Axis = self.smeshpyD.GetAxisStruct(Axis)
2609 Axis,AxisParameters = ParseAxisStruct(Axis)
2610 if TotalAngle and NbOfSteps:
2611 AngleInRadians /= NbOfSteps
2612 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2613 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2614 self.mesh.SetParameters(Parameters)
2616 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2617 AngleInRadians, NbOfSteps, Tolerance)
2618 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2621 ## Generates new elements by rotation of the elements of object around the axis
2622 # @param theObject object which elements should be sweeped
2623 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2624 # @param AngleInRadians the angle of Rotation
2625 # @param NbOfSteps number of steps
2626 # @param Tolerance tolerance
2627 # @param MakeGroups forces the generation of new groups from existing ones
2628 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2629 # of all steps, else - size of each step
2630 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2631 # @ingroup l2_modif_extrurev
2632 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2633 MakeGroups=False, TotalAngle=False):
2635 if isinstance(AngleInRadians,str):
2637 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2639 AngleInRadians = DegreesToRadians(AngleInRadians)
2640 if ( isinstance( theObject, Mesh )):
2641 theObject = theObject.GetMesh()
2642 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2643 Axis = self.smeshpyD.GetAxisStruct(Axis)
2644 Axis,AxisParameters = ParseAxisStruct(Axis)
2645 if TotalAngle and NbOfSteps:
2646 AngleInRadians /= NbOfSteps
2647 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2648 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2649 self.mesh.SetParameters(Parameters)
2651 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2652 NbOfSteps, Tolerance)
2653 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2656 ## Generates new elements by rotation of the elements of object around the axis
2657 # @param theObject object which elements should be sweeped
2658 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2659 # @param AngleInRadians the angle of Rotation
2660 # @param NbOfSteps number of steps
2661 # @param Tolerance tolerance
2662 # @param MakeGroups forces the generation of new groups from existing ones
2663 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2664 # of all steps, else - size of each step
2665 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2666 # @ingroup l2_modif_extrurev
2667 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2668 MakeGroups=False, TotalAngle=False):
2670 if isinstance(AngleInRadians,str):
2672 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2674 AngleInRadians = DegreesToRadians(AngleInRadians)
2675 if ( isinstance( theObject, Mesh )):
2676 theObject = theObject.GetMesh()
2677 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2678 Axis = self.smeshpyD.GetAxisStruct(Axis)
2679 Axis,AxisParameters = ParseAxisStruct(Axis)
2680 if TotalAngle and NbOfSteps:
2681 AngleInRadians /= NbOfSteps
2682 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2683 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2684 self.mesh.SetParameters(Parameters)
2686 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2687 NbOfSteps, Tolerance)
2688 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2691 ## Generates new elements by rotation of the elements of object around the axis
2692 # @param theObject object which elements should be sweeped
2693 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2694 # @param AngleInRadians the angle of Rotation
2695 # @param NbOfSteps number of steps
2696 # @param Tolerance tolerance
2697 # @param MakeGroups forces the generation of new groups from existing ones
2698 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2699 # of all steps, else - size of each step
2700 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2701 # @ingroup l2_modif_extrurev
2702 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2703 MakeGroups=False, TotalAngle=False):
2705 if isinstance(AngleInRadians,str):
2707 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2709 AngleInRadians = DegreesToRadians(AngleInRadians)
2710 if ( isinstance( theObject, Mesh )):
2711 theObject = theObject.GetMesh()
2712 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2713 Axis = self.smeshpyD.GetAxisStruct(Axis)
2714 Axis,AxisParameters = ParseAxisStruct(Axis)
2715 if TotalAngle and NbOfSteps:
2716 AngleInRadians /= NbOfSteps
2717 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2718 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2719 self.mesh.SetParameters(Parameters)
2721 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2722 NbOfSteps, Tolerance)
2723 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2726 ## Generates new elements by extrusion of the elements with given ids
2727 # @param IDsOfElements the list of elements ids for extrusion
2728 # @param StepVector vector, defining the direction and value of extrusion
2729 # @param NbOfSteps the number of steps
2730 # @param MakeGroups forces the generation of new groups from existing ones
2731 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2732 # @ingroup l2_modif_extrurev
2733 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2734 if IDsOfElements == []:
2735 IDsOfElements = self.GetElementsId()
2736 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2737 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2738 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2739 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2740 Parameters = StepVectorParameters + var_separator + Parameters
2741 self.mesh.SetParameters(Parameters)
2743 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2744 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2747 ## Generates new elements by extrusion of the elements with given ids
2748 # @param IDsOfElements is ids of elements
2749 # @param StepVector vector, defining the direction and value of extrusion
2750 # @param NbOfSteps the number of steps
2751 # @param ExtrFlags sets flags for extrusion
2752 # @param SewTolerance uses for comparing locations of nodes if flag
2753 # EXTRUSION_FLAG_SEW is set
2754 # @param MakeGroups forces the generation of new groups from existing ones
2755 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2756 # @ingroup l2_modif_extrurev
2757 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2758 ExtrFlags, SewTolerance, MakeGroups=False):
2759 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2760 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2762 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2763 ExtrFlags, SewTolerance)
2764 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2765 ExtrFlags, SewTolerance)
2768 ## Generates new elements by extrusion of the elements which belong to the object
2769 # @param theObject the object which elements should be processed
2770 # @param StepVector vector, defining the direction and value of extrusion
2771 # @param NbOfSteps the number of steps
2772 # @param MakeGroups forces the generation of new groups from existing ones
2773 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2774 # @ingroup l2_modif_extrurev
2775 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2776 if ( isinstance( theObject, Mesh )):
2777 theObject = theObject.GetMesh()
2778 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2779 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2780 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2781 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2782 Parameters = StepVectorParameters + var_separator + Parameters
2783 self.mesh.SetParameters(Parameters)
2785 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2786 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2789 ## Generates new elements by extrusion of the elements which belong to the object
2790 # @param theObject object which elements should be processed
2791 # @param StepVector vector, defining the direction and value of extrusion
2792 # @param NbOfSteps the number of steps
2793 # @param MakeGroups to generate new groups from existing ones
2794 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2795 # @ingroup l2_modif_extrurev
2796 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2797 if ( isinstance( theObject, Mesh )):
2798 theObject = theObject.GetMesh()
2799 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2800 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2801 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2802 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2803 Parameters = StepVectorParameters + var_separator + Parameters
2804 self.mesh.SetParameters(Parameters)
2806 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2807 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2810 ## Generates new elements by extrusion of the elements which belong to the object
2811 # @param theObject object which elements should be processed
2812 # @param StepVector vector, defining the direction and value of extrusion
2813 # @param NbOfSteps the number of steps
2814 # @param MakeGroups forces the generation of new groups from existing ones
2815 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2816 # @ingroup l2_modif_extrurev
2817 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2818 if ( isinstance( theObject, Mesh )):
2819 theObject = theObject.GetMesh()
2820 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2821 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2822 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2823 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2824 Parameters = StepVectorParameters + var_separator + Parameters
2825 self.mesh.SetParameters(Parameters)
2827 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2828 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2833 ## Generates new elements by extrusion of the given elements
2834 # The path of extrusion must be a meshed edge.
2835 # @param Base mesh or list of ids of elements for extrusion
2836 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2837 # @param NodeStart the start node from Path. Defines the direction of extrusion
2838 # @param HasAngles allows the shape to be rotated around the path
2839 # to get the resulting mesh in a helical fashion
2840 # @param Angles list of angles in radians
2841 # @param LinearVariation forces the computation of rotation angles as linear
2842 # variation of the given Angles along path steps
2843 # @param HasRefPoint allows using the reference point
2844 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2845 # The User can specify any point as the Reference Point.
2846 # @param MakeGroups forces the generation of new groups from existing ones
2847 # @param ElemType type of elements for extrusion (if param Base is a mesh)
2848 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2849 # only SMESH::Extrusion_Error otherwise
2850 # @ingroup l2_modif_extrurev
2851 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2852 HasAngles, Angles, LinearVariation,
2853 HasRefPoint, RefPoint, MakeGroups, ElemType):
2854 Angles,AnglesParameters = ParseAngles(Angles)
2855 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2856 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2857 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2859 Parameters = AnglesParameters + var_separator + RefPointParameters
2860 self.mesh.SetParameters(Parameters)
2862 if isinstance(Base,list):
2864 if Base == []: IDsOfElements = self.GetElementsId()
2865 else: IDsOfElements = Base
2866 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2867 HasAngles, Angles, LinearVariation,
2868 HasRefPoint, RefPoint, MakeGroups, ElemType)
2870 if isinstance(Base,Mesh):
2871 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
2872 HasAngles, Angles, LinearVariation,
2873 HasRefPoint, RefPoint, MakeGroups, ElemType)
2875 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2878 ## Generates new elements by extrusion of the given elements
2879 # The path of extrusion must be a meshed edge.
2880 # @param IDsOfElements ids of elements
2881 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2882 # @param PathShape shape(edge) defines the sub-mesh for the path
2883 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2884 # @param HasAngles allows the shape to be rotated around the path
2885 # to get the resulting mesh in a helical fashion
2886 # @param Angles list of angles in radians
2887 # @param HasRefPoint allows using the reference point
2888 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2889 # The User can specify any point as the Reference Point.
2890 # @param MakeGroups forces the generation of new groups from existing ones
2891 # @param LinearVariation forces the computation of rotation angles as linear
2892 # variation of the given Angles along path steps
2893 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2894 # only SMESH::Extrusion_Error otherwise
2895 # @ingroup l2_modif_extrurev
2896 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2897 HasAngles, Angles, HasRefPoint, RefPoint,
2898 MakeGroups=False, LinearVariation=False):
2899 Angles,AnglesParameters = ParseAngles(Angles)
2900 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2901 if IDsOfElements == []:
2902 IDsOfElements = self.GetElementsId()
2903 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2904 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2906 if ( isinstance( PathMesh, Mesh )):
2907 PathMesh = PathMesh.GetMesh()
2908 if HasAngles and Angles and LinearVariation:
2909 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2911 Parameters = AnglesParameters + var_separator + RefPointParameters
2912 self.mesh.SetParameters(Parameters)
2914 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2915 PathShape, NodeStart, HasAngles,
2916 Angles, HasRefPoint, RefPoint)
2917 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2918 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2920 ## Generates new elements by extrusion of the elements which belong to the object
2921 # The path of extrusion must be a meshed edge.
2922 # @param theObject the object which elements should be processed
2923 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2924 # @param PathShape shape(edge) defines the sub-mesh for the path
2925 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2926 # @param HasAngles allows the shape to be rotated around the path
2927 # to get the resulting mesh in a helical fashion
2928 # @param Angles list of angles
2929 # @param HasRefPoint allows using the reference point
2930 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2931 # The User can specify any point as the Reference Point.
2932 # @param MakeGroups forces the generation of new groups from existing ones
2933 # @param LinearVariation forces the computation of rotation angles as linear
2934 # variation of the given Angles along path steps
2935 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2936 # only SMESH::Extrusion_Error otherwise
2937 # @ingroup l2_modif_extrurev
2938 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2939 HasAngles, Angles, HasRefPoint, RefPoint,
2940 MakeGroups=False, LinearVariation=False):
2941 Angles,AnglesParameters = ParseAngles(Angles)
2942 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2943 if ( isinstance( theObject, Mesh )):
2944 theObject = theObject.GetMesh()
2945 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2946 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2947 if ( isinstance( PathMesh, Mesh )):
2948 PathMesh = PathMesh.GetMesh()
2949 if HasAngles and Angles and LinearVariation:
2950 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2952 Parameters = AnglesParameters + var_separator + RefPointParameters
2953 self.mesh.SetParameters(Parameters)
2955 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2956 PathShape, NodeStart, HasAngles,
2957 Angles, HasRefPoint, RefPoint)
2958 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2959 NodeStart, HasAngles, Angles, HasRefPoint,
2962 ## Generates new elements by extrusion of the elements which belong to the object
2963 # The path of extrusion must be a meshed edge.
2964 # @param theObject the object which elements should be processed
2965 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2966 # @param PathShape shape(edge) defines the sub-mesh for the path
2967 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2968 # @param HasAngles allows the shape to be rotated around the path
2969 # to get the resulting mesh in a helical fashion
2970 # @param Angles list of angles
2971 # @param HasRefPoint allows using the reference point
2972 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2973 # The User can specify any point as the Reference Point.
2974 # @param MakeGroups forces the generation of new groups from existing ones
2975 # @param LinearVariation forces the computation of rotation angles as linear
2976 # variation of the given Angles along path steps
2977 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2978 # only SMESH::Extrusion_Error otherwise
2979 # @ingroup l2_modif_extrurev
2980 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
2981 HasAngles, Angles, HasRefPoint, RefPoint,
2982 MakeGroups=False, LinearVariation=False):
2983 Angles,AnglesParameters = ParseAngles(Angles)
2984 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2985 if ( isinstance( theObject, Mesh )):
2986 theObject = theObject.GetMesh()
2987 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2988 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2989 if ( isinstance( PathMesh, Mesh )):
2990 PathMesh = PathMesh.GetMesh()
2991 if HasAngles and Angles and LinearVariation:
2992 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2994 Parameters = AnglesParameters + var_separator + RefPointParameters
2995 self.mesh.SetParameters(Parameters)
2997 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
2998 PathShape, NodeStart, HasAngles,
2999 Angles, HasRefPoint, RefPoint)
3000 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3001 NodeStart, HasAngles, Angles, HasRefPoint,
3004 ## Generates new elements by extrusion of the elements which belong to the object
3005 # The path of extrusion must be a meshed edge.
3006 # @param theObject the object which elements should be processed
3007 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3008 # @param PathShape shape(edge) defines the sub-mesh for the path
3009 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3010 # @param HasAngles allows the shape to be rotated around the path
3011 # to get the resulting mesh in a helical fashion
3012 # @param Angles list of angles
3013 # @param HasRefPoint allows using the reference point
3014 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3015 # The User can specify any point as the Reference Point.
3016 # @param MakeGroups forces the generation of new groups from existing ones
3017 # @param LinearVariation forces the computation of rotation angles as linear
3018 # variation of the given Angles along path steps
3019 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3020 # only SMESH::Extrusion_Error otherwise
3021 # @ingroup l2_modif_extrurev
3022 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3023 HasAngles, Angles, HasRefPoint, RefPoint,
3024 MakeGroups=False, LinearVariation=False):
3025 Angles,AnglesParameters = ParseAngles(Angles)
3026 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3027 if ( isinstance( theObject, Mesh )):
3028 theObject = theObject.GetMesh()
3029 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3030 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3031 if ( isinstance( PathMesh, Mesh )):
3032 PathMesh = PathMesh.GetMesh()
3033 if HasAngles and Angles and LinearVariation:
3034 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3036 Parameters = AnglesParameters + var_separator + RefPointParameters
3037 self.mesh.SetParameters(Parameters)
3039 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3040 PathShape, NodeStart, HasAngles,
3041 Angles, HasRefPoint, RefPoint)
3042 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3043 NodeStart, HasAngles, Angles, HasRefPoint,
3046 ## Creates a symmetrical copy of mesh elements
3047 # @param IDsOfElements list of elements ids
3048 # @param Mirror is AxisStruct or geom object(point, line, plane)
3049 # @param theMirrorType is POINT, AXIS or PLANE
3050 # If the Mirror is a geom object this parameter is unnecessary
3051 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3052 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3053 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3054 # @ingroup l2_modif_trsf
3055 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3056 if IDsOfElements == []:
3057 IDsOfElements = self.GetElementsId()
3058 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3059 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3060 Mirror,Parameters = ParseAxisStruct(Mirror)
3061 self.mesh.SetParameters(Parameters)
3062 if Copy and MakeGroups:
3063 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3064 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3067 ## Creates a new mesh by a symmetrical copy of mesh elements
3068 # @param IDsOfElements the list of elements ids
3069 # @param Mirror is AxisStruct or geom object (point, line, plane)
3070 # @param theMirrorType is POINT, AXIS or PLANE
3071 # If the Mirror is a geom object this parameter is unnecessary
3072 # @param MakeGroups to generate new groups from existing ones
3073 # @param NewMeshName a name of the new mesh to create
3074 # @return instance of Mesh class
3075 # @ingroup l2_modif_trsf
3076 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3077 if IDsOfElements == []:
3078 IDsOfElements = self.GetElementsId()
3079 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3080 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3081 Mirror,Parameters = ParseAxisStruct(Mirror)
3082 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3083 MakeGroups, NewMeshName)
3084 mesh.SetParameters(Parameters)
3085 return Mesh(self.smeshpyD,self.geompyD,mesh)
3087 ## Creates a symmetrical copy of the object
3088 # @param theObject mesh, submesh or group
3089 # @param Mirror AxisStruct or geom object (point, line, plane)
3090 # @param theMirrorType is POINT, AXIS or PLANE
3091 # If the Mirror is a geom object this parameter is unnecessary
3092 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3093 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3094 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3095 # @ingroup l2_modif_trsf
3096 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3097 if ( isinstance( theObject, Mesh )):
3098 theObject = theObject.GetMesh()
3099 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3100 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3101 Mirror,Parameters = ParseAxisStruct(Mirror)
3102 self.mesh.SetParameters(Parameters)
3103 if Copy and MakeGroups:
3104 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3105 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3108 ## Creates a new mesh by a symmetrical copy of the object
3109 # @param theObject mesh, submesh or group
3110 # @param Mirror AxisStruct or geom object (point, line, plane)
3111 # @param theMirrorType POINT, AXIS or PLANE
3112 # If the Mirror is a geom object this parameter is unnecessary
3113 # @param MakeGroups forces the generation of new groups from existing ones
3114 # @param NewMeshName the name of the new mesh to create
3115 # @return instance of Mesh class
3116 # @ingroup l2_modif_trsf
3117 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3118 if ( isinstance( theObject, Mesh )):
3119 theObject = theObject.GetMesh()
3120 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3121 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3122 Mirror,Parameters = ParseAxisStruct(Mirror)
3123 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3124 MakeGroups, NewMeshName)
3125 mesh.SetParameters(Parameters)
3126 return Mesh( self.smeshpyD,self.geompyD,mesh )
3128 ## Translates the elements
3129 # @param IDsOfElements list of elements ids
3130 # @param Vector the direction of translation (DirStruct or vector)
3131 # @param Copy allows copying the translated elements
3132 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3133 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3134 # @ingroup l2_modif_trsf
3135 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3136 if IDsOfElements == []:
3137 IDsOfElements = self.GetElementsId()
3138 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3139 Vector = self.smeshpyD.GetDirStruct(Vector)
3140 Vector,Parameters = ParseDirStruct(Vector)
3141 self.mesh.SetParameters(Parameters)
3142 if Copy and MakeGroups:
3143 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3144 self.editor.Translate(IDsOfElements, Vector, Copy)
3147 ## Creates a new mesh of translated elements
3148 # @param IDsOfElements list of elements ids
3149 # @param Vector the direction of translation (DirStruct or vector)
3150 # @param MakeGroups forces the generation of new groups from existing ones
3151 # @param NewMeshName the name of the newly created mesh
3152 # @return instance of Mesh class
3153 # @ingroup l2_modif_trsf
3154 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3155 if IDsOfElements == []:
3156 IDsOfElements = self.GetElementsId()
3157 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3158 Vector = self.smeshpyD.GetDirStruct(Vector)
3159 Vector,Parameters = ParseDirStruct(Vector)
3160 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3161 mesh.SetParameters(Parameters)
3162 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3164 ## Translates the object
3165 # @param theObject the object to translate (mesh, submesh, or group)
3166 # @param Vector direction of translation (DirStruct or geom vector)
3167 # @param Copy allows copying the translated elements
3168 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3169 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3170 # @ingroup l2_modif_trsf
3171 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3172 if ( isinstance( theObject, Mesh )):
3173 theObject = theObject.GetMesh()
3174 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3175 Vector = self.smeshpyD.GetDirStruct(Vector)
3176 Vector,Parameters = ParseDirStruct(Vector)
3177 self.mesh.SetParameters(Parameters)
3178 if Copy and MakeGroups:
3179 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3180 self.editor.TranslateObject(theObject, Vector, Copy)
3183 ## Creates a new mesh from the translated object
3184 # @param theObject the object to translate (mesh, submesh, or group)
3185 # @param Vector the direction of translation (DirStruct or geom vector)
3186 # @param MakeGroups forces the generation of new groups from existing ones
3187 # @param NewMeshName the name of the newly created mesh
3188 # @return instance of Mesh class
3189 # @ingroup l2_modif_trsf
3190 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3191 if (isinstance(theObject, Mesh)):
3192 theObject = theObject.GetMesh()
3193 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3194 Vector = self.smeshpyD.GetDirStruct(Vector)
3195 Vector,Parameters = ParseDirStruct(Vector)
3196 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3197 mesh.SetParameters(Parameters)
3198 return Mesh( self.smeshpyD, self.geompyD, mesh )
3200 ## Rotates the elements
3201 # @param IDsOfElements list of elements ids
3202 # @param Axis the axis of rotation (AxisStruct or geom line)
3203 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3204 # @param Copy allows copying the rotated elements
3205 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3206 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3207 # @ingroup l2_modif_trsf
3208 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3210 if isinstance(AngleInRadians,str):
3212 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3214 AngleInRadians = DegreesToRadians(AngleInRadians)
3215 if IDsOfElements == []:
3216 IDsOfElements = self.GetElementsId()
3217 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3218 Axis = self.smeshpyD.GetAxisStruct(Axis)
3219 Axis,AxisParameters = ParseAxisStruct(Axis)
3220 Parameters = AxisParameters + var_separator + Parameters
3221 self.mesh.SetParameters(Parameters)
3222 if Copy and MakeGroups:
3223 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3224 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3227 ## Creates a new mesh of rotated elements
3228 # @param IDsOfElements list of element ids
3229 # @param Axis the axis of rotation (AxisStruct or geom line)
3230 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3231 # @param MakeGroups forces the generation of new groups from existing ones
3232 # @param NewMeshName the name of the newly created mesh
3233 # @return instance of Mesh class
3234 # @ingroup l2_modif_trsf
3235 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3237 if isinstance(AngleInRadians,str):
3239 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3241 AngleInRadians = DegreesToRadians(AngleInRadians)
3242 if IDsOfElements == []:
3243 IDsOfElements = self.GetElementsId()
3244 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3245 Axis = self.smeshpyD.GetAxisStruct(Axis)
3246 Axis,AxisParameters = ParseAxisStruct(Axis)
3247 Parameters = AxisParameters + var_separator + Parameters
3248 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3249 MakeGroups, NewMeshName)
3250 mesh.SetParameters(Parameters)
3251 return Mesh( self.smeshpyD, self.geompyD, mesh )
3253 ## Rotates the object
3254 # @param theObject the object to rotate( mesh, submesh, or group)
3255 # @param Axis the axis of rotation (AxisStruct or geom line)
3256 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3257 # @param Copy allows copying the rotated elements
3258 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3259 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3260 # @ingroup l2_modif_trsf
3261 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3263 if isinstance(AngleInRadians,str):
3265 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3267 AngleInRadians = DegreesToRadians(AngleInRadians)
3268 if (isinstance(theObject, Mesh)):
3269 theObject = theObject.GetMesh()
3270 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3271 Axis = self.smeshpyD.GetAxisStruct(Axis)
3272 Axis,AxisParameters = ParseAxisStruct(Axis)
3273 Parameters = AxisParameters + ":" + Parameters
3274 self.mesh.SetParameters(Parameters)
3275 if Copy and MakeGroups:
3276 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3277 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3280 ## Creates a new mesh from the rotated object
3281 # @param theObject the object to rotate (mesh, submesh, or group)
3282 # @param Axis the axis of rotation (AxisStruct or geom line)
3283 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3284 # @param MakeGroups forces the generation of new groups from existing ones
3285 # @param NewMeshName the name of the newly created mesh
3286 # @return instance of Mesh class
3287 # @ingroup l2_modif_trsf
3288 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3290 if isinstance(AngleInRadians,str):
3292 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3294 AngleInRadians = DegreesToRadians(AngleInRadians)
3295 if (isinstance( theObject, Mesh )):
3296 theObject = theObject.GetMesh()
3297 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3298 Axis = self.smeshpyD.GetAxisStruct(Axis)
3299 Axis,AxisParameters = ParseAxisStruct(Axis)
3300 Parameters = AxisParameters + ":" + Parameters
3301 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3302 MakeGroups, NewMeshName)
3303 mesh.SetParameters(Parameters)
3304 return Mesh( self.smeshpyD, self.geompyD, mesh )
3306 ## Finds groups of ajacent nodes within Tolerance.
3307 # @param Tolerance the value of tolerance
3308 # @return the list of groups of nodes
3309 # @ingroup l2_modif_trsf
3310 def FindCoincidentNodes (self, Tolerance):
3311 return self.editor.FindCoincidentNodes(Tolerance)
3313 ## Finds groups of ajacent nodes within Tolerance.
3314 # @param Tolerance the value of tolerance
3315 # @param SubMeshOrGroup SubMesh or Group
3316 # @return the list of groups of nodes
3317 # @ingroup l2_modif_trsf
3318 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3319 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3322 # @param GroupsOfNodes the list of groups of nodes
3323 # @ingroup l2_modif_trsf
3324 def MergeNodes (self, GroupsOfNodes):
3325 self.editor.MergeNodes(GroupsOfNodes)
3327 ## Finds the elements built on the same nodes.
3328 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3329 # @return a list of groups of equal elements
3330 # @ingroup l2_modif_trsf
3331 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3332 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3333 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3334 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3336 ## Merges elements in each given group.
3337 # @param GroupsOfElementsID groups of elements for merging
3338 # @ingroup l2_modif_trsf
3339 def MergeElements(self, GroupsOfElementsID):
3340 self.editor.MergeElements(GroupsOfElementsID)
3342 ## Leaves one element and removes all other elements built on the same nodes.
3343 # @ingroup l2_modif_trsf
3344 def MergeEqualElements(self):
3345 self.editor.MergeEqualElements()
3347 ## Sews free borders
3348 # @return SMESH::Sew_Error
3349 # @ingroup l2_modif_trsf
3350 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3351 FirstNodeID2, SecondNodeID2, LastNodeID2,
3352 CreatePolygons, CreatePolyedrs):
3353 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3354 FirstNodeID2, SecondNodeID2, LastNodeID2,
3355 CreatePolygons, CreatePolyedrs)
3357 ## Sews conform free borders
3358 # @return SMESH::Sew_Error
3359 # @ingroup l2_modif_trsf
3360 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3361 FirstNodeID2, SecondNodeID2):
3362 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3363 FirstNodeID2, SecondNodeID2)
3365 ## Sews border to side
3366 # @return SMESH::Sew_Error
3367 # @ingroup l2_modif_trsf
3368 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3369 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3370 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3371 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3373 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3374 # merged with the nodes of elements of Side2.
3375 # The number of elements in theSide1 and in theSide2 must be
3376 # equal and they should have similar nodal connectivity.
3377 # The nodes to merge should belong to side borders and
3378 # the first node should be linked to the second.
3379 # @return SMESH::Sew_Error
3380 # @ingroup l2_modif_trsf
3381 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3382 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3383 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3384 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3385 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3386 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3388 ## Sets new nodes for the given element.
3389 # @param ide the element id
3390 # @param newIDs nodes ids
3391 # @return If the number of nodes does not correspond to the type of element - returns false
3392 # @ingroup l2_modif_edit
3393 def ChangeElemNodes(self, ide, newIDs):
3394 return self.editor.ChangeElemNodes(ide, newIDs)
3396 ## If during the last operation of MeshEditor some nodes were
3397 # created, this method returns the list of their IDs, \n
3398 # if new nodes were not created - returns empty list
3399 # @return the list of integer values (can be empty)
3400 # @ingroup l1_auxiliary
3401 def GetLastCreatedNodes(self):
3402 return self.editor.GetLastCreatedNodes()
3404 ## If during the last operation of MeshEditor some elements were
3405 # created this method returns the list of their IDs, \n
3406 # if new elements were not created - returns empty list
3407 # @return the list of integer values (can be empty)
3408 # @ingroup l1_auxiliary
3409 def GetLastCreatedElems(self):
3410 return self.editor.GetLastCreatedElems()
3412 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3413 # @param theElems - the list of elements (edges or faces) to be replicated
3414 # The nodes for duplication could be found from these elements
3415 # @param theNodesNot - list of nodes to NOT replicate
3416 # @param theAffectedElems - the list of elements (cells and edges) to which the
3417 # replicated nodes should be associated to.
3418 # @return TRUE if operation has been completed successfully, FALSE otherwise
3419 # @ingroup l2_modif_edit
3420 def DoubleNodes(self, theElems, theNodesNot, theAffectedElems):
3421 return self.editor.DoubleNodes(theElems, theNodesNot, theAffectedElems)
3423 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3424 # @param theElems - the list of elements (edges or faces) to be replicated
3425 # The nodes for duplication could be found from these elements
3426 # @param theNodesNot - list of nodes to NOT replicate
3427 # @param theShape - shape to detect affected elements (element which geometric center
3428 # located on or inside shape).
3429 # The replicated nodes should be associated to affected elements.
3430 # @return TRUE if operation has been completed successfully, FALSE otherwise
3431 # @ingroup l2_modif_edit
3432 def DoubleNodesInRegion(self, theElems, theNodesNot, theShape):
3433 return self.editor.DoubleNodesInRegion(theElems, theNodesNot, theShape)
3435 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3436 # This method provided for convenience works as DoubleNodes() described above.
3437 # @param theElems - group of of elements (edges or faces) to be replicated
3438 # @param theNodesNot - group of nodes not to replicated
3439 # @param theAffectedElems - group of elements to which the replicated nodes
3440 # should be associated to.
3441 # @ingroup l2_modif_edit
3442 def DoubleNodeGroup(self, theElems, theNodesNot, theAffectedElems):
3443 return self.editor.DoubleNodeGroup(theElems, theNodesNot, theAffectedElems)
3445 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3446 # This method provided for convenience works as DoubleNodes() described above.
3447 # @param theElems - group of of elements (edges or faces) to be replicated
3448 # @param theNodesNot - group of nodes not to replicated
3449 # @param theShape - shape to detect affected elements (element which geometric center
3450 # located on or inside shape).
3451 # The replicated nodes should be associated to affected elements.
3452 # @ingroup l2_modif_edit
3453 def DoubleNodeGroupInRegion(self, theElems, theNodesNot, theShape):
3454 return self.editor.DoubleNodeGroup(theElems, theNodesNot, theShape)
3456 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3457 # This method provided for convenience works as DoubleNodes() described above.
3458 # @param theElems - list of groups of elements (edges or faces) to be replicated
3459 # @param theNodesNot - list of groups of nodes not to replicated
3460 # @param theAffectedElems - group of elements to which the replicated nodes
3461 # should be associated to.
3462 # @return TRUE if operation has been completed successfully, FALSE otherwise
3463 # @ingroup l2_modif_edit
3464 def DoubleNodeGroups(self, theElems, theNodesNot, theAffectedElems):
3465 return self.editor.DoubleNodeGroups(theElems, theNodesNot, theAffectedElems)
3467 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3468 # This method provided for convenience works as DoubleNodes() described above.
3469 # @param theElems - list of groups of elements (edges or faces) to be replicated
3470 # @param theNodesNot - list of groups of nodes not to replicated
3471 # @param theShape - shape to detect affected elements (element which geometric center
3472 # located on or inside shape).
3473 # The replicated nodes should be associated to affected elements.
3474 # @return TRUE if operation has been completed successfully, FALSE otherwise
3475 # @ingroup l2_modif_edit
3476 def DoubleNodeGroupsInRegion(self, theElems, theNodesNot, theShape):
3477 return self.editor.DoubleNodeGroupsInRegion(theElems, theNodesNot, theShape)
3479 ## The mother class to define algorithm, it is not recommended to use it directly.
3482 # @ingroup l2_algorithms
3483 class Mesh_Algorithm:
3484 # @class Mesh_Algorithm
3485 # @brief Class Mesh_Algorithm
3487 #def __init__(self,smesh):
3495 ## Finds a hypothesis in the study by its type name and parameters.
3496 # Finds only the hypotheses created in smeshpyD engine.
3497 # @return SMESH.SMESH_Hypothesis
3498 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3499 study = smeshpyD.GetCurrentStudy()
3500 #to do: find component by smeshpyD object, not by its data type
3501 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3502 if scomp is not None:
3503 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3504 # Check if the root label of the hypotheses exists
3505 if res and hypRoot is not None:
3506 iter = study.NewChildIterator(hypRoot)
3507 # Check all published hypotheses
3509 hypo_so_i = iter.Value()
3510 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3511 if attr is not None:
3512 anIOR = attr.Value()
3513 hypo_o_i = salome.orb.string_to_object(anIOR)
3514 if hypo_o_i is not None:
3515 # Check if this is a hypothesis
3516 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3517 if hypo_i is not None:
3518 # Check if the hypothesis belongs to current engine
3519 if smeshpyD.GetObjectId(hypo_i) > 0:
3520 # Check if this is the required hypothesis
3521 if hypo_i.GetName() == hypname:
3523 if CompareMethod(hypo_i, args):
3537 ## Finds the algorithm in the study by its type name.
3538 # Finds only the algorithms, which have been created in smeshpyD engine.
3539 # @return SMESH.SMESH_Algo
3540 def FindAlgorithm (self, algoname, smeshpyD):
3541 study = smeshpyD.GetCurrentStudy()
3542 #to do: find component by smeshpyD object, not by its data type
3543 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3544 if scomp is not None:
3545 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3546 # Check if the root label of the algorithms exists
3547 if res and hypRoot is not None:
3548 iter = study.NewChildIterator(hypRoot)
3549 # Check all published algorithms
3551 algo_so_i = iter.Value()
3552 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3553 if attr is not None:
3554 anIOR = attr.Value()
3555 algo_o_i = salome.orb.string_to_object(anIOR)
3556 if algo_o_i is not None:
3557 # Check if this is an algorithm
3558 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3559 if algo_i is not None:
3560 # Checks if the algorithm belongs to the current engine
3561 if smeshpyD.GetObjectId(algo_i) > 0:
3562 # Check if this is the required algorithm
3563 if algo_i.GetName() == algoname:
3576 ## If the algorithm is global, returns 0; \n
3577 # else returns the submesh associated to this algorithm.
3578 def GetSubMesh(self):
3581 ## Returns the wrapped mesher.
3582 def GetAlgorithm(self):
3585 ## Gets the list of hypothesis that can be used with this algorithm
3586 def GetCompatibleHypothesis(self):
3589 mylist = self.algo.GetCompatibleHypothesis()
3592 ## Gets the name of the algorithm
3596 ## Sets the name to the algorithm
3597 def SetName(self, name):
3598 self.mesh.smeshpyD.SetName(self.algo, name)
3600 ## Gets the id of the algorithm
3602 return self.algo.GetId()
3605 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3607 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3608 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3610 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3612 self.Assign(algo, mesh, geom)
3616 def Assign(self, algo, mesh, geom):
3618 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3625 name = GetName(geom)
3627 name = mesh.geompyD.SubShapeName(geom, piece)
3628 mesh.geompyD.addToStudyInFather(piece, geom, name)
3629 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3632 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3633 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3635 def CompareHyp (self, hyp, args):
3636 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3639 def CompareEqualHyp (self, hyp, args):
3643 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3644 UseExisting=0, CompareMethod=""):
3647 if CompareMethod == "": CompareMethod = self.CompareHyp
3648 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3651 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3657 a = a + s + str(args[i])
3661 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3663 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3664 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3667 ## Returns entry of the shape to mesh in the study
3668 def MainShapeEntry(self):
3670 if not self.mesh or not self.mesh.GetMesh(): return entry
3671 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3672 study = self.mesh.smeshpyD.GetCurrentStudy()
3673 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3674 sobj = study.FindObjectIOR(ior)
3675 if sobj: entry = sobj.GetID()
3676 if not entry: return ""
3679 # Public class: Mesh_Segment
3680 # --------------------------
3682 ## Class to define a segment 1D algorithm for discretization
3685 # @ingroup l3_algos_basic
3686 class Mesh_Segment(Mesh_Algorithm):
3688 ## Private constructor.
3689 def __init__(self, mesh, geom=0):
3690 Mesh_Algorithm.__init__(self)
3691 self.Create(mesh, geom, "Regular_1D")
3693 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3694 # @param l for the length of segments that cut an edge
3695 # @param UseExisting if ==true - searches for an existing hypothesis created with
3696 # the same parameters, else (default) - creates a new one
3697 # @param p precision, used for calculation of the number of segments.
3698 # The precision should be a positive, meaningful value within the range [0,1].
3699 # In general, the number of segments is calculated with the formula:
3700 # nb = ceil((edge_length / l) - p)
3701 # Function ceil rounds its argument to the higher integer.
3702 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3703 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3704 # p=1 means rounding of (edge_length / l) to the lower integer.
3705 # Default value is 1e-07.
3706 # @return an instance of StdMeshers_LocalLength hypothesis
3707 # @ingroup l3_hypos_1dhyps
3708 def LocalLength(self, l, UseExisting=0, p=1e-07):
3709 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3710 CompareMethod=self.CompareLocalLength)
3716 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3717 def CompareLocalLength(self, hyp, args):
3718 if IsEqual(hyp.GetLength(), args[0]):
3719 return IsEqual(hyp.GetPrecision(), args[1])
3722 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3723 # @param length is optional maximal allowed length of segment, if it is omitted
3724 # the preestimated length is used that depends on geometry size
3725 # @param UseExisting if ==true - searches for an existing hypothesis created with
3726 # the same parameters, else (default) - create a new one
3727 # @return an instance of StdMeshers_MaxLength hypothesis
3728 # @ingroup l3_hypos_1dhyps
3729 def MaxSize(self, length=0.0, UseExisting=0):
3730 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3733 hyp.SetLength(length)
3735 # set preestimated length
3736 gen = self.mesh.smeshpyD
3737 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3738 self.mesh.GetMesh(), self.mesh.GetShape(),
3740 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3742 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3745 hyp.SetUsePreestimatedLength( length == 0.0 )
3748 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3749 # @param n for the number of segments that cut an edge
3750 # @param s for the scale factor (optional)
3751 # @param reversedEdges is a list of edges to mesh using reversed orientation
3752 # @param UseExisting if ==true - searches for an existing hypothesis created with
3753 # the same parameters, else (default) - create a new one
3754 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3755 # @ingroup l3_hypos_1dhyps
3756 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3757 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3758 reversedEdges, UseExisting = [], reversedEdges
3759 entry = self.MainShapeEntry()
3761 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3762 UseExisting=UseExisting,
3763 CompareMethod=self.CompareNumberOfSegments)
3765 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3766 UseExisting=UseExisting,
3767 CompareMethod=self.CompareNumberOfSegments)
3768 hyp.SetDistrType( 1 )
3769 hyp.SetScaleFactor(s)
3770 hyp.SetNumberOfSegments(n)
3771 hyp.SetReversedEdges( reversedEdges )
3772 hyp.SetObjectEntry( entry )
3776 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3777 def CompareNumberOfSegments(self, hyp, args):
3778 if hyp.GetNumberOfSegments() == args[0]:
3780 if hyp.GetReversedEdges() == args[1]:
3781 if not args[1] or hyp.GetObjectEntry() == args[2]:
3784 if hyp.GetReversedEdges() == args[2]:
3785 if not args[2] or hyp.GetObjectEntry() == args[3]:
3786 if hyp.GetDistrType() == 1:
3787 if IsEqual(hyp.GetScaleFactor(), args[1]):
3791 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3792 # @param start defines the length of the first segment
3793 # @param end defines the length of the last segment
3794 # @param reversedEdges is a list of edges to mesh using reversed orientation
3795 # @param UseExisting if ==true - searches for an existing hypothesis created with
3796 # the same parameters, else (default) - creates a new one
3797 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3798 # @ingroup l3_hypos_1dhyps
3799 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3800 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3801 reversedEdges, UseExisting = [], reversedEdges
3802 entry = self.MainShapeEntry()
3803 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
3804 UseExisting=UseExisting,
3805 CompareMethod=self.CompareArithmetic1D)
3806 hyp.SetStartLength(start)
3807 hyp.SetEndLength(end)
3808 hyp.SetReversedEdges( reversedEdges )
3809 hyp.SetObjectEntry( entry )
3813 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3814 def CompareArithmetic1D(self, hyp, args):
3815 if IsEqual(hyp.GetLength(1), args[0]):
3816 if IsEqual(hyp.GetLength(0), args[1]):
3817 if hyp.GetReversedEdges() == args[2]:
3818 if not args[2] or hyp.GetObjectEntry() == args[3]:
3823 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
3824 # on curve from 0 to 1 (additionally it is neecessary to check
3825 # orientation of edges and create list of reversed edges if it is
3826 # needed) and sets numbers of segments between given points (default
3827 # values are equals 1
3828 # @param points defines the list of parameters on curve
3829 # @param nbSegs defines the list of numbers of segments
3830 # @param reversedEdges is a list of edges to mesh using reversed orientation
3831 # @param UseExisting if ==true - searches for an existing hypothesis created with
3832 # the same parameters, else (default) - creates a new one
3833 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3834 # @ingroup l3_hypos_1dhyps
3835 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
3836 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3837 reversedEdges, UseExisting = [], reversedEdges
3838 entry = self.MainShapeEntry()
3839 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
3840 UseExisting=UseExisting,
3841 CompareMethod=self.CompareArithmetic1D)
3842 hyp.SetPoints(points)
3843 hyp.SetNbSegments(nbSegs)
3844 hyp.SetReversedEdges(reversedEdges)
3845 hyp.SetObjectEntry(entry)
3849 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
3850 ## as the given arguments
3851 def CompareFixedPoints1D(self, hyp, args):
3852 if hyp.GetPoints() == args[0]:
3853 if hyp.GetNbSegments() == args[1]:
3854 if hyp.GetReversedEdges() == args[2]:
3855 if not args[2] or hyp.GetObjectEntry() == args[3]:
3861 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3862 # @param start defines the length of the first segment
3863 # @param end defines the length of the last segment
3864 # @param reversedEdges is a list of edges to mesh using reversed orientation
3865 # @param UseExisting if ==true - searches for an existing hypothesis created with
3866 # the same parameters, else (default) - creates a new one
3867 # @return an instance of StdMeshers_StartEndLength hypothesis
3868 # @ingroup l3_hypos_1dhyps
3869 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3870 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3871 reversedEdges, UseExisting = [], reversedEdges
3872 entry = self.MainShapeEntry()
3873 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3874 UseExisting=UseExisting,
3875 CompareMethod=self.CompareStartEndLength)
3876 hyp.SetStartLength(start)
3877 hyp.SetEndLength(end)
3878 hyp.SetReversedEdges( reversedEdges )
3879 hyp.SetObjectEntry( entry )
3882 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3883 def CompareStartEndLength(self, hyp, args):
3884 if IsEqual(hyp.GetLength(1), args[0]):
3885 if IsEqual(hyp.GetLength(0), args[1]):
3886 if hyp.GetReversedEdges() == args[2]:
3887 if not args[2] or hyp.GetObjectEntry() == args[3]:
3891 ## Defines "Deflection1D" hypothesis
3892 # @param d for the deflection
3893 # @param UseExisting if ==true - searches for an existing hypothesis created with
3894 # the same parameters, else (default) - create a new one
3895 # @ingroup l3_hypos_1dhyps
3896 def Deflection1D(self, d, UseExisting=0):
3897 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3898 CompareMethod=self.CompareDeflection1D)
3899 hyp.SetDeflection(d)
3902 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3903 def CompareDeflection1D(self, hyp, args):
3904 return IsEqual(hyp.GetDeflection(), args[0])
3906 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3907 # the opposite side in case of quadrangular faces
3908 # @ingroup l3_hypos_additi
3909 def Propagation(self):
3910 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3912 ## Defines "AutomaticLength" hypothesis
3913 # @param fineness for the fineness [0-1]
3914 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3915 # same parameters, else (default) - create a new one
3916 # @ingroup l3_hypos_1dhyps
3917 def AutomaticLength(self, fineness=0, UseExisting=0):
3918 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3919 CompareMethod=self.CompareAutomaticLength)
3920 hyp.SetFineness( fineness )
3923 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3924 def CompareAutomaticLength(self, hyp, args):
3925 return IsEqual(hyp.GetFineness(), args[0])
3927 ## Defines "SegmentLengthAroundVertex" hypothesis
3928 # @param length for the segment length
3929 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3930 # Any other integer value means that the hypothesis will be set on the
3931 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3932 # @param UseExisting if ==true - searches for an existing hypothesis created with
3933 # the same parameters, else (default) - creates a new one
3934 # @ingroup l3_algos_segmarv
3935 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3937 store_geom = self.geom
3938 if type(vertex) is types.IntType:
3939 if vertex == 0 or vertex == 1:
3940 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3948 if self.geom is None:
3949 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3950 name = GetName(self.geom)
3952 piece = self.mesh.geom
3953 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3954 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3955 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3957 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3959 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3960 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3962 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3963 CompareMethod=self.CompareLengthNearVertex)
3964 self.geom = store_geom
3965 hyp.SetLength( length )
3968 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3969 # @ingroup l3_algos_segmarv
3970 def CompareLengthNearVertex(self, hyp, args):
3971 return IsEqual(hyp.GetLength(), args[0])
3973 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3974 # If the 2D mesher sees that all boundary edges are quadratic,
3975 # it generates quadratic faces, else it generates linear faces using
3976 # medium nodes as if they are vertices.
3977 # The 3D mesher generates quadratic volumes only if all boundary faces
3978 # are quadratic, else it fails.
3980 # @ingroup l3_hypos_additi
3981 def QuadraticMesh(self):
3982 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3985 # Public class: Mesh_CompositeSegment
3986 # --------------------------
3988 ## Defines a segment 1D algorithm for discretization
3990 # @ingroup l3_algos_basic
3991 class Mesh_CompositeSegment(Mesh_Segment):
3993 ## Private constructor.
3994 def __init__(self, mesh, geom=0):
3995 self.Create(mesh, geom, "CompositeSegment_1D")
3998 # Public class: Mesh_Segment_Python
3999 # ---------------------------------
4001 ## Defines a segment 1D algorithm for discretization with python function
4003 # @ingroup l3_algos_basic
4004 class Mesh_Segment_Python(Mesh_Segment):
4006 ## Private constructor.
4007 def __init__(self, mesh, geom=0):
4008 import Python1dPlugin
4009 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4011 ## Defines "PythonSplit1D" hypothesis
4012 # @param n for the number of segments that cut an edge
4013 # @param func for the python function that calculates the length of all segments
4014 # @param UseExisting if ==true - searches for the existing hypothesis created with
4015 # the same parameters, else (default) - creates a new one
4016 # @ingroup l3_hypos_1dhyps
4017 def PythonSplit1D(self, n, func, UseExisting=0):
4018 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4019 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4020 hyp.SetNumberOfSegments(n)
4021 hyp.SetPythonLog10RatioFunction(func)
4024 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4025 def ComparePythonSplit1D(self, hyp, args):
4026 #if hyp.GetNumberOfSegments() == args[0]:
4027 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4031 # Public class: Mesh_Triangle
4032 # ---------------------------
4034 ## Defines a triangle 2D algorithm
4036 # @ingroup l3_algos_basic
4037 class Mesh_Triangle(Mesh_Algorithm):
4046 ## Private constructor.
4047 def __init__(self, mesh, algoType, geom=0):
4048 Mesh_Algorithm.__init__(self)
4050 self.algoType = algoType
4051 if algoType == MEFISTO:
4052 self.Create(mesh, geom, "MEFISTO_2D")
4054 elif algoType == BLSURF:
4056 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4057 #self.SetPhysicalMesh() - PAL19680
4058 elif algoType == NETGEN:
4060 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4062 elif algoType == NETGEN_2D:
4064 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4067 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4068 # @param area for the maximum area of each triangle
4069 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4070 # same parameters, else (default) - creates a new one
4072 # Only for algoType == MEFISTO || NETGEN_2D
4073 # @ingroup l3_hypos_2dhyps
4074 def MaxElementArea(self, area, UseExisting=0):
4075 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4076 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4077 CompareMethod=self.CompareMaxElementArea)
4078 elif self.algoType == NETGEN:
4079 hyp = self.Parameters(SIMPLE)
4080 hyp.SetMaxElementArea(area)
4083 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4084 def CompareMaxElementArea(self, hyp, args):
4085 return IsEqual(hyp.GetMaxElementArea(), args[0])
4087 ## Defines "LengthFromEdges" hypothesis to build triangles
4088 # based on the length of the edges taken from the wire
4090 # Only for algoType == MEFISTO || NETGEN_2D
4091 # @ingroup l3_hypos_2dhyps
4092 def LengthFromEdges(self):
4093 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4094 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4096 elif self.algoType == NETGEN:
4097 hyp = self.Parameters(SIMPLE)
4098 hyp.LengthFromEdges()
4101 ## Sets a way to define size of mesh elements to generate.
4102 # @param thePhysicalMesh is: DefaultSize or Custom.
4103 # @ingroup l3_hypos_blsurf
4104 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4105 # Parameter of BLSURF algo
4106 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4108 ## Sets size of mesh elements to generate.
4109 # @ingroup l3_hypos_blsurf
4110 def SetPhySize(self, theVal):
4111 # Parameter of BLSURF algo
4112 self.Parameters().SetPhySize(theVal)
4114 ## Sets lower boundary of mesh element size (PhySize).
4115 # @ingroup l3_hypos_blsurf
4116 def SetPhyMin(self, theVal=-1):
4117 # Parameter of BLSURF algo
4118 self.Parameters().SetPhyMin(theVal)
4120 ## Sets upper boundary of mesh element size (PhySize).
4121 # @ingroup l3_hypos_blsurf
4122 def SetPhyMax(self, theVal=-1):
4123 # Parameter of BLSURF algo
4124 self.Parameters().SetPhyMax(theVal)
4126 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4127 # @param theGeometricMesh is: DefaultGeom or Custom
4128 # @ingroup l3_hypos_blsurf
4129 def SetGeometricMesh(self, theGeometricMesh=0):
4130 # Parameter of BLSURF algo
4131 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4132 self.params.SetGeometricMesh(theGeometricMesh)
4134 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4135 # @ingroup l3_hypos_blsurf
4136 def SetAngleMeshS(self, theVal=_angleMeshS):
4137 # Parameter of BLSURF algo
4138 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4139 self.params.SetAngleMeshS(theVal)
4141 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4142 # @ingroup l3_hypos_blsurf
4143 def SetAngleMeshC(self, theVal=_angleMeshS):
4144 # Parameter of BLSURF algo
4145 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4146 self.params.SetAngleMeshC(theVal)
4148 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4149 # @ingroup l3_hypos_blsurf
4150 def SetGeoMin(self, theVal=-1):
4151 # Parameter of BLSURF algo
4152 self.Parameters().SetGeoMin(theVal)
4154 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4155 # @ingroup l3_hypos_blsurf
4156 def SetGeoMax(self, theVal=-1):
4157 # Parameter of BLSURF algo
4158 self.Parameters().SetGeoMax(theVal)
4160 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4161 # @ingroup l3_hypos_blsurf
4162 def SetGradation(self, theVal=_gradation):
4163 # Parameter of BLSURF algo
4164 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4165 self.params.SetGradation(theVal)
4167 ## Sets topology usage way.
4168 # @param way defines how mesh conformity is assured <ul>
4169 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4170 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4171 # @ingroup l3_hypos_blsurf
4172 def SetTopology(self, way):
4173 # Parameter of BLSURF algo
4174 self.Parameters().SetTopology(way)
4176 ## To respect geometrical edges or not.
4177 # @ingroup l3_hypos_blsurf
4178 def SetDecimesh(self, toIgnoreEdges=False):
4179 # Parameter of BLSURF algo
4180 self.Parameters().SetDecimesh(toIgnoreEdges)
4182 ## Sets verbosity level in the range 0 to 100.
4183 # @ingroup l3_hypos_blsurf
4184 def SetVerbosity(self, level):
4185 # Parameter of BLSURF algo
4186 self.Parameters().SetVerbosity(level)
4188 ## Sets advanced option value.
4189 # @ingroup l3_hypos_blsurf
4190 def SetOptionValue(self, optionName, level):
4191 # Parameter of BLSURF algo
4192 self.Parameters().SetOptionValue(optionName,level)
4194 ## Sets QuadAllowed flag.
4195 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4196 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4197 def SetQuadAllowed(self, toAllow=True):
4198 if self.algoType == NETGEN_2D:
4199 if toAllow: # add QuadranglePreference
4200 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4201 else: # remove QuadranglePreference
4202 for hyp in self.mesh.GetHypothesisList( self.geom ):
4203 if hyp.GetName() == "QuadranglePreference":
4204 self.mesh.RemoveHypothesis( self.geom, hyp )
4209 if self.Parameters():
4210 self.params.SetQuadAllowed(toAllow)
4213 ## Defines hypothesis having several parameters
4215 # @ingroup l3_hypos_netgen
4216 def Parameters(self, which=SOLE):
4219 if self.algoType == NETGEN:
4221 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4222 "libNETGENEngine.so", UseExisting=0)
4224 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4225 "libNETGENEngine.so", UseExisting=0)
4227 elif self.algoType == MEFISTO:
4228 print "Mefisto algo support no multi-parameter hypothesis"
4230 elif self.algoType == NETGEN_2D:
4231 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4232 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4234 elif self.algoType == BLSURF:
4235 self.params = self.Hypothesis("BLSURF_Parameters", [],
4236 "libBLSURFEngine.so", UseExisting=0)
4239 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4244 # Only for algoType == NETGEN
4245 # @ingroup l3_hypos_netgen
4246 def SetMaxSize(self, theSize):
4247 if self.Parameters():
4248 self.params.SetMaxSize(theSize)
4250 ## Sets SecondOrder flag
4252 # Only for algoType == NETGEN
4253 # @ingroup l3_hypos_netgen
4254 def SetSecondOrder(self, theVal):
4255 if self.Parameters():
4256 self.params.SetSecondOrder(theVal)
4258 ## Sets Optimize flag
4260 # Only for algoType == NETGEN
4261 # @ingroup l3_hypos_netgen
4262 def SetOptimize(self, theVal):
4263 if self.Parameters():
4264 self.params.SetOptimize(theVal)
4267 # @param theFineness is:
4268 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4270 # Only for algoType == NETGEN
4271 # @ingroup l3_hypos_netgen
4272 def SetFineness(self, theFineness):
4273 if self.Parameters():
4274 self.params.SetFineness(theFineness)
4278 # Only for algoType == NETGEN
4279 # @ingroup l3_hypos_netgen
4280 def SetGrowthRate(self, theRate):
4281 if self.Parameters():
4282 self.params.SetGrowthRate(theRate)
4284 ## Sets NbSegPerEdge
4286 # Only for algoType == NETGEN
4287 # @ingroup l3_hypos_netgen
4288 def SetNbSegPerEdge(self, theVal):
4289 if self.Parameters():
4290 self.params.SetNbSegPerEdge(theVal)
4292 ## Sets NbSegPerRadius
4294 # Only for algoType == NETGEN
4295 # @ingroup l3_hypos_netgen
4296 def SetNbSegPerRadius(self, theVal):
4297 if self.Parameters():
4298 self.params.SetNbSegPerRadius(theVal)
4300 ## Sets number of segments overriding value set by SetLocalLength()
4302 # Only for algoType == NETGEN
4303 # @ingroup l3_hypos_netgen
4304 def SetNumberOfSegments(self, theVal):
4305 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4307 ## Sets number of segments overriding value set by SetNumberOfSegments()
4309 # Only for algoType == NETGEN
4310 # @ingroup l3_hypos_netgen
4311 def SetLocalLength(self, theVal):
4312 self.Parameters(SIMPLE).SetLocalLength(theVal)
4317 # Public class: Mesh_Quadrangle
4318 # -----------------------------
4320 ## Defines a quadrangle 2D algorithm
4322 # @ingroup l3_algos_basic
4323 class Mesh_Quadrangle(Mesh_Algorithm):
4325 ## Private constructor.
4326 def __init__(self, mesh, geom=0):
4327 Mesh_Algorithm.__init__(self)
4328 self.Create(mesh, geom, "Quadrangle_2D")
4330 ## Defines "QuadranglePreference" hypothesis, forcing construction
4331 # of quadrangles if the number of nodes on the opposite edges is not the same
4332 # while the total number of nodes on edges is even
4334 # @ingroup l3_hypos_additi
4335 def QuadranglePreference(self):
4336 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4337 CompareMethod=self.CompareEqualHyp)
4340 ## Defines "TrianglePreference" hypothesis, forcing construction
4341 # of triangles in the refinement area if the number of nodes
4342 # on the opposite edges is not the same
4344 # @ingroup l3_hypos_additi
4345 def TrianglePreference(self):
4346 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4347 CompareMethod=self.CompareEqualHyp)
4350 # Public class: Mesh_Tetrahedron
4351 # ------------------------------
4353 ## Defines a tetrahedron 3D algorithm
4355 # @ingroup l3_algos_basic
4356 class Mesh_Tetrahedron(Mesh_Algorithm):
4361 ## Private constructor.
4362 def __init__(self, mesh, algoType, geom=0):
4363 Mesh_Algorithm.__init__(self)
4365 if algoType == NETGEN:
4367 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4370 elif algoType == FULL_NETGEN:
4372 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4375 elif algoType == GHS3D:
4377 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4380 elif algoType == GHS3DPRL:
4381 CheckPlugin(GHS3DPRL)
4382 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4385 self.algoType = algoType
4387 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4388 # @param vol for the maximum volume of each tetrahedron
4389 # @param UseExisting if ==true - searches for the existing hypothesis created with
4390 # the same parameters, else (default) - creates a new one
4391 # @ingroup l3_hypos_maxvol
4392 def MaxElementVolume(self, vol, UseExisting=0):
4393 if self.algoType == NETGEN:
4394 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4395 CompareMethod=self.CompareMaxElementVolume)
4396 hyp.SetMaxElementVolume(vol)
4398 elif self.algoType == FULL_NETGEN:
4399 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4402 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4403 def CompareMaxElementVolume(self, hyp, args):
4404 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4406 ## Defines hypothesis having several parameters
4408 # @ingroup l3_hypos_netgen
4409 def Parameters(self, which=SOLE):
4413 if self.algoType == FULL_NETGEN:
4415 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4416 "libNETGENEngine.so", UseExisting=0)
4418 self.params = self.Hypothesis("NETGEN_Parameters", [],
4419 "libNETGENEngine.so", UseExisting=0)
4422 if self.algoType == GHS3D:
4423 self.params = self.Hypothesis("GHS3D_Parameters", [],
4424 "libGHS3DEngine.so", UseExisting=0)
4427 if self.algoType == GHS3DPRL:
4428 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4429 "libGHS3DPRLEngine.so", UseExisting=0)
4432 print "Algo supports no multi-parameter hypothesis"
4436 # Parameter of FULL_NETGEN
4437 # @ingroup l3_hypos_netgen
4438 def SetMaxSize(self, theSize):
4439 self.Parameters().SetMaxSize(theSize)
4441 ## Sets SecondOrder flag
4442 # Parameter of FULL_NETGEN
4443 # @ingroup l3_hypos_netgen
4444 def SetSecondOrder(self, theVal):
4445 self.Parameters().SetSecondOrder(theVal)
4447 ## Sets Optimize flag
4448 # Parameter of FULL_NETGEN
4449 # @ingroup l3_hypos_netgen
4450 def SetOptimize(self, theVal):
4451 self.Parameters().SetOptimize(theVal)
4454 # @param theFineness is:
4455 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4456 # Parameter of FULL_NETGEN
4457 # @ingroup l3_hypos_netgen
4458 def SetFineness(self, theFineness):
4459 self.Parameters().SetFineness(theFineness)
4462 # Parameter of FULL_NETGEN
4463 # @ingroup l3_hypos_netgen
4464 def SetGrowthRate(self, theRate):
4465 self.Parameters().SetGrowthRate(theRate)
4467 ## Sets NbSegPerEdge
4468 # Parameter of FULL_NETGEN
4469 # @ingroup l3_hypos_netgen
4470 def SetNbSegPerEdge(self, theVal):
4471 self.Parameters().SetNbSegPerEdge(theVal)
4473 ## Sets NbSegPerRadius
4474 # Parameter of FULL_NETGEN
4475 # @ingroup l3_hypos_netgen
4476 def SetNbSegPerRadius(self, theVal):
4477 self.Parameters().SetNbSegPerRadius(theVal)
4479 ## Sets number of segments overriding value set by SetLocalLength()
4480 # Only for algoType == NETGEN_FULL
4481 # @ingroup l3_hypos_netgen
4482 def SetNumberOfSegments(self, theVal):
4483 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4485 ## Sets number of segments overriding value set by SetNumberOfSegments()
4486 # Only for algoType == NETGEN_FULL
4487 # @ingroup l3_hypos_netgen
4488 def SetLocalLength(self, theVal):
4489 self.Parameters(SIMPLE).SetLocalLength(theVal)
4491 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4492 # Overrides value set by LengthFromEdges()
4493 # Only for algoType == NETGEN_FULL
4494 # @ingroup l3_hypos_netgen
4495 def MaxElementArea(self, area):
4496 self.Parameters(SIMPLE).SetMaxElementArea(area)
4498 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4499 # Overrides value set by MaxElementArea()
4500 # Only for algoType == NETGEN_FULL
4501 # @ingroup l3_hypos_netgen
4502 def LengthFromEdges(self):
4503 self.Parameters(SIMPLE).LengthFromEdges()
4505 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4506 # Overrides value set by MaxElementVolume()
4507 # Only for algoType == NETGEN_FULL
4508 # @ingroup l3_hypos_netgen
4509 def LengthFromFaces(self):
4510 self.Parameters(SIMPLE).LengthFromFaces()
4512 ## To mesh "holes" in a solid or not. Default is to mesh.
4513 # @ingroup l3_hypos_ghs3dh
4514 def SetToMeshHoles(self, toMesh):
4515 # Parameter of GHS3D
4516 self.Parameters().SetToMeshHoles(toMesh)
4518 ## Set Optimization level:
4519 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4520 # Strong_Optimization.
4521 # Default is Standard_Optimization
4522 # @ingroup l3_hypos_ghs3dh
4523 def SetOptimizationLevel(self, level):
4524 # Parameter of GHS3D
4525 self.Parameters().SetOptimizationLevel(level)
4527 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4528 # @ingroup l3_hypos_ghs3dh
4529 def SetMaximumMemory(self, MB):
4530 # Advanced parameter of GHS3D
4531 self.Parameters().SetMaximumMemory(MB)
4533 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4534 # automatic memory adjustment mode.
4535 # @ingroup l3_hypos_ghs3dh
4536 def SetInitialMemory(self, MB):
4537 # Advanced parameter of GHS3D
4538 self.Parameters().SetInitialMemory(MB)
4540 ## Path to working directory.
4541 # @ingroup l3_hypos_ghs3dh
4542 def SetWorkingDirectory(self, path):
4543 # Advanced parameter of GHS3D
4544 self.Parameters().SetWorkingDirectory(path)
4546 ## To keep working files or remove them. Log file remains in case of errors anyway.
4547 # @ingroup l3_hypos_ghs3dh
4548 def SetKeepFiles(self, toKeep):
4549 # Advanced parameter of GHS3D and GHS3DPRL
4550 self.Parameters().SetKeepFiles(toKeep)
4552 ## To set verbose level [0-10]. <ul>
4553 #<li> 0 - no standard output,
4554 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4555 # indicates when the final mesh is being saved. In addition the software
4556 # gives indication regarding the CPU time.
4557 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4558 # histogram of the skin mesh, quality statistics histogram together with
4559 # the characteristics of the final mesh.</ul>
4560 # @ingroup l3_hypos_ghs3dh
4561 def SetVerboseLevel(self, level):
4562 # Advanced parameter of GHS3D
4563 self.Parameters().SetVerboseLevel(level)
4565 ## To create new nodes.
4566 # @ingroup l3_hypos_ghs3dh
4567 def SetToCreateNewNodes(self, toCreate):
4568 # Advanced parameter of GHS3D
4569 self.Parameters().SetToCreateNewNodes(toCreate)
4571 ## To use boundary recovery version which tries to create mesh on a very poor
4572 # quality surface mesh.
4573 # @ingroup l3_hypos_ghs3dh
4574 def SetToUseBoundaryRecoveryVersion(self, toUse):
4575 # Advanced parameter of GHS3D
4576 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4578 ## Sets command line option as text.
4579 # @ingroup l3_hypos_ghs3dh
4580 def SetTextOption(self, option):
4581 # Advanced parameter of GHS3D
4582 self.Parameters().SetTextOption(option)
4584 ## Sets MED files name and path.
4585 def SetMEDName(self, value):
4586 self.Parameters().SetMEDName(value)
4588 ## Sets the number of partition of the initial mesh
4589 def SetNbPart(self, value):
4590 self.Parameters().SetNbPart(value)
4592 ## When big mesh, start tepal in background
4593 def SetBackground(self, value):
4594 self.Parameters().SetBackground(value)
4596 # Public class: Mesh_Hexahedron
4597 # ------------------------------
4599 ## Defines a hexahedron 3D algorithm
4601 # @ingroup l3_algos_basic
4602 class Mesh_Hexahedron(Mesh_Algorithm):
4607 ## Private constructor.
4608 def __init__(self, mesh, algoType=Hexa, geom=0):
4609 Mesh_Algorithm.__init__(self)
4611 self.algoType = algoType
4613 if algoType == Hexa:
4614 self.Create(mesh, geom, "Hexa_3D")
4617 elif algoType == Hexotic:
4618 CheckPlugin(Hexotic)
4619 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4622 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4623 # @ingroup l3_hypos_hexotic
4624 def MinMaxQuad(self, min=3, max=8, quad=True):
4625 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4627 self.params.SetHexesMinLevel(min)
4628 self.params.SetHexesMaxLevel(max)
4629 self.params.SetHexoticQuadrangles(quad)
4632 # Deprecated, only for compatibility!
4633 # Public class: Mesh_Netgen
4634 # ------------------------------
4636 ## Defines a NETGEN-based 2D or 3D algorithm
4637 # that needs no discrete boundary (i.e. independent)
4639 # This class is deprecated, only for compatibility!
4642 # @ingroup l3_algos_basic
4643 class Mesh_Netgen(Mesh_Algorithm):
4647 ## Private constructor.
4648 def __init__(self, mesh, is3D, geom=0):
4649 Mesh_Algorithm.__init__(self)
4655 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4659 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4662 ## Defines the hypothesis containing parameters of the algorithm
4663 def Parameters(self):
4665 hyp = self.Hypothesis("NETGEN_Parameters", [],
4666 "libNETGENEngine.so", UseExisting=0)
4668 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4669 "libNETGENEngine.so", UseExisting=0)
4672 # Public class: Mesh_Projection1D
4673 # ------------------------------
4675 ## Defines a projection 1D algorithm
4676 # @ingroup l3_algos_proj
4678 class Mesh_Projection1D(Mesh_Algorithm):
4680 ## Private constructor.
4681 def __init__(self, mesh, geom=0):
4682 Mesh_Algorithm.__init__(self)
4683 self.Create(mesh, geom, "Projection_1D")
4685 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4686 # a mesh pattern is taken, and, optionally, the association of vertices
4687 # between the source edge and a target edge (to which a hypothesis is assigned)
4688 # @param edge from which nodes distribution is taken
4689 # @param mesh from which nodes distribution is taken (optional)
4690 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4691 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4692 # to associate with \a srcV (optional)
4693 # @param UseExisting if ==true - searches for the existing hypothesis created with
4694 # the same parameters, else (default) - creates a new one
4695 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4696 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4698 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4699 hyp.SetSourceEdge( edge )
4700 if not mesh is None and isinstance(mesh, Mesh):
4701 mesh = mesh.GetMesh()
4702 hyp.SetSourceMesh( mesh )
4703 hyp.SetVertexAssociation( srcV, tgtV )
4706 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4707 #def CompareSourceEdge(self, hyp, args):
4708 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4712 # Public class: Mesh_Projection2D
4713 # ------------------------------
4715 ## Defines a projection 2D algorithm
4716 # @ingroup l3_algos_proj
4718 class Mesh_Projection2D(Mesh_Algorithm):
4720 ## Private constructor.
4721 def __init__(self, mesh, geom=0):
4722 Mesh_Algorithm.__init__(self)
4723 self.Create(mesh, geom, "Projection_2D")
4725 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4726 # a mesh pattern is taken, and, optionally, the association of vertices
4727 # between the source face and the target face (to which a hypothesis is assigned)
4728 # @param face from which the mesh pattern is taken
4729 # @param mesh from which the mesh pattern is taken (optional)
4730 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4731 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4732 # to associate with \a srcV1 (optional)
4733 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4734 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4735 # to associate with \a srcV2 (optional)
4736 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4737 # the same parameters, else (default) - forces the creation a new one
4739 # Note: all association vertices must belong to one edge of a face
4740 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4741 srcV2=None, tgtV2=None, UseExisting=0):
4742 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4744 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4745 hyp.SetSourceFace( face )
4746 if not mesh is None and isinstance(mesh, Mesh):
4747 mesh = mesh.GetMesh()
4748 hyp.SetSourceMesh( mesh )
4749 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4752 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4753 #def CompareSourceFace(self, hyp, args):
4754 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4757 # Public class: Mesh_Projection3D
4758 # ------------------------------
4760 ## Defines a projection 3D algorithm
4761 # @ingroup l3_algos_proj
4763 class Mesh_Projection3D(Mesh_Algorithm):
4765 ## Private constructor.
4766 def __init__(self, mesh, geom=0):
4767 Mesh_Algorithm.__init__(self)
4768 self.Create(mesh, geom, "Projection_3D")
4770 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4771 # the mesh pattern is taken, and, optionally, the association of vertices
4772 # between the source and the target solid (to which a hipothesis is assigned)
4773 # @param solid from where the mesh pattern is taken
4774 # @param mesh from where the mesh pattern is taken (optional)
4775 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4776 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4777 # to associate with \a srcV1 (optional)
4778 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4779 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4780 # to associate with \a srcV2 (optional)
4781 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4782 # the same parameters, else (default) - creates a new one
4784 # Note: association vertices must belong to one edge of a solid
4785 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4786 srcV2=0, tgtV2=0, UseExisting=0):
4787 hyp = self.Hypothesis("ProjectionSource3D",
4788 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4790 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4791 hyp.SetSource3DShape( solid )
4792 if not mesh is None and isinstance(mesh, Mesh):
4793 mesh = mesh.GetMesh()
4794 hyp.SetSourceMesh( mesh )
4795 if srcV1 and srcV2 and tgtV1 and tgtV2:
4796 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4797 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4800 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4801 #def CompareSourceShape3D(self, hyp, args):
4802 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4806 # Public class: Mesh_Prism
4807 # ------------------------
4809 ## Defines a 3D extrusion algorithm
4810 # @ingroup l3_algos_3dextr
4812 class Mesh_Prism3D(Mesh_Algorithm):
4814 ## Private constructor.
4815 def __init__(self, mesh, geom=0):
4816 Mesh_Algorithm.__init__(self)
4817 self.Create(mesh, geom, "Prism_3D")
4819 # Public class: Mesh_RadialPrism
4820 # -------------------------------
4822 ## Defines a Radial Prism 3D algorithm
4823 # @ingroup l3_algos_radialp
4825 class Mesh_RadialPrism3D(Mesh_Algorithm):
4827 ## Private constructor.
4828 def __init__(self, mesh, geom=0):
4829 Mesh_Algorithm.__init__(self)
4830 self.Create(mesh, geom, "RadialPrism_3D")
4832 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4833 self.nbLayers = None
4835 ## Return 3D hypothesis holding the 1D one
4836 def Get3DHypothesis(self):
4837 return self.distribHyp
4839 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4840 # hypothesis. Returns the created hypothesis
4841 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4842 #print "OwnHypothesis",hypType
4843 if not self.nbLayers is None:
4844 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4845 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4846 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4847 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4848 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4849 self.distribHyp.SetLayerDistribution( hyp )
4852 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4853 # prisms to build between the inner and outer shells
4854 # @param n number of layers
4855 # @param UseExisting if ==true - searches for the existing hypothesis created with
4856 # the same parameters, else (default) - creates a new one
4857 def NumberOfLayers(self, n, UseExisting=0):
4858 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4859 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4860 CompareMethod=self.CompareNumberOfLayers)
4861 self.nbLayers.SetNumberOfLayers( n )
4862 return self.nbLayers
4864 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4865 def CompareNumberOfLayers(self, hyp, args):
4866 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4868 ## Defines "LocalLength" hypothesis, specifying the segment length
4869 # to build between the inner and the outer shells
4870 # @param l the length of segments
4871 # @param p the precision of rounding
4872 def LocalLength(self, l, p=1e-07):
4873 hyp = self.OwnHypothesis("LocalLength", [l,p])
4878 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4879 # prisms to build between the inner and the outer shells.
4880 # @param n the number of layers
4881 # @param s the scale factor (optional)
4882 def NumberOfSegments(self, n, s=[]):
4884 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4886 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4887 hyp.SetDistrType( 1 )
4888 hyp.SetScaleFactor(s)
4889 hyp.SetNumberOfSegments(n)
4892 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4893 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4894 # @param start the length of the first segment
4895 # @param end the length of the last segment
4896 def Arithmetic1D(self, start, end ):
4897 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4898 hyp.SetLength(start, 1)
4899 hyp.SetLength(end , 0)
4902 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4903 # to build between the inner and the outer shells as geometric length increasing
4904 # @param start for the length of the first segment
4905 # @param end for the length of the last segment
4906 def StartEndLength(self, start, end):
4907 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4908 hyp.SetLength(start, 1)
4909 hyp.SetLength(end , 0)
4912 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4913 # to build between the inner and outer shells
4914 # @param fineness defines the quality of the mesh within the range [0-1]
4915 def AutomaticLength(self, fineness=0):
4916 hyp = self.OwnHypothesis("AutomaticLength")
4917 hyp.SetFineness( fineness )
4920 # Public class: Mesh_RadialQuadrangle1D2D
4921 # -------------------------------
4923 ## Defines a Radial Quadrangle 1D2D algorithm
4924 # @ingroup l2_algos_radialq
4926 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
4928 ## Private constructor.
4929 def __init__(self, mesh, geom=0):
4930 Mesh_Algorithm.__init__(self)
4931 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
4933 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
4934 self.nbLayers = None
4936 ## Return 2D hypothesis holding the 1D one
4937 def Get2DHypothesis(self):
4938 return self.distribHyp
4940 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4941 # hypothesis. Returns the created hypothesis
4942 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4943 #print "OwnHypothesis",hypType
4944 if not self.nbLayers is None:
4945 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4946 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4947 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4948 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4949 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4950 self.distribHyp.SetLayerDistribution( hyp )
4953 ## Defines "NumberOfLayers2D" hypothesis, specifying the number of layers
4954 # @param n number of layers
4955 # @param UseExisting if ==true - searches for the existing hypothesis created with
4956 # the same parameters, else (default) - creates a new one
4957 def NumberOfLayers2D(self, n, UseExisting=0):
4958 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4959 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
4960 CompareMethod=self.CompareNumberOfLayers)
4961 self.nbLayers.SetNumberOfLayers( n )
4962 return self.nbLayers
4964 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4965 def CompareNumberOfLayers(self, hyp, args):
4966 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4968 ## Defines "LocalLength" hypothesis, specifying the segment length
4969 # @param l the length of segments
4970 # @param p the precision of rounding
4971 def LocalLength(self, l, p=1e-07):
4972 hyp = self.OwnHypothesis("LocalLength", [l,p])
4977 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
4978 # @param n the number of layers
4979 # @param s the scale factor (optional)
4980 def NumberOfSegments(self, n, s=[]):
4982 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4984 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4985 hyp.SetDistrType( 1 )
4986 hyp.SetScaleFactor(s)
4987 hyp.SetNumberOfSegments(n)
4990 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4991 # with a length that changes in arithmetic progression
4992 # @param start the length of the first segment
4993 # @param end the length of the last segment
4994 def Arithmetic1D(self, start, end ):
4995 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4996 hyp.SetLength(start, 1)
4997 hyp.SetLength(end , 0)
5000 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5001 # as geometric length increasing
5002 # @param start for the length of the first segment
5003 # @param end for the length of the last segment
5004 def StartEndLength(self, start, end):
5005 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5006 hyp.SetLength(start, 1)
5007 hyp.SetLength(end , 0)
5010 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5011 # @param fineness defines the quality of the mesh within the range [0-1]
5012 def AutomaticLength(self, fineness=0):
5013 hyp = self.OwnHypothesis("AutomaticLength")
5014 hyp.SetFineness( fineness )
5018 # Private class: Mesh_UseExisting
5019 # -------------------------------
5020 class Mesh_UseExisting(Mesh_Algorithm):
5022 def __init__(self, dim, mesh, geom=0):
5024 self.Create(mesh, geom, "UseExisting_1D")
5026 self.Create(mesh, geom, "UseExisting_2D")
5029 import salome_notebook
5030 notebook = salome_notebook.notebook
5032 ##Return values of the notebook variables
5033 def ParseParameters(last, nbParams,nbParam, value):
5037 listSize = len(last)
5038 for n in range(0,nbParams):
5040 if counter < listSize:
5041 strResult = strResult + last[counter]
5043 strResult = strResult + ""
5045 if isinstance(value, str):
5046 if notebook.isVariable(value):
5047 result = notebook.get(value)
5048 strResult=strResult+value
5050 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5052 strResult=strResult+str(value)
5054 if nbParams - 1 != counter:
5055 strResult=strResult+var_separator #":"
5057 return result, strResult
5059 #Wrapper class for StdMeshers_LocalLength hypothesis
5060 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5062 ## Set Length parameter value
5063 # @param length numerical value or name of variable from notebook
5064 def SetLength(self, length):
5065 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5066 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5067 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5069 ## Set Precision parameter value
5070 # @param precision numerical value or name of variable from notebook
5071 def SetPrecision(self, precision):
5072 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5073 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5074 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5076 #Registering the new proxy for LocalLength
5077 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5080 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5081 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5083 def SetLayerDistribution(self, hypo):
5084 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5085 hypo.ClearParameters();
5086 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5088 #Registering the new proxy for LayerDistribution
5089 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5091 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5092 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5094 ## Set Length parameter value
5095 # @param length numerical value or name of variable from notebook
5096 def SetLength(self, length):
5097 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5098 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5099 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5101 #Registering the new proxy for SegmentLengthAroundVertex
5102 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5105 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5106 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5108 ## Set Length parameter value
5109 # @param length numerical value or name of variable from notebook
5110 # @param isStart true is length is Start Length, otherwise false
5111 def SetLength(self, length, isStart):
5115 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5116 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5117 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5119 #Registering the new proxy for Arithmetic1D
5120 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5122 #Wrapper class for StdMeshers_Deflection1D hypothesis
5123 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5125 ## Set Deflection parameter value
5126 # @param deflection numerical value or name of variable from notebook
5127 def SetDeflection(self, deflection):
5128 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5129 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5130 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5132 #Registering the new proxy for Deflection1D
5133 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5135 #Wrapper class for StdMeshers_StartEndLength hypothesis
5136 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5138 ## Set Length parameter value
5139 # @param length numerical value or name of variable from notebook
5140 # @param isStart true is length is Start Length, otherwise false
5141 def SetLength(self, length, isStart):
5145 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5146 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5147 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5149 #Registering the new proxy for StartEndLength
5150 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5152 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5153 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5155 ## Set Max Element Area parameter value
5156 # @param area numerical value or name of variable from notebook
5157 def SetMaxElementArea(self, area):
5158 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5159 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5160 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5162 #Registering the new proxy for MaxElementArea
5163 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5166 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5167 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5169 ## Set Max Element Volume parameter value
5170 # @param area numerical value or name of variable from notebook
5171 def SetMaxElementVolume(self, volume):
5172 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5173 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5174 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5176 #Registering the new proxy for MaxElementVolume
5177 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5180 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5181 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5183 ## Set Number Of Layers parameter value
5184 # @param nbLayers numerical value or name of variable from notebook
5185 def SetNumberOfLayers(self, nbLayers):
5186 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5187 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5188 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5190 #Registering the new proxy for NumberOfLayers
5191 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5193 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5194 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5196 ## Set Number Of Segments parameter value
5197 # @param nbSeg numerical value or name of variable from notebook
5198 def SetNumberOfSegments(self, nbSeg):
5199 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5200 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5201 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5202 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5204 ## Set Scale Factor parameter value
5205 # @param factor numerical value or name of variable from notebook
5206 def SetScaleFactor(self, factor):
5207 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5208 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5209 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5211 #Registering the new proxy for NumberOfSegments
5212 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5214 if not noNETGENPlugin:
5215 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5216 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5218 ## Set Max Size parameter value
5219 # @param maxsize numerical value or name of variable from notebook
5220 def SetMaxSize(self, maxsize):
5221 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5222 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5223 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5224 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5226 ## Set Growth Rate parameter value
5227 # @param value numerical value or name of variable from notebook
5228 def SetGrowthRate(self, value):
5229 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5230 value, parameters = ParseParameters(lastParameters,4,2,value)
5231 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5232 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5234 ## Set Number of Segments per Edge parameter value
5235 # @param value numerical value or name of variable from notebook
5236 def SetNbSegPerEdge(self, value):
5237 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5238 value, parameters = ParseParameters(lastParameters,4,3,value)
5239 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5240 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5242 ## Set Number of Segments per Radius parameter value
5243 # @param value numerical value or name of variable from notebook
5244 def SetNbSegPerRadius(self, value):
5245 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5246 value, parameters = ParseParameters(lastParameters,4,4,value)
5247 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5248 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5250 #Registering the new proxy for NETGENPlugin_Hypothesis
5251 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5254 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5255 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5258 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5259 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5261 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5262 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5264 ## Set Number of Segments parameter value
5265 # @param nbSeg numerical value or name of variable from notebook
5266 def SetNumberOfSegments(self, nbSeg):
5267 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5268 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5269 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5270 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5272 ## Set Local Length parameter value
5273 # @param length numerical value or name of variable from notebook
5274 def SetLocalLength(self, length):
5275 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5276 length, parameters = ParseParameters(lastParameters,2,1,length)
5277 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5278 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5280 ## Set Max Element Area parameter value
5281 # @param area numerical value or name of variable from notebook
5282 def SetMaxElementArea(self, area):
5283 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5284 area, parameters = ParseParameters(lastParameters,2,2,area)
5285 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5286 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5288 def LengthFromEdges(self):
5289 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5291 value, parameters = ParseParameters(lastParameters,2,2,value)
5292 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5293 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5295 #Registering the new proxy for NETGEN_SimpleParameters_2D
5296 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5299 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5300 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5301 ## Set Max Element Volume parameter value
5302 # @param volume numerical value or name of variable from notebook
5303 def SetMaxElementVolume(self, volume):
5304 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5305 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5306 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5307 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5309 def LengthFromFaces(self):
5310 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5312 value, parameters = ParseParameters(lastParameters,3,3,value)
5313 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5314 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5316 #Registering the new proxy for NETGEN_SimpleParameters_3D
5317 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5319 pass # if not noNETGENPlugin:
5321 class Pattern(SMESH._objref_SMESH_Pattern):
5323 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5325 if isinstance(theNodeIndexOnKeyPoint1,str):
5327 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5329 theNodeIndexOnKeyPoint1 -= 1
5330 theMesh.SetParameters(Parameters)
5331 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5333 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5336 if isinstance(theNode000Index,str):
5338 if isinstance(theNode001Index,str):
5340 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5342 theNode000Index -= 1
5344 theNode001Index -= 1
5345 theMesh.SetParameters(Parameters)
5346 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5348 #Registering the new proxy for Pattern
5349 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)