1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # Author : Francis KLOSS, OCC
30 ## @defgroup l1_auxiliary Auxiliary methods and structures
31 ## @defgroup l1_creating Creating meshes
33 ## @defgroup l2_impexp Importing and exporting meshes
34 ## @defgroup l2_construct Constructing meshes
35 ## @defgroup l2_algorithms Defining Algorithms
37 ## @defgroup l3_algos_basic Basic meshing algorithms
38 ## @defgroup l3_algos_proj Projection Algorithms
39 ## @defgroup l3_algos_radialp Radial Prism
40 ## @defgroup l3_algos_segmarv Segments around Vertex
41 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
44 ## @defgroup l2_hypotheses Defining hypotheses
46 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
47 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
48 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
49 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
50 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
51 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
52 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
53 ## @defgroup l3_hypos_quad Quadrangle Parameters hypothesis
54 ## @defgroup l3_hypos_additi Additional Hypotheses
57 ## @defgroup l2_submeshes Constructing submeshes
58 ## @defgroup l2_compounds Building Compounds
59 ## @defgroup l2_editing Editing Meshes
62 ## @defgroup l1_meshinfo Mesh Information
63 ## @defgroup l1_controls Quality controls and Filtering
64 ## @defgroup l1_grouping Grouping elements
66 ## @defgroup l2_grps_create Creating groups
67 ## @defgroup l2_grps_edit Editing groups
68 ## @defgroup l2_grps_operon Using operations on groups
69 ## @defgroup l2_grps_delete Deleting Groups
72 ## @defgroup l1_modifying Modifying meshes
74 ## @defgroup l2_modif_add Adding nodes and elements
75 ## @defgroup l2_modif_del Removing nodes and elements
76 ## @defgroup l2_modif_edit Modifying nodes and elements
77 ## @defgroup l2_modif_renumber Renumbering nodes and elements
78 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
79 ## @defgroup l2_modif_movenode Moving nodes
80 ## @defgroup l2_modif_throughp Mesh through point
81 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
82 ## @defgroup l2_modif_unitetri Uniting triangles
83 ## @defgroup l2_modif_changori Changing orientation of elements
84 ## @defgroup l2_modif_cutquadr Cutting quadrangles
85 ## @defgroup l2_modif_smooth Smoothing
86 ## @defgroup l2_modif_extrurev Extrusion and Revolution
87 ## @defgroup l2_modif_patterns Pattern mapping
88 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
91 ## @defgroup l1_measurements Measurements
96 import SMESH # This is necessary for back compatibility
104 # import NETGENPlugin module if possible
112 # import GHS3DPlugin module if possible
120 # import GHS3DPRLPlugin module if possible
123 import GHS3DPRLPlugin
128 # import HexoticPlugin module if possible
136 # import BLSURFPlugin module if possible
144 ## @addtogroup l1_auxiliary
147 # Types of algorithms
160 NETGEN_1D2D3D = FULL_NETGEN
161 NETGEN_FULL = FULL_NETGEN
169 # MirrorType enumeration
170 POINT = SMESH_MeshEditor.POINT
171 AXIS = SMESH_MeshEditor.AXIS
172 PLANE = SMESH_MeshEditor.PLANE
174 # Smooth_Method enumeration
175 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
176 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
178 # Fineness enumeration (for NETGEN)
186 # Optimization level of GHS3D
188 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
189 # V4.1 (partialy redefines V3.1). Issue 0020574
190 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
192 # Topology treatment way of BLSURF
193 FromCAD, PreProcess, PreProcessPlus = 0,1,2
195 # Element size flag of BLSURF
196 DefaultSize, DefaultGeom, Custom = 0,0,1
198 PrecisionConfusion = 1e-07
200 # TopAbs_State enumeration
201 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
203 # Methods of splitting a hexahedron into tetrahedra
204 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
206 # import items of enum QuadType
207 for e in StdMeshers.QuadType._items: exec('%s = StdMeshers.%s'%(e,e))
209 ## Converts an angle from degrees to radians
210 def DegreesToRadians(AngleInDegrees):
212 return AngleInDegrees * pi / 180.0
214 # Salome notebook variable separator
217 # Parametrized substitute for PointStruct
218 class PointStructStr:
227 def __init__(self, xStr, yStr, zStr):
231 if isinstance(xStr, str) and notebook.isVariable(xStr):
232 self.x = notebook.get(xStr)
235 if isinstance(yStr, str) and notebook.isVariable(yStr):
236 self.y = notebook.get(yStr)
239 if isinstance(zStr, str) and notebook.isVariable(zStr):
240 self.z = notebook.get(zStr)
244 # Parametrized substitute for PointStruct (with 6 parameters)
245 class PointStructStr6:
260 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
267 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
268 self.x1 = notebook.get(x1Str)
271 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
272 self.x2 = notebook.get(x2Str)
275 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
276 self.y1 = notebook.get(y1Str)
279 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
280 self.y2 = notebook.get(y2Str)
283 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
284 self.z1 = notebook.get(z1Str)
287 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
288 self.z2 = notebook.get(z2Str)
292 # Parametrized substitute for AxisStruct
308 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
315 if isinstance(xStr, str) and notebook.isVariable(xStr):
316 self.x = notebook.get(xStr)
319 if isinstance(yStr, str) and notebook.isVariable(yStr):
320 self.y = notebook.get(yStr)
323 if isinstance(zStr, str) and notebook.isVariable(zStr):
324 self.z = notebook.get(zStr)
327 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
328 self.dx = notebook.get(dxStr)
331 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
332 self.dy = notebook.get(dyStr)
335 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
336 self.dz = notebook.get(dzStr)
340 # Parametrized substitute for DirStruct
343 def __init__(self, pointStruct):
344 self.pointStruct = pointStruct
346 # Returns list of variable values from salome notebook
347 def ParsePointStruct(Point):
348 Parameters = 2*var_separator
349 if isinstance(Point, PointStructStr):
350 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
351 Point = PointStruct(Point.x, Point.y, Point.z)
352 return Point, Parameters
354 # Returns list of variable values from salome notebook
355 def ParseDirStruct(Dir):
356 Parameters = 2*var_separator
357 if isinstance(Dir, DirStructStr):
358 pntStr = Dir.pointStruct
359 if isinstance(pntStr, PointStructStr6):
360 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
361 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
362 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
363 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
365 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
366 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
367 Dir = DirStruct(Point)
368 return Dir, Parameters
370 # Returns list of variable values from salome notebook
371 def ParseAxisStruct(Axis):
372 Parameters = 5*var_separator
373 if isinstance(Axis, AxisStructStr):
374 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
375 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
376 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
377 return Axis, Parameters
379 ## Return list of variable values from salome notebook
380 def ParseAngles(list):
383 for parameter in list:
384 if isinstance(parameter,str) and notebook.isVariable(parameter):
385 Result.append(DegreesToRadians(notebook.get(parameter)))
388 Result.append(parameter)
391 Parameters = Parameters + str(parameter)
392 Parameters = Parameters + var_separator
394 Parameters = Parameters[:len(Parameters)-1]
395 return Result, Parameters
397 def IsEqual(val1, val2, tol=PrecisionConfusion):
398 if abs(val1 - val2) < tol:
408 if isinstance(obj, SALOMEDS._objref_SObject):
411 ior = salome.orb.object_to_string(obj)
414 studies = salome.myStudyManager.GetOpenStudies()
415 for sname in studies:
416 s = salome.myStudyManager.GetStudyByName(sname)
418 sobj = s.FindObjectIOR(ior)
419 if not sobj: continue
420 return sobj.GetName()
421 if hasattr(obj, "GetName"):
422 # unknown CORBA object, having GetName() method
425 # unknown CORBA object, no GetName() method
428 if hasattr(obj, "GetName"):
429 # unknown non-CORBA object, having GetName() method
432 raise RuntimeError, "Null or invalid object"
434 ## Prints error message if a hypothesis was not assigned.
435 def TreatHypoStatus(status, hypName, geomName, isAlgo):
437 hypType = "algorithm"
439 hypType = "hypothesis"
441 if status == HYP_UNKNOWN_FATAL :
442 reason = "for unknown reason"
443 elif status == HYP_INCOMPATIBLE :
444 reason = "this hypothesis mismatches the algorithm"
445 elif status == HYP_NOTCONFORM :
446 reason = "a non-conform mesh would be built"
447 elif status == HYP_ALREADY_EXIST :
448 if isAlgo: return # it does not influence anything
449 reason = hypType + " of the same dimension is already assigned to this shape"
450 elif status == HYP_BAD_DIM :
451 reason = hypType + " mismatches the shape"
452 elif status == HYP_CONCURENT :
453 reason = "there are concurrent hypotheses on sub-shapes"
454 elif status == HYP_BAD_SUBSHAPE :
455 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
456 elif status == HYP_BAD_GEOMETRY:
457 reason = "geometry mismatches the expectation of the algorithm"
458 elif status == HYP_HIDDEN_ALGO:
459 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
460 elif status == HYP_HIDING_ALGO:
461 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
462 elif status == HYP_NEED_SHAPE:
463 reason = "Algorithm can't work without shape"
466 hypName = '"' + hypName + '"'
467 geomName= '"' + geomName+ '"'
468 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
469 print hypName, "was assigned to", geomName,"but", reason
470 elif not geomName == '""':
471 print hypName, "was not assigned to",geomName,":", reason
473 print hypName, "was not assigned:", reason
476 ## Check meshing plugin availability
477 def CheckPlugin(plugin):
478 if plugin == NETGEN and noNETGENPlugin:
479 print "Warning: NETGENPlugin module unavailable"
481 elif plugin == GHS3D and noGHS3DPlugin:
482 print "Warning: GHS3DPlugin module unavailable"
484 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
485 print "Warning: GHS3DPRLPlugin module unavailable"
487 elif plugin == Hexotic and noHexoticPlugin:
488 print "Warning: HexoticPlugin module unavailable"
490 elif plugin == BLSURF and noBLSURFPlugin:
491 print "Warning: BLSURFPlugin module unavailable"
495 # end of l1_auxiliary
498 # All methods of this class are accessible directly from the smesh.py package.
499 class smeshDC(SMESH._objref_SMESH_Gen):
501 ## Sets the current study and Geometry component
502 # @ingroup l1_auxiliary
503 def init_smesh(self,theStudy,geompyD):
504 self.SetCurrentStudy(theStudy,geompyD)
506 ## Creates an empty Mesh. This mesh can have an underlying geometry.
507 # @param obj the Geometrical object on which the mesh is built. If not defined,
508 # the mesh will have no underlying geometry.
509 # @param name the name for the new mesh.
510 # @return an instance of Mesh class.
511 # @ingroup l2_construct
512 def Mesh(self, obj=0, name=0):
513 if isinstance(obj,str):
515 return Mesh(self,self.geompyD,obj,name)
517 ## Returns a long value from enumeration
518 # Should be used for SMESH.FunctorType enumeration
519 # @ingroup l1_controls
520 def EnumToLong(self,theItem):
523 ## Returns a string representation of the color.
524 # To be used with filters.
525 # @param c color value (SALOMEDS.Color)
526 # @ingroup l1_controls
527 def ColorToString(self,c):
529 if isinstance(c, SALOMEDS.Color):
530 val = "%s;%s;%s" % (c.R, c.G, c.B)
531 elif isinstance(c, str):
534 raise ValueError, "Color value should be of string or SALOMEDS.Color type"
537 ## Gets PointStruct from vertex
538 # @param theVertex a GEOM object(vertex)
539 # @return SMESH.PointStruct
540 # @ingroup l1_auxiliary
541 def GetPointStruct(self,theVertex):
542 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
543 return PointStruct(x,y,z)
545 ## Gets DirStruct from vector
546 # @param theVector a GEOM object(vector)
547 # @return SMESH.DirStruct
548 # @ingroup l1_auxiliary
549 def GetDirStruct(self,theVector):
550 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
551 if(len(vertices) != 2):
552 print "Error: vector object is incorrect."
554 p1 = self.geompyD.PointCoordinates(vertices[0])
555 p2 = self.geompyD.PointCoordinates(vertices[1])
556 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
557 dirst = DirStruct(pnt)
560 ## Makes DirStruct from a triplet
561 # @param x,y,z vector components
562 # @return SMESH.DirStruct
563 # @ingroup l1_auxiliary
564 def MakeDirStruct(self,x,y,z):
565 pnt = PointStruct(x,y,z)
566 return DirStruct(pnt)
568 ## Get AxisStruct from object
569 # @param theObj a GEOM object (line or plane)
570 # @return SMESH.AxisStruct
571 # @ingroup l1_auxiliary
572 def GetAxisStruct(self,theObj):
573 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
575 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
576 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
577 vertex1 = self.geompyD.PointCoordinates(vertex1)
578 vertex2 = self.geompyD.PointCoordinates(vertex2)
579 vertex3 = self.geompyD.PointCoordinates(vertex3)
580 vertex4 = self.geompyD.PointCoordinates(vertex4)
581 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
582 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
583 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] ]
584 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
586 elif len(edges) == 1:
587 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
588 p1 = self.geompyD.PointCoordinates( vertex1 )
589 p2 = self.geompyD.PointCoordinates( vertex2 )
590 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
594 # From SMESH_Gen interface:
595 # ------------------------
597 ## Sets the given name to the object
598 # @param obj the object to rename
599 # @param name a new object name
600 # @ingroup l1_auxiliary
601 def SetName(self, obj, name):
602 if isinstance( obj, Mesh ):
604 elif isinstance( obj, Mesh_Algorithm ):
605 obj = obj.GetAlgorithm()
606 ior = salome.orb.object_to_string(obj)
607 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
609 ## Sets the current mode
610 # @ingroup l1_auxiliary
611 def SetEmbeddedMode( self,theMode ):
612 #self.SetEmbeddedMode(theMode)
613 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
615 ## Gets the current mode
616 # @ingroup l1_auxiliary
617 def IsEmbeddedMode(self):
618 #return self.IsEmbeddedMode()
619 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
621 ## Sets the current study
622 # @ingroup l1_auxiliary
623 def SetCurrentStudy( self, theStudy, geompyD = None ):
624 #self.SetCurrentStudy(theStudy)
627 geompyD = geompy.geom
630 self.SetGeomEngine(geompyD)
631 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
633 ## Gets the current study
634 # @ingroup l1_auxiliary
635 def GetCurrentStudy(self):
636 #return self.GetCurrentStudy()
637 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
639 ## Creates a Mesh object importing data from the given UNV file
640 # @return an instance of Mesh class
642 def CreateMeshesFromUNV( self,theFileName ):
643 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
644 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
647 ## Creates a Mesh object(s) importing data from the given MED file
648 # @return a list of Mesh class instances
650 def CreateMeshesFromMED( self,theFileName ):
651 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
653 for iMesh in range(len(aSmeshMeshes)) :
654 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
655 aMeshes.append(aMesh)
656 return aMeshes, aStatus
658 ## Creates a Mesh object importing data from the given STL file
659 # @return an instance of Mesh class
661 def CreateMeshesFromSTL( self, theFileName ):
662 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
663 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
666 ## From SMESH_Gen interface
667 # @return the list of integer values
668 # @ingroup l1_auxiliary
669 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
670 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
672 ## From SMESH_Gen interface. Creates a pattern
673 # @return an instance of SMESH_Pattern
675 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
676 # @ingroup l2_modif_patterns
677 def GetPattern(self):
678 return SMESH._objref_SMESH_Gen.GetPattern(self)
680 ## Sets number of segments per diagonal of boundary box of geometry by which
681 # default segment length of appropriate 1D hypotheses is defined.
682 # Default value is 10
683 # @ingroup l1_auxiliary
684 def SetBoundaryBoxSegmentation(self, nbSegments):
685 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
687 ## Concatenate the given meshes into one mesh.
688 # @return an instance of Mesh class
689 # @param meshes the meshes to combine into one mesh
690 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
691 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
692 # @param mergeTolerance tolerance for merging nodes
693 # @param allGroups forces creation of groups of all elements
694 def Concatenate( self, meshes, uniteIdenticalGroups,
695 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
696 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
697 for i,m in enumerate(meshes):
698 if isinstance(m, Mesh):
699 meshes[i] = m.GetMesh()
701 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
702 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
704 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
705 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
706 aSmeshMesh.SetParameters(Parameters)
707 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
710 # Filtering. Auxiliary functions:
711 # ------------------------------
713 ## Creates an empty criterion
714 # @return SMESH.Filter.Criterion
715 # @ingroup l1_controls
716 def GetEmptyCriterion(self):
717 Type = self.EnumToLong(FT_Undefined)
718 Compare = self.EnumToLong(FT_Undefined)
722 UnaryOp = self.EnumToLong(FT_Undefined)
723 BinaryOp = self.EnumToLong(FT_Undefined)
726 Precision = -1 ##@1e-07
727 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
728 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
730 ## Creates a criterion by the given parameters
731 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
732 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
733 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
734 # @param Treshold the threshold value (range of ids as string, shape, numeric)
735 # @param UnaryOp FT_LogicalNOT or FT_Undefined
736 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
737 # FT_Undefined (must be for the last criterion of all criteria)
738 # @return SMESH.Filter.Criterion
739 # @ingroup l1_controls
740 def GetCriterion(self,elementType,
742 Compare = FT_EqualTo,
744 UnaryOp=FT_Undefined,
745 BinaryOp=FT_Undefined):
746 aCriterion = self.GetEmptyCriterion()
747 aCriterion.TypeOfElement = elementType
748 aCriterion.Type = self.EnumToLong(CritType)
752 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
753 aCriterion.Compare = self.EnumToLong(Compare)
754 elif Compare == "=" or Compare == "==":
755 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
757 aCriterion.Compare = self.EnumToLong(FT_LessThan)
759 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
761 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
764 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
765 FT_BelongToCylinder, FT_LyingOnGeom]:
766 # Checks the treshold
767 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
768 aCriterion.ThresholdStr = GetName(aTreshold)
769 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
771 print "Error: The treshold should be a shape."
773 elif CritType == FT_RangeOfIds:
774 # Checks the treshold
775 if isinstance(aTreshold, str):
776 aCriterion.ThresholdStr = aTreshold
778 print "Error: The treshold should be a string."
780 elif CritType == FT_CoplanarFaces:
781 # Checks the treshold
782 if isinstance(aTreshold, int):
783 aCriterion.ThresholdID = "%s"%aTreshold
784 elif isinstance(aTreshold, str):
787 raise ValueError, "Invalid ID of mesh face: '%s'"%aTreshold
788 aCriterion.ThresholdID = aTreshold
791 "The treshold should be an ID of mesh face and not '%s'"%aTreshold
792 elif CritType == FT_ElemGeomType:
793 # Checks the treshold
795 aCriterion.Threshold = self.EnumToLong(aTreshold)
797 if isinstance(aTreshold, int):
798 aCriterion.Threshold = aTreshold
800 print "Error: The treshold should be an integer or SMESH.GeometryType."
804 elif CritType == FT_GroupColor:
805 # Checks the treshold
807 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
809 print "Error: The threshold value should be of SALOMEDS.Color type"
812 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
813 FT_FreeFaces, FT_LinearOrQuadratic]:
814 # At this point the treshold is unnecessary
815 if aTreshold == FT_LogicalNOT:
816 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
817 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
818 aCriterion.BinaryOp = aTreshold
822 aTreshold = float(aTreshold)
823 aCriterion.Threshold = aTreshold
825 print "Error: The treshold should be a number."
828 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
829 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
831 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
832 aCriterion.BinaryOp = self.EnumToLong(Treshold)
834 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
835 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
837 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
838 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
842 ## Creates a filter with the given parameters
843 # @param elementType the type of elements in the group
844 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
845 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
846 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
847 # @param UnaryOp FT_LogicalNOT or FT_Undefined
848 # @return SMESH_Filter
849 # @ingroup l1_controls
850 def GetFilter(self,elementType,
851 CritType=FT_Undefined,
854 UnaryOp=FT_Undefined):
855 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
856 aFilterMgr = self.CreateFilterManager()
857 aFilter = aFilterMgr.CreateFilter()
859 aCriteria.append(aCriterion)
860 aFilter.SetCriteria(aCriteria)
864 ## Creates a numerical functor by its type
865 # @param theCriterion FT_...; functor type
866 # @return SMESH_NumericalFunctor
867 # @ingroup l1_controls
868 def GetFunctor(self,theCriterion):
869 aFilterMgr = self.CreateFilterManager()
870 if theCriterion == FT_AspectRatio:
871 return aFilterMgr.CreateAspectRatio()
872 elif theCriterion == FT_AspectRatio3D:
873 return aFilterMgr.CreateAspectRatio3D()
874 elif theCriterion == FT_Warping:
875 return aFilterMgr.CreateWarping()
876 elif theCriterion == FT_MinimumAngle:
877 return aFilterMgr.CreateMinimumAngle()
878 elif theCriterion == FT_Taper:
879 return aFilterMgr.CreateTaper()
880 elif theCriterion == FT_Skew:
881 return aFilterMgr.CreateSkew()
882 elif theCriterion == FT_Area:
883 return aFilterMgr.CreateArea()
884 elif theCriterion == FT_Volume3D:
885 return aFilterMgr.CreateVolume3D()
886 elif theCriterion == FT_MaxElementLength2D:
887 return aFilterMgr.CreateMaxElementLength2D()
888 elif theCriterion == FT_MaxElementLength3D:
889 return aFilterMgr.CreateMaxElementLength3D()
890 elif theCriterion == FT_MultiConnection:
891 return aFilterMgr.CreateMultiConnection()
892 elif theCriterion == FT_MultiConnection2D:
893 return aFilterMgr.CreateMultiConnection2D()
894 elif theCriterion == FT_Length:
895 return aFilterMgr.CreateLength()
896 elif theCriterion == FT_Length2D:
897 return aFilterMgr.CreateLength2D()
899 print "Error: given parameter is not numerucal functor type."
901 ## Creates hypothesis
902 # @param theHType mesh hypothesis type (string)
903 # @param theLibName mesh plug-in library name
904 # @return created hypothesis instance
905 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
906 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
908 ## Gets the mesh stattistic
909 # @return dictionary type element - count of elements
910 # @ingroup l1_meshinfo
911 def GetMeshInfo(self, obj):
912 if isinstance( obj, Mesh ):
915 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
916 values = obj.GetMeshInfo()
917 for i in range(SMESH.Entity_Last._v):
918 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
922 ## Get minimum distance between two objects
924 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
925 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
927 # @param src1 first source object
928 # @param src2 second source object
929 # @param id1 node/element id from the first source
930 # @param id2 node/element id from the second (or first) source
931 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
932 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
933 # @return minimum distance value
934 # @sa GetMinDistance()
935 # @ingroup l1_measurements
936 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
937 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
941 result = result.value
944 ## Get measure structure specifying minimum distance data between two objects
946 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
947 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
949 # @param src1 first source object
950 # @param src2 second source object
951 # @param id1 node/element id from the first source
952 # @param id2 node/element id from the second (or first) source
953 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
954 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
955 # @return Measure structure or None if input data is invalid
957 # @ingroup l1_measurements
958 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
959 if isinstance(src1, Mesh): src1 = src1.mesh
960 if isinstance(src2, Mesh): src2 = src2.mesh
961 if src2 is None and id2 != 0: src2 = src1
962 if not hasattr(src1, "_narrow"): return None
963 src1 = src1._narrow(SMESH.SMESH_IDSource)
964 if not src1: return None
967 e = m.GetMeshEditor()
969 src1 = e.MakeIDSource([id1], SMESH.FACE)
971 src1 = e.MakeIDSource([id1], SMESH.NODE)
973 if hasattr(src2, "_narrow"):
974 src2 = src2._narrow(SMESH.SMESH_IDSource)
975 if src2 and id2 != 0:
977 e = m.GetMeshEditor()
979 src2 = e.MakeIDSource([id2], SMESH.FACE)
981 src2 = e.MakeIDSource([id2], SMESH.NODE)
984 aMeasurements = self.CreateMeasurements()
985 result = aMeasurements.MinDistance(src1, src2)
986 aMeasurements.Destroy()
989 ## Get bounding box of the specified object(s)
990 # @param objects single source object or list of source objects
991 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
992 # @sa GetBoundingBox()
993 # @ingroup l1_measurements
994 def BoundingBox(self, objects):
995 result = self.GetBoundingBox(objects)
999 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
1002 ## Get measure structure specifying bounding box data of the specified object(s)
1003 # @param objects single source object or list of source objects
1004 # @return Measure structure
1006 # @ingroup l1_measurements
1007 def GetBoundingBox(self, objects):
1008 if isinstance(objects, tuple):
1009 objects = list(objects)
1010 if not isinstance(objects, list):
1014 if isinstance(o, Mesh):
1015 srclist.append(o.mesh)
1016 elif hasattr(o, "_narrow"):
1017 src = o._narrow(SMESH.SMESH_IDSource)
1018 if src: srclist.append(src)
1021 aMeasurements = self.CreateMeasurements()
1022 result = aMeasurements.BoundingBox(srclist)
1023 aMeasurements.Destroy()
1027 #Registering the new proxy for SMESH_Gen
1028 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
1031 # Public class: Mesh
1032 # ==================
1034 ## This class allows defining and managing a mesh.
1035 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
1036 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
1037 # new nodes and elements and by changing the existing entities), to get information
1038 # about a mesh and to export a mesh into different formats.
1047 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
1048 # sets the GUI name of this mesh to \a name.
1049 # @param smeshpyD an instance of smeshDC class
1050 # @param geompyD an instance of geompyDC class
1051 # @param obj Shape to be meshed or SMESH_Mesh object
1052 # @param name Study name of the mesh
1053 # @ingroup l2_construct
1054 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
1055 self.smeshpyD=smeshpyD
1056 self.geompyD=geompyD
1060 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
1062 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1063 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1066 self.mesh = self.smeshpyD.CreateEmptyMesh()
1068 self.smeshpyD.SetName(self.mesh, name)
1070 self.smeshpyD.SetName(self.mesh, GetName(obj))
1073 self.geom = self.mesh.GetShapeToMesh()
1075 self.editor = self.mesh.GetMeshEditor()
1077 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1078 # @param theMesh a SMESH_Mesh object
1079 # @ingroup l2_construct
1080 def SetMesh(self, theMesh):
1082 self.geom = self.mesh.GetShapeToMesh()
1084 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1085 # @return a SMESH_Mesh object
1086 # @ingroup l2_construct
1090 ## Gets the name of the mesh
1091 # @return the name of the mesh as a string
1092 # @ingroup l2_construct
1094 name = GetName(self.GetMesh())
1097 ## Sets a name to the mesh
1098 # @param name a new name of the mesh
1099 # @ingroup l2_construct
1100 def SetName(self, name):
1101 self.smeshpyD.SetName(self.GetMesh(), name)
1103 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1104 # The subMesh object gives access to the IDs of nodes and elements.
1105 # @param theSubObject a geometrical object (shape)
1106 # @param theName a name for the submesh
1107 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1108 # @ingroup l2_submeshes
1109 def GetSubMesh(self, theSubObject, theName):
1110 submesh = self.mesh.GetSubMesh(theSubObject, theName)
1113 ## Returns the shape associated to the mesh
1114 # @return a GEOM_Object
1115 # @ingroup l2_construct
1119 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1120 # @param geom the shape to be meshed (GEOM_Object)
1121 # @ingroup l2_construct
1122 def SetShape(self, geom):
1123 self.mesh = self.smeshpyD.CreateMesh(geom)
1125 ## Returns true if the hypotheses are defined well
1126 # @param theSubObject a subshape of a mesh shape
1127 # @return True or False
1128 # @ingroup l2_construct
1129 def IsReadyToCompute(self, theSubObject):
1130 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1132 ## Returns errors of hypotheses definition.
1133 # The list of errors is empty if everything is OK.
1134 # @param theSubObject a subshape of a mesh shape
1135 # @return a list of errors
1136 # @ingroup l2_construct
1137 def GetAlgoState(self, theSubObject):
1138 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1140 ## Returns a geometrical object on which the given element was built.
1141 # The returned geometrical object, if not nil, is either found in the
1142 # study or published by this method with the given name
1143 # @param theElementID the id of the mesh element
1144 # @param theGeomName the user-defined name of the geometrical object
1145 # @return GEOM::GEOM_Object instance
1146 # @ingroup l2_construct
1147 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1148 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1150 ## Returns the mesh dimension depending on the dimension of the underlying shape
1151 # @return mesh dimension as an integer value [0,3]
1152 # @ingroup l1_auxiliary
1153 def MeshDimension(self):
1154 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1155 if len( shells ) > 0 :
1157 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1159 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1165 ## Creates a segment discretization 1D algorithm.
1166 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1167 # \n If the optional \a geom parameter is not set, this algorithm is global.
1168 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1169 # @param algo the type of the required algorithm. Possible values are:
1171 # - smesh.PYTHON for discretization via a python function,
1172 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1173 # @param geom If defined is the subshape to be meshed
1174 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1175 # @ingroup l3_algos_basic
1176 def Segment(self, algo=REGULAR, geom=0):
1177 ## if Segment(geom) is called by mistake
1178 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1179 algo, geom = geom, algo
1180 if not algo: algo = REGULAR
1183 return Mesh_Segment(self, geom)
1184 elif algo == PYTHON:
1185 return Mesh_Segment_Python(self, geom)
1186 elif algo == COMPOSITE:
1187 return Mesh_CompositeSegment(self, geom)
1189 return Mesh_Segment(self, geom)
1191 ## Creates 1D algorithm importing segments conatined in groups of other mesh.
1192 # If the optional \a geom parameter is not set, this algorithm is global.
1193 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1194 # @param geom If defined the subshape is to be meshed
1195 # @return an instance of Mesh_UseExistingElements class
1196 # @ingroup l3_algos_basic
1197 def UseExisting1DElements(self, geom=0):
1198 return Mesh_UseExistingElements(1,self, geom)
1200 ## Creates 2D algorithm importing faces conatined in groups of other mesh.
1201 # If the optional \a geom parameter is not set, this algorithm is global.
1202 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1203 # @param geom If defined the subshape is to be meshed
1204 # @return an instance of Mesh_UseExistingElements class
1205 # @ingroup l3_algos_basic
1206 def UseExisting2DElements(self, geom=0):
1207 return Mesh_UseExistingElements(2,self, geom)
1209 ## Enables creation of nodes and segments usable by 2D algoritms.
1210 # The added nodes and segments must be bound to edges and vertices by
1211 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1212 # If the optional \a geom parameter is not set, this algorithm is global.
1213 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1214 # @param geom the subshape to be manually meshed
1215 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1216 # @ingroup l3_algos_basic
1217 def UseExistingSegments(self, geom=0):
1218 algo = Mesh_UseExisting(1,self,geom)
1219 return algo.GetAlgorithm()
1221 ## Enables creation of nodes and faces usable by 3D algoritms.
1222 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1223 # and SetMeshElementOnShape()
1224 # If the optional \a geom parameter is not set, this algorithm is global.
1225 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1226 # @param geom the subshape to be manually meshed
1227 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1228 # @ingroup l3_algos_basic
1229 def UseExistingFaces(self, geom=0):
1230 algo = Mesh_UseExisting(2,self,geom)
1231 return algo.GetAlgorithm()
1233 ## Creates a triangle 2D algorithm for faces.
1234 # If the optional \a geom parameter is not set, this algorithm is global.
1235 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1236 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1237 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1238 # @return an instance of Mesh_Triangle algorithm
1239 # @ingroup l3_algos_basic
1240 def Triangle(self, algo=MEFISTO, geom=0):
1241 ## if Triangle(geom) is called by mistake
1242 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1245 return Mesh_Triangle(self, algo, geom)
1247 ## Creates a quadrangle 2D algorithm for faces.
1248 # If the optional \a geom parameter is not set, this algorithm is global.
1249 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1250 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1251 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1252 # @return an instance of Mesh_Quadrangle algorithm
1253 # @ingroup l3_algos_basic
1254 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1255 if algo==RADIAL_QUAD:
1256 return Mesh_RadialQuadrangle1D2D(self,geom)
1258 return Mesh_Quadrangle(self, geom)
1260 ## Creates a tetrahedron 3D algorithm for solids.
1261 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1262 # If the optional \a geom parameter is not set, this algorithm is global.
1263 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1264 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1265 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1266 # @return an instance of Mesh_Tetrahedron algorithm
1267 # @ingroup l3_algos_basic
1268 def Tetrahedron(self, algo=NETGEN, geom=0):
1269 ## if Tetrahedron(geom) is called by mistake
1270 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1271 algo, geom = geom, algo
1272 if not algo: algo = NETGEN
1274 return Mesh_Tetrahedron(self, algo, geom)
1276 ## Creates a hexahedron 3D algorithm for solids.
1277 # If the optional \a geom parameter is not set, this algorithm is global.
1278 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1279 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1280 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1281 # @return an instance of Mesh_Hexahedron algorithm
1282 # @ingroup l3_algos_basic
1283 def Hexahedron(self, algo=Hexa, geom=0):
1284 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1285 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1286 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1287 elif geom == 0: algo, geom = Hexa, algo
1288 return Mesh_Hexahedron(self, algo, geom)
1290 ## Deprecated, used only for compatibility!
1291 # @return an instance of Mesh_Netgen algorithm
1292 # @ingroup l3_algos_basic
1293 def Netgen(self, is3D, geom=0):
1294 return Mesh_Netgen(self, is3D, geom)
1296 ## Creates a projection 1D algorithm for edges.
1297 # If the optional \a geom parameter is not set, this algorithm is global.
1298 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1299 # @param geom If defined, the subshape to be meshed
1300 # @return an instance of Mesh_Projection1D algorithm
1301 # @ingroup l3_algos_proj
1302 def Projection1D(self, geom=0):
1303 return Mesh_Projection1D(self, geom)
1305 ## Creates a projection 2D algorithm for faces.
1306 # If the optional \a geom parameter is not set, this algorithm is global.
1307 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1308 # @param geom If defined, the subshape to be meshed
1309 # @return an instance of Mesh_Projection2D algorithm
1310 # @ingroup l3_algos_proj
1311 def Projection2D(self, geom=0):
1312 return Mesh_Projection2D(self, geom)
1314 ## Creates a projection 3D algorithm for solids.
1315 # If the optional \a geom parameter is not set, this algorithm is global.
1316 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1317 # @param geom If defined, the subshape to be meshed
1318 # @return an instance of Mesh_Projection3D algorithm
1319 # @ingroup l3_algos_proj
1320 def Projection3D(self, geom=0):
1321 return Mesh_Projection3D(self, geom)
1323 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1324 # If the optional \a geom parameter is not set, this algorithm is global.
1325 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1326 # @param geom If defined, the subshape to be meshed
1327 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1328 # @ingroup l3_algos_radialp l3_algos_3dextr
1329 def Prism(self, geom=0):
1333 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1334 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1335 if nbSolids == 0 or nbSolids == nbShells:
1336 return Mesh_Prism3D(self, geom)
1337 return Mesh_RadialPrism3D(self, geom)
1339 ## Evaluates size of prospective mesh on a shape
1340 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1341 # To know predicted number of e.g. edges, inquire it this way
1342 # Evaluate()[ EnumToLong( Entity_Edge )]
1343 def Evaluate(self, geom=0):
1344 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1346 geom = self.mesh.GetShapeToMesh()
1349 return self.smeshpyD.Evaluate(self.mesh, geom)
1352 ## Computes the mesh and returns the status of the computation
1353 # @param geom geomtrical shape on which mesh data should be computed
1354 # @param discardModifs if True and the mesh has been edited since
1355 # a last total re-compute and that may prevent successful partial re-compute,
1356 # then the mesh is cleaned before Compute()
1357 # @return True or False
1358 # @ingroup l2_construct
1359 def Compute(self, geom=0, discardModifs=False):
1360 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1362 geom = self.mesh.GetShapeToMesh()
1367 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1369 ok = self.smeshpyD.Compute(self.mesh, geom)
1370 except SALOME.SALOME_Exception, ex:
1371 print "Mesh computation failed, exception caught:"
1372 print " ", ex.details.text
1375 print "Mesh computation failed, exception caught:"
1376 traceback.print_exc()
1380 # Treat compute errors
1381 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1382 for err in computeErrors:
1384 if self.mesh.HasShapeToMesh():
1386 mainIOR = salome.orb.object_to_string(geom)
1387 for sname in salome.myStudyManager.GetOpenStudies():
1388 s = salome.myStudyManager.GetStudyByName(sname)
1390 mainSO = s.FindObjectIOR(mainIOR)
1391 if not mainSO: continue
1392 if err.subShapeID == 1:
1393 shapeText = ' on "%s"' % mainSO.GetName()
1394 subIt = s.NewChildIterator(mainSO)
1396 subSO = subIt.Value()
1398 obj = subSO.GetObject()
1399 if not obj: continue
1400 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1402 ids = go.GetSubShapeIndices()
1403 if len(ids) == 1 and ids[0] == err.subShapeID:
1404 shapeText = ' on "%s"' % subSO.GetName()
1407 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1409 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1411 shapeText = " on subshape #%s" % (err.subShapeID)
1413 shapeText = " on subshape #%s" % (err.subShapeID)
1415 stdErrors = ["OK", #COMPERR_OK
1416 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1417 "std::exception", #COMPERR_STD_EXCEPTION
1418 "OCC exception", #COMPERR_OCC_EXCEPTION
1419 "SALOME exception", #COMPERR_SLM_EXCEPTION
1420 "Unknown exception", #COMPERR_EXCEPTION
1421 "Memory allocation problem", #COMPERR_MEMORY_PB
1422 "Algorithm failed", #COMPERR_ALGO_FAILED
1423 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1425 if err.code < len(stdErrors): errText = stdErrors[err.code]
1427 errText = "code %s" % -err.code
1428 if errText: errText += ". "
1429 errText += err.comment
1430 if allReasons != "":allReasons += "\n"
1431 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1435 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1437 if err.isGlobalAlgo:
1445 reason = '%s %sD algorithm is missing' % (glob, dim)
1446 elif err.state == HYP_MISSING:
1447 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1448 % (glob, dim, name, dim))
1449 elif err.state == HYP_NOTCONFORM:
1450 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1451 elif err.state == HYP_BAD_PARAMETER:
1452 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1453 % ( glob, dim, name ))
1454 elif err.state == HYP_BAD_GEOMETRY:
1455 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1456 'geometry' % ( glob, dim, name ))
1458 reason = "For unknown reason."+\
1459 " Revise Mesh.Compute() implementation in smeshDC.py!"
1461 if allReasons != "":allReasons += "\n"
1462 allReasons += reason
1464 if allReasons != "":
1465 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1469 print '"' + GetName(self.mesh) + '"',"has not been computed."
1472 if salome.sg.hasDesktop():
1473 smeshgui = salome.ImportComponentGUI("SMESH")
1474 smeshgui.Init(self.mesh.GetStudyId())
1475 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1476 salome.sg.updateObjBrowser(1)
1480 ## Return submesh objects list in meshing order
1481 # @return list of list of submesh objects
1482 # @ingroup l2_construct
1483 def GetMeshOrder(self):
1484 return self.mesh.GetMeshOrder()
1486 ## Return submesh objects list in meshing order
1487 # @return list of list of submesh objects
1488 # @ingroup l2_construct
1489 def SetMeshOrder(self, submeshes):
1490 return self.mesh.SetMeshOrder(submeshes)
1492 ## Removes all nodes and elements
1493 # @ingroup l2_construct
1496 if salome.sg.hasDesktop():
1497 smeshgui = salome.ImportComponentGUI("SMESH")
1498 smeshgui.Init(self.mesh.GetStudyId())
1499 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1500 salome.sg.updateObjBrowser(1)
1502 ## Removes all nodes and elements of indicated shape
1503 # @ingroup l2_construct
1504 def ClearSubMesh(self, geomId):
1505 self.mesh.ClearSubMesh(geomId)
1506 if salome.sg.hasDesktop():
1507 smeshgui = salome.ImportComponentGUI("SMESH")
1508 smeshgui.Init(self.mesh.GetStudyId())
1509 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1510 salome.sg.updateObjBrowser(1)
1512 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1513 # @param fineness [0,-1] defines mesh fineness
1514 # @return True or False
1515 # @ingroup l3_algos_basic
1516 def AutomaticTetrahedralization(self, fineness=0):
1517 dim = self.MeshDimension()
1519 self.RemoveGlobalHypotheses()
1520 self.Segment().AutomaticLength(fineness)
1522 self.Triangle().LengthFromEdges()
1525 self.Tetrahedron(NETGEN)
1527 return self.Compute()
1529 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1530 # @param fineness [0,-1] defines mesh fineness
1531 # @return True or False
1532 # @ingroup l3_algos_basic
1533 def AutomaticHexahedralization(self, fineness=0):
1534 dim = self.MeshDimension()
1535 # assign the hypotheses
1536 self.RemoveGlobalHypotheses()
1537 self.Segment().AutomaticLength(fineness)
1544 return self.Compute()
1546 ## Assigns a hypothesis
1547 # @param hyp a hypothesis to assign
1548 # @param geom a subhape of mesh geometry
1549 # @return SMESH.Hypothesis_Status
1550 # @ingroup l2_hypotheses
1551 def AddHypothesis(self, hyp, geom=0):
1552 if isinstance( hyp, Mesh_Algorithm ):
1553 hyp = hyp.GetAlgorithm()
1558 geom = self.mesh.GetShapeToMesh()
1560 status = self.mesh.AddHypothesis(geom, hyp)
1561 isAlgo = hyp._narrow( SMESH_Algo )
1562 hyp_name = GetName( hyp )
1565 geom_name = GetName( geom )
1566 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1569 ## Unassigns a hypothesis
1570 # @param hyp a hypothesis to unassign
1571 # @param geom a subshape of mesh geometry
1572 # @return SMESH.Hypothesis_Status
1573 # @ingroup l2_hypotheses
1574 def RemoveHypothesis(self, hyp, geom=0):
1575 if isinstance( hyp, Mesh_Algorithm ):
1576 hyp = hyp.GetAlgorithm()
1581 status = self.mesh.RemoveHypothesis(geom, hyp)
1584 ## Gets the list of hypotheses added on a geometry
1585 # @param geom a subshape of mesh geometry
1586 # @return the sequence of SMESH_Hypothesis
1587 # @ingroup l2_hypotheses
1588 def GetHypothesisList(self, geom):
1589 return self.mesh.GetHypothesisList( geom )
1591 ## Removes all global hypotheses
1592 # @ingroup l2_hypotheses
1593 def RemoveGlobalHypotheses(self):
1594 current_hyps = self.mesh.GetHypothesisList( self.geom )
1595 for hyp in current_hyps:
1596 self.mesh.RemoveHypothesis( self.geom, hyp )
1600 ## Creates a mesh group based on the geometric object \a grp
1601 # and gives a \a name, \n if this parameter is not defined
1602 # the name is the same as the geometric group name \n
1603 # Note: Works like GroupOnGeom().
1604 # @param grp a geometric group, a vertex, an edge, a face or a solid
1605 # @param name the name of the mesh group
1606 # @return SMESH_GroupOnGeom
1607 # @ingroup l2_grps_create
1608 def Group(self, grp, name=""):
1609 return self.GroupOnGeom(grp, name)
1611 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1612 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1613 ## allowing to overwrite the file if it exists or add the exported data to its contents
1614 # @param f the file name
1615 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1616 # @param opt boolean parameter for creating/not creating
1617 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1618 # @param overwrite boolean parameter for overwriting/not overwriting the file
1619 # @ingroup l2_impexp
1620 def ExportToMED(self, f, version, opt=0, overwrite=1):
1621 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1623 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1624 ## allowing to overwrite the file if it exists or add the exported data to its contents
1625 # @param f is the file name
1626 # @param auto_groups boolean parameter for creating/not creating
1627 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1628 # the typical use is auto_groups=false.
1629 # @param version MED format version(MED_V2_1 or MED_V2_2)
1630 # @param overwrite boolean parameter for overwriting/not overwriting the file
1631 # @ingroup l2_impexp
1632 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1633 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1635 ## Exports the mesh in a file in DAT format
1636 # @param f the file name
1637 # @ingroup l2_impexp
1638 def ExportDAT(self, f):
1639 self.mesh.ExportDAT(f)
1641 ## Exports the mesh in a file in UNV format
1642 # @param f the file name
1643 # @ingroup l2_impexp
1644 def ExportUNV(self, f):
1645 self.mesh.ExportUNV(f)
1647 ## Export the mesh in a file in STL format
1648 # @param f the file name
1649 # @param ascii defines the file encoding
1650 # @ingroup l2_impexp
1651 def ExportSTL(self, f, ascii=1):
1652 self.mesh.ExportSTL(f, ascii)
1655 # Operations with groups:
1656 # ----------------------
1658 ## Creates an empty mesh group
1659 # @param elementType the type of elements in the group
1660 # @param name the name of the mesh group
1661 # @return SMESH_Group
1662 # @ingroup l2_grps_create
1663 def CreateEmptyGroup(self, elementType, name):
1664 return self.mesh.CreateGroup(elementType, name)
1666 ## Creates a mesh group based on the geometrical object \a grp
1667 # and gives a \a name, \n if this parameter is not defined
1668 # the name is the same as the geometrical group name
1669 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1670 # @param name the name of the mesh group
1671 # @param typ the type of elements in the group. If not set, it is
1672 # automatically detected by the type of the geometry
1673 # @return SMESH_GroupOnGeom
1674 # @ingroup l2_grps_create
1675 def GroupOnGeom(self, grp, name="", typ=None):
1677 name = grp.GetName()
1680 tgeo = str(grp.GetShapeType())
1681 if tgeo == "VERTEX":
1683 elif tgeo == "EDGE":
1685 elif tgeo == "FACE":
1687 elif tgeo == "SOLID":
1689 elif tgeo == "SHELL":
1691 elif tgeo == "COMPOUND":
1692 try: # it raises on a compound of compounds
1693 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1694 print "Mesh.Group: empty geometric group", GetName( grp )
1699 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1701 tgeo = self.geompyD.GetType(grp)
1702 if tgeo == geompyDC.ShapeType["VERTEX"]:
1704 elif tgeo == geompyDC.ShapeType["EDGE"]:
1706 elif tgeo == geompyDC.ShapeType["FACE"]:
1708 elif tgeo == geompyDC.ShapeType["SOLID"]:
1714 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1715 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1716 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1724 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1727 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1729 ## Creates a mesh group by the given ids of elements
1730 # @param groupName the name of the mesh group
1731 # @param elementType the type of elements in the group
1732 # @param elemIDs the list of ids
1733 # @return SMESH_Group
1734 # @ingroup l2_grps_create
1735 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1736 group = self.mesh.CreateGroup(elementType, groupName)
1740 ## Creates a mesh group by the given conditions
1741 # @param groupName the name of the mesh group
1742 # @param elementType the type of elements in the group
1743 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1744 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1745 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1746 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1747 # @return SMESH_Group
1748 # @ingroup l2_grps_create
1752 CritType=FT_Undefined,
1755 UnaryOp=FT_Undefined):
1756 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1757 group = self.MakeGroupByCriterion(groupName, aCriterion)
1760 ## Creates a mesh group by the given criterion
1761 # @param groupName the name of the mesh group
1762 # @param Criterion the instance of Criterion class
1763 # @return SMESH_Group
1764 # @ingroup l2_grps_create
1765 def MakeGroupByCriterion(self, groupName, Criterion):
1766 aFilterMgr = self.smeshpyD.CreateFilterManager()
1767 aFilter = aFilterMgr.CreateFilter()
1769 aCriteria.append(Criterion)
1770 aFilter.SetCriteria(aCriteria)
1771 group = self.MakeGroupByFilter(groupName, aFilter)
1772 aFilterMgr.Destroy()
1775 ## Creates a mesh group by the given criteria (list of criteria)
1776 # @param groupName the name of the mesh group
1777 # @param theCriteria the list of criteria
1778 # @return SMESH_Group
1779 # @ingroup l2_grps_create
1780 def MakeGroupByCriteria(self, groupName, theCriteria):
1781 aFilterMgr = self.smeshpyD.CreateFilterManager()
1782 aFilter = aFilterMgr.CreateFilter()
1783 aFilter.SetCriteria(theCriteria)
1784 group = self.MakeGroupByFilter(groupName, aFilter)
1785 aFilterMgr.Destroy()
1788 ## Creates a mesh group by the given filter
1789 # @param groupName the name of the mesh group
1790 # @param theFilter the instance of Filter class
1791 # @return SMESH_Group
1792 # @ingroup l2_grps_create
1793 def MakeGroupByFilter(self, groupName, theFilter):
1794 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1795 theFilter.SetMesh( self.mesh )
1796 group.AddFrom( theFilter )
1799 ## Passes mesh elements through the given filter and return IDs of fitting elements
1800 # @param theFilter SMESH_Filter
1801 # @return a list of ids
1802 # @ingroup l1_controls
1803 def GetIdsFromFilter(self, theFilter):
1804 theFilter.SetMesh( self.mesh )
1805 return theFilter.GetIDs()
1807 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1808 # Returns a list of special structures (borders).
1809 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1810 # @ingroup l1_controls
1811 def GetFreeBorders(self):
1812 aFilterMgr = self.smeshpyD.CreateFilterManager()
1813 aPredicate = aFilterMgr.CreateFreeEdges()
1814 aPredicate.SetMesh(self.mesh)
1815 aBorders = aPredicate.GetBorders()
1816 aFilterMgr.Destroy()
1820 # @ingroup l2_grps_delete
1821 def RemoveGroup(self, group):
1822 self.mesh.RemoveGroup(group)
1824 ## Removes a group with its contents
1825 # @ingroup l2_grps_delete
1826 def RemoveGroupWithContents(self, group):
1827 self.mesh.RemoveGroupWithContents(group)
1829 ## Gets the list of groups existing in the mesh
1830 # @return a sequence of SMESH_GroupBase
1831 # @ingroup l2_grps_create
1832 def GetGroups(self):
1833 return self.mesh.GetGroups()
1835 ## Gets the number of groups existing in the mesh
1836 # @return the quantity of groups as an integer value
1837 # @ingroup l2_grps_create
1839 return self.mesh.NbGroups()
1841 ## Gets the list of names of groups existing in the mesh
1842 # @return list of strings
1843 # @ingroup l2_grps_create
1844 def GetGroupNames(self):
1845 groups = self.GetGroups()
1847 for group in groups:
1848 names.append(group.GetName())
1851 ## Produces a union of two groups
1852 # A new group is created. All mesh elements that are
1853 # present in the initial groups are added to the new one
1854 # @return an instance of SMESH_Group
1855 # @ingroup l2_grps_operon
1856 def UnionGroups(self, group1, group2, name):
1857 return self.mesh.UnionGroups(group1, group2, name)
1859 ## Produces a union list of groups
1860 # New group is created. All mesh elements that are present in
1861 # initial groups are added to the new one
1862 # @return an instance of SMESH_Group
1863 # @ingroup l2_grps_operon
1864 def UnionListOfGroups(self, groups, name):
1865 return self.mesh.UnionListOfGroups(groups, name)
1867 ## Prodices an intersection of two groups
1868 # A new group is created. All mesh elements that are common
1869 # for the two initial groups are added to the new one.
1870 # @return an instance of SMESH_Group
1871 # @ingroup l2_grps_operon
1872 def IntersectGroups(self, group1, group2, name):
1873 return self.mesh.IntersectGroups(group1, group2, name)
1875 ## Produces an intersection of groups
1876 # New group is created. All mesh elements that are present in all
1877 # initial groups simultaneously are added to the new one
1878 # @return an instance of SMESH_Group
1879 # @ingroup l2_grps_operon
1880 def IntersectListOfGroups(self, groups, name):
1881 return self.mesh.IntersectListOfGroups(groups, name)
1883 ## Produces a cut of two groups
1884 # A new group is created. All mesh elements that are present in
1885 # the main group but are not present in the tool group are added to the new one
1886 # @return an instance of SMESH_Group
1887 # @ingroup l2_grps_operon
1888 def CutGroups(self, main_group, tool_group, name):
1889 return self.mesh.CutGroups(main_group, tool_group, name)
1891 ## Produces a cut of groups
1892 # A new group is created. All mesh elements that are present in main groups
1893 # but do not present in tool groups are added to the new one
1894 # @return an instance of SMESH_Group
1895 # @ingroup l2_grps_operon
1896 def CutListOfGroups(self, main_groups, tool_groups, name):
1897 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1899 ## Produces a group of elements with specified element type using list of existing groups
1900 # A new group is created. System
1901 # 1) extract all nodes on which groups elements are built
1902 # 2) combine all elements of specified dimension laying on these nodes
1903 # @return an instance of SMESH_Group
1904 # @ingroup l2_grps_operon
1905 def CreateDimGroup(self, groups, elem_type, name):
1906 return self.mesh.CreateDimGroup(groups, elem_type, name)
1909 ## Convert group on geom into standalone group
1910 # @ingroup l2_grps_delete
1911 def ConvertToStandalone(self, group):
1912 return self.mesh.ConvertToStandalone(group)
1914 # Get some info about mesh:
1915 # ------------------------
1917 ## Returns the log of nodes and elements added or removed
1918 # since the previous clear of the log.
1919 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1920 # @return list of log_block structures:
1925 # @ingroup l1_auxiliary
1926 def GetLog(self, clearAfterGet):
1927 return self.mesh.GetLog(clearAfterGet)
1929 ## Clears the log of nodes and elements added or removed since the previous
1930 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1931 # @ingroup l1_auxiliary
1933 self.mesh.ClearLog()
1935 ## Toggles auto color mode on the object.
1936 # @param theAutoColor the flag which toggles auto color mode.
1937 # @ingroup l1_auxiliary
1938 def SetAutoColor(self, theAutoColor):
1939 self.mesh.SetAutoColor(theAutoColor)
1941 ## Gets flag of object auto color mode.
1942 # @return True or False
1943 # @ingroup l1_auxiliary
1944 def GetAutoColor(self):
1945 return self.mesh.GetAutoColor()
1947 ## Gets the internal ID
1948 # @return integer value, which is the internal Id of the mesh
1949 # @ingroup l1_auxiliary
1951 return self.mesh.GetId()
1954 # @return integer value, which is the study Id of the mesh
1955 # @ingroup l1_auxiliary
1956 def GetStudyId(self):
1957 return self.mesh.GetStudyId()
1959 ## Checks the group names for duplications.
1960 # Consider the maximum group name length stored in MED file.
1961 # @return True or False
1962 # @ingroup l1_auxiliary
1963 def HasDuplicatedGroupNamesMED(self):
1964 return self.mesh.HasDuplicatedGroupNamesMED()
1966 ## Obtains the mesh editor tool
1967 # @return an instance of SMESH_MeshEditor
1968 # @ingroup l1_modifying
1969 def GetMeshEditor(self):
1970 return self.mesh.GetMeshEditor()
1973 # @return an instance of SALOME_MED::MESH
1974 # @ingroup l1_auxiliary
1975 def GetMEDMesh(self):
1976 return self.mesh.GetMEDMesh()
1979 # Get informations about mesh contents:
1980 # ------------------------------------
1982 ## Gets the mesh stattistic
1983 # @return dictionary type element - count of elements
1984 # @ingroup l1_meshinfo
1985 def GetMeshInfo(self, obj = None):
1986 if not obj: obj = self.mesh
1987 return self.smeshpyD.GetMeshInfo(obj)
1989 ## Returns the number of nodes in the mesh
1990 # @return an integer value
1991 # @ingroup l1_meshinfo
1993 return self.mesh.NbNodes()
1995 ## Returns the number of elements in the mesh
1996 # @return an integer value
1997 # @ingroup l1_meshinfo
1998 def NbElements(self):
1999 return self.mesh.NbElements()
2001 ## Returns the number of 0d elements in the mesh
2002 # @return an integer value
2003 # @ingroup l1_meshinfo
2004 def Nb0DElements(self):
2005 return self.mesh.Nb0DElements()
2007 ## Returns the number of edges in the mesh
2008 # @return an integer value
2009 # @ingroup l1_meshinfo
2011 return self.mesh.NbEdges()
2013 ## Returns the number of edges with the given order in the mesh
2014 # @param elementOrder the order of elements:
2015 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2016 # @return an integer value
2017 # @ingroup l1_meshinfo
2018 def NbEdgesOfOrder(self, elementOrder):
2019 return self.mesh.NbEdgesOfOrder(elementOrder)
2021 ## Returns the number of faces in the mesh
2022 # @return an integer value
2023 # @ingroup l1_meshinfo
2025 return self.mesh.NbFaces()
2027 ## Returns the number of faces with the given order in the mesh
2028 # @param elementOrder the order of elements:
2029 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2030 # @return an integer value
2031 # @ingroup l1_meshinfo
2032 def NbFacesOfOrder(self, elementOrder):
2033 return self.mesh.NbFacesOfOrder(elementOrder)
2035 ## Returns the number of triangles in the mesh
2036 # @return an integer value
2037 # @ingroup l1_meshinfo
2038 def NbTriangles(self):
2039 return self.mesh.NbTriangles()
2041 ## Returns the number of triangles with the given order in the mesh
2042 # @param elementOrder is the order of elements:
2043 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2044 # @return an integer value
2045 # @ingroup l1_meshinfo
2046 def NbTrianglesOfOrder(self, elementOrder):
2047 return self.mesh.NbTrianglesOfOrder(elementOrder)
2049 ## Returns the number of quadrangles in the mesh
2050 # @return an integer value
2051 # @ingroup l1_meshinfo
2052 def NbQuadrangles(self):
2053 return self.mesh.NbQuadrangles()
2055 ## Returns the number of quadrangles with the given order in the mesh
2056 # @param elementOrder the order of elements:
2057 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2058 # @return an integer value
2059 # @ingroup l1_meshinfo
2060 def NbQuadranglesOfOrder(self, elementOrder):
2061 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2063 ## Returns the number of polygons in the mesh
2064 # @return an integer value
2065 # @ingroup l1_meshinfo
2066 def NbPolygons(self):
2067 return self.mesh.NbPolygons()
2069 ## Returns the number of volumes in the mesh
2070 # @return an integer value
2071 # @ingroup l1_meshinfo
2072 def NbVolumes(self):
2073 return self.mesh.NbVolumes()
2075 ## Returns the number of volumes with the given order in the mesh
2076 # @param elementOrder the order of elements:
2077 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2078 # @return an integer value
2079 # @ingroup l1_meshinfo
2080 def NbVolumesOfOrder(self, elementOrder):
2081 return self.mesh.NbVolumesOfOrder(elementOrder)
2083 ## Returns the number of tetrahedrons in the mesh
2084 # @return an integer value
2085 # @ingroup l1_meshinfo
2087 return self.mesh.NbTetras()
2089 ## Returns the number of tetrahedrons with the given order in the mesh
2090 # @param elementOrder the order of elements:
2091 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2092 # @return an integer value
2093 # @ingroup l1_meshinfo
2094 def NbTetrasOfOrder(self, elementOrder):
2095 return self.mesh.NbTetrasOfOrder(elementOrder)
2097 ## Returns the number of hexahedrons in the mesh
2098 # @return an integer value
2099 # @ingroup l1_meshinfo
2101 return self.mesh.NbHexas()
2103 ## Returns the number of hexahedrons with the given order in the mesh
2104 # @param elementOrder the order of elements:
2105 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2106 # @return an integer value
2107 # @ingroup l1_meshinfo
2108 def NbHexasOfOrder(self, elementOrder):
2109 return self.mesh.NbHexasOfOrder(elementOrder)
2111 ## Returns the number of pyramids in the mesh
2112 # @return an integer value
2113 # @ingroup l1_meshinfo
2114 def NbPyramids(self):
2115 return self.mesh.NbPyramids()
2117 ## Returns the number of pyramids with the given order in the mesh
2118 # @param elementOrder the order of elements:
2119 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2120 # @return an integer value
2121 # @ingroup l1_meshinfo
2122 def NbPyramidsOfOrder(self, elementOrder):
2123 return self.mesh.NbPyramidsOfOrder(elementOrder)
2125 ## Returns the number of prisms in the mesh
2126 # @return an integer value
2127 # @ingroup l1_meshinfo
2129 return self.mesh.NbPrisms()
2131 ## Returns the number of prisms with the given order in the mesh
2132 # @param elementOrder the order of elements:
2133 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2134 # @return an integer value
2135 # @ingroup l1_meshinfo
2136 def NbPrismsOfOrder(self, elementOrder):
2137 return self.mesh.NbPrismsOfOrder(elementOrder)
2139 ## Returns the number of polyhedrons in the mesh
2140 # @return an integer value
2141 # @ingroup l1_meshinfo
2142 def NbPolyhedrons(self):
2143 return self.mesh.NbPolyhedrons()
2145 ## Returns the number of submeshes in the mesh
2146 # @return an integer value
2147 # @ingroup l1_meshinfo
2148 def NbSubMesh(self):
2149 return self.mesh.NbSubMesh()
2151 ## Returns the list of mesh elements IDs
2152 # @return the list of integer values
2153 # @ingroup l1_meshinfo
2154 def GetElementsId(self):
2155 return self.mesh.GetElementsId()
2157 ## Returns the list of IDs of mesh elements with the given type
2158 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2159 # @return list of integer values
2160 # @ingroup l1_meshinfo
2161 def GetElementsByType(self, elementType):
2162 return self.mesh.GetElementsByType(elementType)
2164 ## Returns the list of mesh nodes IDs
2165 # @return the list of integer values
2166 # @ingroup l1_meshinfo
2167 def GetNodesId(self):
2168 return self.mesh.GetNodesId()
2170 # Get the information about mesh elements:
2171 # ------------------------------------
2173 ## Returns the type of mesh element
2174 # @return the value from SMESH::ElementType enumeration
2175 # @ingroup l1_meshinfo
2176 def GetElementType(self, id, iselem):
2177 return self.mesh.GetElementType(id, iselem)
2179 ## Returns the geometric type of mesh element
2180 # @return the value from SMESH::EntityType enumeration
2181 # @ingroup l1_meshinfo
2182 def GetElementGeomType(self, id):
2183 return self.mesh.GetElementGeomType(id)
2185 ## Returns the list of submesh elements IDs
2186 # @param Shape a geom object(subshape) IOR
2187 # Shape must be the subshape of a ShapeToMesh()
2188 # @return the list of integer values
2189 # @ingroup l1_meshinfo
2190 def GetSubMeshElementsId(self, Shape):
2191 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2192 ShapeID = Shape.GetSubShapeIndices()[0]
2195 return self.mesh.GetSubMeshElementsId(ShapeID)
2197 ## Returns the list of submesh nodes IDs
2198 # @param Shape a geom object(subshape) IOR
2199 # Shape must be the subshape of a ShapeToMesh()
2200 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2201 # @return the list of integer values
2202 # @ingroup l1_meshinfo
2203 def GetSubMeshNodesId(self, Shape, all):
2204 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2205 ShapeID = Shape.GetSubShapeIndices()[0]
2208 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2210 ## Returns type of elements on given shape
2211 # @param Shape a geom object(subshape) IOR
2212 # Shape must be a subshape of a ShapeToMesh()
2213 # @return element type
2214 # @ingroup l1_meshinfo
2215 def GetSubMeshElementType(self, Shape):
2216 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2217 ShapeID = Shape.GetSubShapeIndices()[0]
2220 return self.mesh.GetSubMeshElementType(ShapeID)
2222 ## Gets the mesh description
2223 # @return string value
2224 # @ingroup l1_meshinfo
2226 return self.mesh.Dump()
2229 # Get the information about nodes and elements of a mesh by its IDs:
2230 # -----------------------------------------------------------
2232 ## Gets XYZ coordinates of a node
2233 # \n If there is no nodes for the given ID - returns an empty list
2234 # @return a list of double precision values
2235 # @ingroup l1_meshinfo
2236 def GetNodeXYZ(self, id):
2237 return self.mesh.GetNodeXYZ(id)
2239 ## Returns list of IDs of inverse elements for the given node
2240 # \n If there is no node for the given ID - returns an empty list
2241 # @return a list of integer values
2242 # @ingroup l1_meshinfo
2243 def GetNodeInverseElements(self, id):
2244 return self.mesh.GetNodeInverseElements(id)
2246 ## @brief Returns the position of a node on the shape
2247 # @return SMESH::NodePosition
2248 # @ingroup l1_meshinfo
2249 def GetNodePosition(self,NodeID):
2250 return self.mesh.GetNodePosition(NodeID)
2252 ## If the given element is a node, returns the ID of shape
2253 # \n If there is no node for the given ID - returns -1
2254 # @return an integer value
2255 # @ingroup l1_meshinfo
2256 def GetShapeID(self, id):
2257 return self.mesh.GetShapeID(id)
2259 ## Returns the ID of the result shape after
2260 # FindShape() from SMESH_MeshEditor for the given element
2261 # \n If there is no element for the given ID - returns -1
2262 # @return an integer value
2263 # @ingroup l1_meshinfo
2264 def GetShapeIDForElem(self,id):
2265 return self.mesh.GetShapeIDForElem(id)
2267 ## Returns the number of nodes for the given element
2268 # \n If there is no element for the given ID - returns -1
2269 # @return an integer value
2270 # @ingroup l1_meshinfo
2271 def GetElemNbNodes(self, id):
2272 return self.mesh.GetElemNbNodes(id)
2274 ## Returns the node ID the given index for the given element
2275 # \n If there is no element for the given ID - returns -1
2276 # \n If there is no node for the given index - returns -2
2277 # @return an integer value
2278 # @ingroup l1_meshinfo
2279 def GetElemNode(self, id, index):
2280 return self.mesh.GetElemNode(id, index)
2282 ## Returns the IDs of nodes of the given element
2283 # @return a list of integer values
2284 # @ingroup l1_meshinfo
2285 def GetElemNodes(self, id):
2286 return self.mesh.GetElemNodes(id)
2288 ## Returns true if the given node is the medium node in the given quadratic element
2289 # @ingroup l1_meshinfo
2290 def IsMediumNode(self, elementID, nodeID):
2291 return self.mesh.IsMediumNode(elementID, nodeID)
2293 ## Returns true if the given node is the medium node in one of quadratic elements
2294 # @ingroup l1_meshinfo
2295 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2296 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2298 ## Returns the number of edges for the given element
2299 # @ingroup l1_meshinfo
2300 def ElemNbEdges(self, id):
2301 return self.mesh.ElemNbEdges(id)
2303 ## Returns the number of faces for the given element
2304 # @ingroup l1_meshinfo
2305 def ElemNbFaces(self, id):
2306 return self.mesh.ElemNbFaces(id)
2308 ## Returns nodes of given face (counted from zero) for given volumic element.
2309 # @ingroup l1_meshinfo
2310 def GetElemFaceNodes(self,elemId, faceIndex):
2311 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2313 ## Returns an element based on all given nodes.
2314 # @ingroup l1_meshinfo
2315 def FindElementByNodes(self,nodes):
2316 return self.mesh.FindElementByNodes(nodes)
2318 ## Returns true if the given element is a polygon
2319 # @ingroup l1_meshinfo
2320 def IsPoly(self, id):
2321 return self.mesh.IsPoly(id)
2323 ## Returns true if the given element is quadratic
2324 # @ingroup l1_meshinfo
2325 def IsQuadratic(self, id):
2326 return self.mesh.IsQuadratic(id)
2328 ## Returns XYZ coordinates of the barycenter of the given element
2329 # \n If there is no element for the given ID - returns an empty list
2330 # @return a list of three double values
2331 # @ingroup l1_meshinfo
2332 def BaryCenter(self, id):
2333 return self.mesh.BaryCenter(id)
2336 # Get mesh measurements information:
2337 # ------------------------------------
2339 ## Get minimum distance between two nodes, elements or distance to the origin
2340 # @param id1 first node/element id
2341 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2342 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2343 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2344 # @return minimum distance value
2345 # @sa GetMinDistance()
2346 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2347 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2348 return aMeasure.value
2350 ## Get measure structure specifying minimum distance data between two objects
2351 # @param id1 first node/element id
2352 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2353 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2354 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2355 # @return Measure structure
2357 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2359 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2361 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2364 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2366 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2371 aMeasurements = self.smeshpyD.CreateMeasurements()
2372 aMeasure = aMeasurements.MinDistance(id1, id2)
2373 aMeasurements.Destroy()
2376 ## Get bounding box of the specified object(s)
2377 # @param objects single source object or list of source objects or list of nodes/elements IDs
2378 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2379 # @c False specifies that @a objects are nodes
2380 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2381 # @sa GetBoundingBox()
2382 def BoundingBox(self, objects=None, isElem=False):
2383 result = self.GetBoundingBox(objects, isElem)
2387 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2390 ## Get measure structure specifying bounding box data of the specified object(s)
2391 # @param objects single source object or list of source objects or list of nodes/elements IDs
2392 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2393 # @c False specifies that @a objects are nodes
2394 # @return Measure structure
2396 def GetBoundingBox(self, IDs=None, isElem=False):
2399 elif isinstance(IDs, tuple):
2401 if not isinstance(IDs, list):
2403 if len(IDs) > 0 and isinstance(IDs[0], int):
2407 if isinstance(o, Mesh):
2408 srclist.append(o.mesh)
2409 elif hasattr(o, "_narrow"):
2410 src = o._narrow(SMESH.SMESH_IDSource)
2411 if src: srclist.append(src)
2413 elif isinstance(o, list):
2415 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2417 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2420 aMeasurements = self.smeshpyD.CreateMeasurements()
2421 aMeasure = aMeasurements.BoundingBox(srclist)
2422 aMeasurements.Destroy()
2425 # Mesh edition (SMESH_MeshEditor functionality):
2426 # ---------------------------------------------
2428 ## Removes the elements from the mesh by ids
2429 # @param IDsOfElements is a list of ids of elements to remove
2430 # @return True or False
2431 # @ingroup l2_modif_del
2432 def RemoveElements(self, IDsOfElements):
2433 return self.editor.RemoveElements(IDsOfElements)
2435 ## Removes nodes from mesh by ids
2436 # @param IDsOfNodes is a list of ids of nodes to remove
2437 # @return True or False
2438 # @ingroup l2_modif_del
2439 def RemoveNodes(self, IDsOfNodes):
2440 return self.editor.RemoveNodes(IDsOfNodes)
2442 ## Removes all orphan (free) nodes from mesh
2443 # @return number of the removed nodes
2444 # @ingroup l2_modif_del
2445 def RemoveOrphanNodes(self):
2446 return self.editor.RemoveOrphanNodes()
2448 ## Add a node to the mesh by coordinates
2449 # @return Id of the new node
2450 # @ingroup l2_modif_add
2451 def AddNode(self, x, y, z):
2452 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2453 self.mesh.SetParameters(Parameters)
2454 return self.editor.AddNode( x, y, z)
2456 ## Creates a 0D element on a node with given number.
2457 # @param IDOfNode the ID of node for creation of the element.
2458 # @return the Id of the new 0D element
2459 # @ingroup l2_modif_add
2460 def Add0DElement(self, IDOfNode):
2461 return self.editor.Add0DElement(IDOfNode)
2463 ## Creates a linear or quadratic edge (this is determined
2464 # by the number of given nodes).
2465 # @param IDsOfNodes the list of node IDs for creation of the element.
2466 # The order of nodes in this list should correspond to the description
2467 # of MED. \n This description is located by the following link:
2468 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2469 # @return the Id of the new edge
2470 # @ingroup l2_modif_add
2471 def AddEdge(self, IDsOfNodes):
2472 return self.editor.AddEdge(IDsOfNodes)
2474 ## Creates a linear or quadratic face (this is determined
2475 # by the number of given nodes).
2476 # @param IDsOfNodes the list of node IDs for creation of the element.
2477 # The order of nodes in this list should correspond to the description
2478 # of MED. \n This description is located by the following link:
2479 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2480 # @return the Id of the new face
2481 # @ingroup l2_modif_add
2482 def AddFace(self, IDsOfNodes):
2483 return self.editor.AddFace(IDsOfNodes)
2485 ## Adds a polygonal face to the mesh by the list of node IDs
2486 # @param IdsOfNodes the list of node IDs for creation of the element.
2487 # @return the Id of the new face
2488 # @ingroup l2_modif_add
2489 def AddPolygonalFace(self, IdsOfNodes):
2490 return self.editor.AddPolygonalFace(IdsOfNodes)
2492 ## Creates both simple and quadratic volume (this is determined
2493 # by the number of given nodes).
2494 # @param IDsOfNodes the list of node IDs for creation of the element.
2495 # The order of nodes in this list should correspond to the description
2496 # of MED. \n This description is located by the following link:
2497 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2498 # @return the Id of the new volumic element
2499 # @ingroup l2_modif_add
2500 def AddVolume(self, IDsOfNodes):
2501 return self.editor.AddVolume(IDsOfNodes)
2503 ## Creates a volume of many faces, giving nodes for each face.
2504 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2505 # @param Quantities the list of integer values, Quantities[i]
2506 # gives the quantity of nodes in face number i.
2507 # @return the Id of the new volumic element
2508 # @ingroup l2_modif_add
2509 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2510 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2512 ## Creates a volume of many faces, giving the IDs of the existing faces.
2513 # @param IdsOfFaces the list of face IDs for volume creation.
2515 # Note: The created volume will refer only to the nodes
2516 # of the given faces, not to the faces themselves.
2517 # @return the Id of the new volumic element
2518 # @ingroup l2_modif_add
2519 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2520 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2523 ## @brief Binds a node to a vertex
2524 # @param NodeID a node ID
2525 # @param Vertex a vertex or vertex ID
2526 # @return True if succeed else raises an exception
2527 # @ingroup l2_modif_add
2528 def SetNodeOnVertex(self, NodeID, Vertex):
2529 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2530 VertexID = Vertex.GetSubShapeIndices()[0]
2534 self.editor.SetNodeOnVertex(NodeID, VertexID)
2535 except SALOME.SALOME_Exception, inst:
2536 raise ValueError, inst.details.text
2540 ## @brief Stores the node position on an edge
2541 # @param NodeID a node ID
2542 # @param Edge an edge or edge ID
2543 # @param paramOnEdge a parameter on the edge where the node is located
2544 # @return True if succeed else raises an exception
2545 # @ingroup l2_modif_add
2546 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2547 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2548 EdgeID = Edge.GetSubShapeIndices()[0]
2552 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2553 except SALOME.SALOME_Exception, inst:
2554 raise ValueError, inst.details.text
2557 ## @brief Stores node position on a face
2558 # @param NodeID a node ID
2559 # @param Face a face or face ID
2560 # @param u U parameter on the face where the node is located
2561 # @param v V parameter on the face where the node is located
2562 # @return True if succeed else raises an exception
2563 # @ingroup l2_modif_add
2564 def SetNodeOnFace(self, NodeID, Face, u, v):
2565 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2566 FaceID = Face.GetSubShapeIndices()[0]
2570 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2571 except SALOME.SALOME_Exception, inst:
2572 raise ValueError, inst.details.text
2575 ## @brief Binds a node to a solid
2576 # @param NodeID a node ID
2577 # @param Solid a solid or solid ID
2578 # @return True if succeed else raises an exception
2579 # @ingroup l2_modif_add
2580 def SetNodeInVolume(self, NodeID, Solid):
2581 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2582 SolidID = Solid.GetSubShapeIndices()[0]
2586 self.editor.SetNodeInVolume(NodeID, SolidID)
2587 except SALOME.SALOME_Exception, inst:
2588 raise ValueError, inst.details.text
2591 ## @brief Bind an element to a shape
2592 # @param ElementID an element ID
2593 # @param Shape a shape or shape ID
2594 # @return True if succeed else raises an exception
2595 # @ingroup l2_modif_add
2596 def SetMeshElementOnShape(self, ElementID, Shape):
2597 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2598 ShapeID = Shape.GetSubShapeIndices()[0]
2602 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2603 except SALOME.SALOME_Exception, inst:
2604 raise ValueError, inst.details.text
2608 ## Moves the node with the given id
2609 # @param NodeID the id of the node
2610 # @param x a new X coordinate
2611 # @param y a new Y coordinate
2612 # @param z a new Z coordinate
2613 # @return True if succeed else False
2614 # @ingroup l2_modif_movenode
2615 def MoveNode(self, NodeID, x, y, z):
2616 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2617 self.mesh.SetParameters(Parameters)
2618 return self.editor.MoveNode(NodeID, x, y, z)
2620 ## Finds the node closest to a point and moves it to a point location
2621 # @param x the X coordinate of a point
2622 # @param y the Y coordinate of a point
2623 # @param z the Z coordinate of a point
2624 # @param NodeID if specified (>0), the node with this ID is moved,
2625 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2626 # @return the ID of a node
2627 # @ingroup l2_modif_throughp
2628 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2629 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2630 self.mesh.SetParameters(Parameters)
2631 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2633 ## Finds the node closest to a point
2634 # @param x the X coordinate of a point
2635 # @param y the Y coordinate of a point
2636 # @param z the Z coordinate of a point
2637 # @return the ID of a node
2638 # @ingroup l2_modif_throughp
2639 def FindNodeClosestTo(self, x, y, z):
2640 #preview = self.mesh.GetMeshEditPreviewer()
2641 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2642 return self.editor.FindNodeClosestTo(x, y, z)
2644 ## Finds the elements where a point lays IN or ON
2645 # @param x the X coordinate of a point
2646 # @param y the Y coordinate of a point
2647 # @param z the Z coordinate of a point
2648 # @param elementType type of elements to find (SMESH.ALL type
2649 # means elements of any type excluding nodes and 0D elements)
2650 # @return list of IDs of found elements
2651 # @ingroup l2_modif_throughp
2652 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2653 return self.editor.FindElementsByPoint(x, y, z, elementType)
2655 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2656 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2658 def GetPointState(self, x, y, z):
2659 return self.editor.GetPointState(x, y, z)
2661 ## Finds the node closest to a point and moves it to a point location
2662 # @param x the X coordinate of a point
2663 # @param y the Y coordinate of a point
2664 # @param z the Z coordinate of a point
2665 # @return the ID of a moved node
2666 # @ingroup l2_modif_throughp
2667 def MeshToPassThroughAPoint(self, x, y, z):
2668 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2670 ## Replaces two neighbour triangles sharing Node1-Node2 link
2671 # with the triangles built on the same 4 nodes but having other common link.
2672 # @param NodeID1 the ID of the first node
2673 # @param NodeID2 the ID of the second node
2674 # @return false if proper faces were not found
2675 # @ingroup l2_modif_invdiag
2676 def InverseDiag(self, NodeID1, NodeID2):
2677 return self.editor.InverseDiag(NodeID1, NodeID2)
2679 ## Replaces two neighbour triangles sharing Node1-Node2 link
2680 # with a quadrangle built on the same 4 nodes.
2681 # @param NodeID1 the ID of the first node
2682 # @param NodeID2 the ID of the second node
2683 # @return false if proper faces were not found
2684 # @ingroup l2_modif_unitetri
2685 def DeleteDiag(self, NodeID1, NodeID2):
2686 return self.editor.DeleteDiag(NodeID1, NodeID2)
2688 ## Reorients elements by ids
2689 # @param IDsOfElements if undefined reorients all mesh elements
2690 # @return True if succeed else False
2691 # @ingroup l2_modif_changori
2692 def Reorient(self, IDsOfElements=None):
2693 if IDsOfElements == None:
2694 IDsOfElements = self.GetElementsId()
2695 return self.editor.Reorient(IDsOfElements)
2697 ## Reorients all elements of the object
2698 # @param theObject mesh, submesh or group
2699 # @return True if succeed else False
2700 # @ingroup l2_modif_changori
2701 def ReorientObject(self, theObject):
2702 if ( isinstance( theObject, Mesh )):
2703 theObject = theObject.GetMesh()
2704 return self.editor.ReorientObject(theObject)
2706 ## Fuses the neighbouring triangles into quadrangles.
2707 # @param IDsOfElements The triangles to be fused,
2708 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2709 # @param MaxAngle is the maximum angle between element normals at which the fusion
2710 # is still performed; theMaxAngle is mesured in radians.
2711 # Also it could be a name of variable which defines angle in degrees.
2712 # @return TRUE in case of success, FALSE otherwise.
2713 # @ingroup l2_modif_unitetri
2714 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2716 if isinstance(MaxAngle,str):
2718 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2720 MaxAngle = DegreesToRadians(MaxAngle)
2721 if IDsOfElements == []:
2722 IDsOfElements = self.GetElementsId()
2723 self.mesh.SetParameters(Parameters)
2725 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2726 Functor = theCriterion
2728 Functor = self.smeshpyD.GetFunctor(theCriterion)
2729 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2731 ## Fuses the neighbouring triangles of the object into quadrangles
2732 # @param theObject is mesh, submesh or group
2733 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2734 # @param MaxAngle a max angle between element normals at which the fusion
2735 # is still performed; theMaxAngle is mesured in radians.
2736 # @return TRUE in case of success, FALSE otherwise.
2737 # @ingroup l2_modif_unitetri
2738 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2739 if ( isinstance( theObject, Mesh )):
2740 theObject = theObject.GetMesh()
2741 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2743 ## Splits quadrangles into triangles.
2744 # @param IDsOfElements the faces to be splitted.
2745 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2746 # @return TRUE in case of success, FALSE otherwise.
2747 # @ingroup l2_modif_cutquadr
2748 def QuadToTri (self, IDsOfElements, theCriterion):
2749 if IDsOfElements == []:
2750 IDsOfElements = self.GetElementsId()
2751 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2753 ## Splits quadrangles into triangles.
2754 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2755 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2756 # @return TRUE in case of success, FALSE otherwise.
2757 # @ingroup l2_modif_cutquadr
2758 def QuadToTriObject (self, theObject, theCriterion):
2759 if ( isinstance( theObject, Mesh )):
2760 theObject = theObject.GetMesh()
2761 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2763 ## Splits quadrangles into triangles.
2764 # @param IDsOfElements the faces to be splitted
2765 # @param Diag13 is used to choose a diagonal for splitting.
2766 # @return TRUE in case of success, FALSE otherwise.
2767 # @ingroup l2_modif_cutquadr
2768 def SplitQuad (self, IDsOfElements, Diag13):
2769 if IDsOfElements == []:
2770 IDsOfElements = self.GetElementsId()
2771 return self.editor.SplitQuad(IDsOfElements, Diag13)
2773 ## Splits quadrangles into triangles.
2774 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2775 # @param Diag13 is used to choose a diagonal for splitting.
2776 # @return TRUE in case of success, FALSE otherwise.
2777 # @ingroup l2_modif_cutquadr
2778 def SplitQuadObject (self, theObject, Diag13):
2779 if ( isinstance( theObject, Mesh )):
2780 theObject = theObject.GetMesh()
2781 return self.editor.SplitQuadObject(theObject, Diag13)
2783 ## Finds a better splitting of the given quadrangle.
2784 # @param IDOfQuad the ID of the quadrangle to be splitted.
2785 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2786 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2787 # diagonal is better, 0 if error occurs.
2788 # @ingroup l2_modif_cutquadr
2789 def BestSplit (self, IDOfQuad, theCriterion):
2790 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2792 ## Splits volumic elements into tetrahedrons
2793 # @param elemIDs either list of elements or mesh or group or submesh
2794 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2795 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2796 # @ingroup l2_modif_cutquadr
2797 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2798 if isinstance( elemIDs, Mesh ):
2799 elemIDs = elemIDs.GetMesh()
2800 if ( isinstance( elemIDs, list )):
2801 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2802 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2804 ## Splits quadrangle faces near triangular facets of volumes
2806 # @ingroup l1_auxiliary
2807 def SplitQuadsNearTriangularFacets(self):
2808 faces_array = self.GetElementsByType(SMESH.FACE)
2809 for face_id in faces_array:
2810 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2811 quad_nodes = self.mesh.GetElemNodes(face_id)
2812 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2813 isVolumeFound = False
2814 for node1_elem in node1_elems:
2815 if not isVolumeFound:
2816 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2817 nb_nodes = self.GetElemNbNodes(node1_elem)
2818 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2819 volume_elem = node1_elem
2820 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2821 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2822 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2823 isVolumeFound = True
2824 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2825 self.SplitQuad([face_id], False) # diagonal 2-4
2826 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2827 isVolumeFound = True
2828 self.SplitQuad([face_id], True) # diagonal 1-3
2829 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2830 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2831 isVolumeFound = True
2832 self.SplitQuad([face_id], True) # diagonal 1-3
2834 ## @brief Splits hexahedrons into tetrahedrons.
2836 # This operation uses pattern mapping functionality for splitting.
2837 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2838 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2839 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2840 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2841 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2842 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2843 # @return TRUE in case of success, FALSE otherwise.
2844 # @ingroup l1_auxiliary
2845 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2846 # Pattern: 5.---------.6
2851 # (0,0,1) 4.---------.7 * |
2858 # (0,0,0) 0.---------.3
2859 pattern_tetra = "!!! Nb of points: \n 8 \n\
2869 !!! Indices of points of 6 tetras: \n\
2877 pattern = self.smeshpyD.GetPattern()
2878 isDone = pattern.LoadFromFile(pattern_tetra)
2880 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2883 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2884 isDone = pattern.MakeMesh(self.mesh, False, False)
2885 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2887 # split quafrangle faces near triangular facets of volumes
2888 self.SplitQuadsNearTriangularFacets()
2892 ## @brief Split hexahedrons into prisms.
2894 # Uses the pattern mapping functionality for splitting.
2895 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2896 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2897 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2898 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2899 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2900 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2901 # @return TRUE in case of success, FALSE otherwise.
2902 # @ingroup l1_auxiliary
2903 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2904 # Pattern: 5.---------.6
2909 # (0,0,1) 4.---------.7 |
2916 # (0,0,0) 0.---------.3
2917 pattern_prism = "!!! Nb of points: \n 8 \n\
2927 !!! Indices of points of 2 prisms: \n\
2931 pattern = self.smeshpyD.GetPattern()
2932 isDone = pattern.LoadFromFile(pattern_prism)
2934 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2937 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2938 isDone = pattern.MakeMesh(self.mesh, False, False)
2939 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2941 # Splits quafrangle faces near triangular facets of volumes
2942 self.SplitQuadsNearTriangularFacets()
2946 ## Smoothes elements
2947 # @param IDsOfElements the list if ids of elements to smooth
2948 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2949 # Note that nodes built on edges and boundary nodes are always fixed.
2950 # @param MaxNbOfIterations the maximum number of iterations
2951 # @param MaxAspectRatio varies in range [1.0, inf]
2952 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2953 # @return TRUE in case of success, FALSE otherwise.
2954 # @ingroup l2_modif_smooth
2955 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2956 MaxNbOfIterations, MaxAspectRatio, Method):
2957 if IDsOfElements == []:
2958 IDsOfElements = self.GetElementsId()
2959 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2960 self.mesh.SetParameters(Parameters)
2961 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2962 MaxNbOfIterations, MaxAspectRatio, Method)
2964 ## Smoothes elements which belong to the given object
2965 # @param theObject the object to smooth
2966 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2967 # Note that nodes built on edges and boundary nodes are always fixed.
2968 # @param MaxNbOfIterations the maximum number of iterations
2969 # @param MaxAspectRatio varies in range [1.0, inf]
2970 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2971 # @return TRUE in case of success, FALSE otherwise.
2972 # @ingroup l2_modif_smooth
2973 def SmoothObject(self, theObject, IDsOfFixedNodes,
2974 MaxNbOfIterations, MaxAspectRatio, Method):
2975 if ( isinstance( theObject, Mesh )):
2976 theObject = theObject.GetMesh()
2977 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2978 MaxNbOfIterations, MaxAspectRatio, Method)
2980 ## Parametrically smoothes the given elements
2981 # @param IDsOfElements the list if ids of elements to smooth
2982 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2983 # Note that nodes built on edges and boundary nodes are always fixed.
2984 # @param MaxNbOfIterations the maximum number of iterations
2985 # @param MaxAspectRatio varies in range [1.0, inf]
2986 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2987 # @return TRUE in case of success, FALSE otherwise.
2988 # @ingroup l2_modif_smooth
2989 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2990 MaxNbOfIterations, MaxAspectRatio, Method):
2991 if IDsOfElements == []:
2992 IDsOfElements = self.GetElementsId()
2993 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2994 self.mesh.SetParameters(Parameters)
2995 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2996 MaxNbOfIterations, MaxAspectRatio, Method)
2998 ## Parametrically smoothes the elements which belong to the given object
2999 # @param theObject the object to smooth
3000 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3001 # Note that nodes built on edges and boundary nodes are always fixed.
3002 # @param MaxNbOfIterations the maximum number of iterations
3003 # @param MaxAspectRatio varies in range [1.0, inf]
3004 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3005 # @return TRUE in case of success, FALSE otherwise.
3006 # @ingroup l2_modif_smooth
3007 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
3008 MaxNbOfIterations, MaxAspectRatio, Method):
3009 if ( isinstance( theObject, Mesh )):
3010 theObject = theObject.GetMesh()
3011 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
3012 MaxNbOfIterations, MaxAspectRatio, Method)
3014 ## Converts the mesh to quadratic, deletes old elements, replacing
3015 # them with quadratic with the same id.
3016 # @param theForce3d new node creation method:
3017 # 0 - the medium node lies at the geometrical edge from which the mesh element is built
3018 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3019 # @ingroup l2_modif_tofromqu
3020 def ConvertToQuadratic(self, theForce3d):
3021 self.editor.ConvertToQuadratic(theForce3d)
3023 ## Converts the mesh from quadratic to ordinary,
3024 # deletes old quadratic elements, \n replacing
3025 # them with ordinary mesh elements with the same id.
3026 # @return TRUE in case of success, FALSE otherwise.
3027 # @ingroup l2_modif_tofromqu
3028 def ConvertFromQuadratic(self):
3029 return self.editor.ConvertFromQuadratic()
3031 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3032 # @return TRUE if operation has been completed successfully, FALSE otherwise
3033 # @ingroup l2_modif_edit
3034 def Make2DMeshFrom3D(self):
3035 return self.editor. Make2DMeshFrom3D()
3037 ## Creates missing boundary elements
3038 # @param elements - elements whose boundary is to be checked:
3039 # mesh, group, sub-mesh or list of elements
3040 # @param dimension - defines type of boundary elements to create:
3041 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3042 # @param groupName - a name of group to store created boundary elements in,
3043 # "" means not to create the group
3044 # @param meshName - a name of new mesh to store created boundary elements in,
3045 # "" means not to create the new mesh
3046 # @param toCopyElements - if true, the checked elements will be copied into the new mesh
3047 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3048 # boundary elements will be copied into the new mesh
3049 # @return tuple (mesh, group) where bondary elements were added to
3050 # @ingroup l2_modif_edit
3051 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3052 toCopyElements=False, toCopyExistingBondary=False):
3053 if isinstance( elements, Mesh ):
3054 elements = elements.GetMesh()
3055 if ( isinstance( elements, list )):
3056 elemType = SMESH.ALL
3057 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3058 elements = self.editor.MakeIDSource(elements, elemType)
3059 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3060 toCopyElements,toCopyExistingBondary)
3061 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3064 ## Renumber mesh nodes
3065 # @ingroup l2_modif_renumber
3066 def RenumberNodes(self):
3067 self.editor.RenumberNodes()
3069 ## Renumber mesh elements
3070 # @ingroup l2_modif_renumber
3071 def RenumberElements(self):
3072 self.editor.RenumberElements()
3074 ## Generates new elements by rotation of the elements around the axis
3075 # @param IDsOfElements the list of ids of elements to sweep
3076 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3077 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3078 # @param NbOfSteps the number of steps
3079 # @param Tolerance tolerance
3080 # @param MakeGroups forces the generation of new groups from existing ones
3081 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3082 # of all steps, else - size of each step
3083 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3084 # @ingroup l2_modif_extrurev
3085 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3086 MakeGroups=False, TotalAngle=False):
3088 if isinstance(AngleInRadians,str):
3090 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3092 AngleInRadians = DegreesToRadians(AngleInRadians)
3093 if IDsOfElements == []:
3094 IDsOfElements = self.GetElementsId()
3095 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3096 Axis = self.smeshpyD.GetAxisStruct(Axis)
3097 Axis,AxisParameters = ParseAxisStruct(Axis)
3098 if TotalAngle and NbOfSteps:
3099 AngleInRadians /= NbOfSteps
3100 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3101 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3102 self.mesh.SetParameters(Parameters)
3104 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3105 AngleInRadians, NbOfSteps, Tolerance)
3106 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3109 ## Generates new elements by rotation of the elements of object around the axis
3110 # @param theObject object which elements should be sweeped
3111 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3112 # @param AngleInRadians the angle of Rotation
3113 # @param NbOfSteps number of steps
3114 # @param Tolerance tolerance
3115 # @param MakeGroups forces the generation of new groups from existing ones
3116 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3117 # of all steps, else - size of each step
3118 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3119 # @ingroup l2_modif_extrurev
3120 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3121 MakeGroups=False, TotalAngle=False):
3123 if isinstance(AngleInRadians,str):
3125 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3127 AngleInRadians = DegreesToRadians(AngleInRadians)
3128 if ( isinstance( theObject, Mesh )):
3129 theObject = theObject.GetMesh()
3130 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3131 Axis = self.smeshpyD.GetAxisStruct(Axis)
3132 Axis,AxisParameters = ParseAxisStruct(Axis)
3133 if TotalAngle and NbOfSteps:
3134 AngleInRadians /= NbOfSteps
3135 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3136 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3137 self.mesh.SetParameters(Parameters)
3139 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3140 NbOfSteps, Tolerance)
3141 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3144 ## Generates new elements by rotation of the elements of object around the axis
3145 # @param theObject object which elements should be sweeped
3146 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3147 # @param AngleInRadians the angle of Rotation
3148 # @param NbOfSteps number of steps
3149 # @param Tolerance tolerance
3150 # @param MakeGroups forces the generation of new groups from existing ones
3151 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3152 # of all steps, else - size of each step
3153 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3154 # @ingroup l2_modif_extrurev
3155 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3156 MakeGroups=False, TotalAngle=False):
3158 if isinstance(AngleInRadians,str):
3160 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3162 AngleInRadians = DegreesToRadians(AngleInRadians)
3163 if ( isinstance( theObject, Mesh )):
3164 theObject = theObject.GetMesh()
3165 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3166 Axis = self.smeshpyD.GetAxisStruct(Axis)
3167 Axis,AxisParameters = ParseAxisStruct(Axis)
3168 if TotalAngle and NbOfSteps:
3169 AngleInRadians /= NbOfSteps
3170 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3171 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3172 self.mesh.SetParameters(Parameters)
3174 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3175 NbOfSteps, Tolerance)
3176 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3179 ## Generates new elements by rotation of the elements of object around the axis
3180 # @param theObject object which elements should be sweeped
3181 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3182 # @param AngleInRadians the angle of Rotation
3183 # @param NbOfSteps number of steps
3184 # @param Tolerance tolerance
3185 # @param MakeGroups forces the generation of new groups from existing ones
3186 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3187 # of all steps, else - size of each step
3188 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3189 # @ingroup l2_modif_extrurev
3190 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3191 MakeGroups=False, TotalAngle=False):
3193 if isinstance(AngleInRadians,str):
3195 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3197 AngleInRadians = DegreesToRadians(AngleInRadians)
3198 if ( isinstance( theObject, Mesh )):
3199 theObject = theObject.GetMesh()
3200 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3201 Axis = self.smeshpyD.GetAxisStruct(Axis)
3202 Axis,AxisParameters = ParseAxisStruct(Axis)
3203 if TotalAngle and NbOfSteps:
3204 AngleInRadians /= NbOfSteps
3205 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3206 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3207 self.mesh.SetParameters(Parameters)
3209 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3210 NbOfSteps, Tolerance)
3211 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3214 ## Generates new elements by extrusion of the elements with given ids
3215 # @param IDsOfElements the list of elements ids for extrusion
3216 # @param StepVector vector, defining the direction and value of extrusion
3217 # @param NbOfSteps the number of steps
3218 # @param MakeGroups forces the generation of new groups from existing ones
3219 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3220 # @ingroup l2_modif_extrurev
3221 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3222 if IDsOfElements == []:
3223 IDsOfElements = self.GetElementsId()
3224 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3225 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3226 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3227 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3228 Parameters = StepVectorParameters + var_separator + Parameters
3229 self.mesh.SetParameters(Parameters)
3231 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3232 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3235 ## Generates new elements by extrusion of the elements with given ids
3236 # @param IDsOfElements is ids of elements
3237 # @param StepVector vector, defining the direction and value of extrusion
3238 # @param NbOfSteps the number of steps
3239 # @param ExtrFlags sets flags for extrusion
3240 # @param SewTolerance uses for comparing locations of nodes if flag
3241 # EXTRUSION_FLAG_SEW is set
3242 # @param MakeGroups forces the generation of new groups from existing ones
3243 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3244 # @ingroup l2_modif_extrurev
3245 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3246 ExtrFlags, SewTolerance, MakeGroups=False):
3247 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3248 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3250 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3251 ExtrFlags, SewTolerance)
3252 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3253 ExtrFlags, SewTolerance)
3256 ## Generates new elements by extrusion of the elements which belong to the object
3257 # @param theObject the object which elements should be processed
3258 # @param StepVector vector, defining the direction and value of extrusion
3259 # @param NbOfSteps the number of steps
3260 # @param MakeGroups forces the generation of new groups from existing ones
3261 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3262 # @ingroup l2_modif_extrurev
3263 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3264 if ( isinstance( theObject, Mesh )):
3265 theObject = theObject.GetMesh()
3266 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3267 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3268 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3269 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3270 Parameters = StepVectorParameters + var_separator + Parameters
3271 self.mesh.SetParameters(Parameters)
3273 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3274 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3277 ## Generates new elements by extrusion of the elements which belong to the object
3278 # @param theObject object which elements should be processed
3279 # @param StepVector vector, defining the direction and value of extrusion
3280 # @param NbOfSteps the number of steps
3281 # @param MakeGroups to generate new groups from existing ones
3282 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3283 # @ingroup l2_modif_extrurev
3284 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3285 if ( isinstance( theObject, Mesh )):
3286 theObject = theObject.GetMesh()
3287 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3288 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3289 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3290 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3291 Parameters = StepVectorParameters + var_separator + Parameters
3292 self.mesh.SetParameters(Parameters)
3294 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3295 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3298 ## Generates new elements by extrusion of the elements which belong to the object
3299 # @param theObject object which elements should be processed
3300 # @param StepVector vector, defining the direction and value of extrusion
3301 # @param NbOfSteps the number of steps
3302 # @param MakeGroups forces the generation of new groups from existing ones
3303 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3304 # @ingroup l2_modif_extrurev
3305 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3306 if ( isinstance( theObject, Mesh )):
3307 theObject = theObject.GetMesh()
3308 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3309 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3310 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3311 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3312 Parameters = StepVectorParameters + var_separator + Parameters
3313 self.mesh.SetParameters(Parameters)
3315 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3316 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3321 ## Generates new elements by extrusion of the given elements
3322 # The path of extrusion must be a meshed edge.
3323 # @param Base mesh or list of ids of elements for extrusion
3324 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3325 # @param NodeStart the start node from Path. Defines the direction of extrusion
3326 # @param HasAngles allows the shape to be rotated around the path
3327 # to get the resulting mesh in a helical fashion
3328 # @param Angles list of angles in radians
3329 # @param LinearVariation forces the computation of rotation angles as linear
3330 # variation of the given Angles along path steps
3331 # @param HasRefPoint allows using the reference point
3332 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3333 # The User can specify any point as the Reference Point.
3334 # @param MakeGroups forces the generation of new groups from existing ones
3335 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3336 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3337 # only SMESH::Extrusion_Error otherwise
3338 # @ingroup l2_modif_extrurev
3339 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3340 HasAngles, Angles, LinearVariation,
3341 HasRefPoint, RefPoint, MakeGroups, ElemType):
3342 Angles,AnglesParameters = ParseAngles(Angles)
3343 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3344 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3345 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3347 Parameters = AnglesParameters + var_separator + RefPointParameters
3348 self.mesh.SetParameters(Parameters)
3350 if isinstance(Base,list):
3352 if Base == []: IDsOfElements = self.GetElementsId()
3353 else: IDsOfElements = Base
3354 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3355 HasAngles, Angles, LinearVariation,
3356 HasRefPoint, RefPoint, MakeGroups, ElemType)
3358 if isinstance(Base,Mesh):
3359 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3360 HasAngles, Angles, LinearVariation,
3361 HasRefPoint, RefPoint, MakeGroups, ElemType)
3363 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3366 ## Generates new elements by extrusion of the given elements
3367 # The path of extrusion must be a meshed edge.
3368 # @param IDsOfElements ids of elements
3369 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3370 # @param PathShape shape(edge) defines the sub-mesh for the path
3371 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3372 # @param HasAngles allows the shape to be rotated around the path
3373 # to get the resulting mesh in a helical fashion
3374 # @param Angles list of angles in radians
3375 # @param HasRefPoint allows using the reference point
3376 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3377 # The User can specify any point as the Reference Point.
3378 # @param MakeGroups forces the generation of new groups from existing ones
3379 # @param LinearVariation forces the computation of rotation angles as linear
3380 # variation of the given Angles along path steps
3381 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3382 # only SMESH::Extrusion_Error otherwise
3383 # @ingroup l2_modif_extrurev
3384 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3385 HasAngles, Angles, HasRefPoint, RefPoint,
3386 MakeGroups=False, LinearVariation=False):
3387 Angles,AnglesParameters = ParseAngles(Angles)
3388 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3389 if IDsOfElements == []:
3390 IDsOfElements = self.GetElementsId()
3391 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3392 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3394 if ( isinstance( PathMesh, Mesh )):
3395 PathMesh = PathMesh.GetMesh()
3396 if HasAngles and Angles and LinearVariation:
3397 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3399 Parameters = AnglesParameters + var_separator + RefPointParameters
3400 self.mesh.SetParameters(Parameters)
3402 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3403 PathShape, NodeStart, HasAngles,
3404 Angles, HasRefPoint, RefPoint)
3405 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3406 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3408 ## Generates new elements by extrusion of the elements which belong to the object
3409 # The path of extrusion must be a meshed edge.
3410 # @param theObject the object which elements should be processed
3411 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3412 # @param PathShape shape(edge) defines the sub-mesh for the path
3413 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3414 # @param HasAngles allows the shape to be rotated around the path
3415 # to get the resulting mesh in a helical fashion
3416 # @param Angles list of angles
3417 # @param HasRefPoint allows using the reference point
3418 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3419 # The User can specify any point as the Reference Point.
3420 # @param MakeGroups forces the generation of new groups from existing ones
3421 # @param LinearVariation forces the computation of rotation angles as linear
3422 # variation of the given Angles along path steps
3423 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3424 # only SMESH::Extrusion_Error otherwise
3425 # @ingroup l2_modif_extrurev
3426 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3427 HasAngles, Angles, HasRefPoint, RefPoint,
3428 MakeGroups=False, LinearVariation=False):
3429 Angles,AnglesParameters = ParseAngles(Angles)
3430 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3431 if ( isinstance( theObject, Mesh )):
3432 theObject = theObject.GetMesh()
3433 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3434 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3435 if ( isinstance( PathMesh, Mesh )):
3436 PathMesh = PathMesh.GetMesh()
3437 if HasAngles and Angles and LinearVariation:
3438 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3440 Parameters = AnglesParameters + var_separator + RefPointParameters
3441 self.mesh.SetParameters(Parameters)
3443 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3444 PathShape, NodeStart, HasAngles,
3445 Angles, HasRefPoint, RefPoint)
3446 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3447 NodeStart, HasAngles, Angles, HasRefPoint,
3450 ## Generates new elements by extrusion of the elements which belong to the object
3451 # The path of extrusion must be a meshed edge.
3452 # @param theObject the object which elements should be processed
3453 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3454 # @param PathShape shape(edge) defines the sub-mesh for the path
3455 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3456 # @param HasAngles allows the shape to be rotated around the path
3457 # to get the resulting mesh in a helical fashion
3458 # @param Angles list of angles
3459 # @param HasRefPoint allows using the reference point
3460 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3461 # The User can specify any point as the Reference Point.
3462 # @param MakeGroups forces the generation of new groups from existing ones
3463 # @param LinearVariation forces the computation of rotation angles as linear
3464 # variation of the given Angles along path steps
3465 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3466 # only SMESH::Extrusion_Error otherwise
3467 # @ingroup l2_modif_extrurev
3468 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3469 HasAngles, Angles, HasRefPoint, RefPoint,
3470 MakeGroups=False, LinearVariation=False):
3471 Angles,AnglesParameters = ParseAngles(Angles)
3472 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3473 if ( isinstance( theObject, Mesh )):
3474 theObject = theObject.GetMesh()
3475 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3476 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3477 if ( isinstance( PathMesh, Mesh )):
3478 PathMesh = PathMesh.GetMesh()
3479 if HasAngles and Angles and LinearVariation:
3480 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3482 Parameters = AnglesParameters + var_separator + RefPointParameters
3483 self.mesh.SetParameters(Parameters)
3485 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3486 PathShape, NodeStart, HasAngles,
3487 Angles, HasRefPoint, RefPoint)
3488 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3489 NodeStart, HasAngles, Angles, HasRefPoint,
3492 ## Generates new elements by extrusion of the elements which belong to the object
3493 # The path of extrusion must be a meshed edge.
3494 # @param theObject the object which elements should be processed
3495 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3496 # @param PathShape shape(edge) defines the sub-mesh for the path
3497 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3498 # @param HasAngles allows the shape to be rotated around the path
3499 # to get the resulting mesh in a helical fashion
3500 # @param Angles list of angles
3501 # @param HasRefPoint allows using the reference point
3502 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3503 # The User can specify any point as the Reference Point.
3504 # @param MakeGroups forces the generation of new groups from existing ones
3505 # @param LinearVariation forces the computation of rotation angles as linear
3506 # variation of the given Angles along path steps
3507 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3508 # only SMESH::Extrusion_Error otherwise
3509 # @ingroup l2_modif_extrurev
3510 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3511 HasAngles, Angles, HasRefPoint, RefPoint,
3512 MakeGroups=False, LinearVariation=False):
3513 Angles,AnglesParameters = ParseAngles(Angles)
3514 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3515 if ( isinstance( theObject, Mesh )):
3516 theObject = theObject.GetMesh()
3517 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3518 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3519 if ( isinstance( PathMesh, Mesh )):
3520 PathMesh = PathMesh.GetMesh()
3521 if HasAngles and Angles and LinearVariation:
3522 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3524 Parameters = AnglesParameters + var_separator + RefPointParameters
3525 self.mesh.SetParameters(Parameters)
3527 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3528 PathShape, NodeStart, HasAngles,
3529 Angles, HasRefPoint, RefPoint)
3530 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3531 NodeStart, HasAngles, Angles, HasRefPoint,
3534 ## Creates a symmetrical copy of mesh elements
3535 # @param IDsOfElements list of elements ids
3536 # @param Mirror is AxisStruct or geom object(point, line, plane)
3537 # @param theMirrorType is POINT, AXIS or PLANE
3538 # If the Mirror is a geom object this parameter is unnecessary
3539 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3540 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3541 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3542 # @ingroup l2_modif_trsf
3543 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3544 if IDsOfElements == []:
3545 IDsOfElements = self.GetElementsId()
3546 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3547 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3548 Mirror,Parameters = ParseAxisStruct(Mirror)
3549 self.mesh.SetParameters(Parameters)
3550 if Copy and MakeGroups:
3551 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3552 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3555 ## Creates a new mesh by a symmetrical copy of mesh elements
3556 # @param IDsOfElements the list of elements ids
3557 # @param Mirror is AxisStruct or geom object (point, line, plane)
3558 # @param theMirrorType is POINT, AXIS or PLANE
3559 # If the Mirror is a geom object this parameter is unnecessary
3560 # @param MakeGroups to generate new groups from existing ones
3561 # @param NewMeshName a name of the new mesh to create
3562 # @return instance of Mesh class
3563 # @ingroup l2_modif_trsf
3564 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3565 if IDsOfElements == []:
3566 IDsOfElements = self.GetElementsId()
3567 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3568 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3569 Mirror,Parameters = ParseAxisStruct(Mirror)
3570 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3571 MakeGroups, NewMeshName)
3572 mesh.SetParameters(Parameters)
3573 return Mesh(self.smeshpyD,self.geompyD,mesh)
3575 ## Creates a symmetrical copy of the object
3576 # @param theObject mesh, submesh or group
3577 # @param Mirror AxisStruct or geom object (point, line, plane)
3578 # @param theMirrorType is POINT, AXIS or PLANE
3579 # If the Mirror is a geom object this parameter is unnecessary
3580 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3581 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3582 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3583 # @ingroup l2_modif_trsf
3584 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3585 if ( isinstance( theObject, Mesh )):
3586 theObject = theObject.GetMesh()
3587 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3588 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3589 Mirror,Parameters = ParseAxisStruct(Mirror)
3590 self.mesh.SetParameters(Parameters)
3591 if Copy and MakeGroups:
3592 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3593 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3596 ## Creates a new mesh by a symmetrical copy of the object
3597 # @param theObject mesh, submesh or group
3598 # @param Mirror AxisStruct or geom object (point, line, plane)
3599 # @param theMirrorType POINT, AXIS or PLANE
3600 # If the Mirror is a geom object this parameter is unnecessary
3601 # @param MakeGroups forces the generation of new groups from existing ones
3602 # @param NewMeshName the name of the new mesh to create
3603 # @return instance of Mesh class
3604 # @ingroup l2_modif_trsf
3605 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3606 if ( isinstance( theObject, Mesh )):
3607 theObject = theObject.GetMesh()
3608 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3609 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3610 Mirror,Parameters = ParseAxisStruct(Mirror)
3611 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3612 MakeGroups, NewMeshName)
3613 mesh.SetParameters(Parameters)
3614 return Mesh( self.smeshpyD,self.geompyD,mesh )
3616 ## Translates the elements
3617 # @param IDsOfElements list of elements ids
3618 # @param Vector the direction of translation (DirStruct or vector)
3619 # @param Copy allows copying the translated elements
3620 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3621 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3622 # @ingroup l2_modif_trsf
3623 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3624 if IDsOfElements == []:
3625 IDsOfElements = self.GetElementsId()
3626 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3627 Vector = self.smeshpyD.GetDirStruct(Vector)
3628 Vector,Parameters = ParseDirStruct(Vector)
3629 self.mesh.SetParameters(Parameters)
3630 if Copy and MakeGroups:
3631 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3632 self.editor.Translate(IDsOfElements, Vector, Copy)
3635 ## Creates a new mesh of translated elements
3636 # @param IDsOfElements list of elements ids
3637 # @param Vector the direction of translation (DirStruct or vector)
3638 # @param MakeGroups forces the generation of new groups from existing ones
3639 # @param NewMeshName the name of the newly created mesh
3640 # @return instance of Mesh class
3641 # @ingroup l2_modif_trsf
3642 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3643 if IDsOfElements == []:
3644 IDsOfElements = self.GetElementsId()
3645 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3646 Vector = self.smeshpyD.GetDirStruct(Vector)
3647 Vector,Parameters = ParseDirStruct(Vector)
3648 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3649 mesh.SetParameters(Parameters)
3650 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3652 ## Translates the object
3653 # @param theObject the object to translate (mesh, submesh, or group)
3654 # @param Vector direction of translation (DirStruct or geom vector)
3655 # @param Copy allows copying the translated elements
3656 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3657 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3658 # @ingroup l2_modif_trsf
3659 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3660 if ( isinstance( theObject, Mesh )):
3661 theObject = theObject.GetMesh()
3662 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3663 Vector = self.smeshpyD.GetDirStruct(Vector)
3664 Vector,Parameters = ParseDirStruct(Vector)
3665 self.mesh.SetParameters(Parameters)
3666 if Copy and MakeGroups:
3667 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3668 self.editor.TranslateObject(theObject, Vector, Copy)
3671 ## Creates a new mesh from the translated object
3672 # @param theObject the object to translate (mesh, submesh, or group)
3673 # @param Vector the direction of translation (DirStruct or geom vector)
3674 # @param MakeGroups forces the generation of new groups from existing ones
3675 # @param NewMeshName the name of the newly created mesh
3676 # @return instance of Mesh class
3677 # @ingroup l2_modif_trsf
3678 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3679 if (isinstance(theObject, Mesh)):
3680 theObject = theObject.GetMesh()
3681 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3682 Vector = self.smeshpyD.GetDirStruct(Vector)
3683 Vector,Parameters = ParseDirStruct(Vector)
3684 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3685 mesh.SetParameters(Parameters)
3686 return Mesh( self.smeshpyD, self.geompyD, mesh )
3690 ## Scales the object
3691 # @param theObject - the object to translate (mesh, submesh, or group)
3692 # @param thePoint - base point for scale
3693 # @param theScaleFact - list of 1-3 scale factors for axises
3694 # @param Copy - allows copying the translated elements
3695 # @param MakeGroups - forces the generation of new groups from existing
3697 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3698 # empty list otherwise
3699 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3700 if ( isinstance( theObject, Mesh )):
3701 theObject = theObject.GetMesh()
3702 if ( isinstance( theObject, list )):
3703 theObject = self.editor.MakeIDSource(theObject, SMESH.ALL)
3705 thePoint, Parameters = ParsePointStruct(thePoint)
3706 self.mesh.SetParameters(Parameters)
3708 if Copy and MakeGroups:
3709 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3710 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3713 ## Creates a new mesh from the translated object
3714 # @param theObject - the object to translate (mesh, submesh, or group)
3715 # @param thePoint - base point for scale
3716 # @param theScaleFact - list of 1-3 scale factors for axises
3717 # @param MakeGroups - forces the generation of new groups from existing ones
3718 # @param NewMeshName - the name of the newly created mesh
3719 # @return instance of Mesh class
3720 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3721 if (isinstance(theObject, Mesh)):
3722 theObject = theObject.GetMesh()
3723 if ( isinstance( theObject, list )):
3724 theObject = self.editor.MakeIDSource(theObject,SMESH.ALL)
3726 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3727 MakeGroups, NewMeshName)
3728 #mesh.SetParameters(Parameters)
3729 return Mesh( self.smeshpyD, self.geompyD, mesh )
3733 ## Rotates the elements
3734 # @param IDsOfElements list of elements ids
3735 # @param Axis the axis of rotation (AxisStruct or geom line)
3736 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3737 # @param Copy allows copying the rotated elements
3738 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3739 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3740 # @ingroup l2_modif_trsf
3741 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3743 if isinstance(AngleInRadians,str):
3745 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3747 AngleInRadians = DegreesToRadians(AngleInRadians)
3748 if IDsOfElements == []:
3749 IDsOfElements = self.GetElementsId()
3750 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3751 Axis = self.smeshpyD.GetAxisStruct(Axis)
3752 Axis,AxisParameters = ParseAxisStruct(Axis)
3753 Parameters = AxisParameters + var_separator + Parameters
3754 self.mesh.SetParameters(Parameters)
3755 if Copy and MakeGroups:
3756 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3757 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3760 ## Creates a new mesh of rotated elements
3761 # @param IDsOfElements list of element ids
3762 # @param Axis the axis of rotation (AxisStruct or geom line)
3763 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3764 # @param MakeGroups forces the generation of new groups from existing ones
3765 # @param NewMeshName the name of the newly created mesh
3766 # @return instance of Mesh class
3767 # @ingroup l2_modif_trsf
3768 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3770 if isinstance(AngleInRadians,str):
3772 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3774 AngleInRadians = DegreesToRadians(AngleInRadians)
3775 if IDsOfElements == []:
3776 IDsOfElements = self.GetElementsId()
3777 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3778 Axis = self.smeshpyD.GetAxisStruct(Axis)
3779 Axis,AxisParameters = ParseAxisStruct(Axis)
3780 Parameters = AxisParameters + var_separator + Parameters
3781 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3782 MakeGroups, NewMeshName)
3783 mesh.SetParameters(Parameters)
3784 return Mesh( self.smeshpyD, self.geompyD, mesh )
3786 ## Rotates the object
3787 # @param theObject the object to rotate( mesh, submesh, or group)
3788 # @param Axis the axis of rotation (AxisStruct or geom line)
3789 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3790 # @param Copy allows copying the rotated elements
3791 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3792 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3793 # @ingroup l2_modif_trsf
3794 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3796 if isinstance(AngleInRadians,str):
3798 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3800 AngleInRadians = DegreesToRadians(AngleInRadians)
3801 if (isinstance(theObject, Mesh)):
3802 theObject = theObject.GetMesh()
3803 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3804 Axis = self.smeshpyD.GetAxisStruct(Axis)
3805 Axis,AxisParameters = ParseAxisStruct(Axis)
3806 Parameters = AxisParameters + ":" + Parameters
3807 self.mesh.SetParameters(Parameters)
3808 if Copy and MakeGroups:
3809 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3810 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3813 ## Creates a new mesh from the rotated object
3814 # @param theObject the object to rotate (mesh, submesh, or group)
3815 # @param Axis the axis of rotation (AxisStruct or geom line)
3816 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3817 # @param MakeGroups forces the generation of new groups from existing ones
3818 # @param NewMeshName the name of the newly created mesh
3819 # @return instance of Mesh class
3820 # @ingroup l2_modif_trsf
3821 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3823 if isinstance(AngleInRadians,str):
3825 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3827 AngleInRadians = DegreesToRadians(AngleInRadians)
3828 if (isinstance( theObject, Mesh )):
3829 theObject = theObject.GetMesh()
3830 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3831 Axis = self.smeshpyD.GetAxisStruct(Axis)
3832 Axis,AxisParameters = ParseAxisStruct(Axis)
3833 Parameters = AxisParameters + ":" + Parameters
3834 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3835 MakeGroups, NewMeshName)
3836 mesh.SetParameters(Parameters)
3837 return Mesh( self.smeshpyD, self.geompyD, mesh )
3839 ## Finds groups of ajacent nodes within Tolerance.
3840 # @param Tolerance the value of tolerance
3841 # @return the list of groups of nodes
3842 # @ingroup l2_modif_trsf
3843 def FindCoincidentNodes (self, Tolerance):
3844 return self.editor.FindCoincidentNodes(Tolerance)
3846 ## Finds groups of ajacent nodes within Tolerance.
3847 # @param Tolerance the value of tolerance
3848 # @param SubMeshOrGroup SubMesh or Group
3849 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3850 # @return the list of groups of nodes
3851 # @ingroup l2_modif_trsf
3852 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3853 if (isinstance( SubMeshOrGroup, Mesh )):
3854 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3855 if not isinstance( exceptNodes, list):
3856 exceptNodes = [ exceptNodes ]
3857 if exceptNodes and isinstance( exceptNodes[0], int):
3858 exceptNodes = [ self.editor.MakeIDSource( exceptNodes, SMESH.NODE)]
3859 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3862 # @param GroupsOfNodes the list of groups of nodes
3863 # @ingroup l2_modif_trsf
3864 def MergeNodes (self, GroupsOfNodes):
3865 self.editor.MergeNodes(GroupsOfNodes)
3867 ## Finds the elements built on the same nodes.
3868 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3869 # @return a list of groups of equal elements
3870 # @ingroup l2_modif_trsf
3871 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3872 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3873 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3874 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3876 ## Merges elements in each given group.
3877 # @param GroupsOfElementsID groups of elements for merging
3878 # @ingroup l2_modif_trsf
3879 def MergeElements(self, GroupsOfElementsID):
3880 self.editor.MergeElements(GroupsOfElementsID)
3882 ## Leaves one element and removes all other elements built on the same nodes.
3883 # @ingroup l2_modif_trsf
3884 def MergeEqualElements(self):
3885 self.editor.MergeEqualElements()
3887 ## Sews free borders
3888 # @return SMESH::Sew_Error
3889 # @ingroup l2_modif_trsf
3890 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3891 FirstNodeID2, SecondNodeID2, LastNodeID2,
3892 CreatePolygons, CreatePolyedrs):
3893 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3894 FirstNodeID2, SecondNodeID2, LastNodeID2,
3895 CreatePolygons, CreatePolyedrs)
3897 ## Sews conform free borders
3898 # @return SMESH::Sew_Error
3899 # @ingroup l2_modif_trsf
3900 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3901 FirstNodeID2, SecondNodeID2):
3902 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3903 FirstNodeID2, SecondNodeID2)
3905 ## Sews border to side
3906 # @return SMESH::Sew_Error
3907 # @ingroup l2_modif_trsf
3908 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3909 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3910 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3911 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3913 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3914 # merged with the nodes of elements of Side2.
3915 # The number of elements in theSide1 and in theSide2 must be
3916 # equal and they should have similar nodal connectivity.
3917 # The nodes to merge should belong to side borders and
3918 # the first node should be linked to the second.
3919 # @return SMESH::Sew_Error
3920 # @ingroup l2_modif_trsf
3921 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3922 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3923 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3924 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3925 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3926 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3928 ## Sets new nodes for the given element.
3929 # @param ide the element id
3930 # @param newIDs nodes ids
3931 # @return If the number of nodes does not correspond to the type of element - returns false
3932 # @ingroup l2_modif_edit
3933 def ChangeElemNodes(self, ide, newIDs):
3934 return self.editor.ChangeElemNodes(ide, newIDs)
3936 ## If during the last operation of MeshEditor some nodes were
3937 # created, this method returns the list of their IDs, \n
3938 # if new nodes were not created - returns empty list
3939 # @return the list of integer values (can be empty)
3940 # @ingroup l1_auxiliary
3941 def GetLastCreatedNodes(self):
3942 return self.editor.GetLastCreatedNodes()
3944 ## If during the last operation of MeshEditor some elements were
3945 # created this method returns the list of their IDs, \n
3946 # if new elements were not created - returns empty list
3947 # @return the list of integer values (can be empty)
3948 # @ingroup l1_auxiliary
3949 def GetLastCreatedElems(self):
3950 return self.editor.GetLastCreatedElems()
3952 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3953 # @param theNodes identifiers of nodes to be doubled
3954 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3955 # nodes. If list of element identifiers is empty then nodes are doubled but
3956 # they not assigned to elements
3957 # @return TRUE if operation has been completed successfully, FALSE otherwise
3958 # @ingroup l2_modif_edit
3959 def DoubleNodes(self, theNodes, theModifiedElems):
3960 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3962 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3963 # This method provided for convenience works as DoubleNodes() described above.
3964 # @param theNodeId identifiers of node to be doubled
3965 # @param theModifiedElems identifiers of elements to be updated
3966 # @return TRUE if operation has been completed successfully, FALSE otherwise
3967 # @ingroup l2_modif_edit
3968 def DoubleNode(self, theNodeId, theModifiedElems):
3969 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3971 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3972 # This method provided for convenience works as DoubleNodes() described above.
3973 # @param theNodes group of nodes to be doubled
3974 # @param theModifiedElems group of elements to be updated.
3975 # @param theMakeGroup forces the generation of a group containing new nodes.
3976 # @return TRUE or a created group if operation has been completed successfully,
3977 # FALSE or None otherwise
3978 # @ingroup l2_modif_edit
3979 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
3981 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
3982 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3984 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3985 # This method provided for convenience works as DoubleNodes() described above.
3986 # @param theNodes list of groups of nodes to be doubled
3987 # @param theModifiedElems list of groups of elements to be updated.
3988 # @return TRUE if operation has been completed successfully, FALSE otherwise
3989 # @ingroup l2_modif_edit
3990 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3991 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3993 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3994 # @param theElems - the list of elements (edges or faces) to be replicated
3995 # The nodes for duplication could be found from these elements
3996 # @param theNodesNot - list of nodes to NOT replicate
3997 # @param theAffectedElems - the list of elements (cells and edges) to which the
3998 # replicated nodes should be associated to.
3999 # @return TRUE if operation has been completed successfully, FALSE otherwise
4000 # @ingroup l2_modif_edit
4001 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4002 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4004 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4005 # @param theElems - the list of elements (edges or faces) to be replicated
4006 # The nodes for duplication could be found from these elements
4007 # @param theNodesNot - list of nodes to NOT replicate
4008 # @param theShape - shape to detect affected elements (element which geometric center
4009 # located on or inside shape).
4010 # The replicated nodes should be associated to affected elements.
4011 # @return TRUE if operation has been completed successfully, FALSE otherwise
4012 # @ingroup l2_modif_edit
4013 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4014 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4016 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4017 # This method provided for convenience works as DoubleNodes() described above.
4018 # @param theElems - group of of elements (edges or faces) to be replicated
4019 # @param theNodesNot - group of nodes not to replicated
4020 # @param theAffectedElems - group of elements to which the replicated nodes
4021 # should be associated to.
4022 # @param theMakeGroup forces the generation of a group containing new elements.
4023 # @ingroup l2_modif_edit
4024 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4026 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4027 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4029 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4030 # This method provided for convenience works as DoubleNodes() described above.
4031 # @param theElems - group of of elements (edges or faces) to be replicated
4032 # @param theNodesNot - group of nodes not to replicated
4033 # @param theShape - shape to detect affected elements (element which geometric center
4034 # located on or inside shape).
4035 # The replicated nodes should be associated to affected elements.
4036 # @ingroup l2_modif_edit
4037 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4038 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4040 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4041 # This method provided for convenience works as DoubleNodes() described above.
4042 # @param theElems - list of groups of elements (edges or faces) to be replicated
4043 # @param theNodesNot - list of groups of nodes not to replicated
4044 # @param theAffectedElems - group of elements to which the replicated nodes
4045 # should be associated to.
4046 # @return TRUE if operation has been completed successfully, FALSE otherwise
4047 # @ingroup l2_modif_edit
4048 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
4049 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4051 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4052 # This method provided for convenience works as DoubleNodes() described above.
4053 # @param theElems - list of groups of elements (edges or faces) to be replicated
4054 # @param theNodesNot - list of groups of nodes not to replicated
4055 # @param theShape - shape to detect affected elements (element which geometric center
4056 # located on or inside shape).
4057 # The replicated nodes should be associated to affected elements.
4058 # @return TRUE if operation has been completed successfully, FALSE otherwise
4059 # @ingroup l2_modif_edit
4060 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4061 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4063 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4064 # The list of groups must describe a partition of the mesh volumes.
4065 # The nodes of the internal faces at the boundaries of the groups are doubled.
4066 # In option, the internal faces are replaced by flat elements.
4067 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4068 # @param theDomains - list of groups of volumes
4069 # @param createJointElems - if TRUE, create the elements
4070 # @return TRUE if operation has been completed successfully, FALSE otherwise
4071 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4072 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4074 def _valueFromFunctor(self, funcType, elemId):
4075 fn = self.smeshpyD.GetFunctor(funcType)
4076 fn.SetMesh(self.mesh)
4077 if fn.GetElementType() == self.GetElementType(elemId, True):
4078 val = fn.GetValue(elemId)
4083 ## Get length of 1D element.
4084 # @param elemId mesh element ID
4085 # @return element's length value
4086 # @ingroup l1_measurements
4087 def GetLength(self, elemId):
4088 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4090 ## Get area of 2D element.
4091 # @param elemId mesh element ID
4092 # @return element's area value
4093 # @ingroup l1_measurements
4094 def GetArea(self, elemId):
4095 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4097 ## Get volume of 3D element.
4098 # @param elemId mesh element ID
4099 # @return element's volume value
4100 # @ingroup l1_measurements
4101 def GetVolume(self, elemId):
4102 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4104 ## Get maximum element length.
4105 # @param elemId mesh element ID
4106 # @return element's maximum length value
4107 # @ingroup l1_measurements
4108 def GetMaxElementLength(self, elemId):
4109 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4110 ftype = SMESH.FT_MaxElementLength3D
4112 ftype = SMESH.FT_MaxElementLength2D
4113 return self._valueFromFunctor(ftype, elemId)
4115 ## Get aspect ratio of 2D or 3D element.
4116 # @param elemId mesh element ID
4117 # @return element's aspect ratio value
4118 # @ingroup l1_measurements
4119 def GetAspectRatio(self, elemId):
4120 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4121 ftype = SMESH.FT_AspectRatio3D
4123 ftype = SMESH.FT_AspectRatio
4124 return self._valueFromFunctor(ftype, elemId)
4126 ## Get warping angle of 2D element.
4127 # @param elemId mesh element ID
4128 # @return element's warping angle value
4129 # @ingroup l1_measurements
4130 def GetWarping(self, elemId):
4131 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4133 ## Get minimum angle of 2D element.
4134 # @param elemId mesh element ID
4135 # @return element's minimum angle value
4136 # @ingroup l1_measurements
4137 def GetMinimumAngle(self, elemId):
4138 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4140 ## Get taper of 2D element.
4141 # @param elemId mesh element ID
4142 # @return element's taper value
4143 # @ingroup l1_measurements
4144 def GetTaper(self, elemId):
4145 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4147 ## Get skew of 2D element.
4148 # @param elemId mesh element ID
4149 # @return element's skew value
4150 # @ingroup l1_measurements
4151 def GetSkew(self, elemId):
4152 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4154 ## The mother class to define algorithm, it is not recommended to use it directly.
4157 # @ingroup l2_algorithms
4158 class Mesh_Algorithm:
4159 # @class Mesh_Algorithm
4160 # @brief Class Mesh_Algorithm
4162 #def __init__(self,smesh):
4170 ## Finds a hypothesis in the study by its type name and parameters.
4171 # Finds only the hypotheses created in smeshpyD engine.
4172 # @return SMESH.SMESH_Hypothesis
4173 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4174 study = smeshpyD.GetCurrentStudy()
4175 #to do: find component by smeshpyD object, not by its data type
4176 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4177 if scomp is not None:
4178 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4179 # Check if the root label of the hypotheses exists
4180 if res and hypRoot is not None:
4181 iter = study.NewChildIterator(hypRoot)
4182 # Check all published hypotheses
4184 hypo_so_i = iter.Value()
4185 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4186 if attr is not None:
4187 anIOR = attr.Value()
4188 hypo_o_i = salome.orb.string_to_object(anIOR)
4189 if hypo_o_i is not None:
4190 # Check if this is a hypothesis
4191 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4192 if hypo_i is not None:
4193 # Check if the hypothesis belongs to current engine
4194 if smeshpyD.GetObjectId(hypo_i) > 0:
4195 # Check if this is the required hypothesis
4196 if hypo_i.GetName() == hypname:
4198 if CompareMethod(hypo_i, args):
4212 ## Finds the algorithm in the study by its type name.
4213 # Finds only the algorithms, which have been created in smeshpyD engine.
4214 # @return SMESH.SMESH_Algo
4215 def FindAlgorithm (self, algoname, smeshpyD):
4216 study = smeshpyD.GetCurrentStudy()
4217 #to do: find component by smeshpyD object, not by its data type
4218 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4219 if scomp is not None:
4220 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4221 # Check if the root label of the algorithms exists
4222 if res and hypRoot is not None:
4223 iter = study.NewChildIterator(hypRoot)
4224 # Check all published algorithms
4226 algo_so_i = iter.Value()
4227 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4228 if attr is not None:
4229 anIOR = attr.Value()
4230 algo_o_i = salome.orb.string_to_object(anIOR)
4231 if algo_o_i is not None:
4232 # Check if this is an algorithm
4233 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4234 if algo_i is not None:
4235 # Checks if the algorithm belongs to the current engine
4236 if smeshpyD.GetObjectId(algo_i) > 0:
4237 # Check if this is the required algorithm
4238 if algo_i.GetName() == algoname:
4251 ## If the algorithm is global, returns 0; \n
4252 # else returns the submesh associated to this algorithm.
4253 def GetSubMesh(self):
4256 ## Returns the wrapped mesher.
4257 def GetAlgorithm(self):
4260 ## Gets the list of hypothesis that can be used with this algorithm
4261 def GetCompatibleHypothesis(self):
4264 mylist = self.algo.GetCompatibleHypothesis()
4267 ## Gets the name of the algorithm
4271 ## Sets the name to the algorithm
4272 def SetName(self, name):
4273 self.mesh.smeshpyD.SetName(self.algo, name)
4275 ## Gets the id of the algorithm
4277 return self.algo.GetId()
4280 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4282 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4283 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4285 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4287 self.Assign(algo, mesh, geom)
4291 def Assign(self, algo, mesh, geom):
4293 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4302 name = GetName(geom)
4305 name = mesh.geompyD.SubShapeName(geom, piece)
4307 name = "%s_%s"%(geom.GetShapeType(), id(geom%1000))
4309 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4312 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4313 TreatHypoStatus( status, algo.GetName(), name, True )
4315 def CompareHyp (self, hyp, args):
4316 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4319 def CompareEqualHyp (self, hyp, args):
4323 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4324 UseExisting=0, CompareMethod=""):
4327 if CompareMethod == "": CompareMethod = self.CompareHyp
4328 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4331 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4337 a = a + s + str(args[i])
4341 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4343 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4344 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
4347 ## Returns entry of the shape to mesh in the study
4348 def MainShapeEntry(self):
4350 if not self.mesh or not self.mesh.GetMesh(): return entry
4351 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4352 study = self.mesh.smeshpyD.GetCurrentStudy()
4353 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4354 sobj = study.FindObjectIOR(ior)
4355 if sobj: entry = sobj.GetID()
4356 if not entry: return ""
4359 # Public class: Mesh_Segment
4360 # --------------------------
4362 ## Class to define a segment 1D algorithm for discretization
4365 # @ingroup l3_algos_basic
4366 class Mesh_Segment(Mesh_Algorithm):
4368 ## Private constructor.
4369 def __init__(self, mesh, geom=0):
4370 Mesh_Algorithm.__init__(self)
4371 self.Create(mesh, geom, "Regular_1D")
4373 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4374 # @param l for the length of segments that cut an edge
4375 # @param UseExisting if ==true - searches for an existing hypothesis created with
4376 # the same parameters, else (default) - creates a new one
4377 # @param p precision, used for calculation of the number of segments.
4378 # The precision should be a positive, meaningful value within the range [0,1].
4379 # In general, the number of segments is calculated with the formula:
4380 # nb = ceil((edge_length / l) - p)
4381 # Function ceil rounds its argument to the higher integer.
4382 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4383 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4384 # p=1 means rounding of (edge_length / l) to the lower integer.
4385 # Default value is 1e-07.
4386 # @return an instance of StdMeshers_LocalLength hypothesis
4387 # @ingroup l3_hypos_1dhyps
4388 def LocalLength(self, l, UseExisting=0, p=1e-07):
4389 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4390 CompareMethod=self.CompareLocalLength)
4396 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4397 def CompareLocalLength(self, hyp, args):
4398 if IsEqual(hyp.GetLength(), args[0]):
4399 return IsEqual(hyp.GetPrecision(), args[1])
4402 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4403 # @param length is optional maximal allowed length of segment, if it is omitted
4404 # the preestimated length is used that depends on geometry size
4405 # @param UseExisting if ==true - searches for an existing hypothesis created with
4406 # the same parameters, else (default) - create a new one
4407 # @return an instance of StdMeshers_MaxLength hypothesis
4408 # @ingroup l3_hypos_1dhyps
4409 def MaxSize(self, length=0.0, UseExisting=0):
4410 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4413 hyp.SetLength(length)
4415 # set preestimated length
4416 gen = self.mesh.smeshpyD
4417 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4418 self.mesh.GetMesh(), self.mesh.GetShape(),
4420 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4422 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4425 hyp.SetUsePreestimatedLength( length == 0.0 )
4428 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4429 # @param n for the number of segments that cut an edge
4430 # @param s for the scale factor (optional)
4431 # @param reversedEdges is a list of edges to mesh using reversed orientation
4432 # @param UseExisting if ==true - searches for an existing hypothesis created with
4433 # the same parameters, else (default) - create a new one
4434 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4435 # @ingroup l3_hypos_1dhyps
4436 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4437 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4438 reversedEdges, UseExisting = [], reversedEdges
4439 entry = self.MainShapeEntry()
4440 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4441 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4443 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4444 UseExisting=UseExisting,
4445 CompareMethod=self.CompareNumberOfSegments)
4447 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4448 UseExisting=UseExisting,
4449 CompareMethod=self.CompareNumberOfSegments)
4450 hyp.SetDistrType( 1 )
4451 hyp.SetScaleFactor(s)
4452 hyp.SetNumberOfSegments(n)
4453 hyp.SetReversedEdges( reversedEdges )
4454 hyp.SetObjectEntry( entry )
4458 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4459 def CompareNumberOfSegments(self, hyp, args):
4460 if hyp.GetNumberOfSegments() == args[0]:
4462 if hyp.GetReversedEdges() == args[1]:
4463 if not args[1] or hyp.GetObjectEntry() == args[2]:
4466 if hyp.GetReversedEdges() == args[2]:
4467 if not args[2] or hyp.GetObjectEntry() == args[3]:
4468 if hyp.GetDistrType() == 1:
4469 if IsEqual(hyp.GetScaleFactor(), args[1]):
4473 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4474 # @param start defines the length of the first segment
4475 # @param end defines the length of the last segment
4476 # @param reversedEdges is a list of edges to mesh using reversed orientation
4477 # @param UseExisting if ==true - searches for an existing hypothesis created with
4478 # the same parameters, else (default) - creates a new one
4479 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4480 # @ingroup l3_hypos_1dhyps
4481 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4482 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4483 reversedEdges, UseExisting = [], reversedEdges
4484 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4485 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4486 entry = self.MainShapeEntry()
4487 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4488 UseExisting=UseExisting,
4489 CompareMethod=self.CompareArithmetic1D)
4490 hyp.SetStartLength(start)
4491 hyp.SetEndLength(end)
4492 hyp.SetReversedEdges( reversedEdges )
4493 hyp.SetObjectEntry( entry )
4497 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4498 def CompareArithmetic1D(self, hyp, args):
4499 if IsEqual(hyp.GetLength(1), args[0]):
4500 if IsEqual(hyp.GetLength(0), args[1]):
4501 if hyp.GetReversedEdges() == args[2]:
4502 if not args[2] or hyp.GetObjectEntry() == args[3]:
4507 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4508 # on curve from 0 to 1 (additionally it is neecessary to check
4509 # orientation of edges and create list of reversed edges if it is
4510 # needed) and sets numbers of segments between given points (default
4511 # values are equals 1
4512 # @param points defines the list of parameters on curve
4513 # @param nbSegs defines the list of numbers of segments
4514 # @param reversedEdges is a list of edges to mesh using reversed orientation
4515 # @param UseExisting if ==true - searches for an existing hypothesis created with
4516 # the same parameters, else (default) - creates a new one
4517 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4518 # @ingroup l3_hypos_1dhyps
4519 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4520 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4521 reversedEdges, UseExisting = [], reversedEdges
4522 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4523 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4524 entry = self.MainShapeEntry()
4525 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4526 UseExisting=UseExisting,
4527 CompareMethod=self.CompareFixedPoints1D)
4528 hyp.SetPoints(points)
4529 hyp.SetNbSegments(nbSegs)
4530 hyp.SetReversedEdges(reversedEdges)
4531 hyp.SetObjectEntry(entry)
4535 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4536 ## as the given arguments
4537 def CompareFixedPoints1D(self, hyp, args):
4538 if hyp.GetPoints() == args[0]:
4539 if hyp.GetNbSegments() == args[1]:
4540 if hyp.GetReversedEdges() == args[2]:
4541 if not args[2] or hyp.GetObjectEntry() == args[3]:
4547 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4548 # @param start defines the length of the first segment
4549 # @param end defines the length of the last segment
4550 # @param reversedEdges is a list of edges to mesh using reversed orientation
4551 # @param UseExisting if ==true - searches for an existing hypothesis created with
4552 # the same parameters, else (default) - creates a new one
4553 # @return an instance of StdMeshers_StartEndLength hypothesis
4554 # @ingroup l3_hypos_1dhyps
4555 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4556 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4557 reversedEdges, UseExisting = [], reversedEdges
4558 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4559 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4560 entry = self.MainShapeEntry()
4561 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4562 UseExisting=UseExisting,
4563 CompareMethod=self.CompareStartEndLength)
4564 hyp.SetStartLength(start)
4565 hyp.SetEndLength(end)
4566 hyp.SetReversedEdges( reversedEdges )
4567 hyp.SetObjectEntry( entry )
4570 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4571 def CompareStartEndLength(self, hyp, args):
4572 if IsEqual(hyp.GetLength(1), args[0]):
4573 if IsEqual(hyp.GetLength(0), args[1]):
4574 if hyp.GetReversedEdges() == args[2]:
4575 if not args[2] or hyp.GetObjectEntry() == args[3]:
4579 ## Defines "Deflection1D" hypothesis
4580 # @param d for the deflection
4581 # @param UseExisting if ==true - searches for an existing hypothesis created with
4582 # the same parameters, else (default) - create a new one
4583 # @ingroup l3_hypos_1dhyps
4584 def Deflection1D(self, d, UseExisting=0):
4585 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4586 CompareMethod=self.CompareDeflection1D)
4587 hyp.SetDeflection(d)
4590 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4591 def CompareDeflection1D(self, hyp, args):
4592 return IsEqual(hyp.GetDeflection(), args[0])
4594 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4595 # the opposite side in case of quadrangular faces
4596 # @ingroup l3_hypos_additi
4597 def Propagation(self):
4598 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4600 ## Defines "AutomaticLength" hypothesis
4601 # @param fineness for the fineness [0-1]
4602 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4603 # same parameters, else (default) - create a new one
4604 # @ingroup l3_hypos_1dhyps
4605 def AutomaticLength(self, fineness=0, UseExisting=0):
4606 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4607 CompareMethod=self.CompareAutomaticLength)
4608 hyp.SetFineness( fineness )
4611 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4612 def CompareAutomaticLength(self, hyp, args):
4613 return IsEqual(hyp.GetFineness(), args[0])
4615 ## Defines "SegmentLengthAroundVertex" hypothesis
4616 # @param length for the segment length
4617 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4618 # Any other integer value means that the hypothesis will be set on the
4619 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4620 # @param UseExisting if ==true - searches for an existing hypothesis created with
4621 # the same parameters, else (default) - creates a new one
4622 # @ingroup l3_algos_segmarv
4623 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4625 store_geom = self.geom
4626 if type(vertex) is types.IntType:
4627 if vertex == 0 or vertex == 1:
4628 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4636 if self.geom is None:
4637 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4639 name = GetName(self.geom)
4642 piece = self.mesh.geom
4643 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4644 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4646 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4648 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4650 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4651 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4653 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4654 CompareMethod=self.CompareLengthNearVertex)
4655 self.geom = store_geom
4656 hyp.SetLength( length )
4659 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4660 # @ingroup l3_algos_segmarv
4661 def CompareLengthNearVertex(self, hyp, args):
4662 return IsEqual(hyp.GetLength(), args[0])
4664 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4665 # If the 2D mesher sees that all boundary edges are quadratic,
4666 # it generates quadratic faces, else it generates linear faces using
4667 # medium nodes as if they are vertices.
4668 # The 3D mesher generates quadratic volumes only if all boundary faces
4669 # are quadratic, else it fails.
4671 # @ingroup l3_hypos_additi
4672 def QuadraticMesh(self):
4673 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4676 # Public class: Mesh_CompositeSegment
4677 # --------------------------
4679 ## Defines a segment 1D algorithm for discretization
4681 # @ingroup l3_algos_basic
4682 class Mesh_CompositeSegment(Mesh_Segment):
4684 ## Private constructor.
4685 def __init__(self, mesh, geom=0):
4686 self.Create(mesh, geom, "CompositeSegment_1D")
4689 # Public class: Mesh_Segment_Python
4690 # ---------------------------------
4692 ## Defines a segment 1D algorithm for discretization with python function
4694 # @ingroup l3_algos_basic
4695 class Mesh_Segment_Python(Mesh_Segment):
4697 ## Private constructor.
4698 def __init__(self, mesh, geom=0):
4699 import Python1dPlugin
4700 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4702 ## Defines "PythonSplit1D" hypothesis
4703 # @param n for the number of segments that cut an edge
4704 # @param func for the python function that calculates the length of all segments
4705 # @param UseExisting if ==true - searches for the existing hypothesis created with
4706 # the same parameters, else (default) - creates a new one
4707 # @ingroup l3_hypos_1dhyps
4708 def PythonSplit1D(self, n, func, UseExisting=0):
4709 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4710 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4711 hyp.SetNumberOfSegments(n)
4712 hyp.SetPythonLog10RatioFunction(func)
4715 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4716 def ComparePythonSplit1D(self, hyp, args):
4717 #if hyp.GetNumberOfSegments() == args[0]:
4718 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4722 # Public class: Mesh_Triangle
4723 # ---------------------------
4725 ## Defines a triangle 2D algorithm
4727 # @ingroup l3_algos_basic
4728 class Mesh_Triangle(Mesh_Algorithm):
4737 ## Private constructor.
4738 def __init__(self, mesh, algoType, geom=0):
4739 Mesh_Algorithm.__init__(self)
4741 self.algoType = algoType
4742 if algoType == MEFISTO:
4743 self.Create(mesh, geom, "MEFISTO_2D")
4745 elif algoType == BLSURF:
4747 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4748 #self.SetPhysicalMesh() - PAL19680
4749 elif algoType == NETGEN:
4751 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4753 elif algoType == NETGEN_2D:
4755 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4758 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4759 # @param area for the maximum area of each triangle
4760 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4761 # same parameters, else (default) - creates a new one
4763 # Only for algoType == MEFISTO || NETGEN_2D
4764 # @ingroup l3_hypos_2dhyps
4765 def MaxElementArea(self, area, UseExisting=0):
4766 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4767 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4768 CompareMethod=self.CompareMaxElementArea)
4769 elif self.algoType == NETGEN:
4770 hyp = self.Parameters(SIMPLE)
4771 hyp.SetMaxElementArea(area)
4774 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4775 def CompareMaxElementArea(self, hyp, args):
4776 return IsEqual(hyp.GetMaxElementArea(), args[0])
4778 ## Defines "LengthFromEdges" hypothesis to build triangles
4779 # based on the length of the edges taken from the wire
4781 # Only for algoType == MEFISTO || NETGEN_2D
4782 # @ingroup l3_hypos_2dhyps
4783 def LengthFromEdges(self):
4784 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4785 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4787 elif self.algoType == NETGEN:
4788 hyp = self.Parameters(SIMPLE)
4789 hyp.LengthFromEdges()
4792 ## Sets a way to define size of mesh elements to generate.
4793 # @param thePhysicalMesh is: DefaultSize or Custom.
4794 # @ingroup l3_hypos_blsurf
4795 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4796 # Parameter of BLSURF algo
4797 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4799 ## Sets size of mesh elements to generate.
4800 # @ingroup l3_hypos_blsurf
4801 def SetPhySize(self, theVal):
4802 # Parameter of BLSURF algo
4803 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4804 self.Parameters().SetPhySize(theVal)
4806 ## Sets lower boundary of mesh element size (PhySize).
4807 # @ingroup l3_hypos_blsurf
4808 def SetPhyMin(self, theVal=-1):
4809 # Parameter of BLSURF algo
4810 self.Parameters().SetPhyMin(theVal)
4812 ## Sets upper boundary of mesh element size (PhySize).
4813 # @ingroup l3_hypos_blsurf
4814 def SetPhyMax(self, theVal=-1):
4815 # Parameter of BLSURF algo
4816 self.Parameters().SetPhyMax(theVal)
4818 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4819 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4820 # @ingroup l3_hypos_blsurf
4821 def SetGeometricMesh(self, theGeometricMesh=0):
4822 # Parameter of BLSURF algo
4823 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4824 self.params.SetGeometricMesh(theGeometricMesh)
4826 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4827 # @ingroup l3_hypos_blsurf
4828 def SetAngleMeshS(self, theVal=_angleMeshS):
4829 # Parameter of BLSURF algo
4830 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4831 self.params.SetAngleMeshS(theVal)
4833 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4834 # @ingroup l3_hypos_blsurf
4835 def SetAngleMeshC(self, theVal=_angleMeshS):
4836 # Parameter of BLSURF algo
4837 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4838 self.params.SetAngleMeshC(theVal)
4840 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4841 # @ingroup l3_hypos_blsurf
4842 def SetGeoMin(self, theVal=-1):
4843 # Parameter of BLSURF algo
4844 self.Parameters().SetGeoMin(theVal)
4846 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4847 # @ingroup l3_hypos_blsurf
4848 def SetGeoMax(self, theVal=-1):
4849 # Parameter of BLSURF algo
4850 self.Parameters().SetGeoMax(theVal)
4852 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4853 # @ingroup l3_hypos_blsurf
4854 def SetGradation(self, theVal=_gradation):
4855 # Parameter of BLSURF algo
4856 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4857 self.params.SetGradation(theVal)
4859 ## Sets topology usage way.
4860 # @param way defines how mesh conformity is assured <ul>
4861 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4862 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4863 # @ingroup l3_hypos_blsurf
4864 def SetTopology(self, way):
4865 # Parameter of BLSURF algo
4866 self.Parameters().SetTopology(way)
4868 ## To respect geometrical edges or not.
4869 # @ingroup l3_hypos_blsurf
4870 def SetDecimesh(self, toIgnoreEdges=False):
4871 # Parameter of BLSURF algo
4872 self.Parameters().SetDecimesh(toIgnoreEdges)
4874 ## Sets verbosity level in the range 0 to 100.
4875 # @ingroup l3_hypos_blsurf
4876 def SetVerbosity(self, level):
4877 # Parameter of BLSURF algo
4878 self.Parameters().SetVerbosity(level)
4880 ## Sets advanced option value.
4881 # @ingroup l3_hypos_blsurf
4882 def SetOptionValue(self, optionName, level):
4883 # Parameter of BLSURF algo
4884 self.Parameters().SetOptionValue(optionName,level)
4886 ## Sets QuadAllowed flag.
4887 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4888 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4889 def SetQuadAllowed(self, toAllow=True):
4890 if self.algoType == NETGEN_2D:
4891 if toAllow: # add QuadranglePreference
4892 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4893 else: # remove QuadranglePreference
4894 for hyp in self.mesh.GetHypothesisList( self.geom ):
4895 if hyp.GetName() == "QuadranglePreference":
4896 self.mesh.RemoveHypothesis( self.geom, hyp )
4901 if self.Parameters():
4902 self.params.SetQuadAllowed(toAllow)
4905 ## Defines hypothesis having several parameters
4907 # @ingroup l3_hypos_netgen
4908 def Parameters(self, which=SOLE):
4911 if self.algoType == NETGEN:
4913 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4914 "libNETGENEngine.so", UseExisting=0)
4916 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4917 "libNETGENEngine.so", UseExisting=0)
4919 elif self.algoType == MEFISTO:
4920 print "Mefisto algo support no multi-parameter hypothesis"
4922 elif self.algoType == NETGEN_2D:
4923 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4924 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4926 elif self.algoType == BLSURF:
4927 self.params = self.Hypothesis("BLSURF_Parameters", [],
4928 "libBLSURFEngine.so", UseExisting=0)
4931 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4936 # Only for algoType == NETGEN
4937 # @ingroup l3_hypos_netgen
4938 def SetMaxSize(self, theSize):
4939 if self.Parameters():
4940 self.params.SetMaxSize(theSize)
4942 ## Sets SecondOrder flag
4944 # Only for algoType == NETGEN
4945 # @ingroup l3_hypos_netgen
4946 def SetSecondOrder(self, theVal):
4947 if self.Parameters():
4948 self.params.SetSecondOrder(theVal)
4950 ## Sets Optimize flag
4952 # Only for algoType == NETGEN
4953 # @ingroup l3_hypos_netgen
4954 def SetOptimize(self, theVal):
4955 if self.Parameters():
4956 self.params.SetOptimize(theVal)
4959 # @param theFineness is:
4960 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4962 # Only for algoType == NETGEN
4963 # @ingroup l3_hypos_netgen
4964 def SetFineness(self, theFineness):
4965 if self.Parameters():
4966 self.params.SetFineness(theFineness)
4970 # Only for algoType == NETGEN
4971 # @ingroup l3_hypos_netgen
4972 def SetGrowthRate(self, theRate):
4973 if self.Parameters():
4974 self.params.SetGrowthRate(theRate)
4976 ## Sets NbSegPerEdge
4978 # Only for algoType == NETGEN
4979 # @ingroup l3_hypos_netgen
4980 def SetNbSegPerEdge(self, theVal):
4981 if self.Parameters():
4982 self.params.SetNbSegPerEdge(theVal)
4984 ## Sets NbSegPerRadius
4986 # Only for algoType == NETGEN
4987 # @ingroup l3_hypos_netgen
4988 def SetNbSegPerRadius(self, theVal):
4989 if self.Parameters():
4990 self.params.SetNbSegPerRadius(theVal)
4992 ## Sets number of segments overriding value set by SetLocalLength()
4994 # Only for algoType == NETGEN
4995 # @ingroup l3_hypos_netgen
4996 def SetNumberOfSegments(self, theVal):
4997 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4999 ## Sets number of segments overriding value set by SetNumberOfSegments()
5001 # Only for algoType == NETGEN
5002 # @ingroup l3_hypos_netgen
5003 def SetLocalLength(self, theVal):
5004 self.Parameters(SIMPLE).SetLocalLength(theVal)
5009 # Public class: Mesh_Quadrangle
5010 # -----------------------------
5012 ## Defines a quadrangle 2D algorithm
5014 # @ingroup l3_algos_basic
5015 class Mesh_Quadrangle(Mesh_Algorithm):
5019 ## Private constructor.
5020 def __init__(self, mesh, geom=0):
5021 Mesh_Algorithm.__init__(self)
5022 self.Create(mesh, geom, "Quadrangle_2D")
5025 ## Defines "QuadrangleParameters" hypothesis
5026 # @param quadType defines the algorithm of transition between differently descretized
5027 # sides of a geometrical face:
5028 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5029 # area along the finer meshed sides.
5030 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5031 # finer meshed sides.
5032 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5033 # the finer meshed sides, iff the total quantity of segments on
5034 # all four sides of the face is even (divisible by 2).
5035 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5036 # area is located along the coarser meshed sides.
5037 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5038 # is made gradually, layer by layer. This type has a limitation on
5039 # the number of segments: one pair of opposite sides must have the
5040 # same number of segments, the other pair must have an even difference
5041 # between the numbers of segments on the sides.
5042 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5043 # will be created while other elements will be quadrangles.
5044 # Vertex can be either a GEOM_Object or a vertex ID within the
5046 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5047 # the same parameters, else (default) - creates a new one
5048 # @ingroup l3_hypos_quad
5049 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5050 vertexID = triangleVertex
5051 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5052 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5054 compFun = lambda hyp,args: \
5055 hyp.GetQuadType() == args[0] and \
5056 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5057 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5058 UseExisting = UseExisting, CompareMethod=compFun)
5060 if self.params.GetQuadType() != quadType:
5061 self.params.SetQuadType(quadType)
5063 self.params.SetTriaVertex( vertexID )
5066 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5067 # quadrangles are built in the transition area along the finer meshed sides,
5068 # iff the total quantity of segments on all four sides of the face is even.
5069 # @param reversed if True, transition area is located along the coarser meshed sides.
5070 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5071 # the same parameters, else (default) - creates a new one
5072 # @ingroup l3_hypos_quad
5073 def QuadranglePreference(self, reversed=False, UseExisting=0):
5075 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5076 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5078 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5079 # triangles are built in the transition area along the finer meshed sides.
5080 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5081 # the same parameters, else (default) - creates a new one
5082 # @ingroup l3_hypos_quad
5083 def TrianglePreference(self, UseExisting=0):
5084 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5086 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5087 # quadrangles are built and the transition between the sides is made gradually,
5088 # layer by layer. This type has a limitation on the number of segments: one pair
5089 # of opposite sides must have the same number of segments, the other pair must
5090 # have an even difference between the numbers of segments on the sides.
5091 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5092 # the same parameters, else (default) - creates a new one
5093 # @ingroup l3_hypos_quad
5094 def Reduced(self, UseExisting=0):
5095 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5097 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5098 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5099 # will be created while other elements will be quadrangles.
5100 # Vertex can be either a GEOM_Object or a vertex ID within the
5102 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5103 # the same parameters, else (default) - creates a new one
5104 # @ingroup l3_hypos_quad
5105 def TriangleVertex(self, vertex, UseExisting=0):
5106 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5109 # Public class: Mesh_Tetrahedron
5110 # ------------------------------
5112 ## Defines a tetrahedron 3D algorithm
5114 # @ingroup l3_algos_basic
5115 class Mesh_Tetrahedron(Mesh_Algorithm):
5120 ## Private constructor.
5121 def __init__(self, mesh, algoType, geom=0):
5122 Mesh_Algorithm.__init__(self)
5124 if algoType == NETGEN:
5126 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5129 elif algoType == FULL_NETGEN:
5131 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5134 elif algoType == GHS3D:
5136 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5139 elif algoType == GHS3DPRL:
5140 CheckPlugin(GHS3DPRL)
5141 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5144 self.algoType = algoType
5146 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5147 # @param vol for the maximum volume of each tetrahedron
5148 # @param UseExisting if ==true - searches for the existing hypothesis created with
5149 # the same parameters, else (default) - creates a new one
5150 # @ingroup l3_hypos_maxvol
5151 def MaxElementVolume(self, vol, UseExisting=0):
5152 if self.algoType == NETGEN:
5153 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5154 CompareMethod=self.CompareMaxElementVolume)
5155 hyp.SetMaxElementVolume(vol)
5157 elif self.algoType == FULL_NETGEN:
5158 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5161 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5162 def CompareMaxElementVolume(self, hyp, args):
5163 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5165 ## Defines hypothesis having several parameters
5167 # @ingroup l3_hypos_netgen
5168 def Parameters(self, which=SOLE):
5172 if self.algoType == FULL_NETGEN:
5174 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5175 "libNETGENEngine.so", UseExisting=0)
5177 self.params = self.Hypothesis("NETGEN_Parameters", [],
5178 "libNETGENEngine.so", UseExisting=0)
5181 if self.algoType == GHS3D:
5182 self.params = self.Hypothesis("GHS3D_Parameters", [],
5183 "libGHS3DEngine.so", UseExisting=0)
5186 if self.algoType == GHS3DPRL:
5187 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5188 "libGHS3DPRLEngine.so", UseExisting=0)
5191 print "Algo supports no multi-parameter hypothesis"
5195 # Parameter of FULL_NETGEN
5196 # @ingroup l3_hypos_netgen
5197 def SetMaxSize(self, theSize):
5198 self.Parameters().SetMaxSize(theSize)
5200 ## Sets SecondOrder flag
5201 # Parameter of FULL_NETGEN
5202 # @ingroup l3_hypos_netgen
5203 def SetSecondOrder(self, theVal):
5204 self.Parameters().SetSecondOrder(theVal)
5206 ## Sets Optimize flag
5207 # Parameter of FULL_NETGEN
5208 # @ingroup l3_hypos_netgen
5209 def SetOptimize(self, theVal):
5210 self.Parameters().SetOptimize(theVal)
5213 # @param theFineness is:
5214 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5215 # Parameter of FULL_NETGEN
5216 # @ingroup l3_hypos_netgen
5217 def SetFineness(self, theFineness):
5218 self.Parameters().SetFineness(theFineness)
5221 # Parameter of FULL_NETGEN
5222 # @ingroup l3_hypos_netgen
5223 def SetGrowthRate(self, theRate):
5224 self.Parameters().SetGrowthRate(theRate)
5226 ## Sets NbSegPerEdge
5227 # Parameter of FULL_NETGEN
5228 # @ingroup l3_hypos_netgen
5229 def SetNbSegPerEdge(self, theVal):
5230 self.Parameters().SetNbSegPerEdge(theVal)
5232 ## Sets NbSegPerRadius
5233 # Parameter of FULL_NETGEN
5234 # @ingroup l3_hypos_netgen
5235 def SetNbSegPerRadius(self, theVal):
5236 self.Parameters().SetNbSegPerRadius(theVal)
5238 ## Sets number of segments overriding value set by SetLocalLength()
5239 # Only for algoType == NETGEN_FULL
5240 # @ingroup l3_hypos_netgen
5241 def SetNumberOfSegments(self, theVal):
5242 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5244 ## Sets number of segments overriding value set by SetNumberOfSegments()
5245 # Only for algoType == NETGEN_FULL
5246 # @ingroup l3_hypos_netgen
5247 def SetLocalLength(self, theVal):
5248 self.Parameters(SIMPLE).SetLocalLength(theVal)
5250 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5251 # Overrides value set by LengthFromEdges()
5252 # Only for algoType == NETGEN_FULL
5253 # @ingroup l3_hypos_netgen
5254 def MaxElementArea(self, area):
5255 self.Parameters(SIMPLE).SetMaxElementArea(area)
5257 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5258 # Overrides value set by MaxElementArea()
5259 # Only for algoType == NETGEN_FULL
5260 # @ingroup l3_hypos_netgen
5261 def LengthFromEdges(self):
5262 self.Parameters(SIMPLE).LengthFromEdges()
5264 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5265 # Overrides value set by MaxElementVolume()
5266 # Only for algoType == NETGEN_FULL
5267 # @ingroup l3_hypos_netgen
5268 def LengthFromFaces(self):
5269 self.Parameters(SIMPLE).LengthFromFaces()
5271 ## To mesh "holes" in a solid or not. Default is to mesh.
5272 # @ingroup l3_hypos_ghs3dh
5273 def SetToMeshHoles(self, toMesh):
5274 # Parameter of GHS3D
5275 self.Parameters().SetToMeshHoles(toMesh)
5277 ## Set Optimization level:
5278 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5279 # Strong_Optimization.
5280 # Default is Standard_Optimization
5281 # @ingroup l3_hypos_ghs3dh
5282 def SetOptimizationLevel(self, level):
5283 # Parameter of GHS3D
5284 self.Parameters().SetOptimizationLevel(level)
5286 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5287 # @ingroup l3_hypos_ghs3dh
5288 def SetMaximumMemory(self, MB):
5289 # Advanced parameter of GHS3D
5290 self.Parameters().SetMaximumMemory(MB)
5292 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5293 # automatic memory adjustment mode.
5294 # @ingroup l3_hypos_ghs3dh
5295 def SetInitialMemory(self, MB):
5296 # Advanced parameter of GHS3D
5297 self.Parameters().SetInitialMemory(MB)
5299 ## Path to working directory.
5300 # @ingroup l3_hypos_ghs3dh
5301 def SetWorkingDirectory(self, path):
5302 # Advanced parameter of GHS3D
5303 self.Parameters().SetWorkingDirectory(path)
5305 ## To keep working files or remove them. Log file remains in case of errors anyway.
5306 # @ingroup l3_hypos_ghs3dh
5307 def SetKeepFiles(self, toKeep):
5308 # Advanced parameter of GHS3D and GHS3DPRL
5309 self.Parameters().SetKeepFiles(toKeep)
5311 ## To set verbose level [0-10]. <ul>
5312 #<li> 0 - no standard output,
5313 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5314 # indicates when the final mesh is being saved. In addition the software
5315 # gives indication regarding the CPU time.
5316 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5317 # histogram of the skin mesh, quality statistics histogram together with
5318 # the characteristics of the final mesh.</ul>
5319 # @ingroup l3_hypos_ghs3dh
5320 def SetVerboseLevel(self, level):
5321 # Advanced parameter of GHS3D
5322 self.Parameters().SetVerboseLevel(level)
5324 ## To create new nodes.
5325 # @ingroup l3_hypos_ghs3dh
5326 def SetToCreateNewNodes(self, toCreate):
5327 # Advanced parameter of GHS3D
5328 self.Parameters().SetToCreateNewNodes(toCreate)
5330 ## To use boundary recovery version which tries to create mesh on a very poor
5331 # quality surface mesh.
5332 # @ingroup l3_hypos_ghs3dh
5333 def SetToUseBoundaryRecoveryVersion(self, toUse):
5334 # Advanced parameter of GHS3D
5335 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5337 ## Sets command line option as text.
5338 # @ingroup l3_hypos_ghs3dh
5339 def SetTextOption(self, option):
5340 # Advanced parameter of GHS3D
5341 self.Parameters().SetTextOption(option)
5343 ## Sets MED files name and path.
5344 def SetMEDName(self, value):
5345 self.Parameters().SetMEDName(value)
5347 ## Sets the number of partition of the initial mesh
5348 def SetNbPart(self, value):
5349 self.Parameters().SetNbPart(value)
5351 ## When big mesh, start tepal in background
5352 def SetBackground(self, value):
5353 self.Parameters().SetBackground(value)
5355 # Public class: Mesh_Hexahedron
5356 # ------------------------------
5358 ## Defines a hexahedron 3D algorithm
5360 # @ingroup l3_algos_basic
5361 class Mesh_Hexahedron(Mesh_Algorithm):
5366 ## Private constructor.
5367 def __init__(self, mesh, algoType=Hexa, geom=0):
5368 Mesh_Algorithm.__init__(self)
5370 self.algoType = algoType
5372 if algoType == Hexa:
5373 self.Create(mesh, geom, "Hexa_3D")
5376 elif algoType == Hexotic:
5377 CheckPlugin(Hexotic)
5378 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5381 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5382 # @ingroup l3_hypos_hexotic
5383 def MinMaxQuad(self, min=3, max=8, quad=True):
5384 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5386 self.params.SetHexesMinLevel(min)
5387 self.params.SetHexesMaxLevel(max)
5388 self.params.SetHexoticQuadrangles(quad)
5391 # Deprecated, only for compatibility!
5392 # Public class: Mesh_Netgen
5393 # ------------------------------
5395 ## Defines a NETGEN-based 2D or 3D algorithm
5396 # that needs no discrete boundary (i.e. independent)
5398 # This class is deprecated, only for compatibility!
5401 # @ingroup l3_algos_basic
5402 class Mesh_Netgen(Mesh_Algorithm):
5406 ## Private constructor.
5407 def __init__(self, mesh, is3D, geom=0):
5408 Mesh_Algorithm.__init__(self)
5414 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5418 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5421 ## Defines the hypothesis containing parameters of the algorithm
5422 def Parameters(self):
5424 hyp = self.Hypothesis("NETGEN_Parameters", [],
5425 "libNETGENEngine.so", UseExisting=0)
5427 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5428 "libNETGENEngine.so", UseExisting=0)
5431 # Public class: Mesh_Projection1D
5432 # ------------------------------
5434 ## Defines a projection 1D algorithm
5435 # @ingroup l3_algos_proj
5437 class Mesh_Projection1D(Mesh_Algorithm):
5439 ## Private constructor.
5440 def __init__(self, mesh, geom=0):
5441 Mesh_Algorithm.__init__(self)
5442 self.Create(mesh, geom, "Projection_1D")
5444 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5445 # a mesh pattern is taken, and, optionally, the association of vertices
5446 # between the source edge and a target edge (to which a hypothesis is assigned)
5447 # @param edge from which nodes distribution is taken
5448 # @param mesh from which nodes distribution is taken (optional)
5449 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5450 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5451 # to associate with \a srcV (optional)
5452 # @param UseExisting if ==true - searches for the existing hypothesis created with
5453 # the same parameters, else (default) - creates a new one
5454 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5455 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5457 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5458 hyp.SetSourceEdge( edge )
5459 if not mesh is None and isinstance(mesh, Mesh):
5460 mesh = mesh.GetMesh()
5461 hyp.SetSourceMesh( mesh )
5462 hyp.SetVertexAssociation( srcV, tgtV )
5465 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5466 #def CompareSourceEdge(self, hyp, args):
5467 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5471 # Public class: Mesh_Projection2D
5472 # ------------------------------
5474 ## Defines a projection 2D algorithm
5475 # @ingroup l3_algos_proj
5477 class Mesh_Projection2D(Mesh_Algorithm):
5479 ## Private constructor.
5480 def __init__(self, mesh, geom=0):
5481 Mesh_Algorithm.__init__(self)
5482 self.Create(mesh, geom, "Projection_2D")
5484 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5485 # a mesh pattern is taken, and, optionally, the association of vertices
5486 # between the source face and the target face (to which a hypothesis is assigned)
5487 # @param face from which the mesh pattern is taken
5488 # @param mesh from which the mesh pattern is taken (optional)
5489 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5490 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5491 # to associate with \a srcV1 (optional)
5492 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5493 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5494 # to associate with \a srcV2 (optional)
5495 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5496 # the same parameters, else (default) - forces the creation a new one
5498 # Note: all association vertices must belong to one edge of a face
5499 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5500 srcV2=None, tgtV2=None, UseExisting=0):
5501 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5503 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5504 hyp.SetSourceFace( face )
5505 if not mesh is None and isinstance(mesh, Mesh):
5506 mesh = mesh.GetMesh()
5507 hyp.SetSourceMesh( mesh )
5508 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5511 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5512 #def CompareSourceFace(self, hyp, args):
5513 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5516 # Public class: Mesh_Projection3D
5517 # ------------------------------
5519 ## Defines a projection 3D algorithm
5520 # @ingroup l3_algos_proj
5522 class Mesh_Projection3D(Mesh_Algorithm):
5524 ## Private constructor.
5525 def __init__(self, mesh, geom=0):
5526 Mesh_Algorithm.__init__(self)
5527 self.Create(mesh, geom, "Projection_3D")
5529 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5530 # the mesh pattern is taken, and, optionally, the association of vertices
5531 # between the source and the target solid (to which a hipothesis is assigned)
5532 # @param solid from where the mesh pattern is taken
5533 # @param mesh from where the mesh pattern is taken (optional)
5534 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5535 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5536 # to associate with \a srcV1 (optional)
5537 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5538 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5539 # to associate with \a srcV2 (optional)
5540 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5541 # the same parameters, else (default) - creates a new one
5543 # Note: association vertices must belong to one edge of a solid
5544 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5545 srcV2=0, tgtV2=0, UseExisting=0):
5546 hyp = self.Hypothesis("ProjectionSource3D",
5547 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5549 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5550 hyp.SetSource3DShape( solid )
5551 if not mesh is None and isinstance(mesh, Mesh):
5552 mesh = mesh.GetMesh()
5553 hyp.SetSourceMesh( mesh )
5554 if srcV1 and srcV2 and tgtV1 and tgtV2:
5555 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5556 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5559 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5560 #def CompareSourceShape3D(self, hyp, args):
5561 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5565 # Public class: Mesh_Prism
5566 # ------------------------
5568 ## Defines a 3D extrusion algorithm
5569 # @ingroup l3_algos_3dextr
5571 class Mesh_Prism3D(Mesh_Algorithm):
5573 ## Private constructor.
5574 def __init__(self, mesh, geom=0):
5575 Mesh_Algorithm.__init__(self)
5576 self.Create(mesh, geom, "Prism_3D")
5578 # Public class: Mesh_RadialPrism
5579 # -------------------------------
5581 ## Defines a Radial Prism 3D algorithm
5582 # @ingroup l3_algos_radialp
5584 class Mesh_RadialPrism3D(Mesh_Algorithm):
5586 ## Private constructor.
5587 def __init__(self, mesh, geom=0):
5588 Mesh_Algorithm.__init__(self)
5589 self.Create(mesh, geom, "RadialPrism_3D")
5591 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5592 self.nbLayers = None
5594 ## Return 3D hypothesis holding the 1D one
5595 def Get3DHypothesis(self):
5596 return self.distribHyp
5598 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5599 # hypothesis. Returns the created hypothesis
5600 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5601 #print "OwnHypothesis",hypType
5602 if not self.nbLayers is None:
5603 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5604 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5605 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5606 self.mesh.smeshpyD.SetCurrentStudy( None )
5607 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5608 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5609 self.distribHyp.SetLayerDistribution( hyp )
5612 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5613 # prisms to build between the inner and outer shells
5614 # @param n number of layers
5615 # @param UseExisting if ==true - searches for the existing hypothesis created with
5616 # the same parameters, else (default) - creates a new one
5617 def NumberOfLayers(self, n, UseExisting=0):
5618 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5619 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5620 CompareMethod=self.CompareNumberOfLayers)
5621 self.nbLayers.SetNumberOfLayers( n )
5622 return self.nbLayers
5624 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5625 def CompareNumberOfLayers(self, hyp, args):
5626 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5628 ## Defines "LocalLength" hypothesis, specifying the segment length
5629 # to build between the inner and the outer shells
5630 # @param l the length of segments
5631 # @param p the precision of rounding
5632 def LocalLength(self, l, p=1e-07):
5633 hyp = self.OwnHypothesis("LocalLength", [l,p])
5638 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5639 # prisms to build between the inner and the outer shells.
5640 # @param n the number of layers
5641 # @param s the scale factor (optional)
5642 def NumberOfSegments(self, n, s=[]):
5644 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5646 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5647 hyp.SetDistrType( 1 )
5648 hyp.SetScaleFactor(s)
5649 hyp.SetNumberOfSegments(n)
5652 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5653 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5654 # @param start the length of the first segment
5655 # @param end the length of the last segment
5656 def Arithmetic1D(self, start, end ):
5657 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5658 hyp.SetLength(start, 1)
5659 hyp.SetLength(end , 0)
5662 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5663 # to build between the inner and the outer shells as geometric length increasing
5664 # @param start for the length of the first segment
5665 # @param end for the length of the last segment
5666 def StartEndLength(self, start, end):
5667 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5668 hyp.SetLength(start, 1)
5669 hyp.SetLength(end , 0)
5672 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5673 # to build between the inner and outer shells
5674 # @param fineness defines the quality of the mesh within the range [0-1]
5675 def AutomaticLength(self, fineness=0):
5676 hyp = self.OwnHypothesis("AutomaticLength")
5677 hyp.SetFineness( fineness )
5680 # Public class: Mesh_RadialQuadrangle1D2D
5681 # -------------------------------
5683 ## Defines a Radial Quadrangle 1D2D algorithm
5684 # @ingroup l2_algos_radialq
5686 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5688 ## Private constructor.
5689 def __init__(self, mesh, geom=0):
5690 Mesh_Algorithm.__init__(self)
5691 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5693 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5694 self.nbLayers = None
5696 ## Return 2D hypothesis holding the 1D one
5697 def Get2DHypothesis(self):
5698 return self.distribHyp
5700 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5701 # hypothesis. Returns the created hypothesis
5702 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5703 #print "OwnHypothesis",hypType
5705 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5706 if self.distribHyp is None:
5707 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5709 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5710 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5711 self.mesh.smeshpyD.SetCurrentStudy( None )
5712 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5713 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5714 self.distribHyp.SetLayerDistribution( hyp )
5717 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5718 # @param n number of layers
5719 # @param UseExisting if ==true - searches for the existing hypothesis created with
5720 # the same parameters, else (default) - creates a new one
5721 def NumberOfLayers(self, n, UseExisting=0):
5723 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5724 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5725 CompareMethod=self.CompareNumberOfLayers)
5726 self.nbLayers.SetNumberOfLayers( n )
5727 return self.nbLayers
5729 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5730 def CompareNumberOfLayers(self, hyp, args):
5731 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5733 ## Defines "LocalLength" hypothesis, specifying the segment length
5734 # @param l the length of segments
5735 # @param p the precision of rounding
5736 def LocalLength(self, l, p=1e-07):
5737 hyp = self.OwnHypothesis("LocalLength", [l,p])
5742 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5743 # @param n the number of layers
5744 # @param s the scale factor (optional)
5745 def NumberOfSegments(self, n, s=[]):
5747 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5749 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5750 hyp.SetDistrType( 1 )
5751 hyp.SetScaleFactor(s)
5752 hyp.SetNumberOfSegments(n)
5755 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5756 # with a length that changes in arithmetic progression
5757 # @param start the length of the first segment
5758 # @param end the length of the last segment
5759 def Arithmetic1D(self, start, end ):
5760 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5761 hyp.SetLength(start, 1)
5762 hyp.SetLength(end , 0)
5765 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5766 # as geometric length increasing
5767 # @param start for the length of the first segment
5768 # @param end for the length of the last segment
5769 def StartEndLength(self, start, end):
5770 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5771 hyp.SetLength(start, 1)
5772 hyp.SetLength(end , 0)
5775 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5776 # @param fineness defines the quality of the mesh within the range [0-1]
5777 def AutomaticLength(self, fineness=0):
5778 hyp = self.OwnHypothesis("AutomaticLength")
5779 hyp.SetFineness( fineness )
5783 # Public class: Mesh_UseExistingElements
5784 # --------------------------------------
5785 ## Defines a Radial Quadrangle 1D2D algorithm
5786 # @ingroup l3_algos_basic
5788 class Mesh_UseExistingElements(Mesh_Algorithm):
5790 def __init__(self, dim, mesh, geom=0):
5792 self.Create(mesh, geom, "Import_1D")
5794 self.Create(mesh, geom, "Import_1D2D")
5797 ## Defines "Source edges" hypothesis, specifying groups of edges to import
5798 # @param groups list of groups of edges
5799 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5800 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5801 # @param UseExisting if ==true - searches for the existing hypothesis created with
5802 # the same parameters, else (default) - creates a new one
5803 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5804 if self.algo.GetName() == "Import_2D":
5805 raise ValueError, "algoritm dimension mismatch"
5806 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
5807 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5808 hyp.SetSourceEdges(groups)
5809 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5812 ## Defines "Source faces" hypothesis, specifying groups of faces to import
5813 # @param groups list of groups of faces
5814 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5815 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5816 # @param UseExisting if ==true - searches for the existing hypothesis created with
5817 # the same parameters, else (default) - creates a new one
5818 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5819 if self.algo.GetName() == "Import_1D":
5820 raise ValueError, "algoritm dimension mismatch"
5821 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
5822 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5823 hyp.SetSourceFaces(groups)
5824 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5827 def _compareHyp(self,hyp,args):
5828 if hasattr( hyp, "GetSourceEdges"):
5829 entries = hyp.GetSourceEdges()
5831 entries = hyp.GetSourceFaces()
5833 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
5834 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
5836 study = self.mesh.smeshpyD.GetCurrentStudy()
5839 ior = salome.orb.object_to_string(g)
5840 sobj = study.FindObjectIOR(ior)
5841 if sobj: entries2.append( sobj.GetID() )
5846 return entries == entries2
5850 # Private class: Mesh_UseExisting
5851 # -------------------------------
5852 class Mesh_UseExisting(Mesh_Algorithm):
5854 def __init__(self, dim, mesh, geom=0):
5856 self.Create(mesh, geom, "UseExisting_1D")
5858 self.Create(mesh, geom, "UseExisting_2D")
5861 import salome_notebook
5862 notebook = salome_notebook.notebook
5864 ##Return values of the notebook variables
5865 def ParseParameters(last, nbParams,nbParam, value):
5869 listSize = len(last)
5870 for n in range(0,nbParams):
5872 if counter < listSize:
5873 strResult = strResult + last[counter]
5875 strResult = strResult + ""
5877 if isinstance(value, str):
5878 if notebook.isVariable(value):
5879 result = notebook.get(value)
5880 strResult=strResult+value
5882 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5884 strResult=strResult+str(value)
5886 if nbParams - 1 != counter:
5887 strResult=strResult+var_separator #":"
5889 return result, strResult
5891 #Wrapper class for StdMeshers_LocalLength hypothesis
5892 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5894 ## Set Length parameter value
5895 # @param length numerical value or name of variable from notebook
5896 def SetLength(self, length):
5897 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5898 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5899 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5901 ## Set Precision parameter value
5902 # @param precision numerical value or name of variable from notebook
5903 def SetPrecision(self, precision):
5904 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5905 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5906 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5908 #Registering the new proxy for LocalLength
5909 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5912 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5913 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5915 def SetLayerDistribution(self, hypo):
5916 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5917 hypo.ClearParameters();
5918 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5920 #Registering the new proxy for LayerDistribution
5921 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5923 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5924 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5926 ## Set Length parameter value
5927 # @param length numerical value or name of variable from notebook
5928 def SetLength(self, length):
5929 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5930 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5931 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5933 #Registering the new proxy for SegmentLengthAroundVertex
5934 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5937 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5938 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5940 ## Set Length parameter value
5941 # @param length numerical value or name of variable from notebook
5942 # @param isStart true is length is Start Length, otherwise false
5943 def SetLength(self, length, isStart):
5947 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5948 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5949 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5951 #Registering the new proxy for Arithmetic1D
5952 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5954 #Wrapper class for StdMeshers_Deflection1D hypothesis
5955 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5957 ## Set Deflection parameter value
5958 # @param deflection numerical value or name of variable from notebook
5959 def SetDeflection(self, deflection):
5960 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5961 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5962 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5964 #Registering the new proxy for Deflection1D
5965 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5967 #Wrapper class for StdMeshers_StartEndLength hypothesis
5968 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5970 ## Set Length parameter value
5971 # @param length numerical value or name of variable from notebook
5972 # @param isStart true is length is Start Length, otherwise false
5973 def SetLength(self, length, isStart):
5977 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5978 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5979 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5981 #Registering the new proxy for StartEndLength
5982 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5984 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5985 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5987 ## Set Max Element Area parameter value
5988 # @param area numerical value or name of variable from notebook
5989 def SetMaxElementArea(self, area):
5990 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5991 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5992 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5994 #Registering the new proxy for MaxElementArea
5995 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5998 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5999 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6001 ## Set Max Element Volume parameter value
6002 # @param volume numerical value or name of variable from notebook
6003 def SetMaxElementVolume(self, volume):
6004 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6005 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6006 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6008 #Registering the new proxy for MaxElementVolume
6009 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6012 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6013 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6015 ## Set Number Of Layers parameter value
6016 # @param nbLayers numerical value or name of variable from notebook
6017 def SetNumberOfLayers(self, nbLayers):
6018 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6019 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6020 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6022 #Registering the new proxy for NumberOfLayers
6023 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6025 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6026 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6028 ## Set Number Of Segments parameter value
6029 # @param nbSeg numerical value or name of variable from notebook
6030 def SetNumberOfSegments(self, nbSeg):
6031 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6032 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6033 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6034 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6036 ## Set Scale Factor parameter value
6037 # @param factor numerical value or name of variable from notebook
6038 def SetScaleFactor(self, factor):
6039 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6040 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6041 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6043 #Registering the new proxy for NumberOfSegments
6044 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6046 if not noNETGENPlugin:
6047 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6048 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6050 ## Set Max Size parameter value
6051 # @param maxsize numerical value or name of variable from notebook
6052 def SetMaxSize(self, maxsize):
6053 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6054 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6055 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6056 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6058 ## Set Growth Rate parameter value
6059 # @param value numerical value or name of variable from notebook
6060 def SetGrowthRate(self, value):
6061 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6062 value, parameters = ParseParameters(lastParameters,4,2,value)
6063 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6064 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6066 ## Set Number of Segments per Edge parameter value
6067 # @param value numerical value or name of variable from notebook
6068 def SetNbSegPerEdge(self, value):
6069 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6070 value, parameters = ParseParameters(lastParameters,4,3,value)
6071 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6072 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6074 ## Set Number of Segments per Radius parameter value
6075 # @param value numerical value or name of variable from notebook
6076 def SetNbSegPerRadius(self, value):
6077 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6078 value, parameters = ParseParameters(lastParameters,4,4,value)
6079 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6080 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6082 #Registering the new proxy for NETGENPlugin_Hypothesis
6083 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6086 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6087 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6090 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6091 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6093 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6094 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6096 ## Set Number of Segments parameter value
6097 # @param nbSeg numerical value or name of variable from notebook
6098 def SetNumberOfSegments(self, nbSeg):
6099 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6100 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6101 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6102 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6104 ## Set Local Length parameter value
6105 # @param length numerical value or name of variable from notebook
6106 def SetLocalLength(self, length):
6107 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6108 length, parameters = ParseParameters(lastParameters,2,1,length)
6109 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6110 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6112 ## Set Max Element Area parameter value
6113 # @param area numerical value or name of variable from notebook
6114 def SetMaxElementArea(self, area):
6115 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6116 area, parameters = ParseParameters(lastParameters,2,2,area)
6117 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6118 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6120 def LengthFromEdges(self):
6121 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6123 value, parameters = ParseParameters(lastParameters,2,2,value)
6124 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6125 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6127 #Registering the new proxy for NETGEN_SimpleParameters_2D
6128 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6131 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6132 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6133 ## Set Max Element Volume parameter value
6134 # @param volume numerical value or name of variable from notebook
6135 def SetMaxElementVolume(self, volume):
6136 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6137 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6138 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6139 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6141 def LengthFromFaces(self):
6142 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6144 value, parameters = ParseParameters(lastParameters,3,3,value)
6145 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6146 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6148 #Registering the new proxy for NETGEN_SimpleParameters_3D
6149 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6151 pass # if not noNETGENPlugin:
6153 class Pattern(SMESH._objref_SMESH_Pattern):
6155 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6157 if isinstance(theNodeIndexOnKeyPoint1,str):
6159 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6161 theNodeIndexOnKeyPoint1 -= 1
6162 theMesh.SetParameters(Parameters)
6163 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6165 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6168 if isinstance(theNode000Index,str):
6170 if isinstance(theNode001Index,str):
6172 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6174 theNode000Index -= 1
6176 theNode001Index -= 1
6177 theMesh.SetParameters(Parameters)
6178 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6180 #Registering the new proxy for Pattern
6181 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)