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_additi Additional Hypotheses
56 ## @defgroup l2_submeshes Constructing submeshes
57 ## @defgroup l2_compounds Building Compounds
58 ## @defgroup l2_editing Editing Meshes
61 ## @defgroup l1_meshinfo Mesh Information
62 ## @defgroup l1_controls Quality controls and Filtering
63 ## @defgroup l1_grouping Grouping elements
65 ## @defgroup l2_grps_create Creating groups
66 ## @defgroup l2_grps_edit Editing groups
67 ## @defgroup l2_grps_operon Using operations on groups
68 ## @defgroup l2_grps_delete Deleting Groups
71 ## @defgroup l1_modifying Modifying meshes
73 ## @defgroup l2_modif_add Adding nodes and elements
74 ## @defgroup l2_modif_del Removing nodes and elements
75 ## @defgroup l2_modif_edit Modifying nodes and elements
76 ## @defgroup l2_modif_renumber Renumbering nodes and elements
77 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
78 ## @defgroup l2_modif_movenode Moving nodes
79 ## @defgroup l2_modif_throughp Mesh through point
80 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
81 ## @defgroup l2_modif_unitetri Uniting triangles
82 ## @defgroup l2_modif_changori Changing orientation of elements
83 ## @defgroup l2_modif_cutquadr Cutting quadrangles
84 ## @defgroup l2_modif_smooth Smoothing
85 ## @defgroup l2_modif_extrurev Extrusion and Revolution
86 ## @defgroup l2_modif_patterns Pattern mapping
87 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
94 import SMESH # This is necessary for back compatibility
102 # import NETGENPlugin module if possible
110 # import GHS3DPlugin module if possible
118 # import GHS3DPRLPlugin module if possible
121 import GHS3DPRLPlugin
126 # import HexoticPlugin module if possible
134 # import BLSURFPlugin module if possible
142 ## @addtogroup l1_auxiliary
145 # Types of algorithms
158 NETGEN_1D2D3D = FULL_NETGEN
159 NETGEN_FULL = FULL_NETGEN
167 # MirrorType enumeration
168 POINT = SMESH_MeshEditor.POINT
169 AXIS = SMESH_MeshEditor.AXIS
170 PLANE = SMESH_MeshEditor.PLANE
172 # Smooth_Method enumeration
173 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
174 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
176 # Fineness enumeration (for NETGEN)
184 # Optimization level of GHS3D
186 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
187 # V4.1 (partialy redefines V3.1). Issue 0020574
188 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
190 # Topology treatment way of BLSURF
191 FromCAD, PreProcess, PreProcessPlus = 0,1,2
193 # Element size flag of BLSURF
194 DefaultSize, DefaultGeom, Custom = 0,0,1
196 PrecisionConfusion = 1e-07
198 # TopAbs_State enumeration
199 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
202 ## Converts an angle from degrees to radians
203 def DegreesToRadians(AngleInDegrees):
205 return AngleInDegrees * pi / 180.0
207 # Salome notebook variable separator
210 # Parametrized substitute for PointStruct
211 class PointStructStr:
220 def __init__(self, xStr, yStr, zStr):
224 if isinstance(xStr, str) and notebook.isVariable(xStr):
225 self.x = notebook.get(xStr)
228 if isinstance(yStr, str) and notebook.isVariable(yStr):
229 self.y = notebook.get(yStr)
232 if isinstance(zStr, str) and notebook.isVariable(zStr):
233 self.z = notebook.get(zStr)
237 # Parametrized substitute for PointStruct (with 6 parameters)
238 class PointStructStr6:
253 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
260 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
261 self.x1 = notebook.get(x1Str)
264 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
265 self.x2 = notebook.get(x2Str)
268 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
269 self.y1 = notebook.get(y1Str)
272 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
273 self.y2 = notebook.get(y2Str)
276 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
277 self.z1 = notebook.get(z1Str)
280 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
281 self.z2 = notebook.get(z2Str)
285 # Parametrized substitute for AxisStruct
301 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
308 if isinstance(xStr, str) and notebook.isVariable(xStr):
309 self.x = notebook.get(xStr)
312 if isinstance(yStr, str) and notebook.isVariable(yStr):
313 self.y = notebook.get(yStr)
316 if isinstance(zStr, str) and notebook.isVariable(zStr):
317 self.z = notebook.get(zStr)
320 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
321 self.dx = notebook.get(dxStr)
324 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
325 self.dy = notebook.get(dyStr)
328 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
329 self.dz = notebook.get(dzStr)
333 # Parametrized substitute for DirStruct
336 def __init__(self, pointStruct):
337 self.pointStruct = pointStruct
339 # Returns list of variable values from salome notebook
340 def ParsePointStruct(Point):
341 Parameters = 2*var_separator
342 if isinstance(Point, PointStructStr):
343 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
344 Point = PointStruct(Point.x, Point.y, Point.z)
345 return Point, Parameters
347 # Returns list of variable values from salome notebook
348 def ParseDirStruct(Dir):
349 Parameters = 2*var_separator
350 if isinstance(Dir, DirStructStr):
351 pntStr = Dir.pointStruct
352 if isinstance(pntStr, PointStructStr6):
353 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
354 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
355 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
356 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
358 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
359 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
360 Dir = DirStruct(Point)
361 return Dir, Parameters
363 # Returns list of variable values from salome notebook
364 def ParseAxisStruct(Axis):
365 Parameters = 5*var_separator
366 if isinstance(Axis, AxisStructStr):
367 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
368 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
369 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
370 return Axis, Parameters
372 ## Return list of variable values from salome notebook
373 def ParseAngles(list):
376 for parameter in list:
377 if isinstance(parameter,str) and notebook.isVariable(parameter):
378 Result.append(DegreesToRadians(notebook.get(parameter)))
381 Result.append(parameter)
384 Parameters = Parameters + str(parameter)
385 Parameters = Parameters + var_separator
387 Parameters = Parameters[:len(Parameters)-1]
388 return Result, Parameters
390 def IsEqual(val1, val2, tol=PrecisionConfusion):
391 if abs(val1 - val2) < tol:
401 if isinstance(obj, SALOMEDS._objref_SObject):
404 ior = salome.orb.object_to_string(obj)
407 studies = salome.myStudyManager.GetOpenStudies()
408 for sname in studies:
409 s = salome.myStudyManager.GetStudyByName(sname)
411 sobj = s.FindObjectIOR(ior)
412 if not sobj: continue
413 return sobj.GetName()
414 if hasattr(obj, "GetName"):
415 # unknown CORBA object, having GetName() method
418 # unknown CORBA object, no GetName() method
421 if hasattr(obj, "GetName"):
422 # unknown non-CORBA object, having GetName() method
425 raise RuntimeError, "Null or invalid object"
427 ## Prints error message if a hypothesis was not assigned.
428 def TreatHypoStatus(status, hypName, geomName, isAlgo):
430 hypType = "algorithm"
432 hypType = "hypothesis"
434 if status == HYP_UNKNOWN_FATAL :
435 reason = "for unknown reason"
436 elif status == HYP_INCOMPATIBLE :
437 reason = "this hypothesis mismatches the algorithm"
438 elif status == HYP_NOTCONFORM :
439 reason = "a non-conform mesh would be built"
440 elif status == HYP_ALREADY_EXIST :
441 reason = hypType + " of the same dimension is already assigned to this shape"
442 elif status == HYP_BAD_DIM :
443 reason = hypType + " mismatches the shape"
444 elif status == HYP_CONCURENT :
445 reason = "there are concurrent hypotheses on sub-shapes"
446 elif status == HYP_BAD_SUBSHAPE :
447 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
448 elif status == HYP_BAD_GEOMETRY:
449 reason = "geometry mismatches the expectation of the algorithm"
450 elif status == HYP_HIDDEN_ALGO:
451 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
452 elif status == HYP_HIDING_ALGO:
453 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
454 elif status == HYP_NEED_SHAPE:
455 reason = "Algorithm can't work without shape"
458 hypName = '"' + hypName + '"'
459 geomName= '"' + geomName+ '"'
460 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
461 print hypName, "was assigned to", geomName,"but", reason
462 elif not geomName == '""':
463 print hypName, "was not assigned to",geomName,":", reason
465 print hypName, "was not assigned:", reason
468 ## Check meshing plugin availability
469 def CheckPlugin(plugin):
470 if plugin == NETGEN and noNETGENPlugin:
471 print "Warning: NETGENPlugin module unavailable"
473 elif plugin == GHS3D and noGHS3DPlugin:
474 print "Warning: GHS3DPlugin module unavailable"
476 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
477 print "Warning: GHS3DPRLPlugin module unavailable"
479 elif plugin == Hexotic and noHexoticPlugin:
480 print "Warning: HexoticPlugin module unavailable"
482 elif plugin == BLSURF and noBLSURFPlugin:
483 print "Warning: BLSURFPlugin module unavailable"
487 # end of l1_auxiliary
490 # All methods of this class are accessible directly from the smesh.py package.
491 class smeshDC(SMESH._objref_SMESH_Gen):
493 ## Sets the current study and Geometry component
494 # @ingroup l1_auxiliary
495 def init_smesh(self,theStudy,geompyD):
496 self.SetCurrentStudy(theStudy,geompyD)
498 ## Creates an empty Mesh. This mesh can have an underlying geometry.
499 # @param obj the Geometrical object on which the mesh is built. If not defined,
500 # the mesh will have no underlying geometry.
501 # @param name the name for the new mesh.
502 # @return an instance of Mesh class.
503 # @ingroup l2_construct
504 def Mesh(self, obj=0, name=0):
505 if isinstance(obj,str):
507 return Mesh(self,self.geompyD,obj,name)
509 ## Returns a long value from enumeration
510 # Should be used for SMESH.FunctorType enumeration
511 # @ingroup l1_controls
512 def EnumToLong(self,theItem):
515 ## Gets PointStruct from vertex
516 # @param theVertex a GEOM object(vertex)
517 # @return SMESH.PointStruct
518 # @ingroup l1_auxiliary
519 def GetPointStruct(self,theVertex):
520 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
521 return PointStruct(x,y,z)
523 ## Gets DirStruct from vector
524 # @param theVector a GEOM object(vector)
525 # @return SMESH.DirStruct
526 # @ingroup l1_auxiliary
527 def GetDirStruct(self,theVector):
528 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
529 if(len(vertices) != 2):
530 print "Error: vector object is incorrect."
532 p1 = self.geompyD.PointCoordinates(vertices[0])
533 p2 = self.geompyD.PointCoordinates(vertices[1])
534 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
535 dirst = DirStruct(pnt)
538 ## Makes DirStruct from a triplet
539 # @param x,y,z vector components
540 # @return SMESH.DirStruct
541 # @ingroup l1_auxiliary
542 def MakeDirStruct(self,x,y,z):
543 pnt = PointStruct(x,y,z)
544 return DirStruct(pnt)
546 ## Get AxisStruct from object
547 # @param theObj a GEOM object (line or plane)
548 # @return SMESH.AxisStruct
549 # @ingroup l1_auxiliary
550 def GetAxisStruct(self,theObj):
551 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
553 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
554 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
555 vertex1 = self.geompyD.PointCoordinates(vertex1)
556 vertex2 = self.geompyD.PointCoordinates(vertex2)
557 vertex3 = self.geompyD.PointCoordinates(vertex3)
558 vertex4 = self.geompyD.PointCoordinates(vertex4)
559 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
560 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
561 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] ]
562 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
564 elif len(edges) == 1:
565 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
566 p1 = self.geompyD.PointCoordinates( vertex1 )
567 p2 = self.geompyD.PointCoordinates( vertex2 )
568 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
572 # From SMESH_Gen interface:
573 # ------------------------
575 ## Sets the given name to the object
576 # @param obj the object to rename
577 # @param name a new object name
578 # @ingroup l1_auxiliary
579 def SetName(self, obj, name):
580 if isinstance( obj, Mesh ):
582 elif isinstance( obj, Mesh_Algorithm ):
583 obj = obj.GetAlgorithm()
584 ior = salome.orb.object_to_string(obj)
585 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
587 ## Sets the current mode
588 # @ingroup l1_auxiliary
589 def SetEmbeddedMode( self,theMode ):
590 #self.SetEmbeddedMode(theMode)
591 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
593 ## Gets the current mode
594 # @ingroup l1_auxiliary
595 def IsEmbeddedMode(self):
596 #return self.IsEmbeddedMode()
597 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
599 ## Sets the current study
600 # @ingroup l1_auxiliary
601 def SetCurrentStudy( self, theStudy, geompyD = None ):
602 #self.SetCurrentStudy(theStudy)
605 geompyD = geompy.geom
608 self.SetGeomEngine(geompyD)
609 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
611 ## Gets the current study
612 # @ingroup l1_auxiliary
613 def GetCurrentStudy(self):
614 #return self.GetCurrentStudy()
615 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
617 ## Creates a Mesh object importing data from the given UNV file
618 # @return an instance of Mesh class
620 def CreateMeshesFromUNV( self,theFileName ):
621 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
622 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
625 ## Creates a Mesh object(s) importing data from the given MED file
626 # @return a list of Mesh class instances
628 def CreateMeshesFromMED( self,theFileName ):
629 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
631 for iMesh in range(len(aSmeshMeshes)) :
632 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
633 aMeshes.append(aMesh)
634 return aMeshes, aStatus
636 ## Creates a Mesh object importing data from the given STL file
637 # @return an instance of Mesh class
639 def CreateMeshesFromSTL( self, theFileName ):
640 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
641 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
644 ## From SMESH_Gen interface
645 # @return the list of integer values
646 # @ingroup l1_auxiliary
647 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
648 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
650 ## From SMESH_Gen interface. Creates a pattern
651 # @return an instance of SMESH_Pattern
653 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
654 # @ingroup l2_modif_patterns
655 def GetPattern(self):
656 return SMESH._objref_SMESH_Gen.GetPattern(self)
658 ## Sets number of segments per diagonal of boundary box of geometry by which
659 # default segment length of appropriate 1D hypotheses is defined.
660 # Default value is 10
661 # @ingroup l1_auxiliary
662 def SetBoundaryBoxSegmentation(self, nbSegments):
663 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
665 ## Concatenate the given meshes into one mesh.
666 # @return an instance of Mesh class
667 # @param meshes the meshes to combine into one mesh
668 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
669 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
670 # @param mergeTolerance tolerance for merging nodes
671 # @param allGroups forces creation of groups of all elements
672 def Concatenate( self, meshes, uniteIdenticalGroups,
673 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
674 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
676 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
677 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
679 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
680 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
681 aSmeshMesh.SetParameters(Parameters)
682 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
685 # Filtering. Auxiliary functions:
686 # ------------------------------
688 ## Creates an empty criterion
689 # @return SMESH.Filter.Criterion
690 # @ingroup l1_controls
691 def GetEmptyCriterion(self):
692 Type = self.EnumToLong(FT_Undefined)
693 Compare = self.EnumToLong(FT_Undefined)
697 UnaryOp = self.EnumToLong(FT_Undefined)
698 BinaryOp = self.EnumToLong(FT_Undefined)
701 Precision = -1 ##@1e-07
702 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
703 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
705 ## Creates a criterion by the given parameters
706 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
707 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
708 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
709 # @param Treshold the threshold value (range of ids as string, shape, numeric)
710 # @param UnaryOp FT_LogicalNOT or FT_Undefined
711 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
712 # FT_Undefined (must be for the last criterion of all criteria)
713 # @return SMESH.Filter.Criterion
714 # @ingroup l1_controls
715 def GetCriterion(self,elementType,
717 Compare = FT_EqualTo,
719 UnaryOp=FT_Undefined,
720 BinaryOp=FT_Undefined):
721 aCriterion = self.GetEmptyCriterion()
722 aCriterion.TypeOfElement = elementType
723 aCriterion.Type = self.EnumToLong(CritType)
727 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
728 aCriterion.Compare = self.EnumToLong(Compare)
729 elif Compare == "=" or Compare == "==":
730 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
732 aCriterion.Compare = self.EnumToLong(FT_LessThan)
734 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
736 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
739 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
740 FT_BelongToCylinder, FT_LyingOnGeom]:
741 # Checks the treshold
742 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
743 aCriterion.ThresholdStr = GetName(aTreshold)
744 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
746 print "Error: The treshold should be a shape."
748 elif CritType == FT_RangeOfIds:
749 # Checks the treshold
750 if isinstance(aTreshold, str):
751 aCriterion.ThresholdStr = aTreshold
753 print "Error: The treshold should be a string."
755 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
756 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
757 # At this point the treshold is unnecessary
758 if aTreshold == FT_LogicalNOT:
759 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
760 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
761 aCriterion.BinaryOp = aTreshold
765 aTreshold = float(aTreshold)
766 aCriterion.Threshold = aTreshold
768 print "Error: The treshold should be a number."
771 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
772 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
774 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
775 aCriterion.BinaryOp = self.EnumToLong(Treshold)
777 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
778 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
780 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
781 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
785 ## Creates a filter with the given parameters
786 # @param elementType the type of elements in the group
787 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
788 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
789 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
790 # @param UnaryOp FT_LogicalNOT or FT_Undefined
791 # @return SMESH_Filter
792 # @ingroup l1_controls
793 def GetFilter(self,elementType,
794 CritType=FT_Undefined,
797 UnaryOp=FT_Undefined):
798 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
799 aFilterMgr = self.CreateFilterManager()
800 aFilter = aFilterMgr.CreateFilter()
802 aCriteria.append(aCriterion)
803 aFilter.SetCriteria(aCriteria)
806 ## Creates a numerical functor by its type
807 # @param theCriterion FT_...; functor type
808 # @return SMESH_NumericalFunctor
809 # @ingroup l1_controls
810 def GetFunctor(self,theCriterion):
811 aFilterMgr = self.CreateFilterManager()
812 if theCriterion == FT_AspectRatio:
813 return aFilterMgr.CreateAspectRatio()
814 elif theCriterion == FT_AspectRatio3D:
815 return aFilterMgr.CreateAspectRatio3D()
816 elif theCriterion == FT_Warping:
817 return aFilterMgr.CreateWarping()
818 elif theCriterion == FT_MinimumAngle:
819 return aFilterMgr.CreateMinimumAngle()
820 elif theCriterion == FT_Taper:
821 return aFilterMgr.CreateTaper()
822 elif theCriterion == FT_Skew:
823 return aFilterMgr.CreateSkew()
824 elif theCriterion == FT_Area:
825 return aFilterMgr.CreateArea()
826 elif theCriterion == FT_Volume3D:
827 return aFilterMgr.CreateVolume3D()
828 elif theCriterion == FT_MultiConnection:
829 return aFilterMgr.CreateMultiConnection()
830 elif theCriterion == FT_MultiConnection2D:
831 return aFilterMgr.CreateMultiConnection2D()
832 elif theCriterion == FT_Length:
833 return aFilterMgr.CreateLength()
834 elif theCriterion == FT_Length2D:
835 return aFilterMgr.CreateLength2D()
837 print "Error: given parameter is not numerucal functor type."
839 ## Creates hypothesis
840 # @param theHType mesh hypothesis type (string)
841 # @param theLibName mesh plug-in library name
842 # @return created hypothesis instance
843 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
844 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
846 ## Gets the mesh stattistic
847 # @return dictionary type element - count of elements
848 # @ingroup l1_meshinfo
849 def GetMeshInfo(self, obj):
850 if isinstance( obj, Mesh ):
853 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
854 values = obj.GetMeshInfo()
855 for i in range(SMESH.Entity_Last._v):
856 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
861 #Registering the new proxy for SMESH_Gen
862 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
868 ## This class allows defining and managing a mesh.
869 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
870 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
871 # new nodes and elements and by changing the existing entities), to get information
872 # about a mesh and to export a mesh into different formats.
881 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
882 # sets the GUI name of this mesh to \a name.
883 # @param smeshpyD an instance of smeshDC class
884 # @param geompyD an instance of geompyDC class
885 # @param obj Shape to be meshed or SMESH_Mesh object
886 # @param name Study name of the mesh
887 # @ingroup l2_construct
888 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
889 self.smeshpyD=smeshpyD
894 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
896 self.mesh = self.smeshpyD.CreateMesh(self.geom)
897 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
900 self.mesh = self.smeshpyD.CreateEmptyMesh()
902 self.smeshpyD.SetName(self.mesh, name)
904 self.smeshpyD.SetName(self.mesh, GetName(obj))
907 self.geom = self.mesh.GetShapeToMesh()
909 self.editor = self.mesh.GetMeshEditor()
911 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
912 # @param theMesh a SMESH_Mesh object
913 # @ingroup l2_construct
914 def SetMesh(self, theMesh):
916 self.geom = self.mesh.GetShapeToMesh()
918 ## Returns the mesh, that is an instance of SMESH_Mesh interface
919 # @return a SMESH_Mesh object
920 # @ingroup l2_construct
924 ## Gets the name of the mesh
925 # @return the name of the mesh as a string
926 # @ingroup l2_construct
928 name = GetName(self.GetMesh())
931 ## Sets a name to the mesh
932 # @param name a new name of the mesh
933 # @ingroup l2_construct
934 def SetName(self, name):
935 self.smeshpyD.SetName(self.GetMesh(), name)
937 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
938 # The subMesh object gives access to the IDs of nodes and elements.
939 # @param theSubObject a geometrical object (shape)
940 # @param theName a name for the submesh
941 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
942 # @ingroup l2_submeshes
943 def GetSubMesh(self, theSubObject, theName):
944 submesh = self.mesh.GetSubMesh(theSubObject, theName)
947 ## Returns the shape associated to the mesh
948 # @return a GEOM_Object
949 # @ingroup l2_construct
953 ## Associates the given shape to the mesh (entails the recreation of the mesh)
954 # @param geom the shape to be meshed (GEOM_Object)
955 # @ingroup l2_construct
956 def SetShape(self, geom):
957 self.mesh = self.smeshpyD.CreateMesh(geom)
959 ## Returns true if the hypotheses are defined well
960 # @param theSubObject a subshape of a mesh shape
961 # @return True or False
962 # @ingroup l2_construct
963 def IsReadyToCompute(self, theSubObject):
964 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
966 ## Returns errors of hypotheses definition.
967 # The list of errors is empty if everything is OK.
968 # @param theSubObject a subshape of a mesh shape
969 # @return a list of errors
970 # @ingroup l2_construct
971 def GetAlgoState(self, theSubObject):
972 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
974 ## Returns a geometrical object on which the given element was built.
975 # The returned geometrical object, if not nil, is either found in the
976 # study or published by this method with the given name
977 # @param theElementID the id of the mesh element
978 # @param theGeomName the user-defined name of the geometrical object
979 # @return GEOM::GEOM_Object instance
980 # @ingroup l2_construct
981 def GetGeometryByMeshElement(self, theElementID, theGeomName):
982 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
984 ## Returns the mesh dimension depending on the dimension of the underlying shape
985 # @return mesh dimension as an integer value [0,3]
986 # @ingroup l1_auxiliary
987 def MeshDimension(self):
988 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
989 if len( shells ) > 0 :
991 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
993 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
999 ## Creates a segment discretization 1D algorithm.
1000 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1001 # \n If the optional \a geom parameter is not set, this algorithm is global.
1002 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1003 # @param algo the type of the required algorithm. Possible values are:
1005 # - smesh.PYTHON for discretization via a python function,
1006 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1007 # @param geom If defined is the subshape to be meshed
1008 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1009 # @ingroup l3_algos_basic
1010 def Segment(self, algo=REGULAR, geom=0):
1011 ## if Segment(geom) is called by mistake
1012 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1013 algo, geom = geom, algo
1014 if not algo: algo = REGULAR
1017 return Mesh_Segment(self, geom)
1018 elif algo == PYTHON:
1019 return Mesh_Segment_Python(self, geom)
1020 elif algo == COMPOSITE:
1021 return Mesh_CompositeSegment(self, geom)
1023 return Mesh_Segment(self, geom)
1025 ## Enables creation of nodes and segments usable by 2D algoritms.
1026 # The added nodes and segments must be bound to edges and vertices by
1027 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1028 # If the optional \a geom parameter is not set, this algorithm is global.
1029 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1030 # @param geom the subshape to be manually meshed
1031 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1032 # @ingroup l3_algos_basic
1033 def UseExistingSegments(self, geom=0):
1034 algo = Mesh_UseExisting(1,self,geom)
1035 return algo.GetAlgorithm()
1037 ## Enables creation of nodes and faces usable by 3D algoritms.
1038 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1039 # and SetMeshElementOnShape()
1040 # If the optional \a geom parameter is not set, this algorithm is global.
1041 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1042 # @param geom the subshape to be manually meshed
1043 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1044 # @ingroup l3_algos_basic
1045 def UseExistingFaces(self, geom=0):
1046 algo = Mesh_UseExisting(2,self,geom)
1047 return algo.GetAlgorithm()
1049 ## Creates a triangle 2D algorithm for faces.
1050 # If the optional \a geom parameter is not set, this algorithm is global.
1051 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1052 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1053 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1054 # @return an instance of Mesh_Triangle algorithm
1055 # @ingroup l3_algos_basic
1056 def Triangle(self, algo=MEFISTO, geom=0):
1057 ## if Triangle(geom) is called by mistake
1058 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1061 return Mesh_Triangle(self, algo, geom)
1063 ## Creates a quadrangle 2D algorithm for faces.
1064 # If the optional \a geom parameter is not set, this algorithm is global.
1065 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1066 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1067 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1068 # @return an instance of Mesh_Quadrangle algorithm
1069 # @ingroup l3_algos_basic
1070 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1071 if algo==RADIAL_QUAD:
1072 return Mesh_RadialQuadrangle1D2D(self,geom)
1074 return Mesh_Quadrangle(self, geom)
1076 ## Creates a tetrahedron 3D algorithm for solids.
1077 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1078 # If the optional \a geom parameter is not set, this algorithm is global.
1079 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1080 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1081 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1082 # @return an instance of Mesh_Tetrahedron algorithm
1083 # @ingroup l3_algos_basic
1084 def Tetrahedron(self, algo=NETGEN, geom=0):
1085 ## if Tetrahedron(geom) is called by mistake
1086 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1087 algo, geom = geom, algo
1088 if not algo: algo = NETGEN
1090 return Mesh_Tetrahedron(self, algo, geom)
1092 ## Creates a hexahedron 3D algorithm for solids.
1093 # If the optional \a geom parameter is not set, this algorithm is global.
1094 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1095 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1096 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1097 # @return an instance of Mesh_Hexahedron algorithm
1098 # @ingroup l3_algos_basic
1099 def Hexahedron(self, algo=Hexa, geom=0):
1100 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1101 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1102 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1103 elif geom == 0: algo, geom = Hexa, algo
1104 return Mesh_Hexahedron(self, algo, geom)
1106 ## Deprecated, used only for compatibility!
1107 # @return an instance of Mesh_Netgen algorithm
1108 # @ingroup l3_algos_basic
1109 def Netgen(self, is3D, geom=0):
1110 return Mesh_Netgen(self, is3D, geom)
1112 ## Creates a projection 1D algorithm for edges.
1113 # If the optional \a geom parameter is not set, this algorithm is global.
1114 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1115 # @param geom If defined, the subshape to be meshed
1116 # @return an instance of Mesh_Projection1D algorithm
1117 # @ingroup l3_algos_proj
1118 def Projection1D(self, geom=0):
1119 return Mesh_Projection1D(self, geom)
1121 ## Creates a projection 2D algorithm for faces.
1122 # If the optional \a geom parameter is not set, this algorithm is global.
1123 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1124 # @param geom If defined, the subshape to be meshed
1125 # @return an instance of Mesh_Projection2D algorithm
1126 # @ingroup l3_algos_proj
1127 def Projection2D(self, geom=0):
1128 return Mesh_Projection2D(self, geom)
1130 ## Creates a projection 3D algorithm for solids.
1131 # If the optional \a geom parameter is not set, this algorithm is global.
1132 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1133 # @param geom If defined, the subshape to be meshed
1134 # @return an instance of Mesh_Projection3D algorithm
1135 # @ingroup l3_algos_proj
1136 def Projection3D(self, geom=0):
1137 return Mesh_Projection3D(self, geom)
1139 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1140 # If the optional \a geom parameter is not set, this algorithm is global.
1141 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1142 # @param geom If defined, the subshape to be meshed
1143 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1144 # @ingroup l3_algos_radialp l3_algos_3dextr
1145 def Prism(self, geom=0):
1149 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1150 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1151 if nbSolids == 0 or nbSolids == nbShells:
1152 return Mesh_Prism3D(self, geom)
1153 return Mesh_RadialPrism3D(self, geom)
1155 ## Evaluates size of prospective mesh on a shape
1156 # @return True or False
1157 def Evaluate(self, geom=0):
1158 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1160 geom = self.mesh.GetShapeToMesh()
1163 return self.smeshpyD.Evaluate(self.mesh, geom)
1166 ## Computes the mesh and returns the status of the computation
1167 # @return True or False
1168 # @ingroup l2_construct
1169 def Compute(self, geom=0):
1170 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1172 geom = self.mesh.GetShapeToMesh()
1177 ok = self.smeshpyD.Compute(self.mesh, geom)
1178 except SALOME.SALOME_Exception, ex:
1179 print "Mesh computation failed, exception caught:"
1180 print " ", ex.details.text
1183 print "Mesh computation failed, exception caught:"
1184 traceback.print_exc()
1188 # Treat compute errors
1189 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1190 for err in computeErrors:
1193 mainIOR = salome.orb.object_to_string(geom)
1194 for sname in salome.myStudyManager.GetOpenStudies():
1195 s = salome.myStudyManager.GetStudyByName(sname)
1197 mainSO = s.FindObjectIOR(mainIOR)
1198 if not mainSO: continue
1199 subIt = s.NewChildIterator(mainSO)
1201 subSO = subIt.Value()
1203 obj = subSO.GetObject()
1204 if not obj: continue
1205 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1207 ids = go.GetSubShapeIndices()
1208 if len(ids) == 1 and ids[0] == err.subShapeID:
1209 shapeText = '"%s"' % subSO.GetName()
1216 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1218 shapeText = "%s #%s" % (shape.GetShapeType(), err.subShapeID)
1220 shapeText = "%subshape #%s" % (err.subShapeID)
1223 stdErrors = ["OK", #COMPERR_OK
1224 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1225 "std::exception", #COMPERR_STD_EXCEPTION
1226 "OCC exception", #COMPERR_OCC_EXCEPTION
1227 "SALOME exception", #COMPERR_SLM_EXCEPTION
1228 "Unknown exception", #COMPERR_EXCEPTION
1229 "Memory allocation problem", #COMPERR_MEMORY_PB
1230 "Algorithm failed", #COMPERR_ALGO_FAILED
1231 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1233 if err.code < len(stdErrors): errText = stdErrors[err.code]
1235 errText = "code %s" % -err.code
1236 if errText: errText += ". "
1237 errText += err.comment
1238 allReasons += '"%s" failed on %s. Error: %s' %(err.algoName, shapeText, errText)
1242 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1244 if err.isGlobalAlgo:
1252 reason = '%s %sD algorithm is missing' % (glob, dim)
1253 elif err.state == HYP_MISSING:
1254 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1255 % (glob, dim, name, dim))
1256 elif err.state == HYP_NOTCONFORM:
1257 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1258 elif err.state == HYP_BAD_PARAMETER:
1259 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1260 % ( glob, dim, name ))
1261 elif err.state == HYP_BAD_GEOMETRY:
1262 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1263 'geometry' % ( glob, dim, name ))
1265 reason = "For unknown reason."+\
1266 " Revise Mesh.Compute() implementation in smeshDC.py!"
1268 if allReasons != "":
1271 allReasons += reason
1273 if allReasons != "":
1274 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1278 print '"' + GetName(self.mesh) + '"',"has not been computed."
1281 if salome.sg.hasDesktop():
1282 smeshgui = salome.ImportComponentGUI("SMESH")
1283 smeshgui.Init(self.mesh.GetStudyId())
1284 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1285 salome.sg.updateObjBrowser(1)
1289 ## Return submesh objects list in meshing order
1290 # @return list of list of submesh objects
1291 # @ingroup l2_construct
1292 def GetMeshOrder(self):
1293 return self.mesh.GetMeshOrder()
1295 ## Return submesh objects list in meshing order
1296 # @return list of list of submesh objects
1297 # @ingroup l2_construct
1298 def SetMeshOrder(self, submeshes):
1299 return self.mesh.SetMeshOrder(submeshes)
1301 ## Removes all nodes and elements
1302 # @ingroup l2_construct
1305 if salome.sg.hasDesktop():
1306 smeshgui = salome.ImportComponentGUI("SMESH")
1307 smeshgui.Init(self.mesh.GetStudyId())
1308 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1309 salome.sg.updateObjBrowser(1)
1311 ## Removes all nodes and elements of indicated shape
1312 # @ingroup l2_construct
1313 def ClearSubMesh(self, geomId):
1314 self.mesh.ClearSubMesh(geomId)
1315 if salome.sg.hasDesktop():
1316 smeshgui = salome.ImportComponentGUI("SMESH")
1317 smeshgui.Init(self.mesh.GetStudyId())
1318 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1319 salome.sg.updateObjBrowser(1)
1321 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1322 # @param fineness [0,-1] defines mesh fineness
1323 # @return True or False
1324 # @ingroup l3_algos_basic
1325 def AutomaticTetrahedralization(self, fineness=0):
1326 dim = self.MeshDimension()
1328 self.RemoveGlobalHypotheses()
1329 self.Segment().AutomaticLength(fineness)
1331 self.Triangle().LengthFromEdges()
1334 self.Tetrahedron(NETGEN)
1336 return self.Compute()
1338 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1339 # @param fineness [0,-1] defines mesh fineness
1340 # @return True or False
1341 # @ingroup l3_algos_basic
1342 def AutomaticHexahedralization(self, fineness=0):
1343 dim = self.MeshDimension()
1344 # assign the hypotheses
1345 self.RemoveGlobalHypotheses()
1346 self.Segment().AutomaticLength(fineness)
1353 return self.Compute()
1355 ## Assigns a hypothesis
1356 # @param hyp a hypothesis to assign
1357 # @param geom a subhape of mesh geometry
1358 # @return SMESH.Hypothesis_Status
1359 # @ingroup l2_hypotheses
1360 def AddHypothesis(self, hyp, geom=0):
1361 if isinstance( hyp, Mesh_Algorithm ):
1362 hyp = hyp.GetAlgorithm()
1367 geom = self.mesh.GetShapeToMesh()
1369 status = self.mesh.AddHypothesis(geom, hyp)
1370 isAlgo = hyp._narrow( SMESH_Algo )
1371 hyp_name = GetName( hyp )
1374 geom_name = GetName( geom )
1375 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1378 ## Unassigns a hypothesis
1379 # @param hyp a hypothesis to unassign
1380 # @param geom a subshape of mesh geometry
1381 # @return SMESH.Hypothesis_Status
1382 # @ingroup l2_hypotheses
1383 def RemoveHypothesis(self, hyp, geom=0):
1384 if isinstance( hyp, Mesh_Algorithm ):
1385 hyp = hyp.GetAlgorithm()
1390 status = self.mesh.RemoveHypothesis(geom, hyp)
1393 ## Gets the list of hypotheses added on a geometry
1394 # @param geom a subshape of mesh geometry
1395 # @return the sequence of SMESH_Hypothesis
1396 # @ingroup l2_hypotheses
1397 def GetHypothesisList(self, geom):
1398 return self.mesh.GetHypothesisList( geom )
1400 ## Removes all global hypotheses
1401 # @ingroup l2_hypotheses
1402 def RemoveGlobalHypotheses(self):
1403 current_hyps = self.mesh.GetHypothesisList( self.geom )
1404 for hyp in current_hyps:
1405 self.mesh.RemoveHypothesis( self.geom, hyp )
1409 ## Creates a mesh group based on the geometric object \a grp
1410 # and gives a \a name, \n if this parameter is not defined
1411 # the name is the same as the geometric group name \n
1412 # Note: Works like GroupOnGeom().
1413 # @param grp a geometric group, a vertex, an edge, a face or a solid
1414 # @param name the name of the mesh group
1415 # @return SMESH_GroupOnGeom
1416 # @ingroup l2_grps_create
1417 def Group(self, grp, name=""):
1418 return self.GroupOnGeom(grp, name)
1420 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1421 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1422 # @param f the file name
1423 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1424 # @param opt boolean parameter for creating/not creating
1425 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1426 # @ingroup l2_impexp
1427 def ExportToMED(self, f, version, opt=0):
1428 self.mesh.ExportToMED(f, opt, version)
1430 ## Exports the mesh in a file in MED format
1431 # @param f is the file name
1432 # @param auto_groups boolean parameter for creating/not creating
1433 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1434 # the typical use is auto_groups=false.
1435 # @param version MED format version(MED_V2_1 or MED_V2_2)
1436 # @ingroup l2_impexp
1437 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1438 self.mesh.ExportToMED(f, auto_groups, version)
1440 ## Exports the mesh in a file in DAT format
1441 # @param f the file name
1442 # @ingroup l2_impexp
1443 def ExportDAT(self, f):
1444 self.mesh.ExportDAT(f)
1446 ## Exports the mesh in a file in UNV format
1447 # @param f the file name
1448 # @ingroup l2_impexp
1449 def ExportUNV(self, f):
1450 self.mesh.ExportUNV(f)
1452 ## Export the mesh in a file in STL format
1453 # @param f the file name
1454 # @param ascii defines the file encoding
1455 # @ingroup l2_impexp
1456 def ExportSTL(self, f, ascii=1):
1457 self.mesh.ExportSTL(f, ascii)
1460 # Operations with groups:
1461 # ----------------------
1463 ## Creates an empty mesh group
1464 # @param elementType the type of elements in the group
1465 # @param name the name of the mesh group
1466 # @return SMESH_Group
1467 # @ingroup l2_grps_create
1468 def CreateEmptyGroup(self, elementType, name):
1469 return self.mesh.CreateGroup(elementType, name)
1471 ## Creates a mesh group based on the geometrical object \a grp
1472 # and gives a \a name, \n if this parameter is not defined
1473 # the name is the same as the geometrical group name
1474 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1475 # @param name the name of the mesh group
1476 # @param typ the type of elements in the group. If not set, it is
1477 # automatically detected by the type of the geometry
1478 # @return SMESH_GroupOnGeom
1479 # @ingroup l2_grps_create
1480 def GroupOnGeom(self, grp, name="", typ=None):
1482 name = grp.GetName()
1485 tgeo = str(grp.GetShapeType())
1486 if tgeo == "VERTEX":
1488 elif tgeo == "EDGE":
1490 elif tgeo == "FACE":
1492 elif tgeo == "SOLID":
1494 elif tgeo == "SHELL":
1496 elif tgeo == "COMPOUND":
1497 try: # it raises on a compound of compounds
1498 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1499 print "Mesh.Group: empty geometric group", GetName( grp )
1504 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1506 tgeo = self.geompyD.GetType(grp)
1507 if tgeo == geompyDC.ShapeType["VERTEX"]:
1509 elif tgeo == geompyDC.ShapeType["EDGE"]:
1511 elif tgeo == geompyDC.ShapeType["FACE"]:
1513 elif tgeo == geompyDC.ShapeType["SOLID"]:
1519 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1520 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1521 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1529 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1532 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1534 ## Creates a mesh group by the given ids of elements
1535 # @param groupName the name of the mesh group
1536 # @param elementType the type of elements in the group
1537 # @param elemIDs the list of ids
1538 # @return SMESH_Group
1539 # @ingroup l2_grps_create
1540 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1541 group = self.mesh.CreateGroup(elementType, groupName)
1545 ## Creates a mesh group by the given conditions
1546 # @param groupName the name of the mesh group
1547 # @param elementType the type of elements in the group
1548 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1549 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1550 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1551 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1552 # @return SMESH_Group
1553 # @ingroup l2_grps_create
1557 CritType=FT_Undefined,
1560 UnaryOp=FT_Undefined):
1561 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1562 group = self.MakeGroupByCriterion(groupName, aCriterion)
1565 ## Creates a mesh group by the given criterion
1566 # @param groupName the name of the mesh group
1567 # @param Criterion the instance of Criterion class
1568 # @return SMESH_Group
1569 # @ingroup l2_grps_create
1570 def MakeGroupByCriterion(self, groupName, Criterion):
1571 aFilterMgr = self.smeshpyD.CreateFilterManager()
1572 aFilter = aFilterMgr.CreateFilter()
1574 aCriteria.append(Criterion)
1575 aFilter.SetCriteria(aCriteria)
1576 group = self.MakeGroupByFilter(groupName, aFilter)
1579 ## Creates a mesh group by the given criteria (list of criteria)
1580 # @param groupName the name of the mesh group
1581 # @param theCriteria the list of criteria
1582 # @return SMESH_Group
1583 # @ingroup l2_grps_create
1584 def MakeGroupByCriteria(self, groupName, theCriteria):
1585 aFilterMgr = self.smeshpyD.CreateFilterManager()
1586 aFilter = aFilterMgr.CreateFilter()
1587 aFilter.SetCriteria(theCriteria)
1588 group = self.MakeGroupByFilter(groupName, aFilter)
1591 ## Creates a mesh group by the given filter
1592 # @param groupName the name of the mesh group
1593 # @param theFilter the instance of Filter class
1594 # @return SMESH_Group
1595 # @ingroup l2_grps_create
1596 def MakeGroupByFilter(self, groupName, theFilter):
1597 anIds = theFilter.GetElementsId(self.mesh)
1598 anElemType = theFilter.GetElementType()
1599 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1602 ## Passes mesh elements through the given filter and return IDs of fitting elements
1603 # @param theFilter SMESH_Filter
1604 # @return a list of ids
1605 # @ingroup l1_controls
1606 def GetIdsFromFilter(self, theFilter):
1607 return theFilter.GetElementsId(self.mesh)
1609 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1610 # Returns a list of special structures (borders).
1611 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1612 # @ingroup l1_controls
1613 def GetFreeBorders(self):
1614 aFilterMgr = self.smeshpyD.CreateFilterManager()
1615 aPredicate = aFilterMgr.CreateFreeEdges()
1616 aPredicate.SetMesh(self.mesh)
1617 aBorders = aPredicate.GetBorders()
1621 # @ingroup l2_grps_delete
1622 def RemoveGroup(self, group):
1623 self.mesh.RemoveGroup(group)
1625 ## Removes a group with its contents
1626 # @ingroup l2_grps_delete
1627 def RemoveGroupWithContents(self, group):
1628 self.mesh.RemoveGroupWithContents(group)
1630 ## Gets the list of groups existing in the mesh
1631 # @return a sequence of SMESH_GroupBase
1632 # @ingroup l2_grps_create
1633 def GetGroups(self):
1634 return self.mesh.GetGroups()
1636 ## Gets the number of groups existing in the mesh
1637 # @return the quantity of groups as an integer value
1638 # @ingroup l2_grps_create
1640 return self.mesh.NbGroups()
1642 ## Gets the list of names of groups existing in the mesh
1643 # @return list of strings
1644 # @ingroup l2_grps_create
1645 def GetGroupNames(self):
1646 groups = self.GetGroups()
1648 for group in groups:
1649 names.append(group.GetName())
1652 ## Produces a union of two groups
1653 # A new group is created. All mesh elements that are
1654 # present in the initial groups are added to the new one
1655 # @return an instance of SMESH_Group
1656 # @ingroup l2_grps_operon
1657 def UnionGroups(self, group1, group2, name):
1658 return self.mesh.UnionGroups(group1, group2, name)
1660 ## Produces a union list of groups
1661 # New group is created. All mesh elements that are present in
1662 # initial groups are added to the new one
1663 # @return an instance of SMESH_Group
1664 # @ingroup l2_grps_operon
1665 def UnionListOfGroups(self, groups, name):
1666 return self.mesh.UnionListOfGroups(groups, name)
1668 ## Prodices an intersection of two groups
1669 # A new group is created. All mesh elements that are common
1670 # for the two initial groups are added to the new one.
1671 # @return an instance of SMESH_Group
1672 # @ingroup l2_grps_operon
1673 def IntersectGroups(self, group1, group2, name):
1674 return self.mesh.IntersectGroups(group1, group2, name)
1676 ## Produces an intersection of groups
1677 # New group is created. All mesh elements that are present in all
1678 # initial groups simultaneously are added to the new one
1679 # @return an instance of SMESH_Group
1680 # @ingroup l2_grps_operon
1681 def IntersectListOfGroups(self, groups, name):
1682 return self.mesh.IntersectListOfGroups(groups, name)
1684 ## Produces a cut of two groups
1685 # A new group is created. All mesh elements that are present in
1686 # the main group but are not present in the tool group are added to the new one
1687 # @return an instance of SMESH_Group
1688 # @ingroup l2_grps_operon
1689 def CutGroups(self, main_group, tool_group, name):
1690 return self.mesh.CutGroups(main_group, tool_group, name)
1692 ## Produces a cut of groups
1693 # A new group is created. All mesh elements that are present in main groups
1694 # but do not present in tool groups are added to the new one
1695 # @return an instance of SMESH_Group
1696 # @ingroup l2_grps_operon
1697 def CutListOfGroups(self, main_groups, tool_groups, name):
1698 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1700 ## Produces a group of elements with specified element type using list of existing groups
1701 # A new group is created. System
1702 # 1) extract all nodes on which groups elements are built
1703 # 2) combine all elements of specified dimension laying on these nodes
1704 # @return an instance of SMESH_Group
1705 # @ingroup l2_grps_operon
1706 def CreateDimGroup(self, groups, elem_type, name):
1707 return self.mesh.CreateDimGroup(groups, elem_type, name)
1710 ## Convert group on geom into standalone group
1711 # @ingroup l2_grps_delete
1712 def ConvertToStandalone(self, group):
1713 return self.mesh.ConvertToStandalone(group)
1715 # Get some info about mesh:
1716 # ------------------------
1718 ## Returns the log of nodes and elements added or removed
1719 # since the previous clear of the log.
1720 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1721 # @return list of log_block structures:
1726 # @ingroup l1_auxiliary
1727 def GetLog(self, clearAfterGet):
1728 return self.mesh.GetLog(clearAfterGet)
1730 ## Clears the log of nodes and elements added or removed since the previous
1731 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1732 # @ingroup l1_auxiliary
1734 self.mesh.ClearLog()
1736 ## Toggles auto color mode on the object.
1737 # @param theAutoColor the flag which toggles auto color mode.
1738 # @ingroup l1_auxiliary
1739 def SetAutoColor(self, theAutoColor):
1740 self.mesh.SetAutoColor(theAutoColor)
1742 ## Gets flag of object auto color mode.
1743 # @return True or False
1744 # @ingroup l1_auxiliary
1745 def GetAutoColor(self):
1746 return self.mesh.GetAutoColor()
1748 ## Gets the internal ID
1749 # @return integer value, which is the internal Id of the mesh
1750 # @ingroup l1_auxiliary
1752 return self.mesh.GetId()
1755 # @return integer value, which is the study Id of the mesh
1756 # @ingroup l1_auxiliary
1757 def GetStudyId(self):
1758 return self.mesh.GetStudyId()
1760 ## Checks the group names for duplications.
1761 # Consider the maximum group name length stored in MED file.
1762 # @return True or False
1763 # @ingroup l1_auxiliary
1764 def HasDuplicatedGroupNamesMED(self):
1765 return self.mesh.HasDuplicatedGroupNamesMED()
1767 ## Obtains the mesh editor tool
1768 # @return an instance of SMESH_MeshEditor
1769 # @ingroup l1_modifying
1770 def GetMeshEditor(self):
1771 return self.mesh.GetMeshEditor()
1774 # @return an instance of SALOME_MED::MESH
1775 # @ingroup l1_auxiliary
1776 def GetMEDMesh(self):
1777 return self.mesh.GetMEDMesh()
1780 # Get informations about mesh contents:
1781 # ------------------------------------
1783 ## Gets the mesh stattistic
1784 # @return dictionary type element - count of elements
1785 # @ingroup l1_meshinfo
1786 def GetMeshInfo(self, obj = None):
1787 if not obj: obj = self.mesh
1788 return self.smeshpyD.GetMeshInfo(obj)
1790 ## Returns the number of nodes in the mesh
1791 # @return an integer value
1792 # @ingroup l1_meshinfo
1794 return self.mesh.NbNodes()
1796 ## Returns the number of elements in the mesh
1797 # @return an integer value
1798 # @ingroup l1_meshinfo
1799 def NbElements(self):
1800 return self.mesh.NbElements()
1802 ## Returns the number of 0d elements in the mesh
1803 # @return an integer value
1804 # @ingroup l1_meshinfo
1805 def Nb0DElements(self):
1806 return self.mesh.Nb0DElements()
1808 ## Returns the number of edges in the mesh
1809 # @return an integer value
1810 # @ingroup l1_meshinfo
1812 return self.mesh.NbEdges()
1814 ## Returns the number of edges with the given order in the mesh
1815 # @param elementOrder the order of elements:
1816 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1817 # @return an integer value
1818 # @ingroup l1_meshinfo
1819 def NbEdgesOfOrder(self, elementOrder):
1820 return self.mesh.NbEdgesOfOrder(elementOrder)
1822 ## Returns the number of faces in the mesh
1823 # @return an integer value
1824 # @ingroup l1_meshinfo
1826 return self.mesh.NbFaces()
1828 ## Returns the number of faces with the given order in the mesh
1829 # @param elementOrder the order of elements:
1830 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1831 # @return an integer value
1832 # @ingroup l1_meshinfo
1833 def NbFacesOfOrder(self, elementOrder):
1834 return self.mesh.NbFacesOfOrder(elementOrder)
1836 ## Returns the number of triangles in the mesh
1837 # @return an integer value
1838 # @ingroup l1_meshinfo
1839 def NbTriangles(self):
1840 return self.mesh.NbTriangles()
1842 ## Returns the number of triangles with the given order in the mesh
1843 # @param elementOrder is the order of elements:
1844 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1845 # @return an integer value
1846 # @ingroup l1_meshinfo
1847 def NbTrianglesOfOrder(self, elementOrder):
1848 return self.mesh.NbTrianglesOfOrder(elementOrder)
1850 ## Returns the number of quadrangles in the mesh
1851 # @return an integer value
1852 # @ingroup l1_meshinfo
1853 def NbQuadrangles(self):
1854 return self.mesh.NbQuadrangles()
1856 ## Returns the number of quadrangles with the given order in the mesh
1857 # @param elementOrder the order of elements:
1858 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1859 # @return an integer value
1860 # @ingroup l1_meshinfo
1861 def NbQuadranglesOfOrder(self, elementOrder):
1862 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1864 ## Returns the number of polygons in the mesh
1865 # @return an integer value
1866 # @ingroup l1_meshinfo
1867 def NbPolygons(self):
1868 return self.mesh.NbPolygons()
1870 ## Returns the number of volumes in the mesh
1871 # @return an integer value
1872 # @ingroup l1_meshinfo
1873 def NbVolumes(self):
1874 return self.mesh.NbVolumes()
1876 ## Returns the number of volumes with the given order in the mesh
1877 # @param elementOrder the order of elements:
1878 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1879 # @return an integer value
1880 # @ingroup l1_meshinfo
1881 def NbVolumesOfOrder(self, elementOrder):
1882 return self.mesh.NbVolumesOfOrder(elementOrder)
1884 ## Returns the number of tetrahedrons in the mesh
1885 # @return an integer value
1886 # @ingroup l1_meshinfo
1888 return self.mesh.NbTetras()
1890 ## Returns the number of tetrahedrons with the given order in the mesh
1891 # @param elementOrder the order of elements:
1892 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1893 # @return an integer value
1894 # @ingroup l1_meshinfo
1895 def NbTetrasOfOrder(self, elementOrder):
1896 return self.mesh.NbTetrasOfOrder(elementOrder)
1898 ## Returns the number of hexahedrons in the mesh
1899 # @return an integer value
1900 # @ingroup l1_meshinfo
1902 return self.mesh.NbHexas()
1904 ## Returns the number of hexahedrons with the given order in the mesh
1905 # @param elementOrder the order of elements:
1906 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1907 # @return an integer value
1908 # @ingroup l1_meshinfo
1909 def NbHexasOfOrder(self, elementOrder):
1910 return self.mesh.NbHexasOfOrder(elementOrder)
1912 ## Returns the number of pyramids in the mesh
1913 # @return an integer value
1914 # @ingroup l1_meshinfo
1915 def NbPyramids(self):
1916 return self.mesh.NbPyramids()
1918 ## Returns the number of pyramids with the given order in the mesh
1919 # @param elementOrder the order of elements:
1920 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1921 # @return an integer value
1922 # @ingroup l1_meshinfo
1923 def NbPyramidsOfOrder(self, elementOrder):
1924 return self.mesh.NbPyramidsOfOrder(elementOrder)
1926 ## Returns the number of prisms in the mesh
1927 # @return an integer value
1928 # @ingroup l1_meshinfo
1930 return self.mesh.NbPrisms()
1932 ## Returns the number of prisms with the given order in the mesh
1933 # @param elementOrder the order of elements:
1934 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1935 # @return an integer value
1936 # @ingroup l1_meshinfo
1937 def NbPrismsOfOrder(self, elementOrder):
1938 return self.mesh.NbPrismsOfOrder(elementOrder)
1940 ## Returns the number of polyhedrons in the mesh
1941 # @return an integer value
1942 # @ingroup l1_meshinfo
1943 def NbPolyhedrons(self):
1944 return self.mesh.NbPolyhedrons()
1946 ## Returns the number of submeshes in the mesh
1947 # @return an integer value
1948 # @ingroup l1_meshinfo
1949 def NbSubMesh(self):
1950 return self.mesh.NbSubMesh()
1952 ## Returns the list of mesh elements IDs
1953 # @return the list of integer values
1954 # @ingroup l1_meshinfo
1955 def GetElementsId(self):
1956 return self.mesh.GetElementsId()
1958 ## Returns the list of IDs of mesh elements with the given type
1959 # @param elementType the required type of elements
1960 # @return list of integer values
1961 # @ingroup l1_meshinfo
1962 def GetElementsByType(self, elementType):
1963 return self.mesh.GetElementsByType(elementType)
1965 ## Returns the list of mesh nodes IDs
1966 # @return the list of integer values
1967 # @ingroup l1_meshinfo
1968 def GetNodesId(self):
1969 return self.mesh.GetNodesId()
1971 # Get the information about mesh elements:
1972 # ------------------------------------
1974 ## Returns the type of mesh element
1975 # @return the value from SMESH::ElementType enumeration
1976 # @ingroup l1_meshinfo
1977 def GetElementType(self, id, iselem):
1978 return self.mesh.GetElementType(id, iselem)
1980 ## Returns the geometric type of mesh element
1981 # @return the value from SMESH::EntityType enumeration
1982 # @ingroup l1_meshinfo
1983 def GetElementGeomType(self, id):
1984 return self.mesh.GetElementGeomType(id)
1986 ## Returns the list of submesh elements IDs
1987 # @param Shape a geom object(subshape) IOR
1988 # Shape must be the subshape of a ShapeToMesh()
1989 # @return the list of integer values
1990 # @ingroup l1_meshinfo
1991 def GetSubMeshElementsId(self, Shape):
1992 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1993 ShapeID = Shape.GetSubShapeIndices()[0]
1996 return self.mesh.GetSubMeshElementsId(ShapeID)
1998 ## Returns the list of submesh nodes IDs
1999 # @param Shape a geom object(subshape) IOR
2000 # Shape must be the subshape of a ShapeToMesh()
2001 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2002 # @return the list of integer values
2003 # @ingroup l1_meshinfo
2004 def GetSubMeshNodesId(self, Shape, all):
2005 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2006 ShapeID = Shape.GetSubShapeIndices()[0]
2009 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2011 ## Returns type of elements on given shape
2012 # @param Shape a geom object(subshape) IOR
2013 # Shape must be a subshape of a ShapeToMesh()
2014 # @return element type
2015 # @ingroup l1_meshinfo
2016 def GetSubMeshElementType(self, Shape):
2017 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2018 ShapeID = Shape.GetSubShapeIndices()[0]
2021 return self.mesh.GetSubMeshElementType(ShapeID)
2023 ## Gets the mesh description
2024 # @return string value
2025 # @ingroup l1_meshinfo
2027 return self.mesh.Dump()
2030 # Get the information about nodes and elements of a mesh by its IDs:
2031 # -----------------------------------------------------------
2033 ## Gets XYZ coordinates of a node
2034 # \n If there is no nodes for the given ID - returns an empty list
2035 # @return a list of double precision values
2036 # @ingroup l1_meshinfo
2037 def GetNodeXYZ(self, id):
2038 return self.mesh.GetNodeXYZ(id)
2040 ## Returns list of IDs of inverse elements for the given node
2041 # \n If there is no node for the given ID - returns an empty list
2042 # @return a list of integer values
2043 # @ingroup l1_meshinfo
2044 def GetNodeInverseElements(self, id):
2045 return self.mesh.GetNodeInverseElements(id)
2047 ## @brief Returns the position of a node on the shape
2048 # @return SMESH::NodePosition
2049 # @ingroup l1_meshinfo
2050 def GetNodePosition(self,NodeID):
2051 return self.mesh.GetNodePosition(NodeID)
2053 ## If the given element is a node, returns the ID of shape
2054 # \n If there is no node for the given ID - returns -1
2055 # @return an integer value
2056 # @ingroup l1_meshinfo
2057 def GetShapeID(self, id):
2058 return self.mesh.GetShapeID(id)
2060 ## Returns the ID of the result shape after
2061 # FindShape() from SMESH_MeshEditor for the given element
2062 # \n If there is no element for the given ID - returns -1
2063 # @return an integer value
2064 # @ingroup l1_meshinfo
2065 def GetShapeIDForElem(self,id):
2066 return self.mesh.GetShapeIDForElem(id)
2068 ## Returns the number of nodes for the given element
2069 # \n If there is no element for the given ID - returns -1
2070 # @return an integer value
2071 # @ingroup l1_meshinfo
2072 def GetElemNbNodes(self, id):
2073 return self.mesh.GetElemNbNodes(id)
2075 ## Returns the node ID the given index for the given element
2076 # \n If there is no element for the given ID - returns -1
2077 # \n If there is no node for the given index - returns -2
2078 # @return an integer value
2079 # @ingroup l1_meshinfo
2080 def GetElemNode(self, id, index):
2081 return self.mesh.GetElemNode(id, index)
2083 ## Returns the IDs of nodes of the given element
2084 # @return a list of integer values
2085 # @ingroup l1_meshinfo
2086 def GetElemNodes(self, id):
2087 return self.mesh.GetElemNodes(id)
2089 ## Returns true if the given node is the medium node in the given quadratic element
2090 # @ingroup l1_meshinfo
2091 def IsMediumNode(self, elementID, nodeID):
2092 return self.mesh.IsMediumNode(elementID, nodeID)
2094 ## Returns true if the given node is the medium node in one of quadratic elements
2095 # @ingroup l1_meshinfo
2096 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2097 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2099 ## Returns the number of edges for the given element
2100 # @ingroup l1_meshinfo
2101 def ElemNbEdges(self, id):
2102 return self.mesh.ElemNbEdges(id)
2104 ## Returns the number of faces for the given element
2105 # @ingroup l1_meshinfo
2106 def ElemNbFaces(self, id):
2107 return self.mesh.ElemNbFaces(id)
2109 ## Returns nodes of given face (counted from zero) for given volumic element.
2110 # @ingroup l1_meshinfo
2111 def GetElemFaceNodes(self,elemId, faceIndex):
2112 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2114 ## Returns an element based on all given nodes.
2115 # @ingroup l1_meshinfo
2116 def FindElementByNodes(self,nodes):
2117 return self.mesh.FindElementByNodes(nodes)
2119 ## Returns true if the given element is a polygon
2120 # @ingroup l1_meshinfo
2121 def IsPoly(self, id):
2122 return self.mesh.IsPoly(id)
2124 ## Returns true if the given element is quadratic
2125 # @ingroup l1_meshinfo
2126 def IsQuadratic(self, id):
2127 return self.mesh.IsQuadratic(id)
2129 ## Returns XYZ coordinates of the barycenter of the given element
2130 # \n If there is no element for the given ID - returns an empty list
2131 # @return a list of three double values
2132 # @ingroup l1_meshinfo
2133 def BaryCenter(self, id):
2134 return self.mesh.BaryCenter(id)
2137 # Mesh edition (SMESH_MeshEditor functionality):
2138 # ---------------------------------------------
2140 ## Removes the elements from the mesh by ids
2141 # @param IDsOfElements is a list of ids of elements to remove
2142 # @return True or False
2143 # @ingroup l2_modif_del
2144 def RemoveElements(self, IDsOfElements):
2145 return self.editor.RemoveElements(IDsOfElements)
2147 ## Removes nodes from mesh by ids
2148 # @param IDsOfNodes is a list of ids of nodes to remove
2149 # @return True or False
2150 # @ingroup l2_modif_del
2151 def RemoveNodes(self, IDsOfNodes):
2152 return self.editor.RemoveNodes(IDsOfNodes)
2154 ## Add a node to the mesh by coordinates
2155 # @return Id of the new node
2156 # @ingroup l2_modif_add
2157 def AddNode(self, x, y, z):
2158 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2159 self.mesh.SetParameters(Parameters)
2160 return self.editor.AddNode( x, y, z)
2162 ## Creates a 0D element on a node with given number.
2163 # @param IDOfNode the ID of node for creation of the element.
2164 # @return the Id of the new 0D element
2165 # @ingroup l2_modif_add
2166 def Add0DElement(self, IDOfNode):
2167 return self.editor.Add0DElement(IDOfNode)
2169 ## Creates a linear or quadratic edge (this is determined
2170 # by the number of given nodes).
2171 # @param IDsOfNodes the list of node IDs for creation of the element.
2172 # The order of nodes in this list should correspond to the description
2173 # of MED. \n This description is located by the following link:
2174 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2175 # @return the Id of the new edge
2176 # @ingroup l2_modif_add
2177 def AddEdge(self, IDsOfNodes):
2178 return self.editor.AddEdge(IDsOfNodes)
2180 ## Creates a linear or quadratic face (this is determined
2181 # by the number of given nodes).
2182 # @param IDsOfNodes the list of node IDs for creation of the element.
2183 # The order of nodes in this list should correspond to the description
2184 # of MED. \n This description is located by the following link:
2185 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2186 # @return the Id of the new face
2187 # @ingroup l2_modif_add
2188 def AddFace(self, IDsOfNodes):
2189 return self.editor.AddFace(IDsOfNodes)
2191 ## Adds a polygonal face to the mesh by the list of node IDs
2192 # @param IdsOfNodes the list of node IDs for creation of the element.
2193 # @return the Id of the new face
2194 # @ingroup l2_modif_add
2195 def AddPolygonalFace(self, IdsOfNodes):
2196 return self.editor.AddPolygonalFace(IdsOfNodes)
2198 ## Creates both simple and quadratic volume (this is determined
2199 # by the number of given nodes).
2200 # @param IDsOfNodes the list of node IDs for creation of the element.
2201 # The order of nodes in this list should correspond to the description
2202 # of MED. \n This description is located by the following link:
2203 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2204 # @return the Id of the new volumic element
2205 # @ingroup l2_modif_add
2206 def AddVolume(self, IDsOfNodes):
2207 return self.editor.AddVolume(IDsOfNodes)
2209 ## Creates a volume of many faces, giving nodes for each face.
2210 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2211 # @param Quantities the list of integer values, Quantities[i]
2212 # gives the quantity of nodes in face number i.
2213 # @return the Id of the new volumic element
2214 # @ingroup l2_modif_add
2215 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2216 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2218 ## Creates a volume of many faces, giving the IDs of the existing faces.
2219 # @param IdsOfFaces the list of face IDs for volume creation.
2221 # Note: The created volume will refer only to the nodes
2222 # of the given faces, not to the faces themselves.
2223 # @return the Id of the new volumic element
2224 # @ingroup l2_modif_add
2225 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2226 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2229 ## @brief Binds a node to a vertex
2230 # @param NodeID a node ID
2231 # @param Vertex a vertex or vertex ID
2232 # @return True if succeed else raises an exception
2233 # @ingroup l2_modif_add
2234 def SetNodeOnVertex(self, NodeID, Vertex):
2235 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2236 VertexID = Vertex.GetSubShapeIndices()[0]
2240 self.editor.SetNodeOnVertex(NodeID, VertexID)
2241 except SALOME.SALOME_Exception, inst:
2242 raise ValueError, inst.details.text
2246 ## @brief Stores the node position on an edge
2247 # @param NodeID a node ID
2248 # @param Edge an edge or edge ID
2249 # @param paramOnEdge a parameter on the edge where the node is located
2250 # @return True if succeed else raises an exception
2251 # @ingroup l2_modif_add
2252 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2253 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2254 EdgeID = Edge.GetSubShapeIndices()[0]
2258 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2259 except SALOME.SALOME_Exception, inst:
2260 raise ValueError, inst.details.text
2263 ## @brief Stores node position on a face
2264 # @param NodeID a node ID
2265 # @param Face a face or face ID
2266 # @param u U parameter on the face where the node is located
2267 # @param v V parameter on the face where the node is located
2268 # @return True if succeed else raises an exception
2269 # @ingroup l2_modif_add
2270 def SetNodeOnFace(self, NodeID, Face, u, v):
2271 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2272 FaceID = Face.GetSubShapeIndices()[0]
2276 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2277 except SALOME.SALOME_Exception, inst:
2278 raise ValueError, inst.details.text
2281 ## @brief Binds a node to a solid
2282 # @param NodeID a node ID
2283 # @param Solid a solid or solid ID
2284 # @return True if succeed else raises an exception
2285 # @ingroup l2_modif_add
2286 def SetNodeInVolume(self, NodeID, Solid):
2287 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2288 SolidID = Solid.GetSubShapeIndices()[0]
2292 self.editor.SetNodeInVolume(NodeID, SolidID)
2293 except SALOME.SALOME_Exception, inst:
2294 raise ValueError, inst.details.text
2297 ## @brief Bind an element to a shape
2298 # @param ElementID an element ID
2299 # @param Shape a shape or shape ID
2300 # @return True if succeed else raises an exception
2301 # @ingroup l2_modif_add
2302 def SetMeshElementOnShape(self, ElementID, Shape):
2303 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2304 ShapeID = Shape.GetSubShapeIndices()[0]
2308 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2309 except SALOME.SALOME_Exception, inst:
2310 raise ValueError, inst.details.text
2314 ## Moves the node with the given id
2315 # @param NodeID the id of the node
2316 # @param x a new X coordinate
2317 # @param y a new Y coordinate
2318 # @param z a new Z coordinate
2319 # @return True if succeed else False
2320 # @ingroup l2_modif_movenode
2321 def MoveNode(self, NodeID, x, y, z):
2322 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2323 self.mesh.SetParameters(Parameters)
2324 return self.editor.MoveNode(NodeID, x, y, z)
2326 ## Finds the node closest to a point and moves it to a point location
2327 # @param x the X coordinate of a point
2328 # @param y the Y coordinate of a point
2329 # @param z the Z coordinate of a point
2330 # @param NodeID if specified (>0), the node with this ID is moved,
2331 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2332 # @return the ID of a node
2333 # @ingroup l2_modif_throughp
2334 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2335 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2336 self.mesh.SetParameters(Parameters)
2337 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2339 ## Finds the node closest to a point
2340 # @param x the X coordinate of a point
2341 # @param y the Y coordinate of a point
2342 # @param z the Z coordinate of a point
2343 # @return the ID of a node
2344 # @ingroup l2_modif_throughp
2345 def FindNodeClosestTo(self, x, y, z):
2346 #preview = self.mesh.GetMeshEditPreviewer()
2347 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2348 return self.editor.FindNodeClosestTo(x, y, z)
2350 ## Finds the elements where a point lays IN or ON
2351 # @param x the X coordinate of a point
2352 # @param y the Y coordinate of a point
2353 # @param z the Z coordinate of a point
2354 # @param elementType type of elements to find (SMESH.ALL type
2355 # means elements of any type excluding nodes and 0D elements)
2356 # @return list of IDs of found elements
2357 # @ingroup l2_modif_throughp
2358 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2359 return self.editor.FindElementsByPoint(x, y, z, elementType)
2361 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2362 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2364 def GetPointState(self, x, y, z):
2365 return self.editor.GetPointState(x, y, z)
2367 ## Finds the node closest to a point and moves it to a point location
2368 # @param x the X coordinate of a point
2369 # @param y the Y coordinate of a point
2370 # @param z the Z coordinate of a point
2371 # @return the ID of a moved node
2372 # @ingroup l2_modif_throughp
2373 def MeshToPassThroughAPoint(self, x, y, z):
2374 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2376 ## Replaces two neighbour triangles sharing Node1-Node2 link
2377 # with the triangles built on the same 4 nodes but having other common link.
2378 # @param NodeID1 the ID of the first node
2379 # @param NodeID2 the ID of the second node
2380 # @return false if proper faces were not found
2381 # @ingroup l2_modif_invdiag
2382 def InverseDiag(self, NodeID1, NodeID2):
2383 return self.editor.InverseDiag(NodeID1, NodeID2)
2385 ## Replaces two neighbour triangles sharing Node1-Node2 link
2386 # with a quadrangle built on the same 4 nodes.
2387 # @param NodeID1 the ID of the first node
2388 # @param NodeID2 the ID of the second node
2389 # @return false if proper faces were not found
2390 # @ingroup l2_modif_unitetri
2391 def DeleteDiag(self, NodeID1, NodeID2):
2392 return self.editor.DeleteDiag(NodeID1, NodeID2)
2394 ## Reorients elements by ids
2395 # @param IDsOfElements if undefined reorients all mesh elements
2396 # @return True if succeed else False
2397 # @ingroup l2_modif_changori
2398 def Reorient(self, IDsOfElements=None):
2399 if IDsOfElements == None:
2400 IDsOfElements = self.GetElementsId()
2401 return self.editor.Reorient(IDsOfElements)
2403 ## Reorients all elements of the object
2404 # @param theObject mesh, submesh or group
2405 # @return True if succeed else False
2406 # @ingroup l2_modif_changori
2407 def ReorientObject(self, theObject):
2408 if ( isinstance( theObject, Mesh )):
2409 theObject = theObject.GetMesh()
2410 return self.editor.ReorientObject(theObject)
2412 ## Fuses the neighbouring triangles into quadrangles.
2413 # @param IDsOfElements The triangles to be fused,
2414 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2415 # @param MaxAngle is the maximum angle between element normals at which the fusion
2416 # is still performed; theMaxAngle is mesured in radians.
2417 # Also it could be a name of variable which defines angle in degrees.
2418 # @return TRUE in case of success, FALSE otherwise.
2419 # @ingroup l2_modif_unitetri
2420 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2422 if isinstance(MaxAngle,str):
2424 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2426 MaxAngle = DegreesToRadians(MaxAngle)
2427 if IDsOfElements == []:
2428 IDsOfElements = self.GetElementsId()
2429 self.mesh.SetParameters(Parameters)
2431 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2432 Functor = theCriterion
2434 Functor = self.smeshpyD.GetFunctor(theCriterion)
2435 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2437 ## Fuses the neighbouring triangles of the object into quadrangles
2438 # @param theObject is mesh, submesh or group
2439 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2440 # @param MaxAngle a max angle between element normals at which the fusion
2441 # is still performed; theMaxAngle is mesured in radians.
2442 # @return TRUE in case of success, FALSE otherwise.
2443 # @ingroup l2_modif_unitetri
2444 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2445 if ( isinstance( theObject, Mesh )):
2446 theObject = theObject.GetMesh()
2447 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2449 ## Splits quadrangles into triangles.
2450 # @param IDsOfElements the faces to be splitted.
2451 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2452 # @return TRUE in case of success, FALSE otherwise.
2453 # @ingroup l2_modif_cutquadr
2454 def QuadToTri (self, IDsOfElements, theCriterion):
2455 if IDsOfElements == []:
2456 IDsOfElements = self.GetElementsId()
2457 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2459 ## Splits quadrangles into triangles.
2460 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2461 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2462 # @return TRUE in case of success, FALSE otherwise.
2463 # @ingroup l2_modif_cutquadr
2464 def QuadToTriObject (self, theObject, theCriterion):
2465 if ( isinstance( theObject, Mesh )):
2466 theObject = theObject.GetMesh()
2467 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2469 ## Splits quadrangles into triangles.
2470 # @param IDsOfElements the faces to be splitted
2471 # @param Diag13 is used to choose a diagonal for splitting.
2472 # @return TRUE in case of success, FALSE otherwise.
2473 # @ingroup l2_modif_cutquadr
2474 def SplitQuad (self, IDsOfElements, Diag13):
2475 if IDsOfElements == []:
2476 IDsOfElements = self.GetElementsId()
2477 return self.editor.SplitQuad(IDsOfElements, Diag13)
2479 ## Splits quadrangles into triangles.
2480 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2481 # @param Diag13 is used to choose a diagonal for splitting.
2482 # @return TRUE in case of success, FALSE otherwise.
2483 # @ingroup l2_modif_cutquadr
2484 def SplitQuadObject (self, theObject, Diag13):
2485 if ( isinstance( theObject, Mesh )):
2486 theObject = theObject.GetMesh()
2487 return self.editor.SplitQuadObject(theObject, Diag13)
2489 ## Finds a better splitting of the given quadrangle.
2490 # @param IDOfQuad the ID of the quadrangle to be splitted.
2491 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2492 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2493 # diagonal is better, 0 if error occurs.
2494 # @ingroup l2_modif_cutquadr
2495 def BestSplit (self, IDOfQuad, theCriterion):
2496 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2498 ## Splits volumic elements into tetrahedrons
2499 # @param elemIDs either list of elements or mesh or group or submesh
2500 # @param method flags passing splitting method:
2501 # 1 - split the hexahedron into 5 tetrahedrons
2502 # 2 - split the hexahedron into 6 tetrahedrons
2503 # @ingroup l2_modif_cutquadr
2504 def SplitVolumesIntoTetra(self, elemIDs, method=1 ):
2505 if isinstance( elemIDs, Mesh ):
2506 elemIDs = elemIDs.GetMesh()
2507 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2509 ## Splits quadrangle faces near triangular facets of volumes
2511 # @ingroup l1_auxiliary
2512 def SplitQuadsNearTriangularFacets(self):
2513 faces_array = self.GetElementsByType(SMESH.FACE)
2514 for face_id in faces_array:
2515 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2516 quad_nodes = self.mesh.GetElemNodes(face_id)
2517 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2518 isVolumeFound = False
2519 for node1_elem in node1_elems:
2520 if not isVolumeFound:
2521 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2522 nb_nodes = self.GetElemNbNodes(node1_elem)
2523 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2524 volume_elem = node1_elem
2525 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2526 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2527 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2528 isVolumeFound = True
2529 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2530 self.SplitQuad([face_id], False) # diagonal 2-4
2531 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2532 isVolumeFound = True
2533 self.SplitQuad([face_id], True) # diagonal 1-3
2534 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2535 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2536 isVolumeFound = True
2537 self.SplitQuad([face_id], True) # diagonal 1-3
2539 ## @brief Splits hexahedrons into tetrahedrons.
2541 # This operation uses pattern mapping functionality for splitting.
2542 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2543 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2544 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2545 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2546 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2547 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2548 # @return TRUE in case of success, FALSE otherwise.
2549 # @ingroup l1_auxiliary
2550 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2551 # Pattern: 5.---------.6
2556 # (0,0,1) 4.---------.7 * |
2563 # (0,0,0) 0.---------.3
2564 pattern_tetra = "!!! Nb of points: \n 8 \n\
2574 !!! Indices of points of 6 tetras: \n\
2582 pattern = self.smeshpyD.GetPattern()
2583 isDone = pattern.LoadFromFile(pattern_tetra)
2585 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2588 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2589 isDone = pattern.MakeMesh(self.mesh, False, False)
2590 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2592 # split quafrangle faces near triangular facets of volumes
2593 self.SplitQuadsNearTriangularFacets()
2597 ## @brief Split hexahedrons into prisms.
2599 # Uses the pattern mapping functionality for splitting.
2600 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2601 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2602 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2603 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2604 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2605 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2606 # @return TRUE in case of success, FALSE otherwise.
2607 # @ingroup l1_auxiliary
2608 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2609 # Pattern: 5.---------.6
2614 # (0,0,1) 4.---------.7 |
2621 # (0,0,0) 0.---------.3
2622 pattern_prism = "!!! Nb of points: \n 8 \n\
2632 !!! Indices of points of 2 prisms: \n\
2636 pattern = self.smeshpyD.GetPattern()
2637 isDone = pattern.LoadFromFile(pattern_prism)
2639 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2642 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2643 isDone = pattern.MakeMesh(self.mesh, False, False)
2644 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2646 # Splits quafrangle faces near triangular facets of volumes
2647 self.SplitQuadsNearTriangularFacets()
2651 ## Smoothes elements
2652 # @param IDsOfElements the list if ids of elements to smooth
2653 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2654 # Note that nodes built on edges and boundary nodes are always fixed.
2655 # @param MaxNbOfIterations the maximum number of iterations
2656 # @param MaxAspectRatio varies in range [1.0, inf]
2657 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2658 # @return TRUE in case of success, FALSE otherwise.
2659 # @ingroup l2_modif_smooth
2660 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2661 MaxNbOfIterations, MaxAspectRatio, Method):
2662 if IDsOfElements == []:
2663 IDsOfElements = self.GetElementsId()
2664 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2665 self.mesh.SetParameters(Parameters)
2666 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2667 MaxNbOfIterations, MaxAspectRatio, Method)
2669 ## Smoothes elements which belong to the given object
2670 # @param theObject the object to smooth
2671 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2672 # Note that nodes built on edges and boundary nodes are always fixed.
2673 # @param MaxNbOfIterations the maximum number of iterations
2674 # @param MaxAspectRatio varies in range [1.0, inf]
2675 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2676 # @return TRUE in case of success, FALSE otherwise.
2677 # @ingroup l2_modif_smooth
2678 def SmoothObject(self, theObject, IDsOfFixedNodes,
2679 MaxNbOfIterations, MaxAspectRatio, Method):
2680 if ( isinstance( theObject, Mesh )):
2681 theObject = theObject.GetMesh()
2682 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2683 MaxNbOfIterations, MaxAspectRatio, Method)
2685 ## Parametrically smoothes the given elements
2686 # @param IDsOfElements the list if ids of elements to smooth
2687 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2688 # Note that nodes built on edges and boundary nodes are always fixed.
2689 # @param MaxNbOfIterations the maximum number of iterations
2690 # @param MaxAspectRatio varies in range [1.0, inf]
2691 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2692 # @return TRUE in case of success, FALSE otherwise.
2693 # @ingroup l2_modif_smooth
2694 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2695 MaxNbOfIterations, MaxAspectRatio, Method):
2696 if IDsOfElements == []:
2697 IDsOfElements = self.GetElementsId()
2698 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2699 self.mesh.SetParameters(Parameters)
2700 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2701 MaxNbOfIterations, MaxAspectRatio, Method)
2703 ## Parametrically smoothes the elements which belong to the given object
2704 # @param theObject the object to smooth
2705 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2706 # Note that nodes built on edges and boundary nodes are always fixed.
2707 # @param MaxNbOfIterations the maximum number of iterations
2708 # @param MaxAspectRatio varies in range [1.0, inf]
2709 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2710 # @return TRUE in case of success, FALSE otherwise.
2711 # @ingroup l2_modif_smooth
2712 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2713 MaxNbOfIterations, MaxAspectRatio, Method):
2714 if ( isinstance( theObject, Mesh )):
2715 theObject = theObject.GetMesh()
2716 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2717 MaxNbOfIterations, MaxAspectRatio, Method)
2719 ## Converts the mesh to quadratic, deletes old elements, replacing
2720 # them with quadratic with the same id.
2721 # @ingroup l2_modif_tofromqu
2722 def ConvertToQuadratic(self, theForce3d):
2723 self.editor.ConvertToQuadratic(theForce3d)
2725 ## Converts the mesh from quadratic to ordinary,
2726 # deletes old quadratic elements, \n replacing
2727 # them with ordinary mesh elements with the same id.
2728 # @return TRUE in case of success, FALSE otherwise.
2729 # @ingroup l2_modif_tofromqu
2730 def ConvertFromQuadratic(self):
2731 return self.editor.ConvertFromQuadratic()
2733 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2734 # @return TRUE if operation has been completed successfully, FALSE otherwise
2735 # @ingroup l2_modif_edit
2736 def Make2DMeshFrom3D(self):
2737 return self.editor. Make2DMeshFrom3D()
2739 ## Renumber mesh nodes
2740 # @ingroup l2_modif_renumber
2741 def RenumberNodes(self):
2742 self.editor.RenumberNodes()
2744 ## Renumber mesh elements
2745 # @ingroup l2_modif_renumber
2746 def RenumberElements(self):
2747 self.editor.RenumberElements()
2749 ## Generates new elements by rotation of the elements around the axis
2750 # @param IDsOfElements the list of ids of elements to sweep
2751 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2752 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2753 # @param NbOfSteps the number of steps
2754 # @param Tolerance tolerance
2755 # @param MakeGroups forces the generation of new groups from existing ones
2756 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2757 # of all steps, else - size of each step
2758 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2759 # @ingroup l2_modif_extrurev
2760 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2761 MakeGroups=False, TotalAngle=False):
2763 if isinstance(AngleInRadians,str):
2765 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2767 AngleInRadians = DegreesToRadians(AngleInRadians)
2768 if IDsOfElements == []:
2769 IDsOfElements = self.GetElementsId()
2770 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2771 Axis = self.smeshpyD.GetAxisStruct(Axis)
2772 Axis,AxisParameters = ParseAxisStruct(Axis)
2773 if TotalAngle and NbOfSteps:
2774 AngleInRadians /= NbOfSteps
2775 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2776 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2777 self.mesh.SetParameters(Parameters)
2779 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2780 AngleInRadians, NbOfSteps, Tolerance)
2781 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2784 ## Generates new elements by rotation of the elements of object around the axis
2785 # @param theObject object which elements should be sweeped
2786 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2787 # @param AngleInRadians the angle of Rotation
2788 # @param NbOfSteps number of steps
2789 # @param Tolerance tolerance
2790 # @param MakeGroups forces the generation of new groups from existing ones
2791 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2792 # of all steps, else - size of each step
2793 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2794 # @ingroup l2_modif_extrurev
2795 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2796 MakeGroups=False, TotalAngle=False):
2798 if isinstance(AngleInRadians,str):
2800 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2802 AngleInRadians = DegreesToRadians(AngleInRadians)
2803 if ( isinstance( theObject, Mesh )):
2804 theObject = theObject.GetMesh()
2805 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2806 Axis = self.smeshpyD.GetAxisStruct(Axis)
2807 Axis,AxisParameters = ParseAxisStruct(Axis)
2808 if TotalAngle and NbOfSteps:
2809 AngleInRadians /= NbOfSteps
2810 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2811 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2812 self.mesh.SetParameters(Parameters)
2814 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2815 NbOfSteps, Tolerance)
2816 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2819 ## Generates new elements by rotation of the elements of object around the axis
2820 # @param theObject object which elements should be sweeped
2821 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2822 # @param AngleInRadians the angle of Rotation
2823 # @param NbOfSteps number of steps
2824 # @param Tolerance tolerance
2825 # @param MakeGroups forces the generation of new groups from existing ones
2826 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2827 # of all steps, else - size of each step
2828 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2829 # @ingroup l2_modif_extrurev
2830 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2831 MakeGroups=False, TotalAngle=False):
2833 if isinstance(AngleInRadians,str):
2835 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2837 AngleInRadians = DegreesToRadians(AngleInRadians)
2838 if ( isinstance( theObject, Mesh )):
2839 theObject = theObject.GetMesh()
2840 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2841 Axis = self.smeshpyD.GetAxisStruct(Axis)
2842 Axis,AxisParameters = ParseAxisStruct(Axis)
2843 if TotalAngle and NbOfSteps:
2844 AngleInRadians /= NbOfSteps
2845 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2846 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2847 self.mesh.SetParameters(Parameters)
2849 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2850 NbOfSteps, Tolerance)
2851 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2854 ## Generates new elements by rotation of the elements of object around the axis
2855 # @param theObject object which elements should be sweeped
2856 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2857 # @param AngleInRadians the angle of Rotation
2858 # @param NbOfSteps number of steps
2859 # @param Tolerance tolerance
2860 # @param MakeGroups forces the generation of new groups from existing ones
2861 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2862 # of all steps, else - size of each step
2863 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2864 # @ingroup l2_modif_extrurev
2865 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2866 MakeGroups=False, TotalAngle=False):
2868 if isinstance(AngleInRadians,str):
2870 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2872 AngleInRadians = DegreesToRadians(AngleInRadians)
2873 if ( isinstance( theObject, Mesh )):
2874 theObject = theObject.GetMesh()
2875 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2876 Axis = self.smeshpyD.GetAxisStruct(Axis)
2877 Axis,AxisParameters = ParseAxisStruct(Axis)
2878 if TotalAngle and NbOfSteps:
2879 AngleInRadians /= NbOfSteps
2880 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2881 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2882 self.mesh.SetParameters(Parameters)
2884 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2885 NbOfSteps, Tolerance)
2886 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2889 ## Generates new elements by extrusion of the elements with given ids
2890 # @param IDsOfElements the list of elements ids for extrusion
2891 # @param StepVector vector, defining the direction and value of extrusion
2892 # @param NbOfSteps the number of steps
2893 # @param MakeGroups forces the generation of new groups from existing ones
2894 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2895 # @ingroup l2_modif_extrurev
2896 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2897 if IDsOfElements == []:
2898 IDsOfElements = self.GetElementsId()
2899 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2900 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2901 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2902 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2903 Parameters = StepVectorParameters + var_separator + Parameters
2904 self.mesh.SetParameters(Parameters)
2906 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2907 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2910 ## Generates new elements by extrusion of the elements with given ids
2911 # @param IDsOfElements is ids of elements
2912 # @param StepVector vector, defining the direction and value of extrusion
2913 # @param NbOfSteps the number of steps
2914 # @param ExtrFlags sets flags for extrusion
2915 # @param SewTolerance uses for comparing locations of nodes if flag
2916 # EXTRUSION_FLAG_SEW is set
2917 # @param MakeGroups forces the generation of new groups from existing ones
2918 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2919 # @ingroup l2_modif_extrurev
2920 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2921 ExtrFlags, SewTolerance, MakeGroups=False):
2922 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2923 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2925 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2926 ExtrFlags, SewTolerance)
2927 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2928 ExtrFlags, SewTolerance)
2931 ## Generates new elements by extrusion of the elements which belong to the object
2932 # @param theObject the object which elements should be processed
2933 # @param StepVector vector, defining the direction and value of extrusion
2934 # @param NbOfSteps the number of steps
2935 # @param MakeGroups forces the generation of new groups from existing ones
2936 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2937 # @ingroup l2_modif_extrurev
2938 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2939 if ( isinstance( theObject, Mesh )):
2940 theObject = theObject.GetMesh()
2941 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2942 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2943 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2944 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2945 Parameters = StepVectorParameters + var_separator + Parameters
2946 self.mesh.SetParameters(Parameters)
2948 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2949 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2952 ## Generates new elements by extrusion of the elements which belong to the object
2953 # @param theObject object which elements should be processed
2954 # @param StepVector vector, defining the direction and value of extrusion
2955 # @param NbOfSteps the number of steps
2956 # @param MakeGroups to generate new groups from existing ones
2957 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2958 # @ingroup l2_modif_extrurev
2959 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2960 if ( isinstance( theObject, Mesh )):
2961 theObject = theObject.GetMesh()
2962 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2963 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2964 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2965 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2966 Parameters = StepVectorParameters + var_separator + Parameters
2967 self.mesh.SetParameters(Parameters)
2969 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2970 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2973 ## Generates new elements by extrusion of the elements which belong to the object
2974 # @param theObject object which elements should be processed
2975 # @param StepVector vector, defining the direction and value of extrusion
2976 # @param NbOfSteps the number of steps
2977 # @param MakeGroups forces the generation of new groups from existing ones
2978 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2979 # @ingroup l2_modif_extrurev
2980 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2981 if ( isinstance( theObject, Mesh )):
2982 theObject = theObject.GetMesh()
2983 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2984 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2985 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2986 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2987 Parameters = StepVectorParameters + var_separator + Parameters
2988 self.mesh.SetParameters(Parameters)
2990 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2991 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2996 ## Generates new elements by extrusion of the given elements
2997 # The path of extrusion must be a meshed edge.
2998 # @param Base mesh or list of ids of elements for extrusion
2999 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3000 # @param NodeStart the start node from Path. Defines the direction of extrusion
3001 # @param HasAngles allows the shape to be rotated around the path
3002 # to get the resulting mesh in a helical fashion
3003 # @param Angles list of angles in radians
3004 # @param LinearVariation forces the computation of rotation angles as linear
3005 # variation of the given Angles along path steps
3006 # @param HasRefPoint allows using the reference point
3007 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3008 # The User can specify any point as the Reference Point.
3009 # @param MakeGroups forces the generation of new groups from existing ones
3010 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3011 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3012 # only SMESH::Extrusion_Error otherwise
3013 # @ingroup l2_modif_extrurev
3014 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3015 HasAngles, Angles, LinearVariation,
3016 HasRefPoint, RefPoint, MakeGroups, ElemType):
3017 Angles,AnglesParameters = ParseAngles(Angles)
3018 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3019 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3020 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3022 Parameters = AnglesParameters + var_separator + RefPointParameters
3023 self.mesh.SetParameters(Parameters)
3025 if isinstance(Base,list):
3027 if Base == []: IDsOfElements = self.GetElementsId()
3028 else: IDsOfElements = Base
3029 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3030 HasAngles, Angles, LinearVariation,
3031 HasRefPoint, RefPoint, MakeGroups, ElemType)
3033 if isinstance(Base,Mesh):
3034 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3035 HasAngles, Angles, LinearVariation,
3036 HasRefPoint, RefPoint, MakeGroups, ElemType)
3038 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3041 ## Generates new elements by extrusion of the given elements
3042 # The path of extrusion must be a meshed edge.
3043 # @param IDsOfElements ids of elements
3044 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3045 # @param PathShape shape(edge) defines the sub-mesh for the path
3046 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3047 # @param HasAngles allows the shape to be rotated around the path
3048 # to get the resulting mesh in a helical fashion
3049 # @param Angles list of angles in radians
3050 # @param HasRefPoint allows using the reference point
3051 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3052 # The User can specify any point as the Reference Point.
3053 # @param MakeGroups forces the generation of new groups from existing ones
3054 # @param LinearVariation forces the computation of rotation angles as linear
3055 # variation of the given Angles along path steps
3056 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3057 # only SMESH::Extrusion_Error otherwise
3058 # @ingroup l2_modif_extrurev
3059 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3060 HasAngles, Angles, HasRefPoint, RefPoint,
3061 MakeGroups=False, LinearVariation=False):
3062 Angles,AnglesParameters = ParseAngles(Angles)
3063 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3064 if IDsOfElements == []:
3065 IDsOfElements = self.GetElementsId()
3066 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3067 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3069 if ( isinstance( PathMesh, Mesh )):
3070 PathMesh = PathMesh.GetMesh()
3071 if HasAngles and Angles and LinearVariation:
3072 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3074 Parameters = AnglesParameters + var_separator + RefPointParameters
3075 self.mesh.SetParameters(Parameters)
3077 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3078 PathShape, NodeStart, HasAngles,
3079 Angles, HasRefPoint, RefPoint)
3080 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3081 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3083 ## Generates new elements by extrusion of the elements which belong to the object
3084 # The path of extrusion must be a meshed edge.
3085 # @param theObject the object which elements should be processed
3086 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3087 # @param PathShape shape(edge) defines the sub-mesh for the path
3088 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3089 # @param HasAngles allows the shape to be rotated around the path
3090 # to get the resulting mesh in a helical fashion
3091 # @param Angles list of angles
3092 # @param HasRefPoint allows using the reference point
3093 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3094 # The User can specify any point as the Reference Point.
3095 # @param MakeGroups forces the generation of new groups from existing ones
3096 # @param LinearVariation forces the computation of rotation angles as linear
3097 # variation of the given Angles along path steps
3098 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3099 # only SMESH::Extrusion_Error otherwise
3100 # @ingroup l2_modif_extrurev
3101 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3102 HasAngles, Angles, HasRefPoint, RefPoint,
3103 MakeGroups=False, LinearVariation=False):
3104 Angles,AnglesParameters = ParseAngles(Angles)
3105 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3106 if ( isinstance( theObject, Mesh )):
3107 theObject = theObject.GetMesh()
3108 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3109 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3110 if ( isinstance( PathMesh, Mesh )):
3111 PathMesh = PathMesh.GetMesh()
3112 if HasAngles and Angles and LinearVariation:
3113 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3115 Parameters = AnglesParameters + var_separator + RefPointParameters
3116 self.mesh.SetParameters(Parameters)
3118 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3119 PathShape, NodeStart, HasAngles,
3120 Angles, HasRefPoint, RefPoint)
3121 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3122 NodeStart, HasAngles, Angles, HasRefPoint,
3125 ## Generates new elements by extrusion of the elements which belong to the object
3126 # The path of extrusion must be a meshed edge.
3127 # @param theObject the object which elements should be processed
3128 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3129 # @param PathShape shape(edge) defines the sub-mesh for the path
3130 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3131 # @param HasAngles allows the shape to be rotated around the path
3132 # to get the resulting mesh in a helical fashion
3133 # @param Angles list of angles
3134 # @param HasRefPoint allows using the reference point
3135 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3136 # The User can specify any point as the Reference Point.
3137 # @param MakeGroups forces the generation of new groups from existing ones
3138 # @param LinearVariation forces the computation of rotation angles as linear
3139 # variation of the given Angles along path steps
3140 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3141 # only SMESH::Extrusion_Error otherwise
3142 # @ingroup l2_modif_extrurev
3143 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3144 HasAngles, Angles, HasRefPoint, RefPoint,
3145 MakeGroups=False, LinearVariation=False):
3146 Angles,AnglesParameters = ParseAngles(Angles)
3147 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3148 if ( isinstance( theObject, Mesh )):
3149 theObject = theObject.GetMesh()
3150 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3151 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3152 if ( isinstance( PathMesh, Mesh )):
3153 PathMesh = PathMesh.GetMesh()
3154 if HasAngles and Angles and LinearVariation:
3155 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3157 Parameters = AnglesParameters + var_separator + RefPointParameters
3158 self.mesh.SetParameters(Parameters)
3160 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3161 PathShape, NodeStart, HasAngles,
3162 Angles, HasRefPoint, RefPoint)
3163 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3164 NodeStart, HasAngles, Angles, HasRefPoint,
3167 ## Generates new elements by extrusion of the elements which belong to the object
3168 # The path of extrusion must be a meshed edge.
3169 # @param theObject the object which elements should be processed
3170 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3171 # @param PathShape shape(edge) defines the sub-mesh for the path
3172 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3173 # @param HasAngles allows the shape to be rotated around the path
3174 # to get the resulting mesh in a helical fashion
3175 # @param Angles list of angles
3176 # @param HasRefPoint allows using the reference point
3177 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3178 # The User can specify any point as the Reference Point.
3179 # @param MakeGroups forces the generation of new groups from existing ones
3180 # @param LinearVariation forces the computation of rotation angles as linear
3181 # variation of the given Angles along path steps
3182 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3183 # only SMESH::Extrusion_Error otherwise
3184 # @ingroup l2_modif_extrurev
3185 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3186 HasAngles, Angles, HasRefPoint, RefPoint,
3187 MakeGroups=False, LinearVariation=False):
3188 Angles,AnglesParameters = ParseAngles(Angles)
3189 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3190 if ( isinstance( theObject, Mesh )):
3191 theObject = theObject.GetMesh()
3192 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3193 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3194 if ( isinstance( PathMesh, Mesh )):
3195 PathMesh = PathMesh.GetMesh()
3196 if HasAngles and Angles and LinearVariation:
3197 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3199 Parameters = AnglesParameters + var_separator + RefPointParameters
3200 self.mesh.SetParameters(Parameters)
3202 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3203 PathShape, NodeStart, HasAngles,
3204 Angles, HasRefPoint, RefPoint)
3205 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3206 NodeStart, HasAngles, Angles, HasRefPoint,
3209 ## Creates a symmetrical copy of mesh elements
3210 # @param IDsOfElements list of elements ids
3211 # @param Mirror is AxisStruct or geom object(point, line, plane)
3212 # @param theMirrorType is POINT, AXIS or PLANE
3213 # If the Mirror is a geom object this parameter is unnecessary
3214 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3215 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3216 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3217 # @ingroup l2_modif_trsf
3218 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3219 if IDsOfElements == []:
3220 IDsOfElements = self.GetElementsId()
3221 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3222 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3223 Mirror,Parameters = ParseAxisStruct(Mirror)
3224 self.mesh.SetParameters(Parameters)
3225 if Copy and MakeGroups:
3226 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3227 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3230 ## Creates a new mesh by a symmetrical copy of mesh elements
3231 # @param IDsOfElements the list of elements ids
3232 # @param Mirror is AxisStruct or geom object (point, line, plane)
3233 # @param theMirrorType is POINT, AXIS or PLANE
3234 # If the Mirror is a geom object this parameter is unnecessary
3235 # @param MakeGroups to generate new groups from existing ones
3236 # @param NewMeshName a name of the new mesh to create
3237 # @return instance of Mesh class
3238 # @ingroup l2_modif_trsf
3239 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3240 if IDsOfElements == []:
3241 IDsOfElements = self.GetElementsId()
3242 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3243 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3244 Mirror,Parameters = ParseAxisStruct(Mirror)
3245 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3246 MakeGroups, NewMeshName)
3247 mesh.SetParameters(Parameters)
3248 return Mesh(self.smeshpyD,self.geompyD,mesh)
3250 ## Creates a symmetrical copy of the object
3251 # @param theObject mesh, submesh or group
3252 # @param Mirror AxisStruct or geom object (point, line, plane)
3253 # @param theMirrorType is POINT, AXIS or PLANE
3254 # If the Mirror is a geom object this parameter is unnecessary
3255 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3256 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3257 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3258 # @ingroup l2_modif_trsf
3259 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3260 if ( isinstance( theObject, Mesh )):
3261 theObject = theObject.GetMesh()
3262 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3263 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3264 Mirror,Parameters = ParseAxisStruct(Mirror)
3265 self.mesh.SetParameters(Parameters)
3266 if Copy and MakeGroups:
3267 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3268 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3271 ## Creates a new mesh by a symmetrical copy of the object
3272 # @param theObject mesh, submesh or group
3273 # @param Mirror AxisStruct or geom object (point, line, plane)
3274 # @param theMirrorType POINT, AXIS or PLANE
3275 # If the Mirror is a geom object this parameter is unnecessary
3276 # @param MakeGroups forces the generation of new groups from existing ones
3277 # @param NewMeshName the name of the new mesh to create
3278 # @return instance of Mesh class
3279 # @ingroup l2_modif_trsf
3280 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3281 if ( isinstance( theObject, Mesh )):
3282 theObject = theObject.GetMesh()
3283 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3284 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3285 Mirror,Parameters = ParseAxisStruct(Mirror)
3286 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3287 MakeGroups, NewMeshName)
3288 mesh.SetParameters(Parameters)
3289 return Mesh( self.smeshpyD,self.geompyD,mesh )
3291 ## Translates the elements
3292 # @param IDsOfElements list of elements ids
3293 # @param Vector the direction of translation (DirStruct or vector)
3294 # @param Copy allows copying the translated elements
3295 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3296 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3297 # @ingroup l2_modif_trsf
3298 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3299 if IDsOfElements == []:
3300 IDsOfElements = self.GetElementsId()
3301 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3302 Vector = self.smeshpyD.GetDirStruct(Vector)
3303 Vector,Parameters = ParseDirStruct(Vector)
3304 self.mesh.SetParameters(Parameters)
3305 if Copy and MakeGroups:
3306 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3307 self.editor.Translate(IDsOfElements, Vector, Copy)
3310 ## Creates a new mesh of translated elements
3311 # @param IDsOfElements list of elements ids
3312 # @param Vector the direction of translation (DirStruct or vector)
3313 # @param MakeGroups forces the generation of new groups from existing ones
3314 # @param NewMeshName the name of the newly created mesh
3315 # @return instance of Mesh class
3316 # @ingroup l2_modif_trsf
3317 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3318 if IDsOfElements == []:
3319 IDsOfElements = self.GetElementsId()
3320 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3321 Vector = self.smeshpyD.GetDirStruct(Vector)
3322 Vector,Parameters = ParseDirStruct(Vector)
3323 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3324 mesh.SetParameters(Parameters)
3325 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3327 ## Translates the object
3328 # @param theObject the object to translate (mesh, submesh, or group)
3329 # @param Vector direction of translation (DirStruct or geom vector)
3330 # @param Copy allows copying the translated elements
3331 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3332 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3333 # @ingroup l2_modif_trsf
3334 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3335 if ( isinstance( theObject, Mesh )):
3336 theObject = theObject.GetMesh()
3337 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3338 Vector = self.smeshpyD.GetDirStruct(Vector)
3339 Vector,Parameters = ParseDirStruct(Vector)
3340 self.mesh.SetParameters(Parameters)
3341 if Copy and MakeGroups:
3342 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3343 self.editor.TranslateObject(theObject, Vector, Copy)
3346 ## Creates a new mesh from the translated object
3347 # @param theObject the object to translate (mesh, submesh, or group)
3348 # @param Vector the direction of translation (DirStruct or geom vector)
3349 # @param MakeGroups forces the generation of new groups from existing ones
3350 # @param NewMeshName the name of the newly created mesh
3351 # @return instance of Mesh class
3352 # @ingroup l2_modif_trsf
3353 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3354 if (isinstance(theObject, Mesh)):
3355 theObject = theObject.GetMesh()
3356 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3357 Vector = self.smeshpyD.GetDirStruct(Vector)
3358 Vector,Parameters = ParseDirStruct(Vector)
3359 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3360 mesh.SetParameters(Parameters)
3361 return Mesh( self.smeshpyD, self.geompyD, mesh )
3365 ## Scales the object
3366 # @param theObject - the object to translate (mesh, submesh, or group)
3367 # @param thePoint - base point for scale
3368 # @param theScaleFact - scale factors for axises
3369 # @param Copy - allows copying the translated elements
3370 # @param MakeGroups - forces the generation of new groups from existing
3372 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3373 # empty list otherwise
3374 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3375 if ( isinstance( theObject, Mesh )):
3376 theObject = theObject.GetMesh()
3377 if ( isinstance( theObject, list )):
3378 theObject = self.editor.MakeIDSource(theObject)
3380 thePoint, Parameters = ParsePointStruct(thePoint)
3381 self.mesh.SetParameters(Parameters)
3383 if Copy and MakeGroups:
3384 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3385 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3388 ## Creates a new mesh from the translated object
3389 # @param theObject - the object to translate (mesh, submesh, or group)
3390 # @param thePoint - base point for scale
3391 # @param theScaleFact - scale factors for axises
3392 # @param MakeGroups - forces the generation of new groups from existing ones
3393 # @param NewMeshName - the name of the newly created mesh
3394 # @return instance of Mesh class
3395 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3396 if (isinstance(theObject, Mesh)):
3397 theObject = theObject.GetMesh()
3398 if ( isinstance( theObject, list )):
3399 theObject = self.editor.MakeIDSource(theObject)
3401 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3402 MakeGroups, NewMeshName)
3403 #mesh.SetParameters(Parameters)
3404 return Mesh( self.smeshpyD, self.geompyD, mesh )
3408 ## Rotates the elements
3409 # @param IDsOfElements list of elements ids
3410 # @param Axis the axis of rotation (AxisStruct or geom line)
3411 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3412 # @param Copy allows copying the rotated elements
3413 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3414 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3415 # @ingroup l2_modif_trsf
3416 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3418 if isinstance(AngleInRadians,str):
3420 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3422 AngleInRadians = DegreesToRadians(AngleInRadians)
3423 if IDsOfElements == []:
3424 IDsOfElements = self.GetElementsId()
3425 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3426 Axis = self.smeshpyD.GetAxisStruct(Axis)
3427 Axis,AxisParameters = ParseAxisStruct(Axis)
3428 Parameters = AxisParameters + var_separator + Parameters
3429 self.mesh.SetParameters(Parameters)
3430 if Copy and MakeGroups:
3431 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3432 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3435 ## Creates a new mesh of rotated elements
3436 # @param IDsOfElements list of element ids
3437 # @param Axis the axis of rotation (AxisStruct or geom line)
3438 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3439 # @param MakeGroups forces the generation of new groups from existing ones
3440 # @param NewMeshName the name of the newly created mesh
3441 # @return instance of Mesh class
3442 # @ingroup l2_modif_trsf
3443 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3445 if isinstance(AngleInRadians,str):
3447 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3449 AngleInRadians = DegreesToRadians(AngleInRadians)
3450 if IDsOfElements == []:
3451 IDsOfElements = self.GetElementsId()
3452 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3453 Axis = self.smeshpyD.GetAxisStruct(Axis)
3454 Axis,AxisParameters = ParseAxisStruct(Axis)
3455 Parameters = AxisParameters + var_separator + Parameters
3456 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3457 MakeGroups, NewMeshName)
3458 mesh.SetParameters(Parameters)
3459 return Mesh( self.smeshpyD, self.geompyD, mesh )
3461 ## Rotates the object
3462 # @param theObject the object to rotate( mesh, submesh, or group)
3463 # @param Axis the axis of rotation (AxisStruct or geom line)
3464 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3465 # @param Copy allows copying the rotated elements
3466 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3467 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3468 # @ingroup l2_modif_trsf
3469 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3471 if isinstance(AngleInRadians,str):
3473 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3475 AngleInRadians = DegreesToRadians(AngleInRadians)
3476 if (isinstance(theObject, Mesh)):
3477 theObject = theObject.GetMesh()
3478 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3479 Axis = self.smeshpyD.GetAxisStruct(Axis)
3480 Axis,AxisParameters = ParseAxisStruct(Axis)
3481 Parameters = AxisParameters + ":" + Parameters
3482 self.mesh.SetParameters(Parameters)
3483 if Copy and MakeGroups:
3484 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3485 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3488 ## Creates a new mesh from the rotated object
3489 # @param theObject the object to rotate (mesh, submesh, or group)
3490 # @param Axis the axis of rotation (AxisStruct or geom line)
3491 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3492 # @param MakeGroups forces the generation of new groups from existing ones
3493 # @param NewMeshName the name of the newly created mesh
3494 # @return instance of Mesh class
3495 # @ingroup l2_modif_trsf
3496 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3498 if isinstance(AngleInRadians,str):
3500 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3502 AngleInRadians = DegreesToRadians(AngleInRadians)
3503 if (isinstance( theObject, Mesh )):
3504 theObject = theObject.GetMesh()
3505 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3506 Axis = self.smeshpyD.GetAxisStruct(Axis)
3507 Axis,AxisParameters = ParseAxisStruct(Axis)
3508 Parameters = AxisParameters + ":" + Parameters
3509 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3510 MakeGroups, NewMeshName)
3511 mesh.SetParameters(Parameters)
3512 return Mesh( self.smeshpyD, self.geompyD, mesh )
3514 ## Finds groups of ajacent nodes within Tolerance.
3515 # @param Tolerance the value of tolerance
3516 # @return the list of groups of nodes
3517 # @ingroup l2_modif_trsf
3518 def FindCoincidentNodes (self, Tolerance):
3519 return self.editor.FindCoincidentNodes(Tolerance)
3521 ## Finds groups of ajacent nodes within Tolerance.
3522 # @param Tolerance the value of tolerance
3523 # @param SubMeshOrGroup SubMesh or Group
3524 # @return the list of groups of nodes
3525 # @ingroup l2_modif_trsf
3526 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3527 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3530 # @param GroupsOfNodes the list of groups of nodes
3531 # @ingroup l2_modif_trsf
3532 def MergeNodes (self, GroupsOfNodes):
3533 self.editor.MergeNodes(GroupsOfNodes)
3535 ## Finds the elements built on the same nodes.
3536 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3537 # @return a list of groups of equal elements
3538 # @ingroup l2_modif_trsf
3539 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3540 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3541 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3542 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3544 ## Merges elements in each given group.
3545 # @param GroupsOfElementsID groups of elements for merging
3546 # @ingroup l2_modif_trsf
3547 def MergeElements(self, GroupsOfElementsID):
3548 self.editor.MergeElements(GroupsOfElementsID)
3550 ## Leaves one element and removes all other elements built on the same nodes.
3551 # @ingroup l2_modif_trsf
3552 def MergeEqualElements(self):
3553 self.editor.MergeEqualElements()
3555 ## Sews free borders
3556 # @return SMESH::Sew_Error
3557 # @ingroup l2_modif_trsf
3558 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3559 FirstNodeID2, SecondNodeID2, LastNodeID2,
3560 CreatePolygons, CreatePolyedrs):
3561 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3562 FirstNodeID2, SecondNodeID2, LastNodeID2,
3563 CreatePolygons, CreatePolyedrs)
3565 ## Sews conform free borders
3566 # @return SMESH::Sew_Error
3567 # @ingroup l2_modif_trsf
3568 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3569 FirstNodeID2, SecondNodeID2):
3570 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3571 FirstNodeID2, SecondNodeID2)
3573 ## Sews border to side
3574 # @return SMESH::Sew_Error
3575 # @ingroup l2_modif_trsf
3576 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3577 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3578 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3579 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3581 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3582 # merged with the nodes of elements of Side2.
3583 # The number of elements in theSide1 and in theSide2 must be
3584 # equal and they should have similar nodal connectivity.
3585 # The nodes to merge should belong to side borders and
3586 # the first node should be linked to the second.
3587 # @return SMESH::Sew_Error
3588 # @ingroup l2_modif_trsf
3589 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3590 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3591 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3592 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3593 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3594 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3596 ## Sets new nodes for the given element.
3597 # @param ide the element id
3598 # @param newIDs nodes ids
3599 # @return If the number of nodes does not correspond to the type of element - returns false
3600 # @ingroup l2_modif_edit
3601 def ChangeElemNodes(self, ide, newIDs):
3602 return self.editor.ChangeElemNodes(ide, newIDs)
3604 ## If during the last operation of MeshEditor some nodes were
3605 # created, this method returns the list of their IDs, \n
3606 # if new nodes were not created - returns empty list
3607 # @return the list of integer values (can be empty)
3608 # @ingroup l1_auxiliary
3609 def GetLastCreatedNodes(self):
3610 return self.editor.GetLastCreatedNodes()
3612 ## If during the last operation of MeshEditor some elements were
3613 # created this method returns the list of their IDs, \n
3614 # if new elements were not created - returns empty list
3615 # @return the list of integer values (can be empty)
3616 # @ingroup l1_auxiliary
3617 def GetLastCreatedElems(self):
3618 return self.editor.GetLastCreatedElems()
3620 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3621 # @param theNodes identifiers of nodes to be doubled
3622 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3623 # nodes. If list of element identifiers is empty then nodes are doubled but
3624 # they not assigned to elements
3625 # @return TRUE if operation has been completed successfully, FALSE otherwise
3626 # @ingroup l2_modif_edit
3627 def DoubleNodes(self, theNodes, theModifiedElems):
3628 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3630 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3631 # This method provided for convenience works as DoubleNodes() described above.
3632 # @param theNodes identifiers of node to be doubled
3633 # @param theModifiedElems identifiers of elements to be updated
3634 # @return TRUE if operation has been completed successfully, FALSE otherwise
3635 # @ingroup l2_modif_edit
3636 def DoubleNode(self, theNodeId, theModifiedElems):
3637 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3639 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3640 # This method provided for convenience works as DoubleNodes() described above.
3641 # @param theNodes group of nodes to be doubled
3642 # @param theModifiedElems group of elements to be updated.
3643 # @return TRUE if operation has been completed successfully, FALSE otherwise
3644 # @ingroup l2_modif_edit
3645 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3646 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3648 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3649 # This method provided for convenience works as DoubleNodes() described above.
3650 # @param theNodes list of groups of nodes to be doubled
3651 # @param theModifiedElems list of groups of elements to be updated.
3652 # @return TRUE if operation has been completed successfully, FALSE otherwise
3653 # @ingroup l2_modif_edit
3654 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3655 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3657 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3658 # @param theElems - the list of elements (edges or faces) to be replicated
3659 # The nodes for duplication could be found from these elements
3660 # @param theNodesNot - list of nodes to NOT replicate
3661 # @param theAffectedElems - the list of elements (cells and edges) to which the
3662 # replicated nodes should be associated to.
3663 # @return TRUE if operation has been completed successfully, FALSE otherwise
3664 # @ingroup l2_modif_edit
3665 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3666 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3668 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3669 # @param theElems - the list of elements (edges or faces) to be replicated
3670 # The nodes for duplication could be found from these elements
3671 # @param theNodesNot - list of nodes to NOT replicate
3672 # @param theShape - shape to detect affected elements (element which geometric center
3673 # located on or inside shape).
3674 # The replicated nodes should be associated to affected elements.
3675 # @return TRUE if operation has been completed successfully, FALSE otherwise
3676 # @ingroup l2_modif_edit
3677 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3678 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3680 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3681 # This method provided for convenience works as DoubleNodes() described above.
3682 # @param theElems - group of of elements (edges or faces) to be replicated
3683 # @param theNodesNot - group of nodes not to replicated
3684 # @param theAffectedElems - group of elements to which the replicated nodes
3685 # should be associated to.
3686 # @ingroup l2_modif_edit
3687 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
3688 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3690 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3691 # This method provided for convenience works as DoubleNodes() described above.
3692 # @param theElems - group of of elements (edges or faces) to be replicated
3693 # @param theNodesNot - group of nodes not to replicated
3694 # @param theShape - shape to detect affected elements (element which geometric center
3695 # located on or inside shape).
3696 # The replicated nodes should be associated to affected elements.
3697 # @ingroup l2_modif_edit
3698 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3699 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3701 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3702 # This method provided for convenience works as DoubleNodes() described above.
3703 # @param theElems - list of groups of elements (edges or faces) to be replicated
3704 # @param theNodesNot - list of groups of nodes not to replicated
3705 # @param theAffectedElems - group of elements to which the replicated nodes
3706 # should be associated to.
3707 # @return TRUE if operation has been completed successfully, FALSE otherwise
3708 # @ingroup l2_modif_edit
3709 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3710 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3712 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3713 # This method provided for convenience works as DoubleNodes() described above.
3714 # @param theElems - list of groups of elements (edges or faces) to be replicated
3715 # @param theNodesNot - list of groups of nodes not to replicated
3716 # @param theShape - shape to detect affected elements (element which geometric center
3717 # located on or inside shape).
3718 # The replicated nodes should be associated to affected elements.
3719 # @return TRUE if operation has been completed successfully, FALSE otherwise
3720 # @ingroup l2_modif_edit
3721 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3722 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3724 ## The mother class to define algorithm, it is not recommended to use it directly.
3727 # @ingroup l2_algorithms
3728 class Mesh_Algorithm:
3729 # @class Mesh_Algorithm
3730 # @brief Class Mesh_Algorithm
3732 #def __init__(self,smesh):
3740 ## Finds a hypothesis in the study by its type name and parameters.
3741 # Finds only the hypotheses created in smeshpyD engine.
3742 # @return SMESH.SMESH_Hypothesis
3743 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3744 study = smeshpyD.GetCurrentStudy()
3745 #to do: find component by smeshpyD object, not by its data type
3746 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3747 if scomp is not None:
3748 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3749 # Check if the root label of the hypotheses exists
3750 if res and hypRoot is not None:
3751 iter = study.NewChildIterator(hypRoot)
3752 # Check all published hypotheses
3754 hypo_so_i = iter.Value()
3755 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3756 if attr is not None:
3757 anIOR = attr.Value()
3758 hypo_o_i = salome.orb.string_to_object(anIOR)
3759 if hypo_o_i is not None:
3760 # Check if this is a hypothesis
3761 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3762 if hypo_i is not None:
3763 # Check if the hypothesis belongs to current engine
3764 if smeshpyD.GetObjectId(hypo_i) > 0:
3765 # Check if this is the required hypothesis
3766 if hypo_i.GetName() == hypname:
3768 if CompareMethod(hypo_i, args):
3782 ## Finds the algorithm in the study by its type name.
3783 # Finds only the algorithms, which have been created in smeshpyD engine.
3784 # @return SMESH.SMESH_Algo
3785 def FindAlgorithm (self, algoname, smeshpyD):
3786 study = smeshpyD.GetCurrentStudy()
3787 #to do: find component by smeshpyD object, not by its data type
3788 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3789 if scomp is not None:
3790 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3791 # Check if the root label of the algorithms exists
3792 if res and hypRoot is not None:
3793 iter = study.NewChildIterator(hypRoot)
3794 # Check all published algorithms
3796 algo_so_i = iter.Value()
3797 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3798 if attr is not None:
3799 anIOR = attr.Value()
3800 algo_o_i = salome.orb.string_to_object(anIOR)
3801 if algo_o_i is not None:
3802 # Check if this is an algorithm
3803 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3804 if algo_i is not None:
3805 # Checks if the algorithm belongs to the current engine
3806 if smeshpyD.GetObjectId(algo_i) > 0:
3807 # Check if this is the required algorithm
3808 if algo_i.GetName() == algoname:
3821 ## If the algorithm is global, returns 0; \n
3822 # else returns the submesh associated to this algorithm.
3823 def GetSubMesh(self):
3826 ## Returns the wrapped mesher.
3827 def GetAlgorithm(self):
3830 ## Gets the list of hypothesis that can be used with this algorithm
3831 def GetCompatibleHypothesis(self):
3834 mylist = self.algo.GetCompatibleHypothesis()
3837 ## Gets the name of the algorithm
3841 ## Sets the name to the algorithm
3842 def SetName(self, name):
3843 self.mesh.smeshpyD.SetName(self.algo, name)
3845 ## Gets the id of the algorithm
3847 return self.algo.GetId()
3850 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3852 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3853 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3855 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3857 self.Assign(algo, mesh, geom)
3861 def Assign(self, algo, mesh, geom):
3863 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3872 name = GetName(geom)
3875 name = mesh.geompyD.SubShapeName(geom, piece)
3876 mesh.geompyD.addToStudyInFather(piece, geom, name)
3878 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3881 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3882 TreatHypoStatus( status, algo.GetName(), name, True )
3884 def CompareHyp (self, hyp, args):
3885 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3888 def CompareEqualHyp (self, hyp, args):
3892 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3893 UseExisting=0, CompareMethod=""):
3896 if CompareMethod == "": CompareMethod = self.CompareHyp
3897 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3900 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3906 a = a + s + str(args[i])
3910 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3912 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3913 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3916 ## Returns entry of the shape to mesh in the study
3917 def MainShapeEntry(self):
3919 if not self.mesh or not self.mesh.GetMesh(): return entry
3920 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3921 study = self.mesh.smeshpyD.GetCurrentStudy()
3922 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3923 sobj = study.FindObjectIOR(ior)
3924 if sobj: entry = sobj.GetID()
3925 if not entry: return ""
3928 # Public class: Mesh_Segment
3929 # --------------------------
3931 ## Class to define a segment 1D algorithm for discretization
3934 # @ingroup l3_algos_basic
3935 class Mesh_Segment(Mesh_Algorithm):
3937 ## Private constructor.
3938 def __init__(self, mesh, geom=0):
3939 Mesh_Algorithm.__init__(self)
3940 self.Create(mesh, geom, "Regular_1D")
3942 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3943 # @param l for the length of segments that cut an edge
3944 # @param UseExisting if ==true - searches for an existing hypothesis created with
3945 # the same parameters, else (default) - creates a new one
3946 # @param p precision, used for calculation of the number of segments.
3947 # The precision should be a positive, meaningful value within the range [0,1].
3948 # In general, the number of segments is calculated with the formula:
3949 # nb = ceil((edge_length / l) - p)
3950 # Function ceil rounds its argument to the higher integer.
3951 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3952 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3953 # p=1 means rounding of (edge_length / l) to the lower integer.
3954 # Default value is 1e-07.
3955 # @return an instance of StdMeshers_LocalLength hypothesis
3956 # @ingroup l3_hypos_1dhyps
3957 def LocalLength(self, l, UseExisting=0, p=1e-07):
3958 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3959 CompareMethod=self.CompareLocalLength)
3965 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3966 def CompareLocalLength(self, hyp, args):
3967 if IsEqual(hyp.GetLength(), args[0]):
3968 return IsEqual(hyp.GetPrecision(), args[1])
3971 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3972 # @param length is optional maximal allowed length of segment, if it is omitted
3973 # the preestimated length is used that depends on geometry size
3974 # @param UseExisting if ==true - searches for an existing hypothesis created with
3975 # the same parameters, else (default) - create a new one
3976 # @return an instance of StdMeshers_MaxLength hypothesis
3977 # @ingroup l3_hypos_1dhyps
3978 def MaxSize(self, length=0.0, UseExisting=0):
3979 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3982 hyp.SetLength(length)
3984 # set preestimated length
3985 gen = self.mesh.smeshpyD
3986 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3987 self.mesh.GetMesh(), self.mesh.GetShape(),
3989 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3991 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3994 hyp.SetUsePreestimatedLength( length == 0.0 )
3997 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3998 # @param n for the number of segments that cut an edge
3999 # @param s for the scale factor (optional)
4000 # @param reversedEdges is a list of edges to mesh using reversed orientation
4001 # @param UseExisting if ==true - searches for an existing hypothesis created with
4002 # the same parameters, else (default) - create a new one
4003 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4004 # @ingroup l3_hypos_1dhyps
4005 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4006 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4007 reversedEdges, UseExisting = [], reversedEdges
4008 entry = self.MainShapeEntry()
4010 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4011 UseExisting=UseExisting,
4012 CompareMethod=self.CompareNumberOfSegments)
4014 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4015 UseExisting=UseExisting,
4016 CompareMethod=self.CompareNumberOfSegments)
4017 hyp.SetDistrType( 1 )
4018 hyp.SetScaleFactor(s)
4019 hyp.SetNumberOfSegments(n)
4020 hyp.SetReversedEdges( reversedEdges )
4021 hyp.SetObjectEntry( entry )
4025 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4026 def CompareNumberOfSegments(self, hyp, args):
4027 if hyp.GetNumberOfSegments() == args[0]:
4029 if hyp.GetReversedEdges() == args[1]:
4030 if not args[1] or hyp.GetObjectEntry() == args[2]:
4033 if hyp.GetReversedEdges() == args[2]:
4034 if not args[2] or hyp.GetObjectEntry() == args[3]:
4035 if hyp.GetDistrType() == 1:
4036 if IsEqual(hyp.GetScaleFactor(), args[1]):
4040 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4041 # @param start defines the length of the first segment
4042 # @param end defines the length of the last segment
4043 # @param reversedEdges is a list of edges to mesh using reversed orientation
4044 # @param UseExisting if ==true - searches for an existing hypothesis created with
4045 # the same parameters, else (default) - creates a new one
4046 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4047 # @ingroup l3_hypos_1dhyps
4048 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4049 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4050 reversedEdges, UseExisting = [], reversedEdges
4051 entry = self.MainShapeEntry()
4052 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4053 UseExisting=UseExisting,
4054 CompareMethod=self.CompareArithmetic1D)
4055 hyp.SetStartLength(start)
4056 hyp.SetEndLength(end)
4057 hyp.SetReversedEdges( reversedEdges )
4058 hyp.SetObjectEntry( entry )
4062 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4063 def CompareArithmetic1D(self, hyp, args):
4064 if IsEqual(hyp.GetLength(1), args[0]):
4065 if IsEqual(hyp.GetLength(0), args[1]):
4066 if hyp.GetReversedEdges() == args[2]:
4067 if not args[2] or hyp.GetObjectEntry() == args[3]:
4072 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4073 # on curve from 0 to 1 (additionally it is neecessary to check
4074 # orientation of edges and create list of reversed edges if it is
4075 # needed) and sets numbers of segments between given points (default
4076 # values are equals 1
4077 # @param points defines the list of parameters on curve
4078 # @param nbSegs defines the list of numbers of segments
4079 # @param reversedEdges is a list of edges to mesh using reversed orientation
4080 # @param UseExisting if ==true - searches for an existing hypothesis created with
4081 # the same parameters, else (default) - creates a new one
4082 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4083 # @ingroup l3_hypos_1dhyps
4084 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4085 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4086 reversedEdges, UseExisting = [], reversedEdges
4087 if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4088 for i in range( len( reversedEdges )):
4089 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4090 entry = self.MainShapeEntry()
4091 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4092 UseExisting=UseExisting,
4093 CompareMethod=self.CompareFixedPoints1D)
4094 hyp.SetPoints(points)
4095 hyp.SetNbSegments(nbSegs)
4096 hyp.SetReversedEdges(reversedEdges)
4097 hyp.SetObjectEntry(entry)
4101 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4102 ## as the given arguments
4103 def CompareFixedPoints1D(self, hyp, args):
4104 if hyp.GetPoints() == args[0]:
4105 if hyp.GetNbSegments() == args[1]:
4106 if hyp.GetReversedEdges() == args[2]:
4107 if not args[2] or hyp.GetObjectEntry() == args[3]:
4113 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4114 # @param start defines the length of the first segment
4115 # @param end defines the length of the last segment
4116 # @param reversedEdges is a list of edges to mesh using reversed orientation
4117 # @param UseExisting if ==true - searches for an existing hypothesis created with
4118 # the same parameters, else (default) - creates a new one
4119 # @return an instance of StdMeshers_StartEndLength hypothesis
4120 # @ingroup l3_hypos_1dhyps
4121 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4122 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4123 reversedEdges, UseExisting = [], reversedEdges
4124 entry = self.MainShapeEntry()
4125 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4126 UseExisting=UseExisting,
4127 CompareMethod=self.CompareStartEndLength)
4128 hyp.SetStartLength(start)
4129 hyp.SetEndLength(end)
4130 hyp.SetReversedEdges( reversedEdges )
4131 hyp.SetObjectEntry( entry )
4134 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4135 def CompareStartEndLength(self, hyp, args):
4136 if IsEqual(hyp.GetLength(1), args[0]):
4137 if IsEqual(hyp.GetLength(0), args[1]):
4138 if hyp.GetReversedEdges() == args[2]:
4139 if not args[2] or hyp.GetObjectEntry() == args[3]:
4143 ## Defines "Deflection1D" hypothesis
4144 # @param d for the deflection
4145 # @param UseExisting if ==true - searches for an existing hypothesis created with
4146 # the same parameters, else (default) - create a new one
4147 # @ingroup l3_hypos_1dhyps
4148 def Deflection1D(self, d, UseExisting=0):
4149 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4150 CompareMethod=self.CompareDeflection1D)
4151 hyp.SetDeflection(d)
4154 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4155 def CompareDeflection1D(self, hyp, args):
4156 return IsEqual(hyp.GetDeflection(), args[0])
4158 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4159 # the opposite side in case of quadrangular faces
4160 # @ingroup l3_hypos_additi
4161 def Propagation(self):
4162 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4164 ## Defines "AutomaticLength" hypothesis
4165 # @param fineness for the fineness [0-1]
4166 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4167 # same parameters, else (default) - create a new one
4168 # @ingroup l3_hypos_1dhyps
4169 def AutomaticLength(self, fineness=0, UseExisting=0):
4170 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4171 CompareMethod=self.CompareAutomaticLength)
4172 hyp.SetFineness( fineness )
4175 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4176 def CompareAutomaticLength(self, hyp, args):
4177 return IsEqual(hyp.GetFineness(), args[0])
4179 ## Defines "SegmentLengthAroundVertex" hypothesis
4180 # @param length for the segment length
4181 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4182 # Any other integer value means that the hypothesis will be set on the
4183 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4184 # @param UseExisting if ==true - searches for an existing hypothesis created with
4185 # the same parameters, else (default) - creates a new one
4186 # @ingroup l3_algos_segmarv
4187 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4189 store_geom = self.geom
4190 if type(vertex) is types.IntType:
4191 if vertex == 0 or vertex == 1:
4192 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4200 if self.geom is None:
4201 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4203 name = GetName(self.geom)
4206 piece = self.mesh.geom
4207 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4208 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4210 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4212 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4214 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4215 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4217 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4218 CompareMethod=self.CompareLengthNearVertex)
4219 self.geom = store_geom
4220 hyp.SetLength( length )
4223 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4224 # @ingroup l3_algos_segmarv
4225 def CompareLengthNearVertex(self, hyp, args):
4226 return IsEqual(hyp.GetLength(), args[0])
4228 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4229 # If the 2D mesher sees that all boundary edges are quadratic,
4230 # it generates quadratic faces, else it generates linear faces using
4231 # medium nodes as if they are vertices.
4232 # The 3D mesher generates quadratic volumes only if all boundary faces
4233 # are quadratic, else it fails.
4235 # @ingroup l3_hypos_additi
4236 def QuadraticMesh(self):
4237 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4240 # Public class: Mesh_CompositeSegment
4241 # --------------------------
4243 ## Defines a segment 1D algorithm for discretization
4245 # @ingroup l3_algos_basic
4246 class Mesh_CompositeSegment(Mesh_Segment):
4248 ## Private constructor.
4249 def __init__(self, mesh, geom=0):
4250 self.Create(mesh, geom, "CompositeSegment_1D")
4253 # Public class: Mesh_Segment_Python
4254 # ---------------------------------
4256 ## Defines a segment 1D algorithm for discretization with python function
4258 # @ingroup l3_algos_basic
4259 class Mesh_Segment_Python(Mesh_Segment):
4261 ## Private constructor.
4262 def __init__(self, mesh, geom=0):
4263 import Python1dPlugin
4264 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4266 ## Defines "PythonSplit1D" hypothesis
4267 # @param n for the number of segments that cut an edge
4268 # @param func for the python function that calculates the length of all segments
4269 # @param UseExisting if ==true - searches for the existing hypothesis created with
4270 # the same parameters, else (default) - creates a new one
4271 # @ingroup l3_hypos_1dhyps
4272 def PythonSplit1D(self, n, func, UseExisting=0):
4273 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4274 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4275 hyp.SetNumberOfSegments(n)
4276 hyp.SetPythonLog10RatioFunction(func)
4279 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4280 def ComparePythonSplit1D(self, hyp, args):
4281 #if hyp.GetNumberOfSegments() == args[0]:
4282 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4286 # Public class: Mesh_Triangle
4287 # ---------------------------
4289 ## Defines a triangle 2D algorithm
4291 # @ingroup l3_algos_basic
4292 class Mesh_Triangle(Mesh_Algorithm):
4301 ## Private constructor.
4302 def __init__(self, mesh, algoType, geom=0):
4303 Mesh_Algorithm.__init__(self)
4305 self.algoType = algoType
4306 if algoType == MEFISTO:
4307 self.Create(mesh, geom, "MEFISTO_2D")
4309 elif algoType == BLSURF:
4311 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4312 #self.SetPhysicalMesh() - PAL19680
4313 elif algoType == NETGEN:
4315 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4317 elif algoType == NETGEN_2D:
4319 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4322 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4323 # @param area for the maximum area of each triangle
4324 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4325 # same parameters, else (default) - creates a new one
4327 # Only for algoType == MEFISTO || NETGEN_2D
4328 # @ingroup l3_hypos_2dhyps
4329 def MaxElementArea(self, area, UseExisting=0):
4330 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4331 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4332 CompareMethod=self.CompareMaxElementArea)
4333 elif self.algoType == NETGEN:
4334 hyp = self.Parameters(SIMPLE)
4335 hyp.SetMaxElementArea(area)
4338 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4339 def CompareMaxElementArea(self, hyp, args):
4340 return IsEqual(hyp.GetMaxElementArea(), args[0])
4342 ## Defines "LengthFromEdges" hypothesis to build triangles
4343 # based on the length of the edges taken from the wire
4345 # Only for algoType == MEFISTO || NETGEN_2D
4346 # @ingroup l3_hypos_2dhyps
4347 def LengthFromEdges(self):
4348 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4349 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4351 elif self.algoType == NETGEN:
4352 hyp = self.Parameters(SIMPLE)
4353 hyp.LengthFromEdges()
4356 ## Sets a way to define size of mesh elements to generate.
4357 # @param thePhysicalMesh is: DefaultSize or Custom.
4358 # @ingroup l3_hypos_blsurf
4359 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4360 # Parameter of BLSURF algo
4361 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4363 ## Sets size of mesh elements to generate.
4364 # @ingroup l3_hypos_blsurf
4365 def SetPhySize(self, theVal):
4366 # Parameter of BLSURF algo
4367 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4368 self.Parameters().SetPhySize(theVal)
4370 ## Sets lower boundary of mesh element size (PhySize).
4371 # @ingroup l3_hypos_blsurf
4372 def SetPhyMin(self, theVal=-1):
4373 # Parameter of BLSURF algo
4374 self.Parameters().SetPhyMin(theVal)
4376 ## Sets upper boundary of mesh element size (PhySize).
4377 # @ingroup l3_hypos_blsurf
4378 def SetPhyMax(self, theVal=-1):
4379 # Parameter of BLSURF algo
4380 self.Parameters().SetPhyMax(theVal)
4382 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4383 # @param theGeometricMesh is: DefaultGeom or Custom
4384 # @ingroup l3_hypos_blsurf
4385 def SetGeometricMesh(self, theGeometricMesh=0):
4386 # Parameter of BLSURF algo
4387 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4388 self.params.SetGeometricMesh(theGeometricMesh)
4390 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4391 # @ingroup l3_hypos_blsurf
4392 def SetAngleMeshS(self, theVal=_angleMeshS):
4393 # Parameter of BLSURF algo
4394 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4395 self.params.SetAngleMeshS(theVal)
4397 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4398 # @ingroup l3_hypos_blsurf
4399 def SetAngleMeshC(self, theVal=_angleMeshS):
4400 # Parameter of BLSURF algo
4401 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4402 self.params.SetAngleMeshC(theVal)
4404 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4405 # @ingroup l3_hypos_blsurf
4406 def SetGeoMin(self, theVal=-1):
4407 # Parameter of BLSURF algo
4408 self.Parameters().SetGeoMin(theVal)
4410 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4411 # @ingroup l3_hypos_blsurf
4412 def SetGeoMax(self, theVal=-1):
4413 # Parameter of BLSURF algo
4414 self.Parameters().SetGeoMax(theVal)
4416 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4417 # @ingroup l3_hypos_blsurf
4418 def SetGradation(self, theVal=_gradation):
4419 # Parameter of BLSURF algo
4420 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4421 self.params.SetGradation(theVal)
4423 ## Sets topology usage way.
4424 # @param way defines how mesh conformity is assured <ul>
4425 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4426 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4427 # @ingroup l3_hypos_blsurf
4428 def SetTopology(self, way):
4429 # Parameter of BLSURF algo
4430 self.Parameters().SetTopology(way)
4432 ## To respect geometrical edges or not.
4433 # @ingroup l3_hypos_blsurf
4434 def SetDecimesh(self, toIgnoreEdges=False):
4435 # Parameter of BLSURF algo
4436 self.Parameters().SetDecimesh(toIgnoreEdges)
4438 ## Sets verbosity level in the range 0 to 100.
4439 # @ingroup l3_hypos_blsurf
4440 def SetVerbosity(self, level):
4441 # Parameter of BLSURF algo
4442 self.Parameters().SetVerbosity(level)
4444 ## Sets advanced option value.
4445 # @ingroup l3_hypos_blsurf
4446 def SetOptionValue(self, optionName, level):
4447 # Parameter of BLSURF algo
4448 self.Parameters().SetOptionValue(optionName,level)
4450 ## Sets QuadAllowed flag.
4451 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4452 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4453 def SetQuadAllowed(self, toAllow=True):
4454 if self.algoType == NETGEN_2D:
4455 if toAllow: # add QuadranglePreference
4456 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4457 else: # remove QuadranglePreference
4458 for hyp in self.mesh.GetHypothesisList( self.geom ):
4459 if hyp.GetName() == "QuadranglePreference":
4460 self.mesh.RemoveHypothesis( self.geom, hyp )
4465 if self.Parameters():
4466 self.params.SetQuadAllowed(toAllow)
4469 ## Defines hypothesis having several parameters
4471 # @ingroup l3_hypos_netgen
4472 def Parameters(self, which=SOLE):
4475 if self.algoType == NETGEN:
4477 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4478 "libNETGENEngine.so", UseExisting=0)
4480 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4481 "libNETGENEngine.so", UseExisting=0)
4483 elif self.algoType == MEFISTO:
4484 print "Mefisto algo support no multi-parameter hypothesis"
4486 elif self.algoType == NETGEN_2D:
4487 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4488 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4490 elif self.algoType == BLSURF:
4491 self.params = self.Hypothesis("BLSURF_Parameters", [],
4492 "libBLSURFEngine.so", UseExisting=0)
4495 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4500 # Only for algoType == NETGEN
4501 # @ingroup l3_hypos_netgen
4502 def SetMaxSize(self, theSize):
4503 if self.Parameters():
4504 self.params.SetMaxSize(theSize)
4506 ## Sets SecondOrder flag
4508 # Only for algoType == NETGEN
4509 # @ingroup l3_hypos_netgen
4510 def SetSecondOrder(self, theVal):
4511 if self.Parameters():
4512 self.params.SetSecondOrder(theVal)
4514 ## Sets Optimize flag
4516 # Only for algoType == NETGEN
4517 # @ingroup l3_hypos_netgen
4518 def SetOptimize(self, theVal):
4519 if self.Parameters():
4520 self.params.SetOptimize(theVal)
4523 # @param theFineness is:
4524 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4526 # Only for algoType == NETGEN
4527 # @ingroup l3_hypos_netgen
4528 def SetFineness(self, theFineness):
4529 if self.Parameters():
4530 self.params.SetFineness(theFineness)
4534 # Only for algoType == NETGEN
4535 # @ingroup l3_hypos_netgen
4536 def SetGrowthRate(self, theRate):
4537 if self.Parameters():
4538 self.params.SetGrowthRate(theRate)
4540 ## Sets NbSegPerEdge
4542 # Only for algoType == NETGEN
4543 # @ingroup l3_hypos_netgen
4544 def SetNbSegPerEdge(self, theVal):
4545 if self.Parameters():
4546 self.params.SetNbSegPerEdge(theVal)
4548 ## Sets NbSegPerRadius
4550 # Only for algoType == NETGEN
4551 # @ingroup l3_hypos_netgen
4552 def SetNbSegPerRadius(self, theVal):
4553 if self.Parameters():
4554 self.params.SetNbSegPerRadius(theVal)
4556 ## Sets number of segments overriding value set by SetLocalLength()
4558 # Only for algoType == NETGEN
4559 # @ingroup l3_hypos_netgen
4560 def SetNumberOfSegments(self, theVal):
4561 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4563 ## Sets number of segments overriding value set by SetNumberOfSegments()
4565 # Only for algoType == NETGEN
4566 # @ingroup l3_hypos_netgen
4567 def SetLocalLength(self, theVal):
4568 self.Parameters(SIMPLE).SetLocalLength(theVal)
4573 # Public class: Mesh_Quadrangle
4574 # -----------------------------
4576 ## Defines a quadrangle 2D algorithm
4578 # @ingroup l3_algos_basic
4579 class Mesh_Quadrangle(Mesh_Algorithm):
4581 ## Private constructor.
4582 def __init__(self, mesh, geom=0):
4583 Mesh_Algorithm.__init__(self)
4584 self.Create(mesh, geom, "Quadrangle_2D")
4586 ## Defines "QuadranglePreference" hypothesis, forcing construction
4587 # of quadrangles if the number of nodes on the opposite edges is not the same
4588 # while the total number of nodes on edges is even
4590 # @ingroup l3_hypos_additi
4591 def QuadranglePreference(self):
4592 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4593 CompareMethod=self.CompareEqualHyp)
4596 ## Defines "TrianglePreference" hypothesis, forcing construction
4597 # of triangles in the refinement area if the number of nodes
4598 # on the opposite edges is not the same
4600 # @ingroup l3_hypos_additi
4601 def TrianglePreference(self):
4602 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4603 CompareMethod=self.CompareEqualHyp)
4606 ## Defines "QuadrangleParams" hypothesis
4607 # @param vertex: vertex of a trilateral geometrical face, around which triangles
4608 # will be created while other elements will be quadrangles.
4609 # Vertex can be either a GEOM_Object or a vertex ID within the
4612 # @ingroup l3_hypos_additi
4613 def TriangleVertex(self, vertex, UseExisting=0):
4615 if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4616 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4617 hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4618 CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4619 hyp.SetTriaVertex( vertexID )
4623 # Public class: Mesh_Tetrahedron
4624 # ------------------------------
4626 ## Defines a tetrahedron 3D algorithm
4628 # @ingroup l3_algos_basic
4629 class Mesh_Tetrahedron(Mesh_Algorithm):
4634 ## Private constructor.
4635 def __init__(self, mesh, algoType, geom=0):
4636 Mesh_Algorithm.__init__(self)
4638 if algoType == NETGEN:
4640 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4643 elif algoType == FULL_NETGEN:
4645 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4648 elif algoType == GHS3D:
4650 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4653 elif algoType == GHS3DPRL:
4654 CheckPlugin(GHS3DPRL)
4655 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4658 self.algoType = algoType
4660 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4661 # @param vol for the maximum volume of each tetrahedron
4662 # @param UseExisting if ==true - searches for the existing hypothesis created with
4663 # the same parameters, else (default) - creates a new one
4664 # @ingroup l3_hypos_maxvol
4665 def MaxElementVolume(self, vol, UseExisting=0):
4666 if self.algoType == NETGEN:
4667 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4668 CompareMethod=self.CompareMaxElementVolume)
4669 hyp.SetMaxElementVolume(vol)
4671 elif self.algoType == FULL_NETGEN:
4672 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4675 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4676 def CompareMaxElementVolume(self, hyp, args):
4677 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4679 ## Defines hypothesis having several parameters
4681 # @ingroup l3_hypos_netgen
4682 def Parameters(self, which=SOLE):
4686 if self.algoType == FULL_NETGEN:
4688 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4689 "libNETGENEngine.so", UseExisting=0)
4691 self.params = self.Hypothesis("NETGEN_Parameters", [],
4692 "libNETGENEngine.so", UseExisting=0)
4695 if self.algoType == GHS3D:
4696 self.params = self.Hypothesis("GHS3D_Parameters", [],
4697 "libGHS3DEngine.so", UseExisting=0)
4700 if self.algoType == GHS3DPRL:
4701 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4702 "libGHS3DPRLEngine.so", UseExisting=0)
4705 print "Algo supports no multi-parameter hypothesis"
4709 # Parameter of FULL_NETGEN
4710 # @ingroup l3_hypos_netgen
4711 def SetMaxSize(self, theSize):
4712 self.Parameters().SetMaxSize(theSize)
4714 ## Sets SecondOrder flag
4715 # Parameter of FULL_NETGEN
4716 # @ingroup l3_hypos_netgen
4717 def SetSecondOrder(self, theVal):
4718 self.Parameters().SetSecondOrder(theVal)
4720 ## Sets Optimize flag
4721 # Parameter of FULL_NETGEN
4722 # @ingroup l3_hypos_netgen
4723 def SetOptimize(self, theVal):
4724 self.Parameters().SetOptimize(theVal)
4727 # @param theFineness is:
4728 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4729 # Parameter of FULL_NETGEN
4730 # @ingroup l3_hypos_netgen
4731 def SetFineness(self, theFineness):
4732 self.Parameters().SetFineness(theFineness)
4735 # Parameter of FULL_NETGEN
4736 # @ingroup l3_hypos_netgen
4737 def SetGrowthRate(self, theRate):
4738 self.Parameters().SetGrowthRate(theRate)
4740 ## Sets NbSegPerEdge
4741 # Parameter of FULL_NETGEN
4742 # @ingroup l3_hypos_netgen
4743 def SetNbSegPerEdge(self, theVal):
4744 self.Parameters().SetNbSegPerEdge(theVal)
4746 ## Sets NbSegPerRadius
4747 # Parameter of FULL_NETGEN
4748 # @ingroup l3_hypos_netgen
4749 def SetNbSegPerRadius(self, theVal):
4750 self.Parameters().SetNbSegPerRadius(theVal)
4752 ## Sets number of segments overriding value set by SetLocalLength()
4753 # Only for algoType == NETGEN_FULL
4754 # @ingroup l3_hypos_netgen
4755 def SetNumberOfSegments(self, theVal):
4756 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4758 ## Sets number of segments overriding value set by SetNumberOfSegments()
4759 # Only for algoType == NETGEN_FULL
4760 # @ingroup l3_hypos_netgen
4761 def SetLocalLength(self, theVal):
4762 self.Parameters(SIMPLE).SetLocalLength(theVal)
4764 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4765 # Overrides value set by LengthFromEdges()
4766 # Only for algoType == NETGEN_FULL
4767 # @ingroup l3_hypos_netgen
4768 def MaxElementArea(self, area):
4769 self.Parameters(SIMPLE).SetMaxElementArea(area)
4771 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4772 # Overrides value set by MaxElementArea()
4773 # Only for algoType == NETGEN_FULL
4774 # @ingroup l3_hypos_netgen
4775 def LengthFromEdges(self):
4776 self.Parameters(SIMPLE).LengthFromEdges()
4778 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4779 # Overrides value set by MaxElementVolume()
4780 # Only for algoType == NETGEN_FULL
4781 # @ingroup l3_hypos_netgen
4782 def LengthFromFaces(self):
4783 self.Parameters(SIMPLE).LengthFromFaces()
4785 ## To mesh "holes" in a solid or not. Default is to mesh.
4786 # @ingroup l3_hypos_ghs3dh
4787 def SetToMeshHoles(self, toMesh):
4788 # Parameter of GHS3D
4789 self.Parameters().SetToMeshHoles(toMesh)
4791 ## Set Optimization level:
4792 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4793 # Strong_Optimization.
4794 # Default is Standard_Optimization
4795 # @ingroup l3_hypos_ghs3dh
4796 def SetOptimizationLevel(self, level):
4797 # Parameter of GHS3D
4798 self.Parameters().SetOptimizationLevel(level)
4800 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4801 # @ingroup l3_hypos_ghs3dh
4802 def SetMaximumMemory(self, MB):
4803 # Advanced parameter of GHS3D
4804 self.Parameters().SetMaximumMemory(MB)
4806 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4807 # automatic memory adjustment mode.
4808 # @ingroup l3_hypos_ghs3dh
4809 def SetInitialMemory(self, MB):
4810 # Advanced parameter of GHS3D
4811 self.Parameters().SetInitialMemory(MB)
4813 ## Path to working directory.
4814 # @ingroup l3_hypos_ghs3dh
4815 def SetWorkingDirectory(self, path):
4816 # Advanced parameter of GHS3D
4817 self.Parameters().SetWorkingDirectory(path)
4819 ## To keep working files or remove them. Log file remains in case of errors anyway.
4820 # @ingroup l3_hypos_ghs3dh
4821 def SetKeepFiles(self, toKeep):
4822 # Advanced parameter of GHS3D and GHS3DPRL
4823 self.Parameters().SetKeepFiles(toKeep)
4825 ## To set verbose level [0-10]. <ul>
4826 #<li> 0 - no standard output,
4827 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4828 # indicates when the final mesh is being saved. In addition the software
4829 # gives indication regarding the CPU time.
4830 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4831 # histogram of the skin mesh, quality statistics histogram together with
4832 # the characteristics of the final mesh.</ul>
4833 # @ingroup l3_hypos_ghs3dh
4834 def SetVerboseLevel(self, level):
4835 # Advanced parameter of GHS3D
4836 self.Parameters().SetVerboseLevel(level)
4838 ## To create new nodes.
4839 # @ingroup l3_hypos_ghs3dh
4840 def SetToCreateNewNodes(self, toCreate):
4841 # Advanced parameter of GHS3D
4842 self.Parameters().SetToCreateNewNodes(toCreate)
4844 ## To use boundary recovery version which tries to create mesh on a very poor
4845 # quality surface mesh.
4846 # @ingroup l3_hypos_ghs3dh
4847 def SetToUseBoundaryRecoveryVersion(self, toUse):
4848 # Advanced parameter of GHS3D
4849 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4851 ## Sets command line option as text.
4852 # @ingroup l3_hypos_ghs3dh
4853 def SetTextOption(self, option):
4854 # Advanced parameter of GHS3D
4855 self.Parameters().SetTextOption(option)
4857 ## Sets MED files name and path.
4858 def SetMEDName(self, value):
4859 self.Parameters().SetMEDName(value)
4861 ## Sets the number of partition of the initial mesh
4862 def SetNbPart(self, value):
4863 self.Parameters().SetNbPart(value)
4865 ## When big mesh, start tepal in background
4866 def SetBackground(self, value):
4867 self.Parameters().SetBackground(value)
4869 # Public class: Mesh_Hexahedron
4870 # ------------------------------
4872 ## Defines a hexahedron 3D algorithm
4874 # @ingroup l3_algos_basic
4875 class Mesh_Hexahedron(Mesh_Algorithm):
4880 ## Private constructor.
4881 def __init__(self, mesh, algoType=Hexa, geom=0):
4882 Mesh_Algorithm.__init__(self)
4884 self.algoType = algoType
4886 if algoType == Hexa:
4887 self.Create(mesh, geom, "Hexa_3D")
4890 elif algoType == Hexotic:
4891 CheckPlugin(Hexotic)
4892 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4895 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4896 # @ingroup l3_hypos_hexotic
4897 def MinMaxQuad(self, min=3, max=8, quad=True):
4898 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4900 self.params.SetHexesMinLevel(min)
4901 self.params.SetHexesMaxLevel(max)
4902 self.params.SetHexoticQuadrangles(quad)
4905 # Deprecated, only for compatibility!
4906 # Public class: Mesh_Netgen
4907 # ------------------------------
4909 ## Defines a NETGEN-based 2D or 3D algorithm
4910 # that needs no discrete boundary (i.e. independent)
4912 # This class is deprecated, only for compatibility!
4915 # @ingroup l3_algos_basic
4916 class Mesh_Netgen(Mesh_Algorithm):
4920 ## Private constructor.
4921 def __init__(self, mesh, is3D, geom=0):
4922 Mesh_Algorithm.__init__(self)
4928 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4932 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4935 ## Defines the hypothesis containing parameters of the algorithm
4936 def Parameters(self):
4938 hyp = self.Hypothesis("NETGEN_Parameters", [],
4939 "libNETGENEngine.so", UseExisting=0)
4941 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4942 "libNETGENEngine.so", UseExisting=0)
4945 # Public class: Mesh_Projection1D
4946 # ------------------------------
4948 ## Defines a projection 1D algorithm
4949 # @ingroup l3_algos_proj
4951 class Mesh_Projection1D(Mesh_Algorithm):
4953 ## Private constructor.
4954 def __init__(self, mesh, geom=0):
4955 Mesh_Algorithm.__init__(self)
4956 self.Create(mesh, geom, "Projection_1D")
4958 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4959 # a mesh pattern is taken, and, optionally, the association of vertices
4960 # between the source edge and a target edge (to which a hypothesis is assigned)
4961 # @param edge from which nodes distribution is taken
4962 # @param mesh from which nodes distribution is taken (optional)
4963 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4964 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4965 # to associate with \a srcV (optional)
4966 # @param UseExisting if ==true - searches for the existing hypothesis created with
4967 # the same parameters, else (default) - creates a new one
4968 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4969 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4971 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4972 hyp.SetSourceEdge( edge )
4973 if not mesh is None and isinstance(mesh, Mesh):
4974 mesh = mesh.GetMesh()
4975 hyp.SetSourceMesh( mesh )
4976 hyp.SetVertexAssociation( srcV, tgtV )
4979 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4980 #def CompareSourceEdge(self, hyp, args):
4981 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4985 # Public class: Mesh_Projection2D
4986 # ------------------------------
4988 ## Defines a projection 2D algorithm
4989 # @ingroup l3_algos_proj
4991 class Mesh_Projection2D(Mesh_Algorithm):
4993 ## Private constructor.
4994 def __init__(self, mesh, geom=0):
4995 Mesh_Algorithm.__init__(self)
4996 self.Create(mesh, geom, "Projection_2D")
4998 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4999 # a mesh pattern is taken, and, optionally, the association of vertices
5000 # between the source face and the target face (to which a hypothesis is assigned)
5001 # @param face from which the mesh pattern is taken
5002 # @param mesh from which the mesh pattern is taken (optional)
5003 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5004 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5005 # to associate with \a srcV1 (optional)
5006 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5007 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5008 # to associate with \a srcV2 (optional)
5009 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5010 # the same parameters, else (default) - forces the creation a new one
5012 # Note: all association vertices must belong to one edge of a face
5013 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5014 srcV2=None, tgtV2=None, UseExisting=0):
5015 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5017 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5018 hyp.SetSourceFace( face )
5019 if not mesh is None and isinstance(mesh, Mesh):
5020 mesh = mesh.GetMesh()
5021 hyp.SetSourceMesh( mesh )
5022 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5025 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5026 #def CompareSourceFace(self, hyp, args):
5027 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5030 # Public class: Mesh_Projection3D
5031 # ------------------------------
5033 ## Defines a projection 3D algorithm
5034 # @ingroup l3_algos_proj
5036 class Mesh_Projection3D(Mesh_Algorithm):
5038 ## Private constructor.
5039 def __init__(self, mesh, geom=0):
5040 Mesh_Algorithm.__init__(self)
5041 self.Create(mesh, geom, "Projection_3D")
5043 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5044 # the mesh pattern is taken, and, optionally, the association of vertices
5045 # between the source and the target solid (to which a hipothesis is assigned)
5046 # @param solid from where the mesh pattern is taken
5047 # @param mesh from where the mesh pattern is taken (optional)
5048 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5049 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5050 # to associate with \a srcV1 (optional)
5051 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5052 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5053 # to associate with \a srcV2 (optional)
5054 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5055 # the same parameters, else (default) - creates a new one
5057 # Note: association vertices must belong to one edge of a solid
5058 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5059 srcV2=0, tgtV2=0, UseExisting=0):
5060 hyp = self.Hypothesis("ProjectionSource3D",
5061 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5063 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5064 hyp.SetSource3DShape( solid )
5065 if not mesh is None and isinstance(mesh, Mesh):
5066 mesh = mesh.GetMesh()
5067 hyp.SetSourceMesh( mesh )
5068 if srcV1 and srcV2 and tgtV1 and tgtV2:
5069 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5070 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5073 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5074 #def CompareSourceShape3D(self, hyp, args):
5075 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5079 # Public class: Mesh_Prism
5080 # ------------------------
5082 ## Defines a 3D extrusion algorithm
5083 # @ingroup l3_algos_3dextr
5085 class Mesh_Prism3D(Mesh_Algorithm):
5087 ## Private constructor.
5088 def __init__(self, mesh, geom=0):
5089 Mesh_Algorithm.__init__(self)
5090 self.Create(mesh, geom, "Prism_3D")
5092 # Public class: Mesh_RadialPrism
5093 # -------------------------------
5095 ## Defines a Radial Prism 3D algorithm
5096 # @ingroup l3_algos_radialp
5098 class Mesh_RadialPrism3D(Mesh_Algorithm):
5100 ## Private constructor.
5101 def __init__(self, mesh, geom=0):
5102 Mesh_Algorithm.__init__(self)
5103 self.Create(mesh, geom, "RadialPrism_3D")
5105 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5106 self.nbLayers = None
5108 ## Return 3D hypothesis holding the 1D one
5109 def Get3DHypothesis(self):
5110 return self.distribHyp
5112 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5113 # hypothesis. Returns the created hypothesis
5114 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5115 #print "OwnHypothesis",hypType
5116 if not self.nbLayers is None:
5117 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5118 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5119 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5120 self.mesh.smeshpyD.SetCurrentStudy( None )
5121 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5122 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5123 self.distribHyp.SetLayerDistribution( hyp )
5126 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5127 # prisms to build between the inner and outer shells
5128 # @param n number of layers
5129 # @param UseExisting if ==true - searches for the existing hypothesis created with
5130 # the same parameters, else (default) - creates a new one
5131 def NumberOfLayers(self, n, UseExisting=0):
5132 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5133 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5134 CompareMethod=self.CompareNumberOfLayers)
5135 self.nbLayers.SetNumberOfLayers( n )
5136 return self.nbLayers
5138 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5139 def CompareNumberOfLayers(self, hyp, args):
5140 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5142 ## Defines "LocalLength" hypothesis, specifying the segment length
5143 # to build between the inner and the outer shells
5144 # @param l the length of segments
5145 # @param p the precision of rounding
5146 def LocalLength(self, l, p=1e-07):
5147 hyp = self.OwnHypothesis("LocalLength", [l,p])
5152 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5153 # prisms to build between the inner and the outer shells.
5154 # @param n the number of layers
5155 # @param s the scale factor (optional)
5156 def NumberOfSegments(self, n, s=[]):
5158 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5160 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5161 hyp.SetDistrType( 1 )
5162 hyp.SetScaleFactor(s)
5163 hyp.SetNumberOfSegments(n)
5166 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5167 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5168 # @param start the length of the first segment
5169 # @param end the length of the last segment
5170 def Arithmetic1D(self, start, end ):
5171 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5172 hyp.SetLength(start, 1)
5173 hyp.SetLength(end , 0)
5176 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5177 # to build between the inner and the outer shells as geometric length increasing
5178 # @param start for the length of the first segment
5179 # @param end for the length of the last segment
5180 def StartEndLength(self, start, end):
5181 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5182 hyp.SetLength(start, 1)
5183 hyp.SetLength(end , 0)
5186 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5187 # to build between the inner and outer shells
5188 # @param fineness defines the quality of the mesh within the range [0-1]
5189 def AutomaticLength(self, fineness=0):
5190 hyp = self.OwnHypothesis("AutomaticLength")
5191 hyp.SetFineness( fineness )
5194 # Public class: Mesh_RadialQuadrangle1D2D
5195 # -------------------------------
5197 ## Defines a Radial Quadrangle 1D2D algorithm
5198 # @ingroup l2_algos_radialq
5200 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5202 ## Private constructor.
5203 def __init__(self, mesh, geom=0):
5204 Mesh_Algorithm.__init__(self)
5205 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5207 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5208 self.nbLayers = None
5210 ## Return 2D hypothesis holding the 1D one
5211 def Get2DHypothesis(self):
5212 return self.distribHyp
5214 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5215 # hypothesis. Returns the created hypothesis
5216 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5217 #print "OwnHypothesis",hypType
5219 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5220 if self.distribHyp is None:
5221 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5223 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5224 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5225 self.mesh.smeshpyD.SetCurrentStudy( None )
5226 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5227 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5228 self.distribHyp.SetLayerDistribution( hyp )
5231 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5232 # @param n number of layers
5233 # @param UseExisting if ==true - searches for the existing hypothesis created with
5234 # the same parameters, else (default) - creates a new one
5235 def NumberOfLayers(self, n, UseExisting=0):
5237 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5238 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5239 CompareMethod=self.CompareNumberOfLayers)
5240 self.nbLayers.SetNumberOfLayers( n )
5241 return self.nbLayers
5243 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5244 def CompareNumberOfLayers(self, hyp, args):
5245 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5247 ## Defines "LocalLength" hypothesis, specifying the segment length
5248 # @param l the length of segments
5249 # @param p the precision of rounding
5250 def LocalLength(self, l, p=1e-07):
5251 hyp = self.OwnHypothesis("LocalLength", [l,p])
5256 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5257 # @param n the number of layers
5258 # @param s the scale factor (optional)
5259 def NumberOfSegments(self, n, s=[]):
5261 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5263 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5264 hyp.SetDistrType( 1 )
5265 hyp.SetScaleFactor(s)
5266 hyp.SetNumberOfSegments(n)
5269 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5270 # with a length that changes in arithmetic progression
5271 # @param start the length of the first segment
5272 # @param end the length of the last segment
5273 def Arithmetic1D(self, start, end ):
5274 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5275 hyp.SetLength(start, 1)
5276 hyp.SetLength(end , 0)
5279 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5280 # as geometric length increasing
5281 # @param start for the length of the first segment
5282 # @param end for the length of the last segment
5283 def StartEndLength(self, start, end):
5284 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5285 hyp.SetLength(start, 1)
5286 hyp.SetLength(end , 0)
5289 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5290 # @param fineness defines the quality of the mesh within the range [0-1]
5291 def AutomaticLength(self, fineness=0):
5292 hyp = self.OwnHypothesis("AutomaticLength")
5293 hyp.SetFineness( fineness )
5297 # Private class: Mesh_UseExisting
5298 # -------------------------------
5299 class Mesh_UseExisting(Mesh_Algorithm):
5301 def __init__(self, dim, mesh, geom=0):
5303 self.Create(mesh, geom, "UseExisting_1D")
5305 self.Create(mesh, geom, "UseExisting_2D")
5308 import salome_notebook
5309 notebook = salome_notebook.notebook
5311 ##Return values of the notebook variables
5312 def ParseParameters(last, nbParams,nbParam, value):
5316 listSize = len(last)
5317 for n in range(0,nbParams):
5319 if counter < listSize:
5320 strResult = strResult + last[counter]
5322 strResult = strResult + ""
5324 if isinstance(value, str):
5325 if notebook.isVariable(value):
5326 result = notebook.get(value)
5327 strResult=strResult+value
5329 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5331 strResult=strResult+str(value)
5333 if nbParams - 1 != counter:
5334 strResult=strResult+var_separator #":"
5336 return result, strResult
5338 #Wrapper class for StdMeshers_LocalLength hypothesis
5339 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5341 ## Set Length parameter value
5342 # @param length numerical value or name of variable from notebook
5343 def SetLength(self, length):
5344 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5345 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5346 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5348 ## Set Precision parameter value
5349 # @param precision numerical value or name of variable from notebook
5350 def SetPrecision(self, precision):
5351 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5352 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5353 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5355 #Registering the new proxy for LocalLength
5356 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5359 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5360 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5362 def SetLayerDistribution(self, hypo):
5363 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5364 hypo.ClearParameters();
5365 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5367 #Registering the new proxy for LayerDistribution
5368 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5370 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5371 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5373 ## Set Length parameter value
5374 # @param length numerical value or name of variable from notebook
5375 def SetLength(self, length):
5376 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5377 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5378 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5380 #Registering the new proxy for SegmentLengthAroundVertex
5381 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5384 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5385 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5387 ## Set Length parameter value
5388 # @param length numerical value or name of variable from notebook
5389 # @param isStart true is length is Start Length, otherwise false
5390 def SetLength(self, length, isStart):
5394 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5395 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5396 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5398 #Registering the new proxy for Arithmetic1D
5399 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5401 #Wrapper class for StdMeshers_Deflection1D hypothesis
5402 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5404 ## Set Deflection parameter value
5405 # @param deflection numerical value or name of variable from notebook
5406 def SetDeflection(self, deflection):
5407 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5408 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5409 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5411 #Registering the new proxy for Deflection1D
5412 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5414 #Wrapper class for StdMeshers_StartEndLength hypothesis
5415 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5417 ## Set Length parameter value
5418 # @param length numerical value or name of variable from notebook
5419 # @param isStart true is length is Start Length, otherwise false
5420 def SetLength(self, length, isStart):
5424 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5425 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5426 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5428 #Registering the new proxy for StartEndLength
5429 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5431 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5432 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5434 ## Set Max Element Area parameter value
5435 # @param area numerical value or name of variable from notebook
5436 def SetMaxElementArea(self, area):
5437 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5438 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5439 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5441 #Registering the new proxy for MaxElementArea
5442 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5445 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5446 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5448 ## Set Max Element Volume parameter value
5449 # @param volume numerical value or name of variable from notebook
5450 def SetMaxElementVolume(self, volume):
5451 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5452 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5453 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5455 #Registering the new proxy for MaxElementVolume
5456 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5459 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5460 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5462 ## Set Number Of Layers parameter value
5463 # @param nbLayers numerical value or name of variable from notebook
5464 def SetNumberOfLayers(self, nbLayers):
5465 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5466 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5467 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5469 #Registering the new proxy for NumberOfLayers
5470 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5472 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5473 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5475 ## Set Number Of Segments parameter value
5476 # @param nbSeg numerical value or name of variable from notebook
5477 def SetNumberOfSegments(self, nbSeg):
5478 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5479 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5480 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5481 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5483 ## Set Scale Factor parameter value
5484 # @param factor numerical value or name of variable from notebook
5485 def SetScaleFactor(self, factor):
5486 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5487 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5488 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5490 #Registering the new proxy for NumberOfSegments
5491 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5493 if not noNETGENPlugin:
5494 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5495 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5497 ## Set Max Size parameter value
5498 # @param maxsize numerical value or name of variable from notebook
5499 def SetMaxSize(self, maxsize):
5500 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5501 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5502 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5503 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5505 ## Set Growth Rate parameter value
5506 # @param value numerical value or name of variable from notebook
5507 def SetGrowthRate(self, value):
5508 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5509 value, parameters = ParseParameters(lastParameters,4,2,value)
5510 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5511 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5513 ## Set Number of Segments per Edge parameter value
5514 # @param value numerical value or name of variable from notebook
5515 def SetNbSegPerEdge(self, value):
5516 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5517 value, parameters = ParseParameters(lastParameters,4,3,value)
5518 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5519 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5521 ## Set Number of Segments per Radius parameter value
5522 # @param value numerical value or name of variable from notebook
5523 def SetNbSegPerRadius(self, value):
5524 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5525 value, parameters = ParseParameters(lastParameters,4,4,value)
5526 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5527 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5529 #Registering the new proxy for NETGENPlugin_Hypothesis
5530 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5533 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5534 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5537 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5538 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5540 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5541 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5543 ## Set Number of Segments parameter value
5544 # @param nbSeg numerical value or name of variable from notebook
5545 def SetNumberOfSegments(self, nbSeg):
5546 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5547 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5548 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5549 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5551 ## Set Local Length parameter value
5552 # @param length numerical value or name of variable from notebook
5553 def SetLocalLength(self, length):
5554 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5555 length, parameters = ParseParameters(lastParameters,2,1,length)
5556 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5557 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5559 ## Set Max Element Area parameter value
5560 # @param area numerical value or name of variable from notebook
5561 def SetMaxElementArea(self, area):
5562 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5563 area, parameters = ParseParameters(lastParameters,2,2,area)
5564 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5565 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5567 def LengthFromEdges(self):
5568 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5570 value, parameters = ParseParameters(lastParameters,2,2,value)
5571 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5572 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5574 #Registering the new proxy for NETGEN_SimpleParameters_2D
5575 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5578 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5579 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5580 ## Set Max Element Volume parameter value
5581 # @param volume numerical value or name of variable from notebook
5582 def SetMaxElementVolume(self, volume):
5583 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5584 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5585 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5586 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5588 def LengthFromFaces(self):
5589 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5591 value, parameters = ParseParameters(lastParameters,3,3,value)
5592 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5593 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5595 #Registering the new proxy for NETGEN_SimpleParameters_3D
5596 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5598 pass # if not noNETGENPlugin:
5600 class Pattern(SMESH._objref_SMESH_Pattern):
5602 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5604 if isinstance(theNodeIndexOnKeyPoint1,str):
5606 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5608 theNodeIndexOnKeyPoint1 -= 1
5609 theMesh.SetParameters(Parameters)
5610 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5612 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5615 if isinstance(theNode000Index,str):
5617 if isinstance(theNode001Index,str):
5619 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5621 theNode000Index -= 1
5623 theNode001Index -= 1
5624 theMesh.SetParameters(Parameters)
5625 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5627 #Registering the new proxy for Pattern
5628 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)