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:
1192 if self.mesh.HasShapeToMesh():
1194 mainIOR = salome.orb.object_to_string(geom)
1195 for sname in salome.myStudyManager.GetOpenStudies():
1196 s = salome.myStudyManager.GetStudyByName(sname)
1198 mainSO = s.FindObjectIOR(mainIOR)
1199 if not mainSO: continue
1200 if err.subShapeID == 1:
1201 shapeText = ' on "%s"' % mainSO.GetName()
1202 subIt = s.NewChildIterator(mainSO)
1204 subSO = subIt.Value()
1206 obj = subSO.GetObject()
1207 if not obj: continue
1208 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1210 ids = go.GetSubShapeIndices()
1211 if len(ids) == 1 and ids[0] == err.subShapeID:
1212 shapeText = ' on "%s"' % subSO.GetName()
1215 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1217 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1219 shapeText = " on subshape #%s" % (err.subShapeID)
1221 shapeText = " on 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 if allReasons != "":allReasons += "\n"
1239 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1243 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1245 if err.isGlobalAlgo:
1253 reason = '%s %sD algorithm is missing' % (glob, dim)
1254 elif err.state == HYP_MISSING:
1255 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1256 % (glob, dim, name, dim))
1257 elif err.state == HYP_NOTCONFORM:
1258 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1259 elif err.state == HYP_BAD_PARAMETER:
1260 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1261 % ( glob, dim, name ))
1262 elif err.state == HYP_BAD_GEOMETRY:
1263 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1264 'geometry' % ( glob, dim, name ))
1266 reason = "For unknown reason."+\
1267 " Revise Mesh.Compute() implementation in smeshDC.py!"
1269 if allReasons != "":allReasons += "\n"
1270 allReasons += reason
1272 if allReasons != "":
1273 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1277 print '"' + GetName(self.mesh) + '"',"has not been computed."
1280 if salome.sg.hasDesktop():
1281 smeshgui = salome.ImportComponentGUI("SMESH")
1282 smeshgui.Init(self.mesh.GetStudyId())
1283 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1284 salome.sg.updateObjBrowser(1)
1288 ## Return submesh objects list in meshing order
1289 # @return list of list of submesh objects
1290 # @ingroup l2_construct
1291 def GetMeshOrder(self):
1292 return self.mesh.GetMeshOrder()
1294 ## Return submesh objects list in meshing order
1295 # @return list of list of submesh objects
1296 # @ingroup l2_construct
1297 def SetMeshOrder(self, submeshes):
1298 return self.mesh.SetMeshOrder(submeshes)
1300 ## Removes all nodes and elements
1301 # @ingroup l2_construct
1304 if salome.sg.hasDesktop():
1305 smeshgui = salome.ImportComponentGUI("SMESH")
1306 smeshgui.Init(self.mesh.GetStudyId())
1307 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1308 salome.sg.updateObjBrowser(1)
1310 ## Removes all nodes and elements of indicated shape
1311 # @ingroup l2_construct
1312 def ClearSubMesh(self, geomId):
1313 self.mesh.ClearSubMesh(geomId)
1314 if salome.sg.hasDesktop():
1315 smeshgui = salome.ImportComponentGUI("SMESH")
1316 smeshgui.Init(self.mesh.GetStudyId())
1317 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1318 salome.sg.updateObjBrowser(1)
1320 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1321 # @param fineness [0,-1] defines mesh fineness
1322 # @return True or False
1323 # @ingroup l3_algos_basic
1324 def AutomaticTetrahedralization(self, fineness=0):
1325 dim = self.MeshDimension()
1327 self.RemoveGlobalHypotheses()
1328 self.Segment().AutomaticLength(fineness)
1330 self.Triangle().LengthFromEdges()
1333 self.Tetrahedron(NETGEN)
1335 return self.Compute()
1337 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1338 # @param fineness [0,-1] defines mesh fineness
1339 # @return True or False
1340 # @ingroup l3_algos_basic
1341 def AutomaticHexahedralization(self, fineness=0):
1342 dim = self.MeshDimension()
1343 # assign the hypotheses
1344 self.RemoveGlobalHypotheses()
1345 self.Segment().AutomaticLength(fineness)
1352 return self.Compute()
1354 ## Assigns a hypothesis
1355 # @param hyp a hypothesis to assign
1356 # @param geom a subhape of mesh geometry
1357 # @return SMESH.Hypothesis_Status
1358 # @ingroup l2_hypotheses
1359 def AddHypothesis(self, hyp, geom=0):
1360 if isinstance( hyp, Mesh_Algorithm ):
1361 hyp = hyp.GetAlgorithm()
1366 geom = self.mesh.GetShapeToMesh()
1368 status = self.mesh.AddHypothesis(geom, hyp)
1369 isAlgo = hyp._narrow( SMESH_Algo )
1370 hyp_name = GetName( hyp )
1373 geom_name = GetName( geom )
1374 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1377 ## Unassigns a hypothesis
1378 # @param hyp a hypothesis to unassign
1379 # @param geom a subshape of mesh geometry
1380 # @return SMESH.Hypothesis_Status
1381 # @ingroup l2_hypotheses
1382 def RemoveHypothesis(self, hyp, geom=0):
1383 if isinstance( hyp, Mesh_Algorithm ):
1384 hyp = hyp.GetAlgorithm()
1389 status = self.mesh.RemoveHypothesis(geom, hyp)
1392 ## Gets the list of hypotheses added on a geometry
1393 # @param geom a subshape of mesh geometry
1394 # @return the sequence of SMESH_Hypothesis
1395 # @ingroup l2_hypotheses
1396 def GetHypothesisList(self, geom):
1397 return self.mesh.GetHypothesisList( geom )
1399 ## Removes all global hypotheses
1400 # @ingroup l2_hypotheses
1401 def RemoveGlobalHypotheses(self):
1402 current_hyps = self.mesh.GetHypothesisList( self.geom )
1403 for hyp in current_hyps:
1404 self.mesh.RemoveHypothesis( self.geom, hyp )
1408 ## Creates a mesh group based on the geometric object \a grp
1409 # and gives a \a name, \n if this parameter is not defined
1410 # the name is the same as the geometric group name \n
1411 # Note: Works like GroupOnGeom().
1412 # @param grp a geometric group, a vertex, an edge, a face or a solid
1413 # @param name the name of the mesh group
1414 # @return SMESH_GroupOnGeom
1415 # @ingroup l2_grps_create
1416 def Group(self, grp, name=""):
1417 return self.GroupOnGeom(grp, name)
1419 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1420 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1421 # @param f the file name
1422 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1423 # @param opt boolean parameter for creating/not creating
1424 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1425 # @ingroup l2_impexp
1426 def ExportToMED(self, f, version, opt=0):
1427 self.mesh.ExportToMED(f, opt, version)
1429 ## Exports the mesh in a file in MED format
1430 # @param f is the file name
1431 # @param auto_groups boolean parameter for creating/not creating
1432 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1433 # the typical use is auto_groups=false.
1434 # @param version MED format version(MED_V2_1 or MED_V2_2)
1435 # @ingroup l2_impexp
1436 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1437 self.mesh.ExportToMED(f, auto_groups, version)
1439 ## Exports the mesh in a file in DAT format
1440 # @param f the file name
1441 # @ingroup l2_impexp
1442 def ExportDAT(self, f):
1443 self.mesh.ExportDAT(f)
1445 ## Exports the mesh in a file in UNV format
1446 # @param f the file name
1447 # @ingroup l2_impexp
1448 def ExportUNV(self, f):
1449 self.mesh.ExportUNV(f)
1451 ## Export the mesh in a file in STL format
1452 # @param f the file name
1453 # @param ascii defines the file encoding
1454 # @ingroup l2_impexp
1455 def ExportSTL(self, f, ascii=1):
1456 self.mesh.ExportSTL(f, ascii)
1459 # Operations with groups:
1460 # ----------------------
1462 ## Creates an empty mesh group
1463 # @param elementType the type of elements in the group
1464 # @param name the name of the mesh group
1465 # @return SMESH_Group
1466 # @ingroup l2_grps_create
1467 def CreateEmptyGroup(self, elementType, name):
1468 return self.mesh.CreateGroup(elementType, name)
1470 ## Creates a mesh group based on the geometrical object \a grp
1471 # and gives a \a name, \n if this parameter is not defined
1472 # the name is the same as the geometrical group name
1473 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1474 # @param name the name of the mesh group
1475 # @param typ the type of elements in the group. If not set, it is
1476 # automatically detected by the type of the geometry
1477 # @return SMESH_GroupOnGeom
1478 # @ingroup l2_grps_create
1479 def GroupOnGeom(self, grp, name="", typ=None):
1481 name = grp.GetName()
1484 tgeo = str(grp.GetShapeType())
1485 if tgeo == "VERTEX":
1487 elif tgeo == "EDGE":
1489 elif tgeo == "FACE":
1491 elif tgeo == "SOLID":
1493 elif tgeo == "SHELL":
1495 elif tgeo == "COMPOUND":
1496 try: # it raises on a compound of compounds
1497 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1498 print "Mesh.Group: empty geometric group", GetName( grp )
1503 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1505 tgeo = self.geompyD.GetType(grp)
1506 if tgeo == geompyDC.ShapeType["VERTEX"]:
1508 elif tgeo == geompyDC.ShapeType["EDGE"]:
1510 elif tgeo == geompyDC.ShapeType["FACE"]:
1512 elif tgeo == geompyDC.ShapeType["SOLID"]:
1518 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1519 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1520 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1528 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1531 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1533 ## Creates a mesh group by the given ids of elements
1534 # @param groupName the name of the mesh group
1535 # @param elementType the type of elements in the group
1536 # @param elemIDs the list of ids
1537 # @return SMESH_Group
1538 # @ingroup l2_grps_create
1539 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1540 group = self.mesh.CreateGroup(elementType, groupName)
1544 ## Creates a mesh group by the given conditions
1545 # @param groupName the name of the mesh group
1546 # @param elementType the type of elements in the group
1547 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1548 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1549 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1550 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1551 # @return SMESH_Group
1552 # @ingroup l2_grps_create
1556 CritType=FT_Undefined,
1559 UnaryOp=FT_Undefined):
1560 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1561 group = self.MakeGroupByCriterion(groupName, aCriterion)
1564 ## Creates a mesh group by the given criterion
1565 # @param groupName the name of the mesh group
1566 # @param Criterion the instance of Criterion class
1567 # @return SMESH_Group
1568 # @ingroup l2_grps_create
1569 def MakeGroupByCriterion(self, groupName, Criterion):
1570 aFilterMgr = self.smeshpyD.CreateFilterManager()
1571 aFilter = aFilterMgr.CreateFilter()
1573 aCriteria.append(Criterion)
1574 aFilter.SetCriteria(aCriteria)
1575 group = self.MakeGroupByFilter(groupName, aFilter)
1578 ## Creates a mesh group by the given criteria (list of criteria)
1579 # @param groupName the name of the mesh group
1580 # @param theCriteria the list of criteria
1581 # @return SMESH_Group
1582 # @ingroup l2_grps_create
1583 def MakeGroupByCriteria(self, groupName, theCriteria):
1584 aFilterMgr = self.smeshpyD.CreateFilterManager()
1585 aFilter = aFilterMgr.CreateFilter()
1586 aFilter.SetCriteria(theCriteria)
1587 group = self.MakeGroupByFilter(groupName, aFilter)
1590 ## Creates a mesh group by the given filter
1591 # @param groupName the name of the mesh group
1592 # @param theFilter the instance of Filter class
1593 # @return SMESH_Group
1594 # @ingroup l2_grps_create
1595 def MakeGroupByFilter(self, groupName, theFilter):
1596 anIds = theFilter.GetElementsId(self.mesh)
1597 anElemType = theFilter.GetElementType()
1598 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1601 ## Passes mesh elements through the given filter and return IDs of fitting elements
1602 # @param theFilter SMESH_Filter
1603 # @return a list of ids
1604 # @ingroup l1_controls
1605 def GetIdsFromFilter(self, theFilter):
1606 return theFilter.GetElementsId(self.mesh)
1608 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1609 # Returns a list of special structures (borders).
1610 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1611 # @ingroup l1_controls
1612 def GetFreeBorders(self):
1613 aFilterMgr = self.smeshpyD.CreateFilterManager()
1614 aPredicate = aFilterMgr.CreateFreeEdges()
1615 aPredicate.SetMesh(self.mesh)
1616 aBorders = aPredicate.GetBorders()
1620 # @ingroup l2_grps_delete
1621 def RemoveGroup(self, group):
1622 self.mesh.RemoveGroup(group)
1624 ## Removes a group with its contents
1625 # @ingroup l2_grps_delete
1626 def RemoveGroupWithContents(self, group):
1627 self.mesh.RemoveGroupWithContents(group)
1629 ## Gets the list of groups existing in the mesh
1630 # @return a sequence of SMESH_GroupBase
1631 # @ingroup l2_grps_create
1632 def GetGroups(self):
1633 return self.mesh.GetGroups()
1635 ## Gets the number of groups existing in the mesh
1636 # @return the quantity of groups as an integer value
1637 # @ingroup l2_grps_create
1639 return self.mesh.NbGroups()
1641 ## Gets the list of names of groups existing in the mesh
1642 # @return list of strings
1643 # @ingroup l2_grps_create
1644 def GetGroupNames(self):
1645 groups = self.GetGroups()
1647 for group in groups:
1648 names.append(group.GetName())
1651 ## Produces a union of two groups
1652 # A new group is created. All mesh elements that are
1653 # present in the initial groups are added to the new one
1654 # @return an instance of SMESH_Group
1655 # @ingroup l2_grps_operon
1656 def UnionGroups(self, group1, group2, name):
1657 return self.mesh.UnionGroups(group1, group2, name)
1659 ## Produces a union list of groups
1660 # New group is created. All mesh elements that are present in
1661 # initial groups are added to the new one
1662 # @return an instance of SMESH_Group
1663 # @ingroup l2_grps_operon
1664 def UnionListOfGroups(self, groups, name):
1665 return self.mesh.UnionListOfGroups(groups, name)
1667 ## Prodices an intersection of two groups
1668 # A new group is created. All mesh elements that are common
1669 # for the two initial groups are added to the new one.
1670 # @return an instance of SMESH_Group
1671 # @ingroup l2_grps_operon
1672 def IntersectGroups(self, group1, group2, name):
1673 return self.mesh.IntersectGroups(group1, group2, name)
1675 ## Produces an intersection of groups
1676 # New group is created. All mesh elements that are present in all
1677 # initial groups simultaneously are added to the new one
1678 # @return an instance of SMESH_Group
1679 # @ingroup l2_grps_operon
1680 def IntersectListOfGroups(self, groups, name):
1681 return self.mesh.IntersectListOfGroups(groups, name)
1683 ## Produces a cut of two groups
1684 # A new group is created. All mesh elements that are present in
1685 # the main group but are not present in the tool group are added to the new one
1686 # @return an instance of SMESH_Group
1687 # @ingroup l2_grps_operon
1688 def CutGroups(self, main_group, tool_group, name):
1689 return self.mesh.CutGroups(main_group, tool_group, name)
1691 ## Produces a cut of groups
1692 # A new group is created. All mesh elements that are present in main groups
1693 # but do not present in tool groups are added to the new one
1694 # @return an instance of SMESH_Group
1695 # @ingroup l2_grps_operon
1696 def CutListOfGroups(self, main_groups, tool_groups, name):
1697 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1699 ## Produces a group of elements with specified element type using list of existing groups
1700 # A new group is created. System
1701 # 1) extract all nodes on which groups elements are built
1702 # 2) combine all elements of specified dimension laying on these nodes
1703 # @return an instance of SMESH_Group
1704 # @ingroup l2_grps_operon
1705 def CreateDimGroup(self, groups, elem_type, name):
1706 return self.mesh.CreateDimGroup(groups, elem_type, name)
1709 ## Convert group on geom into standalone group
1710 # @ingroup l2_grps_delete
1711 def ConvertToStandalone(self, group):
1712 return self.mesh.ConvertToStandalone(group)
1714 # Get some info about mesh:
1715 # ------------------------
1717 ## Returns the log of nodes and elements added or removed
1718 # since the previous clear of the log.
1719 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1720 # @return list of log_block structures:
1725 # @ingroup l1_auxiliary
1726 def GetLog(self, clearAfterGet):
1727 return self.mesh.GetLog(clearAfterGet)
1729 ## Clears the log of nodes and elements added or removed since the previous
1730 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1731 # @ingroup l1_auxiliary
1733 self.mesh.ClearLog()
1735 ## Toggles auto color mode on the object.
1736 # @param theAutoColor the flag which toggles auto color mode.
1737 # @ingroup l1_auxiliary
1738 def SetAutoColor(self, theAutoColor):
1739 self.mesh.SetAutoColor(theAutoColor)
1741 ## Gets flag of object auto color mode.
1742 # @return True or False
1743 # @ingroup l1_auxiliary
1744 def GetAutoColor(self):
1745 return self.mesh.GetAutoColor()
1747 ## Gets the internal ID
1748 # @return integer value, which is the internal Id of the mesh
1749 # @ingroup l1_auxiliary
1751 return self.mesh.GetId()
1754 # @return integer value, which is the study Id of the mesh
1755 # @ingroup l1_auxiliary
1756 def GetStudyId(self):
1757 return self.mesh.GetStudyId()
1759 ## Checks the group names for duplications.
1760 # Consider the maximum group name length stored in MED file.
1761 # @return True or False
1762 # @ingroup l1_auxiliary
1763 def HasDuplicatedGroupNamesMED(self):
1764 return self.mesh.HasDuplicatedGroupNamesMED()
1766 ## Obtains the mesh editor tool
1767 # @return an instance of SMESH_MeshEditor
1768 # @ingroup l1_modifying
1769 def GetMeshEditor(self):
1770 return self.mesh.GetMeshEditor()
1773 # @return an instance of SALOME_MED::MESH
1774 # @ingroup l1_auxiliary
1775 def GetMEDMesh(self):
1776 return self.mesh.GetMEDMesh()
1779 # Get informations about mesh contents:
1780 # ------------------------------------
1782 ## Gets the mesh stattistic
1783 # @return dictionary type element - count of elements
1784 # @ingroup l1_meshinfo
1785 def GetMeshInfo(self, obj = None):
1786 if not obj: obj = self.mesh
1787 return self.smeshpyD.GetMeshInfo(obj)
1789 ## Returns the number of nodes in the mesh
1790 # @return an integer value
1791 # @ingroup l1_meshinfo
1793 return self.mesh.NbNodes()
1795 ## Returns the number of elements in the mesh
1796 # @return an integer value
1797 # @ingroup l1_meshinfo
1798 def NbElements(self):
1799 return self.mesh.NbElements()
1801 ## Returns the number of 0d elements in the mesh
1802 # @return an integer value
1803 # @ingroup l1_meshinfo
1804 def Nb0DElements(self):
1805 return self.mesh.Nb0DElements()
1807 ## Returns the number of edges in the mesh
1808 # @return an integer value
1809 # @ingroup l1_meshinfo
1811 return self.mesh.NbEdges()
1813 ## Returns the number of edges with the given order in the mesh
1814 # @param elementOrder the order of elements:
1815 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1816 # @return an integer value
1817 # @ingroup l1_meshinfo
1818 def NbEdgesOfOrder(self, elementOrder):
1819 return self.mesh.NbEdgesOfOrder(elementOrder)
1821 ## Returns the number of faces in the mesh
1822 # @return an integer value
1823 # @ingroup l1_meshinfo
1825 return self.mesh.NbFaces()
1827 ## Returns the number of faces with the given order in the mesh
1828 # @param elementOrder the order of elements:
1829 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1830 # @return an integer value
1831 # @ingroup l1_meshinfo
1832 def NbFacesOfOrder(self, elementOrder):
1833 return self.mesh.NbFacesOfOrder(elementOrder)
1835 ## Returns the number of triangles in the mesh
1836 # @return an integer value
1837 # @ingroup l1_meshinfo
1838 def NbTriangles(self):
1839 return self.mesh.NbTriangles()
1841 ## Returns the number of triangles with the given order in the mesh
1842 # @param elementOrder is the order of elements:
1843 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1844 # @return an integer value
1845 # @ingroup l1_meshinfo
1846 def NbTrianglesOfOrder(self, elementOrder):
1847 return self.mesh.NbTrianglesOfOrder(elementOrder)
1849 ## Returns the number of quadrangles in the mesh
1850 # @return an integer value
1851 # @ingroup l1_meshinfo
1852 def NbQuadrangles(self):
1853 return self.mesh.NbQuadrangles()
1855 ## Returns the number of quadrangles with the given order in the mesh
1856 # @param elementOrder the order of elements:
1857 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1858 # @return an integer value
1859 # @ingroup l1_meshinfo
1860 def NbQuadranglesOfOrder(self, elementOrder):
1861 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1863 ## Returns the number of polygons in the mesh
1864 # @return an integer value
1865 # @ingroup l1_meshinfo
1866 def NbPolygons(self):
1867 return self.mesh.NbPolygons()
1869 ## Returns the number of volumes in the mesh
1870 # @return an integer value
1871 # @ingroup l1_meshinfo
1872 def NbVolumes(self):
1873 return self.mesh.NbVolumes()
1875 ## Returns the number of volumes with the given order in the mesh
1876 # @param elementOrder the order of elements:
1877 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1878 # @return an integer value
1879 # @ingroup l1_meshinfo
1880 def NbVolumesOfOrder(self, elementOrder):
1881 return self.mesh.NbVolumesOfOrder(elementOrder)
1883 ## Returns the number of tetrahedrons in the mesh
1884 # @return an integer value
1885 # @ingroup l1_meshinfo
1887 return self.mesh.NbTetras()
1889 ## Returns the number of tetrahedrons with the given order in the mesh
1890 # @param elementOrder the order of elements:
1891 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1892 # @return an integer value
1893 # @ingroup l1_meshinfo
1894 def NbTetrasOfOrder(self, elementOrder):
1895 return self.mesh.NbTetrasOfOrder(elementOrder)
1897 ## Returns the number of hexahedrons in the mesh
1898 # @return an integer value
1899 # @ingroup l1_meshinfo
1901 return self.mesh.NbHexas()
1903 ## Returns the number of hexahedrons with the given order in the mesh
1904 # @param elementOrder the order of elements:
1905 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1906 # @return an integer value
1907 # @ingroup l1_meshinfo
1908 def NbHexasOfOrder(self, elementOrder):
1909 return self.mesh.NbHexasOfOrder(elementOrder)
1911 ## Returns the number of pyramids in the mesh
1912 # @return an integer value
1913 # @ingroup l1_meshinfo
1914 def NbPyramids(self):
1915 return self.mesh.NbPyramids()
1917 ## Returns the number of pyramids with the given order in the mesh
1918 # @param elementOrder the order of elements:
1919 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1920 # @return an integer value
1921 # @ingroup l1_meshinfo
1922 def NbPyramidsOfOrder(self, elementOrder):
1923 return self.mesh.NbPyramidsOfOrder(elementOrder)
1925 ## Returns the number of prisms in the mesh
1926 # @return an integer value
1927 # @ingroup l1_meshinfo
1929 return self.mesh.NbPrisms()
1931 ## Returns the number of prisms with the given order in the mesh
1932 # @param elementOrder the order of elements:
1933 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1934 # @return an integer value
1935 # @ingroup l1_meshinfo
1936 def NbPrismsOfOrder(self, elementOrder):
1937 return self.mesh.NbPrismsOfOrder(elementOrder)
1939 ## Returns the number of polyhedrons in the mesh
1940 # @return an integer value
1941 # @ingroup l1_meshinfo
1942 def NbPolyhedrons(self):
1943 return self.mesh.NbPolyhedrons()
1945 ## Returns the number of submeshes in the mesh
1946 # @return an integer value
1947 # @ingroup l1_meshinfo
1948 def NbSubMesh(self):
1949 return self.mesh.NbSubMesh()
1951 ## Returns the list of mesh elements IDs
1952 # @return the list of integer values
1953 # @ingroup l1_meshinfo
1954 def GetElementsId(self):
1955 return self.mesh.GetElementsId()
1957 ## Returns the list of IDs of mesh elements with the given type
1958 # @param elementType the required type of elements
1959 # @return list of integer values
1960 # @ingroup l1_meshinfo
1961 def GetElementsByType(self, elementType):
1962 return self.mesh.GetElementsByType(elementType)
1964 ## Returns the list of mesh nodes IDs
1965 # @return the list of integer values
1966 # @ingroup l1_meshinfo
1967 def GetNodesId(self):
1968 return self.mesh.GetNodesId()
1970 # Get the information about mesh elements:
1971 # ------------------------------------
1973 ## Returns the type of mesh element
1974 # @return the value from SMESH::ElementType enumeration
1975 # @ingroup l1_meshinfo
1976 def GetElementType(self, id, iselem):
1977 return self.mesh.GetElementType(id, iselem)
1979 ## Returns the geometric type of mesh element
1980 # @return the value from SMESH::EntityType enumeration
1981 # @ingroup l1_meshinfo
1982 def GetElementGeomType(self, id):
1983 return self.mesh.GetElementGeomType(id)
1985 ## Returns the list of submesh elements IDs
1986 # @param Shape a geom object(subshape) IOR
1987 # Shape must be the subshape of a ShapeToMesh()
1988 # @return the list of integer values
1989 # @ingroup l1_meshinfo
1990 def GetSubMeshElementsId(self, Shape):
1991 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1992 ShapeID = Shape.GetSubShapeIndices()[0]
1995 return self.mesh.GetSubMeshElementsId(ShapeID)
1997 ## Returns the list of submesh nodes IDs
1998 # @param Shape a geom object(subshape) IOR
1999 # Shape must be the subshape of a ShapeToMesh()
2000 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2001 # @return the list of integer values
2002 # @ingroup l1_meshinfo
2003 def GetSubMeshNodesId(self, Shape, all):
2004 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2005 ShapeID = Shape.GetSubShapeIndices()[0]
2008 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2010 ## Returns type of elements on given shape
2011 # @param Shape a geom object(subshape) IOR
2012 # Shape must be a subshape of a ShapeToMesh()
2013 # @return element type
2014 # @ingroup l1_meshinfo
2015 def GetSubMeshElementType(self, Shape):
2016 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2017 ShapeID = Shape.GetSubShapeIndices()[0]
2020 return self.mesh.GetSubMeshElementType(ShapeID)
2022 ## Gets the mesh description
2023 # @return string value
2024 # @ingroup l1_meshinfo
2026 return self.mesh.Dump()
2029 # Get the information about nodes and elements of a mesh by its IDs:
2030 # -----------------------------------------------------------
2032 ## Gets XYZ coordinates of a node
2033 # \n If there is no nodes for the given ID - returns an empty list
2034 # @return a list of double precision values
2035 # @ingroup l1_meshinfo
2036 def GetNodeXYZ(self, id):
2037 return self.mesh.GetNodeXYZ(id)
2039 ## Returns list of IDs of inverse elements for the given node
2040 # \n If there is no node for the given ID - returns an empty list
2041 # @return a list of integer values
2042 # @ingroup l1_meshinfo
2043 def GetNodeInverseElements(self, id):
2044 return self.mesh.GetNodeInverseElements(id)
2046 ## @brief Returns the position of a node on the shape
2047 # @return SMESH::NodePosition
2048 # @ingroup l1_meshinfo
2049 def GetNodePosition(self,NodeID):
2050 return self.mesh.GetNodePosition(NodeID)
2052 ## If the given element is a node, returns the ID of shape
2053 # \n If there is no node for the given ID - returns -1
2054 # @return an integer value
2055 # @ingroup l1_meshinfo
2056 def GetShapeID(self, id):
2057 return self.mesh.GetShapeID(id)
2059 ## Returns the ID of the result shape after
2060 # FindShape() from SMESH_MeshEditor for the given element
2061 # \n If there is no element for the given ID - returns -1
2062 # @return an integer value
2063 # @ingroup l1_meshinfo
2064 def GetShapeIDForElem(self,id):
2065 return self.mesh.GetShapeIDForElem(id)
2067 ## Returns the number of nodes for the given element
2068 # \n If there is no element for the given ID - returns -1
2069 # @return an integer value
2070 # @ingroup l1_meshinfo
2071 def GetElemNbNodes(self, id):
2072 return self.mesh.GetElemNbNodes(id)
2074 ## Returns the node ID the given index for the given element
2075 # \n If there is no element for the given ID - returns -1
2076 # \n If there is no node for the given index - returns -2
2077 # @return an integer value
2078 # @ingroup l1_meshinfo
2079 def GetElemNode(self, id, index):
2080 return self.mesh.GetElemNode(id, index)
2082 ## Returns the IDs of nodes of the given element
2083 # @return a list of integer values
2084 # @ingroup l1_meshinfo
2085 def GetElemNodes(self, id):
2086 return self.mesh.GetElemNodes(id)
2088 ## Returns true if the given node is the medium node in the given quadratic element
2089 # @ingroup l1_meshinfo
2090 def IsMediumNode(self, elementID, nodeID):
2091 return self.mesh.IsMediumNode(elementID, nodeID)
2093 ## Returns true if the given node is the medium node in one of quadratic elements
2094 # @ingroup l1_meshinfo
2095 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2096 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2098 ## Returns the number of edges for the given element
2099 # @ingroup l1_meshinfo
2100 def ElemNbEdges(self, id):
2101 return self.mesh.ElemNbEdges(id)
2103 ## Returns the number of faces for the given element
2104 # @ingroup l1_meshinfo
2105 def ElemNbFaces(self, id):
2106 return self.mesh.ElemNbFaces(id)
2108 ## Returns nodes of given face (counted from zero) for given volumic element.
2109 # @ingroup l1_meshinfo
2110 def GetElemFaceNodes(self,elemId, faceIndex):
2111 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2113 ## Returns an element based on all given nodes.
2114 # @ingroup l1_meshinfo
2115 def FindElementByNodes(self,nodes):
2116 return self.mesh.FindElementByNodes(nodes)
2118 ## Returns true if the given element is a polygon
2119 # @ingroup l1_meshinfo
2120 def IsPoly(self, id):
2121 return self.mesh.IsPoly(id)
2123 ## Returns true if the given element is quadratic
2124 # @ingroup l1_meshinfo
2125 def IsQuadratic(self, id):
2126 return self.mesh.IsQuadratic(id)
2128 ## Returns XYZ coordinates of the barycenter of the given element
2129 # \n If there is no element for the given ID - returns an empty list
2130 # @return a list of three double values
2131 # @ingroup l1_meshinfo
2132 def BaryCenter(self, id):
2133 return self.mesh.BaryCenter(id)
2136 # Mesh edition (SMESH_MeshEditor functionality):
2137 # ---------------------------------------------
2139 ## Removes the elements from the mesh by ids
2140 # @param IDsOfElements is a list of ids of elements to remove
2141 # @return True or False
2142 # @ingroup l2_modif_del
2143 def RemoveElements(self, IDsOfElements):
2144 return self.editor.RemoveElements(IDsOfElements)
2146 ## Removes nodes from mesh by ids
2147 # @param IDsOfNodes is a list of ids of nodes to remove
2148 # @return True or False
2149 # @ingroup l2_modif_del
2150 def RemoveNodes(self, IDsOfNodes):
2151 return self.editor.RemoveNodes(IDsOfNodes)
2153 ## Add a node to the mesh by coordinates
2154 # @return Id of the new node
2155 # @ingroup l2_modif_add
2156 def AddNode(self, x, y, z):
2157 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2158 self.mesh.SetParameters(Parameters)
2159 return self.editor.AddNode( x, y, z)
2161 ## Creates a 0D element on a node with given number.
2162 # @param IDOfNode the ID of node for creation of the element.
2163 # @return the Id of the new 0D element
2164 # @ingroup l2_modif_add
2165 def Add0DElement(self, IDOfNode):
2166 return self.editor.Add0DElement(IDOfNode)
2168 ## Creates a linear or quadratic edge (this is determined
2169 # by the number of given nodes).
2170 # @param IDsOfNodes the list of node IDs for creation of the element.
2171 # The order of nodes in this list should correspond to the description
2172 # of MED. \n This description is located by the following link:
2173 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2174 # @return the Id of the new edge
2175 # @ingroup l2_modif_add
2176 def AddEdge(self, IDsOfNodes):
2177 return self.editor.AddEdge(IDsOfNodes)
2179 ## Creates a linear or quadratic face (this is determined
2180 # by the number of given nodes).
2181 # @param IDsOfNodes the list of node IDs for creation of the element.
2182 # The order of nodes in this list should correspond to the description
2183 # of MED. \n This description is located by the following link:
2184 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2185 # @return the Id of the new face
2186 # @ingroup l2_modif_add
2187 def AddFace(self, IDsOfNodes):
2188 return self.editor.AddFace(IDsOfNodes)
2190 ## Adds a polygonal face to the mesh by the list of node IDs
2191 # @param IdsOfNodes the list of node IDs for creation of the element.
2192 # @return the Id of the new face
2193 # @ingroup l2_modif_add
2194 def AddPolygonalFace(self, IdsOfNodes):
2195 return self.editor.AddPolygonalFace(IdsOfNodes)
2197 ## Creates both simple and quadratic volume (this is determined
2198 # by the number of given nodes).
2199 # @param IDsOfNodes the list of node IDs for creation of the element.
2200 # The order of nodes in this list should correspond to the description
2201 # of MED. \n This description is located by the following link:
2202 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2203 # @return the Id of the new volumic element
2204 # @ingroup l2_modif_add
2205 def AddVolume(self, IDsOfNodes):
2206 return self.editor.AddVolume(IDsOfNodes)
2208 ## Creates a volume of many faces, giving nodes for each face.
2209 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2210 # @param Quantities the list of integer values, Quantities[i]
2211 # gives the quantity of nodes in face number i.
2212 # @return the Id of the new volumic element
2213 # @ingroup l2_modif_add
2214 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2215 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2217 ## Creates a volume of many faces, giving the IDs of the existing faces.
2218 # @param IdsOfFaces the list of face IDs for volume creation.
2220 # Note: The created volume will refer only to the nodes
2221 # of the given faces, not to the faces themselves.
2222 # @return the Id of the new volumic element
2223 # @ingroup l2_modif_add
2224 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2225 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2228 ## @brief Binds a node to a vertex
2229 # @param NodeID a node ID
2230 # @param Vertex a vertex or vertex ID
2231 # @return True if succeed else raises an exception
2232 # @ingroup l2_modif_add
2233 def SetNodeOnVertex(self, NodeID, Vertex):
2234 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2235 VertexID = Vertex.GetSubShapeIndices()[0]
2239 self.editor.SetNodeOnVertex(NodeID, VertexID)
2240 except SALOME.SALOME_Exception, inst:
2241 raise ValueError, inst.details.text
2245 ## @brief Stores the node position on an edge
2246 # @param NodeID a node ID
2247 # @param Edge an edge or edge ID
2248 # @param paramOnEdge a parameter on the edge where the node is located
2249 # @return True if succeed else raises an exception
2250 # @ingroup l2_modif_add
2251 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2252 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2253 EdgeID = Edge.GetSubShapeIndices()[0]
2257 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2258 except SALOME.SALOME_Exception, inst:
2259 raise ValueError, inst.details.text
2262 ## @brief Stores node position on a face
2263 # @param NodeID a node ID
2264 # @param Face a face or face ID
2265 # @param u U parameter on the face where the node is located
2266 # @param v V parameter on the face where the node is located
2267 # @return True if succeed else raises an exception
2268 # @ingroup l2_modif_add
2269 def SetNodeOnFace(self, NodeID, Face, u, v):
2270 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2271 FaceID = Face.GetSubShapeIndices()[0]
2275 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2276 except SALOME.SALOME_Exception, inst:
2277 raise ValueError, inst.details.text
2280 ## @brief Binds a node to a solid
2281 # @param NodeID a node ID
2282 # @param Solid a solid or solid ID
2283 # @return True if succeed else raises an exception
2284 # @ingroup l2_modif_add
2285 def SetNodeInVolume(self, NodeID, Solid):
2286 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2287 SolidID = Solid.GetSubShapeIndices()[0]
2291 self.editor.SetNodeInVolume(NodeID, SolidID)
2292 except SALOME.SALOME_Exception, inst:
2293 raise ValueError, inst.details.text
2296 ## @brief Bind an element to a shape
2297 # @param ElementID an element ID
2298 # @param Shape a shape or shape ID
2299 # @return True if succeed else raises an exception
2300 # @ingroup l2_modif_add
2301 def SetMeshElementOnShape(self, ElementID, Shape):
2302 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2303 ShapeID = Shape.GetSubShapeIndices()[0]
2307 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2308 except SALOME.SALOME_Exception, inst:
2309 raise ValueError, inst.details.text
2313 ## Moves the node with the given id
2314 # @param NodeID the id of the node
2315 # @param x a new X coordinate
2316 # @param y a new Y coordinate
2317 # @param z a new Z coordinate
2318 # @return True if succeed else False
2319 # @ingroup l2_modif_movenode
2320 def MoveNode(self, NodeID, x, y, z):
2321 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2322 self.mesh.SetParameters(Parameters)
2323 return self.editor.MoveNode(NodeID, x, y, z)
2325 ## Finds the node closest to a point and moves it to a point location
2326 # @param x the X coordinate of a point
2327 # @param y the Y coordinate of a point
2328 # @param z the Z coordinate of a point
2329 # @param NodeID if specified (>0), the node with this ID is moved,
2330 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2331 # @return the ID of a node
2332 # @ingroup l2_modif_throughp
2333 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2334 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2335 self.mesh.SetParameters(Parameters)
2336 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2338 ## Finds the node closest to a point
2339 # @param x the X coordinate of a point
2340 # @param y the Y coordinate of a point
2341 # @param z the Z coordinate of a point
2342 # @return the ID of a node
2343 # @ingroup l2_modif_throughp
2344 def FindNodeClosestTo(self, x, y, z):
2345 #preview = self.mesh.GetMeshEditPreviewer()
2346 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2347 return self.editor.FindNodeClosestTo(x, y, z)
2349 ## Finds the elements where a point lays IN or ON
2350 # @param x the X coordinate of a point
2351 # @param y the Y coordinate of a point
2352 # @param z the Z coordinate of a point
2353 # @param elementType type of elements to find (SMESH.ALL type
2354 # means elements of any type excluding nodes and 0D elements)
2355 # @return list of IDs of found elements
2356 # @ingroup l2_modif_throughp
2357 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2358 return self.editor.FindElementsByPoint(x, y, z, elementType)
2360 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2361 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2363 def GetPointState(self, x, y, z):
2364 return self.editor.GetPointState(x, y, z)
2366 ## Finds the node closest to a point and moves it to a point location
2367 # @param x the X coordinate of a point
2368 # @param y the Y coordinate of a point
2369 # @param z the Z coordinate of a point
2370 # @return the ID of a moved node
2371 # @ingroup l2_modif_throughp
2372 def MeshToPassThroughAPoint(self, x, y, z):
2373 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2375 ## Replaces two neighbour triangles sharing Node1-Node2 link
2376 # with the triangles built on the same 4 nodes but having other common link.
2377 # @param NodeID1 the ID of the first node
2378 # @param NodeID2 the ID of the second node
2379 # @return false if proper faces were not found
2380 # @ingroup l2_modif_invdiag
2381 def InverseDiag(self, NodeID1, NodeID2):
2382 return self.editor.InverseDiag(NodeID1, NodeID2)
2384 ## Replaces two neighbour triangles sharing Node1-Node2 link
2385 # with a quadrangle built on the same 4 nodes.
2386 # @param NodeID1 the ID of the first node
2387 # @param NodeID2 the ID of the second node
2388 # @return false if proper faces were not found
2389 # @ingroup l2_modif_unitetri
2390 def DeleteDiag(self, NodeID1, NodeID2):
2391 return self.editor.DeleteDiag(NodeID1, NodeID2)
2393 ## Reorients elements by ids
2394 # @param IDsOfElements if undefined reorients all mesh elements
2395 # @return True if succeed else False
2396 # @ingroup l2_modif_changori
2397 def Reorient(self, IDsOfElements=None):
2398 if IDsOfElements == None:
2399 IDsOfElements = self.GetElementsId()
2400 return self.editor.Reorient(IDsOfElements)
2402 ## Reorients all elements of the object
2403 # @param theObject mesh, submesh or group
2404 # @return True if succeed else False
2405 # @ingroup l2_modif_changori
2406 def ReorientObject(self, theObject):
2407 if ( isinstance( theObject, Mesh )):
2408 theObject = theObject.GetMesh()
2409 return self.editor.ReorientObject(theObject)
2411 ## Fuses the neighbouring triangles into quadrangles.
2412 # @param IDsOfElements The triangles to be fused,
2413 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2414 # @param MaxAngle is the maximum angle between element normals at which the fusion
2415 # is still performed; theMaxAngle is mesured in radians.
2416 # Also it could be a name of variable which defines angle in degrees.
2417 # @return TRUE in case of success, FALSE otherwise.
2418 # @ingroup l2_modif_unitetri
2419 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2421 if isinstance(MaxAngle,str):
2423 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2425 MaxAngle = DegreesToRadians(MaxAngle)
2426 if IDsOfElements == []:
2427 IDsOfElements = self.GetElementsId()
2428 self.mesh.SetParameters(Parameters)
2430 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2431 Functor = theCriterion
2433 Functor = self.smeshpyD.GetFunctor(theCriterion)
2434 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2436 ## Fuses the neighbouring triangles of the object into quadrangles
2437 # @param theObject is mesh, submesh or group
2438 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2439 # @param MaxAngle a max angle between element normals at which the fusion
2440 # is still performed; theMaxAngle is mesured in radians.
2441 # @return TRUE in case of success, FALSE otherwise.
2442 # @ingroup l2_modif_unitetri
2443 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2444 if ( isinstance( theObject, Mesh )):
2445 theObject = theObject.GetMesh()
2446 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2448 ## Splits quadrangles into triangles.
2449 # @param IDsOfElements the faces to be splitted.
2450 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2451 # @return TRUE in case of success, FALSE otherwise.
2452 # @ingroup l2_modif_cutquadr
2453 def QuadToTri (self, IDsOfElements, theCriterion):
2454 if IDsOfElements == []:
2455 IDsOfElements = self.GetElementsId()
2456 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2458 ## Splits quadrangles into triangles.
2459 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2460 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2461 # @return TRUE in case of success, FALSE otherwise.
2462 # @ingroup l2_modif_cutquadr
2463 def QuadToTriObject (self, theObject, theCriterion):
2464 if ( isinstance( theObject, Mesh )):
2465 theObject = theObject.GetMesh()
2466 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2468 ## Splits quadrangles into triangles.
2469 # @param IDsOfElements the faces to be splitted
2470 # @param Diag13 is used to choose a diagonal for splitting.
2471 # @return TRUE in case of success, FALSE otherwise.
2472 # @ingroup l2_modif_cutquadr
2473 def SplitQuad (self, IDsOfElements, Diag13):
2474 if IDsOfElements == []:
2475 IDsOfElements = self.GetElementsId()
2476 return self.editor.SplitQuad(IDsOfElements, Diag13)
2478 ## Splits quadrangles into triangles.
2479 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2480 # @param Diag13 is used to choose a diagonal for splitting.
2481 # @return TRUE in case of success, FALSE otherwise.
2482 # @ingroup l2_modif_cutquadr
2483 def SplitQuadObject (self, theObject, Diag13):
2484 if ( isinstance( theObject, Mesh )):
2485 theObject = theObject.GetMesh()
2486 return self.editor.SplitQuadObject(theObject, Diag13)
2488 ## Finds a better splitting of the given quadrangle.
2489 # @param IDOfQuad the ID of the quadrangle to be splitted.
2490 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2491 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2492 # diagonal is better, 0 if error occurs.
2493 # @ingroup l2_modif_cutquadr
2494 def BestSplit (self, IDOfQuad, theCriterion):
2495 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2497 ## Splits volumic elements into tetrahedrons
2498 # @param elemIDs either list of elements or mesh or group or submesh
2499 # @param method flags passing splitting method:
2500 # 1 - split the hexahedron into 5 tetrahedrons
2501 # 2 - split the hexahedron into 6 tetrahedrons
2502 # @ingroup l2_modif_cutquadr
2503 def SplitVolumesIntoTetra(self, elemIDs, method=1 ):
2504 if isinstance( elemIDs, Mesh ):
2505 elemIDs = elemIDs.GetMesh()
2506 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2508 ## Splits quadrangle faces near triangular facets of volumes
2510 # @ingroup l1_auxiliary
2511 def SplitQuadsNearTriangularFacets(self):
2512 faces_array = self.GetElementsByType(SMESH.FACE)
2513 for face_id in faces_array:
2514 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2515 quad_nodes = self.mesh.GetElemNodes(face_id)
2516 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2517 isVolumeFound = False
2518 for node1_elem in node1_elems:
2519 if not isVolumeFound:
2520 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2521 nb_nodes = self.GetElemNbNodes(node1_elem)
2522 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2523 volume_elem = node1_elem
2524 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2525 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2526 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2527 isVolumeFound = True
2528 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2529 self.SplitQuad([face_id], False) # diagonal 2-4
2530 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2531 isVolumeFound = True
2532 self.SplitQuad([face_id], True) # diagonal 1-3
2533 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2534 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2535 isVolumeFound = True
2536 self.SplitQuad([face_id], True) # diagonal 1-3
2538 ## @brief Splits hexahedrons into tetrahedrons.
2540 # This operation uses pattern mapping functionality for splitting.
2541 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2542 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2543 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2544 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2545 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2546 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2547 # @return TRUE in case of success, FALSE otherwise.
2548 # @ingroup l1_auxiliary
2549 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2550 # Pattern: 5.---------.6
2555 # (0,0,1) 4.---------.7 * |
2562 # (0,0,0) 0.---------.3
2563 pattern_tetra = "!!! Nb of points: \n 8 \n\
2573 !!! Indices of points of 6 tetras: \n\
2581 pattern = self.smeshpyD.GetPattern()
2582 isDone = pattern.LoadFromFile(pattern_tetra)
2584 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2587 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2588 isDone = pattern.MakeMesh(self.mesh, False, False)
2589 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2591 # split quafrangle faces near triangular facets of volumes
2592 self.SplitQuadsNearTriangularFacets()
2596 ## @brief Split hexahedrons into prisms.
2598 # Uses the pattern mapping functionality for splitting.
2599 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2600 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2601 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2602 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2603 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2604 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2605 # @return TRUE in case of success, FALSE otherwise.
2606 # @ingroup l1_auxiliary
2607 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2608 # Pattern: 5.---------.6
2613 # (0,0,1) 4.---------.7 |
2620 # (0,0,0) 0.---------.3
2621 pattern_prism = "!!! Nb of points: \n 8 \n\
2631 !!! Indices of points of 2 prisms: \n\
2635 pattern = self.smeshpyD.GetPattern()
2636 isDone = pattern.LoadFromFile(pattern_prism)
2638 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2641 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2642 isDone = pattern.MakeMesh(self.mesh, False, False)
2643 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2645 # Splits quafrangle faces near triangular facets of volumes
2646 self.SplitQuadsNearTriangularFacets()
2650 ## Smoothes elements
2651 # @param IDsOfElements the list if ids of elements to smooth
2652 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2653 # Note that nodes built on edges and boundary nodes are always fixed.
2654 # @param MaxNbOfIterations the maximum number of iterations
2655 # @param MaxAspectRatio varies in range [1.0, inf]
2656 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2657 # @return TRUE in case of success, FALSE otherwise.
2658 # @ingroup l2_modif_smooth
2659 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2660 MaxNbOfIterations, MaxAspectRatio, Method):
2661 if IDsOfElements == []:
2662 IDsOfElements = self.GetElementsId()
2663 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2664 self.mesh.SetParameters(Parameters)
2665 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2666 MaxNbOfIterations, MaxAspectRatio, Method)
2668 ## Smoothes elements which belong to the given object
2669 # @param theObject the object to smooth
2670 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2671 # Note that nodes built on edges and boundary nodes are always fixed.
2672 # @param MaxNbOfIterations the maximum number of iterations
2673 # @param MaxAspectRatio varies in range [1.0, inf]
2674 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2675 # @return TRUE in case of success, FALSE otherwise.
2676 # @ingroup l2_modif_smooth
2677 def SmoothObject(self, theObject, IDsOfFixedNodes,
2678 MaxNbOfIterations, MaxAspectRatio, Method):
2679 if ( isinstance( theObject, Mesh )):
2680 theObject = theObject.GetMesh()
2681 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2682 MaxNbOfIterations, MaxAspectRatio, Method)
2684 ## Parametrically smoothes the given elements
2685 # @param IDsOfElements the list if ids of elements to smooth
2686 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2687 # Note that nodes built on edges and boundary nodes are always fixed.
2688 # @param MaxNbOfIterations the maximum number of iterations
2689 # @param MaxAspectRatio varies in range [1.0, inf]
2690 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2691 # @return TRUE in case of success, FALSE otherwise.
2692 # @ingroup l2_modif_smooth
2693 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2694 MaxNbOfIterations, MaxAspectRatio, Method):
2695 if IDsOfElements == []:
2696 IDsOfElements = self.GetElementsId()
2697 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2698 self.mesh.SetParameters(Parameters)
2699 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2700 MaxNbOfIterations, MaxAspectRatio, Method)
2702 ## Parametrically smoothes the elements which belong to the given object
2703 # @param theObject the object to smooth
2704 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2705 # Note that nodes built on edges and boundary nodes are always fixed.
2706 # @param MaxNbOfIterations the maximum number of iterations
2707 # @param MaxAspectRatio varies in range [1.0, inf]
2708 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2709 # @return TRUE in case of success, FALSE otherwise.
2710 # @ingroup l2_modif_smooth
2711 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2712 MaxNbOfIterations, MaxAspectRatio, Method):
2713 if ( isinstance( theObject, Mesh )):
2714 theObject = theObject.GetMesh()
2715 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2716 MaxNbOfIterations, MaxAspectRatio, Method)
2718 ## Converts the mesh to quadratic, deletes old elements, replacing
2719 # them with quadratic with the same id.
2720 # @ingroup l2_modif_tofromqu
2721 def ConvertToQuadratic(self, theForce3d):
2722 self.editor.ConvertToQuadratic(theForce3d)
2724 ## Converts the mesh from quadratic to ordinary,
2725 # deletes old quadratic elements, \n replacing
2726 # them with ordinary mesh elements with the same id.
2727 # @return TRUE in case of success, FALSE otherwise.
2728 # @ingroup l2_modif_tofromqu
2729 def ConvertFromQuadratic(self):
2730 return self.editor.ConvertFromQuadratic()
2732 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2733 # @return TRUE if operation has been completed successfully, FALSE otherwise
2734 # @ingroup l2_modif_edit
2735 def Make2DMeshFrom3D(self):
2736 return self.editor. Make2DMeshFrom3D()
2738 ## Renumber mesh nodes
2739 # @ingroup l2_modif_renumber
2740 def RenumberNodes(self):
2741 self.editor.RenumberNodes()
2743 ## Renumber mesh elements
2744 # @ingroup l2_modif_renumber
2745 def RenumberElements(self):
2746 self.editor.RenumberElements()
2748 ## Generates new elements by rotation of the elements around the axis
2749 # @param IDsOfElements the list of ids of elements to sweep
2750 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2751 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2752 # @param NbOfSteps the number of steps
2753 # @param Tolerance tolerance
2754 # @param MakeGroups forces the generation of new groups from existing ones
2755 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2756 # of all steps, else - size of each step
2757 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2758 # @ingroup l2_modif_extrurev
2759 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2760 MakeGroups=False, TotalAngle=False):
2762 if isinstance(AngleInRadians,str):
2764 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2766 AngleInRadians = DegreesToRadians(AngleInRadians)
2767 if IDsOfElements == []:
2768 IDsOfElements = self.GetElementsId()
2769 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2770 Axis = self.smeshpyD.GetAxisStruct(Axis)
2771 Axis,AxisParameters = ParseAxisStruct(Axis)
2772 if TotalAngle and NbOfSteps:
2773 AngleInRadians /= NbOfSteps
2774 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2775 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2776 self.mesh.SetParameters(Parameters)
2778 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2779 AngleInRadians, NbOfSteps, Tolerance)
2780 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2783 ## Generates new elements by rotation of the elements of object around the axis
2784 # @param theObject object which elements should be sweeped
2785 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2786 # @param AngleInRadians the angle of Rotation
2787 # @param NbOfSteps number of steps
2788 # @param Tolerance tolerance
2789 # @param MakeGroups forces the generation of new groups from existing ones
2790 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2791 # of all steps, else - size of each step
2792 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2793 # @ingroup l2_modif_extrurev
2794 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2795 MakeGroups=False, TotalAngle=False):
2797 if isinstance(AngleInRadians,str):
2799 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2801 AngleInRadians = DegreesToRadians(AngleInRadians)
2802 if ( isinstance( theObject, Mesh )):
2803 theObject = theObject.GetMesh()
2804 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2805 Axis = self.smeshpyD.GetAxisStruct(Axis)
2806 Axis,AxisParameters = ParseAxisStruct(Axis)
2807 if TotalAngle and NbOfSteps:
2808 AngleInRadians /= NbOfSteps
2809 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2810 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2811 self.mesh.SetParameters(Parameters)
2813 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2814 NbOfSteps, Tolerance)
2815 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2818 ## Generates new elements by rotation of the elements of object around the axis
2819 # @param theObject object which elements should be sweeped
2820 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2821 # @param AngleInRadians the angle of Rotation
2822 # @param NbOfSteps number of steps
2823 # @param Tolerance tolerance
2824 # @param MakeGroups forces the generation of new groups from existing ones
2825 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2826 # of all steps, else - size of each step
2827 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2828 # @ingroup l2_modif_extrurev
2829 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2830 MakeGroups=False, TotalAngle=False):
2832 if isinstance(AngleInRadians,str):
2834 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2836 AngleInRadians = DegreesToRadians(AngleInRadians)
2837 if ( isinstance( theObject, Mesh )):
2838 theObject = theObject.GetMesh()
2839 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2840 Axis = self.smeshpyD.GetAxisStruct(Axis)
2841 Axis,AxisParameters = ParseAxisStruct(Axis)
2842 if TotalAngle and NbOfSteps:
2843 AngleInRadians /= NbOfSteps
2844 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2845 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2846 self.mesh.SetParameters(Parameters)
2848 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2849 NbOfSteps, Tolerance)
2850 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2853 ## Generates new elements by rotation of the elements of object around the axis
2854 # @param theObject object which elements should be sweeped
2855 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2856 # @param AngleInRadians the angle of Rotation
2857 # @param NbOfSteps number of steps
2858 # @param Tolerance tolerance
2859 # @param MakeGroups forces the generation of new groups from existing ones
2860 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2861 # of all steps, else - size of each step
2862 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2863 # @ingroup l2_modif_extrurev
2864 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2865 MakeGroups=False, TotalAngle=False):
2867 if isinstance(AngleInRadians,str):
2869 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2871 AngleInRadians = DegreesToRadians(AngleInRadians)
2872 if ( isinstance( theObject, Mesh )):
2873 theObject = theObject.GetMesh()
2874 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2875 Axis = self.smeshpyD.GetAxisStruct(Axis)
2876 Axis,AxisParameters = ParseAxisStruct(Axis)
2877 if TotalAngle and NbOfSteps:
2878 AngleInRadians /= NbOfSteps
2879 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2880 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2881 self.mesh.SetParameters(Parameters)
2883 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2884 NbOfSteps, Tolerance)
2885 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2888 ## Generates new elements by extrusion of the elements with given ids
2889 # @param IDsOfElements the list of elements ids for extrusion
2890 # @param StepVector vector, defining the direction and value of extrusion
2891 # @param NbOfSteps the number of steps
2892 # @param MakeGroups forces the generation of new groups from existing ones
2893 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2894 # @ingroup l2_modif_extrurev
2895 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2896 if IDsOfElements == []:
2897 IDsOfElements = self.GetElementsId()
2898 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2899 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2900 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2901 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2902 Parameters = StepVectorParameters + var_separator + Parameters
2903 self.mesh.SetParameters(Parameters)
2905 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2906 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2909 ## Generates new elements by extrusion of the elements with given ids
2910 # @param IDsOfElements is ids of elements
2911 # @param StepVector vector, defining the direction and value of extrusion
2912 # @param NbOfSteps the number of steps
2913 # @param ExtrFlags sets flags for extrusion
2914 # @param SewTolerance uses for comparing locations of nodes if flag
2915 # EXTRUSION_FLAG_SEW is set
2916 # @param MakeGroups forces the generation of new groups from existing ones
2917 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2918 # @ingroup l2_modif_extrurev
2919 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2920 ExtrFlags, SewTolerance, MakeGroups=False):
2921 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2922 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2924 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2925 ExtrFlags, SewTolerance)
2926 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2927 ExtrFlags, SewTolerance)
2930 ## Generates new elements by extrusion of the elements which belong to the object
2931 # @param theObject the object which elements should be processed
2932 # @param StepVector vector, defining the direction and value of extrusion
2933 # @param NbOfSteps the number of steps
2934 # @param MakeGroups forces the generation of new groups from existing ones
2935 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2936 # @ingroup l2_modif_extrurev
2937 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2938 if ( isinstance( theObject, Mesh )):
2939 theObject = theObject.GetMesh()
2940 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2941 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2942 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2943 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2944 Parameters = StepVectorParameters + var_separator + Parameters
2945 self.mesh.SetParameters(Parameters)
2947 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2948 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2951 ## Generates new elements by extrusion of the elements which belong to the object
2952 # @param theObject object which elements should be processed
2953 # @param StepVector vector, defining the direction and value of extrusion
2954 # @param NbOfSteps the number of steps
2955 # @param MakeGroups to generate new groups from existing ones
2956 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2957 # @ingroup l2_modif_extrurev
2958 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2959 if ( isinstance( theObject, Mesh )):
2960 theObject = theObject.GetMesh()
2961 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2962 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2963 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2964 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2965 Parameters = StepVectorParameters + var_separator + Parameters
2966 self.mesh.SetParameters(Parameters)
2968 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2969 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2972 ## Generates new elements by extrusion of the elements which belong to the object
2973 # @param theObject object which elements should be processed
2974 # @param StepVector vector, defining the direction and value of extrusion
2975 # @param NbOfSteps the number of steps
2976 # @param MakeGroups forces the generation of new groups from existing ones
2977 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2978 # @ingroup l2_modif_extrurev
2979 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2980 if ( isinstance( theObject, Mesh )):
2981 theObject = theObject.GetMesh()
2982 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2983 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2984 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2985 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2986 Parameters = StepVectorParameters + var_separator + Parameters
2987 self.mesh.SetParameters(Parameters)
2989 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2990 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2995 ## Generates new elements by extrusion of the given elements
2996 # The path of extrusion must be a meshed edge.
2997 # @param Base mesh or list of ids of elements for extrusion
2998 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2999 # @param NodeStart the start node from Path. Defines the direction of extrusion
3000 # @param HasAngles allows the shape to be rotated around the path
3001 # to get the resulting mesh in a helical fashion
3002 # @param Angles list of angles in radians
3003 # @param LinearVariation forces the computation of rotation angles as linear
3004 # variation of the given Angles along path steps
3005 # @param HasRefPoint allows using the reference point
3006 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3007 # The User can specify any point as the Reference Point.
3008 # @param MakeGroups forces the generation of new groups from existing ones
3009 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3010 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3011 # only SMESH::Extrusion_Error otherwise
3012 # @ingroup l2_modif_extrurev
3013 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3014 HasAngles, Angles, LinearVariation,
3015 HasRefPoint, RefPoint, MakeGroups, ElemType):
3016 Angles,AnglesParameters = ParseAngles(Angles)
3017 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3018 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3019 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3021 Parameters = AnglesParameters + var_separator + RefPointParameters
3022 self.mesh.SetParameters(Parameters)
3024 if isinstance(Base,list):
3026 if Base == []: IDsOfElements = self.GetElementsId()
3027 else: IDsOfElements = Base
3028 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3029 HasAngles, Angles, LinearVariation,
3030 HasRefPoint, RefPoint, MakeGroups, ElemType)
3032 if isinstance(Base,Mesh):
3033 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3034 HasAngles, Angles, LinearVariation,
3035 HasRefPoint, RefPoint, MakeGroups, ElemType)
3037 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3040 ## Generates new elements by extrusion of the given elements
3041 # The path of extrusion must be a meshed edge.
3042 # @param IDsOfElements ids of elements
3043 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3044 # @param PathShape shape(edge) defines the sub-mesh for the path
3045 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3046 # @param HasAngles allows the shape to be rotated around the path
3047 # to get the resulting mesh in a helical fashion
3048 # @param Angles list of angles in radians
3049 # @param HasRefPoint allows using the reference point
3050 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3051 # The User can specify any point as the Reference Point.
3052 # @param MakeGroups forces the generation of new groups from existing ones
3053 # @param LinearVariation forces the computation of rotation angles as linear
3054 # variation of the given Angles along path steps
3055 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3056 # only SMESH::Extrusion_Error otherwise
3057 # @ingroup l2_modif_extrurev
3058 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3059 HasAngles, Angles, HasRefPoint, RefPoint,
3060 MakeGroups=False, LinearVariation=False):
3061 Angles,AnglesParameters = ParseAngles(Angles)
3062 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3063 if IDsOfElements == []:
3064 IDsOfElements = self.GetElementsId()
3065 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3066 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3068 if ( isinstance( PathMesh, Mesh )):
3069 PathMesh = PathMesh.GetMesh()
3070 if HasAngles and Angles and LinearVariation:
3071 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3073 Parameters = AnglesParameters + var_separator + RefPointParameters
3074 self.mesh.SetParameters(Parameters)
3076 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3077 PathShape, NodeStart, HasAngles,
3078 Angles, HasRefPoint, RefPoint)
3079 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3080 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3082 ## Generates new elements by extrusion of the elements which belong to the object
3083 # The path of extrusion must be a meshed edge.
3084 # @param theObject the object which elements should be processed
3085 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3086 # @param PathShape shape(edge) defines the sub-mesh for the path
3087 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3088 # @param HasAngles allows the shape to be rotated around the path
3089 # to get the resulting mesh in a helical fashion
3090 # @param Angles list of angles
3091 # @param HasRefPoint allows using the reference point
3092 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3093 # The User can specify any point as the Reference Point.
3094 # @param MakeGroups forces the generation of new groups from existing ones
3095 # @param LinearVariation forces the computation of rotation angles as linear
3096 # variation of the given Angles along path steps
3097 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3098 # only SMESH::Extrusion_Error otherwise
3099 # @ingroup l2_modif_extrurev
3100 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3101 HasAngles, Angles, HasRefPoint, RefPoint,
3102 MakeGroups=False, LinearVariation=False):
3103 Angles,AnglesParameters = ParseAngles(Angles)
3104 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3105 if ( isinstance( theObject, Mesh )):
3106 theObject = theObject.GetMesh()
3107 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3108 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3109 if ( isinstance( PathMesh, Mesh )):
3110 PathMesh = PathMesh.GetMesh()
3111 if HasAngles and Angles and LinearVariation:
3112 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3114 Parameters = AnglesParameters + var_separator + RefPointParameters
3115 self.mesh.SetParameters(Parameters)
3117 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3118 PathShape, NodeStart, HasAngles,
3119 Angles, HasRefPoint, RefPoint)
3120 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3121 NodeStart, HasAngles, Angles, HasRefPoint,
3124 ## Generates new elements by extrusion of the elements which belong to the object
3125 # The path of extrusion must be a meshed edge.
3126 # @param theObject the object which elements should be processed
3127 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3128 # @param PathShape shape(edge) defines the sub-mesh for the path
3129 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3130 # @param HasAngles allows the shape to be rotated around the path
3131 # to get the resulting mesh in a helical fashion
3132 # @param Angles list of angles
3133 # @param HasRefPoint allows using the reference point
3134 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3135 # The User can specify any point as the Reference Point.
3136 # @param MakeGroups forces the generation of new groups from existing ones
3137 # @param LinearVariation forces the computation of rotation angles as linear
3138 # variation of the given Angles along path steps
3139 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3140 # only SMESH::Extrusion_Error otherwise
3141 # @ingroup l2_modif_extrurev
3142 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3143 HasAngles, Angles, HasRefPoint, RefPoint,
3144 MakeGroups=False, LinearVariation=False):
3145 Angles,AnglesParameters = ParseAngles(Angles)
3146 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3147 if ( isinstance( theObject, Mesh )):
3148 theObject = theObject.GetMesh()
3149 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3150 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3151 if ( isinstance( PathMesh, Mesh )):
3152 PathMesh = PathMesh.GetMesh()
3153 if HasAngles and Angles and LinearVariation:
3154 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3156 Parameters = AnglesParameters + var_separator + RefPointParameters
3157 self.mesh.SetParameters(Parameters)
3159 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3160 PathShape, NodeStart, HasAngles,
3161 Angles, HasRefPoint, RefPoint)
3162 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3163 NodeStart, HasAngles, Angles, HasRefPoint,
3166 ## Generates new elements by extrusion of the elements which belong to the object
3167 # The path of extrusion must be a meshed edge.
3168 # @param theObject the object which elements should be processed
3169 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3170 # @param PathShape shape(edge) defines the sub-mesh for the path
3171 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3172 # @param HasAngles allows the shape to be rotated around the path
3173 # to get the resulting mesh in a helical fashion
3174 # @param Angles list of angles
3175 # @param HasRefPoint allows using the reference point
3176 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3177 # The User can specify any point as the Reference Point.
3178 # @param MakeGroups forces the generation of new groups from existing ones
3179 # @param LinearVariation forces the computation of rotation angles as linear
3180 # variation of the given Angles along path steps
3181 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3182 # only SMESH::Extrusion_Error otherwise
3183 # @ingroup l2_modif_extrurev
3184 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3185 HasAngles, Angles, HasRefPoint, RefPoint,
3186 MakeGroups=False, LinearVariation=False):
3187 Angles,AnglesParameters = ParseAngles(Angles)
3188 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3189 if ( isinstance( theObject, Mesh )):
3190 theObject = theObject.GetMesh()
3191 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3192 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3193 if ( isinstance( PathMesh, Mesh )):
3194 PathMesh = PathMesh.GetMesh()
3195 if HasAngles and Angles and LinearVariation:
3196 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3198 Parameters = AnglesParameters + var_separator + RefPointParameters
3199 self.mesh.SetParameters(Parameters)
3201 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3202 PathShape, NodeStart, HasAngles,
3203 Angles, HasRefPoint, RefPoint)
3204 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3205 NodeStart, HasAngles, Angles, HasRefPoint,
3208 ## Creates a symmetrical copy of mesh elements
3209 # @param IDsOfElements list of elements ids
3210 # @param Mirror is AxisStruct or geom object(point, line, plane)
3211 # @param theMirrorType is POINT, AXIS or PLANE
3212 # If the Mirror is a geom object this parameter is unnecessary
3213 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3214 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3215 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3216 # @ingroup l2_modif_trsf
3217 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3218 if IDsOfElements == []:
3219 IDsOfElements = self.GetElementsId()
3220 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3221 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3222 Mirror,Parameters = ParseAxisStruct(Mirror)
3223 self.mesh.SetParameters(Parameters)
3224 if Copy and MakeGroups:
3225 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3226 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3229 ## Creates a new mesh by a symmetrical copy of mesh elements
3230 # @param IDsOfElements the list of elements ids
3231 # @param Mirror is AxisStruct or geom object (point, line, plane)
3232 # @param theMirrorType is POINT, AXIS or PLANE
3233 # If the Mirror is a geom object this parameter is unnecessary
3234 # @param MakeGroups to generate new groups from existing ones
3235 # @param NewMeshName a name of the new mesh to create
3236 # @return instance of Mesh class
3237 # @ingroup l2_modif_trsf
3238 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3239 if IDsOfElements == []:
3240 IDsOfElements = self.GetElementsId()
3241 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3242 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3243 Mirror,Parameters = ParseAxisStruct(Mirror)
3244 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3245 MakeGroups, NewMeshName)
3246 mesh.SetParameters(Parameters)
3247 return Mesh(self.smeshpyD,self.geompyD,mesh)
3249 ## Creates a symmetrical copy of the object
3250 # @param theObject mesh, submesh or group
3251 # @param Mirror AxisStruct or geom object (point, line, plane)
3252 # @param theMirrorType is POINT, AXIS or PLANE
3253 # If the Mirror is a geom object this parameter is unnecessary
3254 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3255 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3256 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3257 # @ingroup l2_modif_trsf
3258 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3259 if ( isinstance( theObject, Mesh )):
3260 theObject = theObject.GetMesh()
3261 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3262 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3263 Mirror,Parameters = ParseAxisStruct(Mirror)
3264 self.mesh.SetParameters(Parameters)
3265 if Copy and MakeGroups:
3266 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3267 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3270 ## Creates a new mesh by a symmetrical copy of the object
3271 # @param theObject mesh, submesh or group
3272 # @param Mirror AxisStruct or geom object (point, line, plane)
3273 # @param theMirrorType POINT, AXIS or PLANE
3274 # If the Mirror is a geom object this parameter is unnecessary
3275 # @param MakeGroups forces the generation of new groups from existing ones
3276 # @param NewMeshName the name of the new mesh to create
3277 # @return instance of Mesh class
3278 # @ingroup l2_modif_trsf
3279 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3280 if ( isinstance( theObject, Mesh )):
3281 theObject = theObject.GetMesh()
3282 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3283 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3284 Mirror,Parameters = ParseAxisStruct(Mirror)
3285 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3286 MakeGroups, NewMeshName)
3287 mesh.SetParameters(Parameters)
3288 return Mesh( self.smeshpyD,self.geompyD,mesh )
3290 ## Translates the elements
3291 # @param IDsOfElements list of elements ids
3292 # @param Vector the direction of translation (DirStruct or vector)
3293 # @param Copy allows copying the translated elements
3294 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3295 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3296 # @ingroup l2_modif_trsf
3297 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3298 if IDsOfElements == []:
3299 IDsOfElements = self.GetElementsId()
3300 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3301 Vector = self.smeshpyD.GetDirStruct(Vector)
3302 Vector,Parameters = ParseDirStruct(Vector)
3303 self.mesh.SetParameters(Parameters)
3304 if Copy and MakeGroups:
3305 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3306 self.editor.Translate(IDsOfElements, Vector, Copy)
3309 ## Creates a new mesh of translated elements
3310 # @param IDsOfElements list of elements ids
3311 # @param Vector the direction of translation (DirStruct or vector)
3312 # @param MakeGroups forces the generation of new groups from existing ones
3313 # @param NewMeshName the name of the newly created mesh
3314 # @return instance of Mesh class
3315 # @ingroup l2_modif_trsf
3316 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3317 if IDsOfElements == []:
3318 IDsOfElements = self.GetElementsId()
3319 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3320 Vector = self.smeshpyD.GetDirStruct(Vector)
3321 Vector,Parameters = ParseDirStruct(Vector)
3322 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3323 mesh.SetParameters(Parameters)
3324 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3326 ## Translates the object
3327 # @param theObject the object to translate (mesh, submesh, or group)
3328 # @param Vector direction of translation (DirStruct or geom vector)
3329 # @param Copy allows copying the translated elements
3330 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3331 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3332 # @ingroup l2_modif_trsf
3333 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3334 if ( isinstance( theObject, Mesh )):
3335 theObject = theObject.GetMesh()
3336 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3337 Vector = self.smeshpyD.GetDirStruct(Vector)
3338 Vector,Parameters = ParseDirStruct(Vector)
3339 self.mesh.SetParameters(Parameters)
3340 if Copy and MakeGroups:
3341 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3342 self.editor.TranslateObject(theObject, Vector, Copy)
3345 ## Creates a new mesh from the translated object
3346 # @param theObject the object to translate (mesh, submesh, or group)
3347 # @param Vector the direction of translation (DirStruct or geom vector)
3348 # @param MakeGroups forces the generation of new groups from existing ones
3349 # @param NewMeshName the name of the newly created mesh
3350 # @return instance of Mesh class
3351 # @ingroup l2_modif_trsf
3352 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3353 if (isinstance(theObject, Mesh)):
3354 theObject = theObject.GetMesh()
3355 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3356 Vector = self.smeshpyD.GetDirStruct(Vector)
3357 Vector,Parameters = ParseDirStruct(Vector)
3358 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3359 mesh.SetParameters(Parameters)
3360 return Mesh( self.smeshpyD, self.geompyD, mesh )
3364 ## Scales the object
3365 # @param theObject - the object to translate (mesh, submesh, or group)
3366 # @param thePoint - base point for scale
3367 # @param theScaleFact - scale factors for axises
3368 # @param Copy - allows copying the translated elements
3369 # @param MakeGroups - forces the generation of new groups from existing
3371 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3372 # empty list otherwise
3373 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3374 if ( isinstance( theObject, Mesh )):
3375 theObject = theObject.GetMesh()
3376 if ( isinstance( theObject, list )):
3377 theObject = self.editor.MakeIDSource(theObject)
3379 thePoint, Parameters = ParsePointStruct(thePoint)
3380 self.mesh.SetParameters(Parameters)
3382 if Copy and MakeGroups:
3383 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3384 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3387 ## Creates a new mesh from the translated object
3388 # @param theObject - the object to translate (mesh, submesh, or group)
3389 # @param thePoint - base point for scale
3390 # @param theScaleFact - scale factors for axises
3391 # @param MakeGroups - forces the generation of new groups from existing ones
3392 # @param NewMeshName - the name of the newly created mesh
3393 # @return instance of Mesh class
3394 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3395 if (isinstance(theObject, Mesh)):
3396 theObject = theObject.GetMesh()
3397 if ( isinstance( theObject, list )):
3398 theObject = self.editor.MakeIDSource(theObject)
3400 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3401 MakeGroups, NewMeshName)
3402 #mesh.SetParameters(Parameters)
3403 return Mesh( self.smeshpyD, self.geompyD, mesh )
3407 ## Rotates the elements
3408 # @param IDsOfElements list of elements ids
3409 # @param Axis the axis of rotation (AxisStruct or geom line)
3410 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3411 # @param Copy allows copying the rotated elements
3412 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3413 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3414 # @ingroup l2_modif_trsf
3415 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3417 if isinstance(AngleInRadians,str):
3419 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3421 AngleInRadians = DegreesToRadians(AngleInRadians)
3422 if IDsOfElements == []:
3423 IDsOfElements = self.GetElementsId()
3424 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3425 Axis = self.smeshpyD.GetAxisStruct(Axis)
3426 Axis,AxisParameters = ParseAxisStruct(Axis)
3427 Parameters = AxisParameters + var_separator + Parameters
3428 self.mesh.SetParameters(Parameters)
3429 if Copy and MakeGroups:
3430 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3431 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3434 ## Creates a new mesh of rotated elements
3435 # @param IDsOfElements list of element ids
3436 # @param Axis the axis of rotation (AxisStruct or geom line)
3437 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3438 # @param MakeGroups forces the generation of new groups from existing ones
3439 # @param NewMeshName the name of the newly created mesh
3440 # @return instance of Mesh class
3441 # @ingroup l2_modif_trsf
3442 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3444 if isinstance(AngleInRadians,str):
3446 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3448 AngleInRadians = DegreesToRadians(AngleInRadians)
3449 if IDsOfElements == []:
3450 IDsOfElements = self.GetElementsId()
3451 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3452 Axis = self.smeshpyD.GetAxisStruct(Axis)
3453 Axis,AxisParameters = ParseAxisStruct(Axis)
3454 Parameters = AxisParameters + var_separator + Parameters
3455 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3456 MakeGroups, NewMeshName)
3457 mesh.SetParameters(Parameters)
3458 return Mesh( self.smeshpyD, self.geompyD, mesh )
3460 ## Rotates the object
3461 # @param theObject the object to rotate( mesh, submesh, or group)
3462 # @param Axis the axis of rotation (AxisStruct or geom line)
3463 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3464 # @param Copy allows copying the rotated elements
3465 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3466 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3467 # @ingroup l2_modif_trsf
3468 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3470 if isinstance(AngleInRadians,str):
3472 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3474 AngleInRadians = DegreesToRadians(AngleInRadians)
3475 if (isinstance(theObject, Mesh)):
3476 theObject = theObject.GetMesh()
3477 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3478 Axis = self.smeshpyD.GetAxisStruct(Axis)
3479 Axis,AxisParameters = ParseAxisStruct(Axis)
3480 Parameters = AxisParameters + ":" + Parameters
3481 self.mesh.SetParameters(Parameters)
3482 if Copy and MakeGroups:
3483 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3484 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3487 ## Creates a new mesh from the rotated object
3488 # @param theObject the object to rotate (mesh, submesh, or group)
3489 # @param Axis the axis of rotation (AxisStruct or geom line)
3490 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3491 # @param MakeGroups forces the generation of new groups from existing ones
3492 # @param NewMeshName the name of the newly created mesh
3493 # @return instance of Mesh class
3494 # @ingroup l2_modif_trsf
3495 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3497 if isinstance(AngleInRadians,str):
3499 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3501 AngleInRadians = DegreesToRadians(AngleInRadians)
3502 if (isinstance( theObject, Mesh )):
3503 theObject = theObject.GetMesh()
3504 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3505 Axis = self.smeshpyD.GetAxisStruct(Axis)
3506 Axis,AxisParameters = ParseAxisStruct(Axis)
3507 Parameters = AxisParameters + ":" + Parameters
3508 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3509 MakeGroups, NewMeshName)
3510 mesh.SetParameters(Parameters)
3511 return Mesh( self.smeshpyD, self.geompyD, mesh )
3513 ## Finds groups of ajacent nodes within Tolerance.
3514 # @param Tolerance the value of tolerance
3515 # @return the list of groups of nodes
3516 # @ingroup l2_modif_trsf
3517 def FindCoincidentNodes (self, Tolerance):
3518 return self.editor.FindCoincidentNodes(Tolerance)
3520 ## Finds groups of ajacent nodes within Tolerance.
3521 # @param Tolerance the value of tolerance
3522 # @param SubMeshOrGroup SubMesh or Group
3523 # @return the list of groups of nodes
3524 # @ingroup l2_modif_trsf
3525 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3526 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3529 # @param GroupsOfNodes the list of groups of nodes
3530 # @ingroup l2_modif_trsf
3531 def MergeNodes (self, GroupsOfNodes):
3532 self.editor.MergeNodes(GroupsOfNodes)
3534 ## Finds the elements built on the same nodes.
3535 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3536 # @return a list of groups of equal elements
3537 # @ingroup l2_modif_trsf
3538 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3539 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3540 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3541 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3543 ## Merges elements in each given group.
3544 # @param GroupsOfElementsID groups of elements for merging
3545 # @ingroup l2_modif_trsf
3546 def MergeElements(self, GroupsOfElementsID):
3547 self.editor.MergeElements(GroupsOfElementsID)
3549 ## Leaves one element and removes all other elements built on the same nodes.
3550 # @ingroup l2_modif_trsf
3551 def MergeEqualElements(self):
3552 self.editor.MergeEqualElements()
3554 ## Sews free borders
3555 # @return SMESH::Sew_Error
3556 # @ingroup l2_modif_trsf
3557 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3558 FirstNodeID2, SecondNodeID2, LastNodeID2,
3559 CreatePolygons, CreatePolyedrs):
3560 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3561 FirstNodeID2, SecondNodeID2, LastNodeID2,
3562 CreatePolygons, CreatePolyedrs)
3564 ## Sews conform free borders
3565 # @return SMESH::Sew_Error
3566 # @ingroup l2_modif_trsf
3567 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3568 FirstNodeID2, SecondNodeID2):
3569 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3570 FirstNodeID2, SecondNodeID2)
3572 ## Sews border to side
3573 # @return SMESH::Sew_Error
3574 # @ingroup l2_modif_trsf
3575 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3576 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3577 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3578 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3580 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3581 # merged with the nodes of elements of Side2.
3582 # The number of elements in theSide1 and in theSide2 must be
3583 # equal and they should have similar nodal connectivity.
3584 # The nodes to merge should belong to side borders and
3585 # the first node should be linked to the second.
3586 # @return SMESH::Sew_Error
3587 # @ingroup l2_modif_trsf
3588 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3589 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3590 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3591 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3592 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3593 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3595 ## Sets new nodes for the given element.
3596 # @param ide the element id
3597 # @param newIDs nodes ids
3598 # @return If the number of nodes does not correspond to the type of element - returns false
3599 # @ingroup l2_modif_edit
3600 def ChangeElemNodes(self, ide, newIDs):
3601 return self.editor.ChangeElemNodes(ide, newIDs)
3603 ## If during the last operation of MeshEditor some nodes were
3604 # created, this method returns the list of their IDs, \n
3605 # if new nodes were not created - returns empty list
3606 # @return the list of integer values (can be empty)
3607 # @ingroup l1_auxiliary
3608 def GetLastCreatedNodes(self):
3609 return self.editor.GetLastCreatedNodes()
3611 ## If during the last operation of MeshEditor some elements were
3612 # created this method returns the list of their IDs, \n
3613 # if new elements were not created - returns empty list
3614 # @return the list of integer values (can be empty)
3615 # @ingroup l1_auxiliary
3616 def GetLastCreatedElems(self):
3617 return self.editor.GetLastCreatedElems()
3619 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3620 # @param theNodes identifiers of nodes to be doubled
3621 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3622 # nodes. If list of element identifiers is empty then nodes are doubled but
3623 # they not assigned to elements
3624 # @return TRUE if operation has been completed successfully, FALSE otherwise
3625 # @ingroup l2_modif_edit
3626 def DoubleNodes(self, theNodes, theModifiedElems):
3627 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3629 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3630 # This method provided for convenience works as DoubleNodes() described above.
3631 # @param theNodeId identifiers of node to be doubled
3632 # @param theModifiedElems identifiers of elements to be updated
3633 # @return TRUE if operation has been completed successfully, FALSE otherwise
3634 # @ingroup l2_modif_edit
3635 def DoubleNode(self, theNodeId, theModifiedElems):
3636 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3638 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3639 # This method provided for convenience works as DoubleNodes() described above.
3640 # @param theNodes group of nodes to be doubled
3641 # @param theModifiedElems group of elements to be updated.
3642 # @return TRUE if operation has been completed successfully, FALSE otherwise
3643 # @ingroup l2_modif_edit
3644 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3645 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3647 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3648 # This method provided for convenience works as DoubleNodes() described above.
3649 # @param theNodes list of groups of nodes to be doubled
3650 # @param theModifiedElems list of groups of elements to be updated.
3651 # @return TRUE if operation has been completed successfully, FALSE otherwise
3652 # @ingroup l2_modif_edit
3653 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3654 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3656 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3657 # @param theElems - the list of elements (edges or faces) to be replicated
3658 # The nodes for duplication could be found from these elements
3659 # @param theNodesNot - list of nodes to NOT replicate
3660 # @param theAffectedElems - the list of elements (cells and edges) to which the
3661 # replicated nodes should be associated to.
3662 # @return TRUE if operation has been completed successfully, FALSE otherwise
3663 # @ingroup l2_modif_edit
3664 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3665 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3667 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3668 # @param theElems - the list of elements (edges or faces) to be replicated
3669 # The nodes for duplication could be found from these elements
3670 # @param theNodesNot - list of nodes to NOT replicate
3671 # @param theShape - shape to detect affected elements (element which geometric center
3672 # located on or inside shape).
3673 # The replicated nodes should be associated to affected elements.
3674 # @return TRUE if operation has been completed successfully, FALSE otherwise
3675 # @ingroup l2_modif_edit
3676 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3677 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3679 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3680 # This method provided for convenience works as DoubleNodes() described above.
3681 # @param theElems - group of of elements (edges or faces) to be replicated
3682 # @param theNodesNot - group of nodes not to replicated
3683 # @param theAffectedElems - group of elements to which the replicated nodes
3684 # should be associated to.
3685 # @ingroup l2_modif_edit
3686 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
3687 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3689 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3690 # This method provided for convenience works as DoubleNodes() described above.
3691 # @param theElems - group of of elements (edges or faces) to be replicated
3692 # @param theNodesNot - group of nodes not to replicated
3693 # @param theShape - shape to detect affected elements (element which geometric center
3694 # located on or inside shape).
3695 # The replicated nodes should be associated to affected elements.
3696 # @ingroup l2_modif_edit
3697 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3698 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3700 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3701 # This method provided for convenience works as DoubleNodes() described above.
3702 # @param theElems - list of groups of elements (edges or faces) to be replicated
3703 # @param theNodesNot - list of groups of nodes not to replicated
3704 # @param theAffectedElems - group of elements to which the replicated nodes
3705 # should be associated to.
3706 # @return TRUE if operation has been completed successfully, FALSE otherwise
3707 # @ingroup l2_modif_edit
3708 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3709 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3711 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3712 # This method provided for convenience works as DoubleNodes() described above.
3713 # @param theElems - list of groups of elements (edges or faces) to be replicated
3714 # @param theNodesNot - list of groups of nodes not to replicated
3715 # @param theShape - shape to detect affected elements (element which geometric center
3716 # located on or inside shape).
3717 # The replicated nodes should be associated to affected elements.
3718 # @return TRUE if operation has been completed successfully, FALSE otherwise
3719 # @ingroup l2_modif_edit
3720 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3721 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3723 ## The mother class to define algorithm, it is not recommended to use it directly.
3726 # @ingroup l2_algorithms
3727 class Mesh_Algorithm:
3728 # @class Mesh_Algorithm
3729 # @brief Class Mesh_Algorithm
3731 #def __init__(self,smesh):
3739 ## Finds a hypothesis in the study by its type name and parameters.
3740 # Finds only the hypotheses created in smeshpyD engine.
3741 # @return SMESH.SMESH_Hypothesis
3742 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3743 study = smeshpyD.GetCurrentStudy()
3744 #to do: find component by smeshpyD object, not by its data type
3745 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3746 if scomp is not None:
3747 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3748 # Check if the root label of the hypotheses exists
3749 if res and hypRoot is not None:
3750 iter = study.NewChildIterator(hypRoot)
3751 # Check all published hypotheses
3753 hypo_so_i = iter.Value()
3754 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3755 if attr is not None:
3756 anIOR = attr.Value()
3757 hypo_o_i = salome.orb.string_to_object(anIOR)
3758 if hypo_o_i is not None:
3759 # Check if this is a hypothesis
3760 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3761 if hypo_i is not None:
3762 # Check if the hypothesis belongs to current engine
3763 if smeshpyD.GetObjectId(hypo_i) > 0:
3764 # Check if this is the required hypothesis
3765 if hypo_i.GetName() == hypname:
3767 if CompareMethod(hypo_i, args):
3781 ## Finds the algorithm in the study by its type name.
3782 # Finds only the algorithms, which have been created in smeshpyD engine.
3783 # @return SMESH.SMESH_Algo
3784 def FindAlgorithm (self, algoname, smeshpyD):
3785 study = smeshpyD.GetCurrentStudy()
3786 #to do: find component by smeshpyD object, not by its data type
3787 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3788 if scomp is not None:
3789 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3790 # Check if the root label of the algorithms exists
3791 if res and hypRoot is not None:
3792 iter = study.NewChildIterator(hypRoot)
3793 # Check all published algorithms
3795 algo_so_i = iter.Value()
3796 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3797 if attr is not None:
3798 anIOR = attr.Value()
3799 algo_o_i = salome.orb.string_to_object(anIOR)
3800 if algo_o_i is not None:
3801 # Check if this is an algorithm
3802 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3803 if algo_i is not None:
3804 # Checks if the algorithm belongs to the current engine
3805 if smeshpyD.GetObjectId(algo_i) > 0:
3806 # Check if this is the required algorithm
3807 if algo_i.GetName() == algoname:
3820 ## If the algorithm is global, returns 0; \n
3821 # else returns the submesh associated to this algorithm.
3822 def GetSubMesh(self):
3825 ## Returns the wrapped mesher.
3826 def GetAlgorithm(self):
3829 ## Gets the list of hypothesis that can be used with this algorithm
3830 def GetCompatibleHypothesis(self):
3833 mylist = self.algo.GetCompatibleHypothesis()
3836 ## Gets the name of the algorithm
3840 ## Sets the name to the algorithm
3841 def SetName(self, name):
3842 self.mesh.smeshpyD.SetName(self.algo, name)
3844 ## Gets the id of the algorithm
3846 return self.algo.GetId()
3849 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3851 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3852 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3854 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3856 self.Assign(algo, mesh, geom)
3860 def Assign(self, algo, mesh, geom):
3862 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3871 name = GetName(geom)
3874 name = mesh.geompyD.SubShapeName(geom, piece)
3875 mesh.geompyD.addToStudyInFather(piece, geom, name)
3877 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3880 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3881 TreatHypoStatus( status, algo.GetName(), name, True )
3883 def CompareHyp (self, hyp, args):
3884 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3887 def CompareEqualHyp (self, hyp, args):
3891 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3892 UseExisting=0, CompareMethod=""):
3895 if CompareMethod == "": CompareMethod = self.CompareHyp
3896 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3899 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3905 a = a + s + str(args[i])
3909 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3911 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3912 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3915 ## Returns entry of the shape to mesh in the study
3916 def MainShapeEntry(self):
3918 if not self.mesh or not self.mesh.GetMesh(): return entry
3919 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3920 study = self.mesh.smeshpyD.GetCurrentStudy()
3921 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3922 sobj = study.FindObjectIOR(ior)
3923 if sobj: entry = sobj.GetID()
3924 if not entry: return ""
3927 # Public class: Mesh_Segment
3928 # --------------------------
3930 ## Class to define a segment 1D algorithm for discretization
3933 # @ingroup l3_algos_basic
3934 class Mesh_Segment(Mesh_Algorithm):
3936 ## Private constructor.
3937 def __init__(self, mesh, geom=0):
3938 Mesh_Algorithm.__init__(self)
3939 self.Create(mesh, geom, "Regular_1D")
3941 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3942 # @param l for the length of segments that cut an edge
3943 # @param UseExisting if ==true - searches for an existing hypothesis created with
3944 # the same parameters, else (default) - creates a new one
3945 # @param p precision, used for calculation of the number of segments.
3946 # The precision should be a positive, meaningful value within the range [0,1].
3947 # In general, the number of segments is calculated with the formula:
3948 # nb = ceil((edge_length / l) - p)
3949 # Function ceil rounds its argument to the higher integer.
3950 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3951 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3952 # p=1 means rounding of (edge_length / l) to the lower integer.
3953 # Default value is 1e-07.
3954 # @return an instance of StdMeshers_LocalLength hypothesis
3955 # @ingroup l3_hypos_1dhyps
3956 def LocalLength(self, l, UseExisting=0, p=1e-07):
3957 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3958 CompareMethod=self.CompareLocalLength)
3964 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3965 def CompareLocalLength(self, hyp, args):
3966 if IsEqual(hyp.GetLength(), args[0]):
3967 return IsEqual(hyp.GetPrecision(), args[1])
3970 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3971 # @param length is optional maximal allowed length of segment, if it is omitted
3972 # the preestimated length is used that depends on geometry size
3973 # @param UseExisting if ==true - searches for an existing hypothesis created with
3974 # the same parameters, else (default) - create a new one
3975 # @return an instance of StdMeshers_MaxLength hypothesis
3976 # @ingroup l3_hypos_1dhyps
3977 def MaxSize(self, length=0.0, UseExisting=0):
3978 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3981 hyp.SetLength(length)
3983 # set preestimated length
3984 gen = self.mesh.smeshpyD
3985 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3986 self.mesh.GetMesh(), self.mesh.GetShape(),
3988 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3990 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3993 hyp.SetUsePreestimatedLength( length == 0.0 )
3996 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3997 # @param n for the number of segments that cut an edge
3998 # @param s for the scale factor (optional)
3999 # @param reversedEdges is a list of edges to mesh using reversed orientation
4000 # @param UseExisting if ==true - searches for an existing hypothesis created with
4001 # the same parameters, else (default) - create a new one
4002 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4003 # @ingroup l3_hypos_1dhyps
4004 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4005 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4006 reversedEdges, UseExisting = [], reversedEdges
4007 entry = self.MainShapeEntry()
4009 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4010 UseExisting=UseExisting,
4011 CompareMethod=self.CompareNumberOfSegments)
4013 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4014 UseExisting=UseExisting,
4015 CompareMethod=self.CompareNumberOfSegments)
4016 hyp.SetDistrType( 1 )
4017 hyp.SetScaleFactor(s)
4018 hyp.SetNumberOfSegments(n)
4019 hyp.SetReversedEdges( reversedEdges )
4020 hyp.SetObjectEntry( entry )
4024 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4025 def CompareNumberOfSegments(self, hyp, args):
4026 if hyp.GetNumberOfSegments() == args[0]:
4028 if hyp.GetReversedEdges() == args[1]:
4029 if not args[1] or hyp.GetObjectEntry() == args[2]:
4032 if hyp.GetReversedEdges() == args[2]:
4033 if not args[2] or hyp.GetObjectEntry() == args[3]:
4034 if hyp.GetDistrType() == 1:
4035 if IsEqual(hyp.GetScaleFactor(), args[1]):
4039 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4040 # @param start defines the length of the first segment
4041 # @param end defines the length of the last segment
4042 # @param reversedEdges is a list of edges to mesh using reversed orientation
4043 # @param UseExisting if ==true - searches for an existing hypothesis created with
4044 # the same parameters, else (default) - creates a new one
4045 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4046 # @ingroup l3_hypos_1dhyps
4047 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4048 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4049 reversedEdges, UseExisting = [], reversedEdges
4050 entry = self.MainShapeEntry()
4051 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4052 UseExisting=UseExisting,
4053 CompareMethod=self.CompareArithmetic1D)
4054 hyp.SetStartLength(start)
4055 hyp.SetEndLength(end)
4056 hyp.SetReversedEdges( reversedEdges )
4057 hyp.SetObjectEntry( entry )
4061 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4062 def CompareArithmetic1D(self, hyp, args):
4063 if IsEqual(hyp.GetLength(1), args[0]):
4064 if IsEqual(hyp.GetLength(0), args[1]):
4065 if hyp.GetReversedEdges() == args[2]:
4066 if not args[2] or hyp.GetObjectEntry() == args[3]:
4071 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4072 # on curve from 0 to 1 (additionally it is neecessary to check
4073 # orientation of edges and create list of reversed edges if it is
4074 # needed) and sets numbers of segments between given points (default
4075 # values are equals 1
4076 # @param points defines the list of parameters on curve
4077 # @param nbSegs defines the list of numbers of segments
4078 # @param reversedEdges is a list of edges to mesh using reversed orientation
4079 # @param UseExisting if ==true - searches for an existing hypothesis created with
4080 # the same parameters, else (default) - creates a new one
4081 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4082 # @ingroup l3_hypos_1dhyps
4083 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4084 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4085 reversedEdges, UseExisting = [], reversedEdges
4086 if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4087 for i in range( len( reversedEdges )):
4088 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4089 entry = self.MainShapeEntry()
4090 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4091 UseExisting=UseExisting,
4092 CompareMethod=self.CompareFixedPoints1D)
4093 hyp.SetPoints(points)
4094 hyp.SetNbSegments(nbSegs)
4095 hyp.SetReversedEdges(reversedEdges)
4096 hyp.SetObjectEntry(entry)
4100 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4101 ## as the given arguments
4102 def CompareFixedPoints1D(self, hyp, args):
4103 if hyp.GetPoints() == args[0]:
4104 if hyp.GetNbSegments() == args[1]:
4105 if hyp.GetReversedEdges() == args[2]:
4106 if not args[2] or hyp.GetObjectEntry() == args[3]:
4112 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4113 # @param start defines the length of the first segment
4114 # @param end defines the length of the last segment
4115 # @param reversedEdges is a list of edges to mesh using reversed orientation
4116 # @param UseExisting if ==true - searches for an existing hypothesis created with
4117 # the same parameters, else (default) - creates a new one
4118 # @return an instance of StdMeshers_StartEndLength hypothesis
4119 # @ingroup l3_hypos_1dhyps
4120 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4121 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4122 reversedEdges, UseExisting = [], reversedEdges
4123 entry = self.MainShapeEntry()
4124 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4125 UseExisting=UseExisting,
4126 CompareMethod=self.CompareStartEndLength)
4127 hyp.SetStartLength(start)
4128 hyp.SetEndLength(end)
4129 hyp.SetReversedEdges( reversedEdges )
4130 hyp.SetObjectEntry( entry )
4133 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4134 def CompareStartEndLength(self, hyp, args):
4135 if IsEqual(hyp.GetLength(1), args[0]):
4136 if IsEqual(hyp.GetLength(0), args[1]):
4137 if hyp.GetReversedEdges() == args[2]:
4138 if not args[2] or hyp.GetObjectEntry() == args[3]:
4142 ## Defines "Deflection1D" hypothesis
4143 # @param d for the deflection
4144 # @param UseExisting if ==true - searches for an existing hypothesis created with
4145 # the same parameters, else (default) - create a new one
4146 # @ingroup l3_hypos_1dhyps
4147 def Deflection1D(self, d, UseExisting=0):
4148 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4149 CompareMethod=self.CompareDeflection1D)
4150 hyp.SetDeflection(d)
4153 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4154 def CompareDeflection1D(self, hyp, args):
4155 return IsEqual(hyp.GetDeflection(), args[0])
4157 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4158 # the opposite side in case of quadrangular faces
4159 # @ingroup l3_hypos_additi
4160 def Propagation(self):
4161 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4163 ## Defines "AutomaticLength" hypothesis
4164 # @param fineness for the fineness [0-1]
4165 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4166 # same parameters, else (default) - create a new one
4167 # @ingroup l3_hypos_1dhyps
4168 def AutomaticLength(self, fineness=0, UseExisting=0):
4169 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4170 CompareMethod=self.CompareAutomaticLength)
4171 hyp.SetFineness( fineness )
4174 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4175 def CompareAutomaticLength(self, hyp, args):
4176 return IsEqual(hyp.GetFineness(), args[0])
4178 ## Defines "SegmentLengthAroundVertex" hypothesis
4179 # @param length for the segment length
4180 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4181 # Any other integer value means that the hypothesis will be set on the
4182 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4183 # @param UseExisting if ==true - searches for an existing hypothesis created with
4184 # the same parameters, else (default) - creates a new one
4185 # @ingroup l3_algos_segmarv
4186 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4188 store_geom = self.geom
4189 if type(vertex) is types.IntType:
4190 if vertex == 0 or vertex == 1:
4191 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4199 if self.geom is None:
4200 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4202 name = GetName(self.geom)
4205 piece = self.mesh.geom
4206 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4207 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4209 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4211 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4213 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4214 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4216 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4217 CompareMethod=self.CompareLengthNearVertex)
4218 self.geom = store_geom
4219 hyp.SetLength( length )
4222 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4223 # @ingroup l3_algos_segmarv
4224 def CompareLengthNearVertex(self, hyp, args):
4225 return IsEqual(hyp.GetLength(), args[0])
4227 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4228 # If the 2D mesher sees that all boundary edges are quadratic,
4229 # it generates quadratic faces, else it generates linear faces using
4230 # medium nodes as if they are vertices.
4231 # The 3D mesher generates quadratic volumes only if all boundary faces
4232 # are quadratic, else it fails.
4234 # @ingroup l3_hypos_additi
4235 def QuadraticMesh(self):
4236 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4239 # Public class: Mesh_CompositeSegment
4240 # --------------------------
4242 ## Defines a segment 1D algorithm for discretization
4244 # @ingroup l3_algos_basic
4245 class Mesh_CompositeSegment(Mesh_Segment):
4247 ## Private constructor.
4248 def __init__(self, mesh, geom=0):
4249 self.Create(mesh, geom, "CompositeSegment_1D")
4252 # Public class: Mesh_Segment_Python
4253 # ---------------------------------
4255 ## Defines a segment 1D algorithm for discretization with python function
4257 # @ingroup l3_algos_basic
4258 class Mesh_Segment_Python(Mesh_Segment):
4260 ## Private constructor.
4261 def __init__(self, mesh, geom=0):
4262 import Python1dPlugin
4263 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4265 ## Defines "PythonSplit1D" hypothesis
4266 # @param n for the number of segments that cut an edge
4267 # @param func for the python function that calculates the length of all segments
4268 # @param UseExisting if ==true - searches for the existing hypothesis created with
4269 # the same parameters, else (default) - creates a new one
4270 # @ingroup l3_hypos_1dhyps
4271 def PythonSplit1D(self, n, func, UseExisting=0):
4272 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4273 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4274 hyp.SetNumberOfSegments(n)
4275 hyp.SetPythonLog10RatioFunction(func)
4278 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4279 def ComparePythonSplit1D(self, hyp, args):
4280 #if hyp.GetNumberOfSegments() == args[0]:
4281 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4285 # Public class: Mesh_Triangle
4286 # ---------------------------
4288 ## Defines a triangle 2D algorithm
4290 # @ingroup l3_algos_basic
4291 class Mesh_Triangle(Mesh_Algorithm):
4300 ## Private constructor.
4301 def __init__(self, mesh, algoType, geom=0):
4302 Mesh_Algorithm.__init__(self)
4304 self.algoType = algoType
4305 if algoType == MEFISTO:
4306 self.Create(mesh, geom, "MEFISTO_2D")
4308 elif algoType == BLSURF:
4310 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4311 #self.SetPhysicalMesh() - PAL19680
4312 elif algoType == NETGEN:
4314 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4316 elif algoType == NETGEN_2D:
4318 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4321 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4322 # @param area for the maximum area of each triangle
4323 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4324 # same parameters, else (default) - creates a new one
4326 # Only for algoType == MEFISTO || NETGEN_2D
4327 # @ingroup l3_hypos_2dhyps
4328 def MaxElementArea(self, area, UseExisting=0):
4329 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4330 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4331 CompareMethod=self.CompareMaxElementArea)
4332 elif self.algoType == NETGEN:
4333 hyp = self.Parameters(SIMPLE)
4334 hyp.SetMaxElementArea(area)
4337 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4338 def CompareMaxElementArea(self, hyp, args):
4339 return IsEqual(hyp.GetMaxElementArea(), args[0])
4341 ## Defines "LengthFromEdges" hypothesis to build triangles
4342 # based on the length of the edges taken from the wire
4344 # Only for algoType == MEFISTO || NETGEN_2D
4345 # @ingroup l3_hypos_2dhyps
4346 def LengthFromEdges(self):
4347 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4348 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4350 elif self.algoType == NETGEN:
4351 hyp = self.Parameters(SIMPLE)
4352 hyp.LengthFromEdges()
4355 ## Sets a way to define size of mesh elements to generate.
4356 # @param thePhysicalMesh is: DefaultSize or Custom.
4357 # @ingroup l3_hypos_blsurf
4358 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4359 # Parameter of BLSURF algo
4360 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4362 ## Sets size of mesh elements to generate.
4363 # @ingroup l3_hypos_blsurf
4364 def SetPhySize(self, theVal):
4365 # Parameter of BLSURF algo
4366 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4367 self.Parameters().SetPhySize(theVal)
4369 ## Sets lower boundary of mesh element size (PhySize).
4370 # @ingroup l3_hypos_blsurf
4371 def SetPhyMin(self, theVal=-1):
4372 # Parameter of BLSURF algo
4373 self.Parameters().SetPhyMin(theVal)
4375 ## Sets upper boundary of mesh element size (PhySize).
4376 # @ingroup l3_hypos_blsurf
4377 def SetPhyMax(self, theVal=-1):
4378 # Parameter of BLSURF algo
4379 self.Parameters().SetPhyMax(theVal)
4381 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4382 # @param theGeometricMesh is: DefaultGeom or Custom
4383 # @ingroup l3_hypos_blsurf
4384 def SetGeometricMesh(self, theGeometricMesh=0):
4385 # Parameter of BLSURF algo
4386 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4387 self.params.SetGeometricMesh(theGeometricMesh)
4389 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4390 # @ingroup l3_hypos_blsurf
4391 def SetAngleMeshS(self, theVal=_angleMeshS):
4392 # Parameter of BLSURF algo
4393 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4394 self.params.SetAngleMeshS(theVal)
4396 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4397 # @ingroup l3_hypos_blsurf
4398 def SetAngleMeshC(self, theVal=_angleMeshS):
4399 # Parameter of BLSURF algo
4400 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4401 self.params.SetAngleMeshC(theVal)
4403 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4404 # @ingroup l3_hypos_blsurf
4405 def SetGeoMin(self, theVal=-1):
4406 # Parameter of BLSURF algo
4407 self.Parameters().SetGeoMin(theVal)
4409 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4410 # @ingroup l3_hypos_blsurf
4411 def SetGeoMax(self, theVal=-1):
4412 # Parameter of BLSURF algo
4413 self.Parameters().SetGeoMax(theVal)
4415 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4416 # @ingroup l3_hypos_blsurf
4417 def SetGradation(self, theVal=_gradation):
4418 # Parameter of BLSURF algo
4419 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4420 self.params.SetGradation(theVal)
4422 ## Sets topology usage way.
4423 # @param way defines how mesh conformity is assured <ul>
4424 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4425 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4426 # @ingroup l3_hypos_blsurf
4427 def SetTopology(self, way):
4428 # Parameter of BLSURF algo
4429 self.Parameters().SetTopology(way)
4431 ## To respect geometrical edges or not.
4432 # @ingroup l3_hypos_blsurf
4433 def SetDecimesh(self, toIgnoreEdges=False):
4434 # Parameter of BLSURF algo
4435 self.Parameters().SetDecimesh(toIgnoreEdges)
4437 ## Sets verbosity level in the range 0 to 100.
4438 # @ingroup l3_hypos_blsurf
4439 def SetVerbosity(self, level):
4440 # Parameter of BLSURF algo
4441 self.Parameters().SetVerbosity(level)
4443 ## Sets advanced option value.
4444 # @ingroup l3_hypos_blsurf
4445 def SetOptionValue(self, optionName, level):
4446 # Parameter of BLSURF algo
4447 self.Parameters().SetOptionValue(optionName,level)
4449 ## Sets QuadAllowed flag.
4450 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4451 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4452 def SetQuadAllowed(self, toAllow=True):
4453 if self.algoType == NETGEN_2D:
4454 if toAllow: # add QuadranglePreference
4455 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4456 else: # remove QuadranglePreference
4457 for hyp in self.mesh.GetHypothesisList( self.geom ):
4458 if hyp.GetName() == "QuadranglePreference":
4459 self.mesh.RemoveHypothesis( self.geom, hyp )
4464 if self.Parameters():
4465 self.params.SetQuadAllowed(toAllow)
4468 ## Defines hypothesis having several parameters
4470 # @ingroup l3_hypos_netgen
4471 def Parameters(self, which=SOLE):
4474 if self.algoType == NETGEN:
4476 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4477 "libNETGENEngine.so", UseExisting=0)
4479 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4480 "libNETGENEngine.so", UseExisting=0)
4482 elif self.algoType == MEFISTO:
4483 print "Mefisto algo support no multi-parameter hypothesis"
4485 elif self.algoType == NETGEN_2D:
4486 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4487 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4489 elif self.algoType == BLSURF:
4490 self.params = self.Hypothesis("BLSURF_Parameters", [],
4491 "libBLSURFEngine.so", UseExisting=0)
4494 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4499 # Only for algoType == NETGEN
4500 # @ingroup l3_hypos_netgen
4501 def SetMaxSize(self, theSize):
4502 if self.Parameters():
4503 self.params.SetMaxSize(theSize)
4505 ## Sets SecondOrder flag
4507 # Only for algoType == NETGEN
4508 # @ingroup l3_hypos_netgen
4509 def SetSecondOrder(self, theVal):
4510 if self.Parameters():
4511 self.params.SetSecondOrder(theVal)
4513 ## Sets Optimize flag
4515 # Only for algoType == NETGEN
4516 # @ingroup l3_hypos_netgen
4517 def SetOptimize(self, theVal):
4518 if self.Parameters():
4519 self.params.SetOptimize(theVal)
4522 # @param theFineness is:
4523 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4525 # Only for algoType == NETGEN
4526 # @ingroup l3_hypos_netgen
4527 def SetFineness(self, theFineness):
4528 if self.Parameters():
4529 self.params.SetFineness(theFineness)
4533 # Only for algoType == NETGEN
4534 # @ingroup l3_hypos_netgen
4535 def SetGrowthRate(self, theRate):
4536 if self.Parameters():
4537 self.params.SetGrowthRate(theRate)
4539 ## Sets NbSegPerEdge
4541 # Only for algoType == NETGEN
4542 # @ingroup l3_hypos_netgen
4543 def SetNbSegPerEdge(self, theVal):
4544 if self.Parameters():
4545 self.params.SetNbSegPerEdge(theVal)
4547 ## Sets NbSegPerRadius
4549 # Only for algoType == NETGEN
4550 # @ingroup l3_hypos_netgen
4551 def SetNbSegPerRadius(self, theVal):
4552 if self.Parameters():
4553 self.params.SetNbSegPerRadius(theVal)
4555 ## Sets number of segments overriding value set by SetLocalLength()
4557 # Only for algoType == NETGEN
4558 # @ingroup l3_hypos_netgen
4559 def SetNumberOfSegments(self, theVal):
4560 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4562 ## Sets number of segments overriding value set by SetNumberOfSegments()
4564 # Only for algoType == NETGEN
4565 # @ingroup l3_hypos_netgen
4566 def SetLocalLength(self, theVal):
4567 self.Parameters(SIMPLE).SetLocalLength(theVal)
4572 # Public class: Mesh_Quadrangle
4573 # -----------------------------
4575 ## Defines a quadrangle 2D algorithm
4577 # @ingroup l3_algos_basic
4578 class Mesh_Quadrangle(Mesh_Algorithm):
4580 ## Private constructor.
4581 def __init__(self, mesh, geom=0):
4582 Mesh_Algorithm.__init__(self)
4583 self.Create(mesh, geom, "Quadrangle_2D")
4585 ## Defines "QuadranglePreference" hypothesis, forcing construction
4586 # of quadrangles if the number of nodes on the opposite edges is not the same
4587 # while the total number of nodes on edges is even
4589 # @ingroup l3_hypos_additi
4590 def QuadranglePreference(self):
4591 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4592 CompareMethod=self.CompareEqualHyp)
4595 ## Defines "TrianglePreference" hypothesis, forcing construction
4596 # of triangles in the refinement area if the number of nodes
4597 # on the opposite edges is not the same
4599 # @ingroup l3_hypos_additi
4600 def TrianglePreference(self):
4601 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4602 CompareMethod=self.CompareEqualHyp)
4605 ## Defines "QuadrangleParams" hypothesis
4606 # @param vertex: vertex of a trilateral geometrical face, around which triangles
4607 # will be created while other elements will be quadrangles.
4608 # Vertex can be either a GEOM_Object or a vertex ID within the
4610 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4611 # the same parameters, else (default) - creates a new one
4613 # @ingroup l3_hypos_additi
4614 def TriangleVertex(self, vertex, UseExisting=0):
4616 if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4617 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4618 hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4619 CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4620 hyp.SetTriaVertex( vertexID )
4624 # Public class: Mesh_Tetrahedron
4625 # ------------------------------
4627 ## Defines a tetrahedron 3D algorithm
4629 # @ingroup l3_algos_basic
4630 class Mesh_Tetrahedron(Mesh_Algorithm):
4635 ## Private constructor.
4636 def __init__(self, mesh, algoType, geom=0):
4637 Mesh_Algorithm.__init__(self)
4639 if algoType == NETGEN:
4641 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4644 elif algoType == FULL_NETGEN:
4646 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4649 elif algoType == GHS3D:
4651 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4654 elif algoType == GHS3DPRL:
4655 CheckPlugin(GHS3DPRL)
4656 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4659 self.algoType = algoType
4661 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4662 # @param vol for the maximum volume of each tetrahedron
4663 # @param UseExisting if ==true - searches for the existing hypothesis created with
4664 # the same parameters, else (default) - creates a new one
4665 # @ingroup l3_hypos_maxvol
4666 def MaxElementVolume(self, vol, UseExisting=0):
4667 if self.algoType == NETGEN:
4668 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4669 CompareMethod=self.CompareMaxElementVolume)
4670 hyp.SetMaxElementVolume(vol)
4672 elif self.algoType == FULL_NETGEN:
4673 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4676 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4677 def CompareMaxElementVolume(self, hyp, args):
4678 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4680 ## Defines hypothesis having several parameters
4682 # @ingroup l3_hypos_netgen
4683 def Parameters(self, which=SOLE):
4687 if self.algoType == FULL_NETGEN:
4689 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4690 "libNETGENEngine.so", UseExisting=0)
4692 self.params = self.Hypothesis("NETGEN_Parameters", [],
4693 "libNETGENEngine.so", UseExisting=0)
4696 if self.algoType == GHS3D:
4697 self.params = self.Hypothesis("GHS3D_Parameters", [],
4698 "libGHS3DEngine.so", UseExisting=0)
4701 if self.algoType == GHS3DPRL:
4702 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4703 "libGHS3DPRLEngine.so", UseExisting=0)
4706 print "Algo supports no multi-parameter hypothesis"
4710 # Parameter of FULL_NETGEN
4711 # @ingroup l3_hypos_netgen
4712 def SetMaxSize(self, theSize):
4713 self.Parameters().SetMaxSize(theSize)
4715 ## Sets SecondOrder flag
4716 # Parameter of FULL_NETGEN
4717 # @ingroup l3_hypos_netgen
4718 def SetSecondOrder(self, theVal):
4719 self.Parameters().SetSecondOrder(theVal)
4721 ## Sets Optimize flag
4722 # Parameter of FULL_NETGEN
4723 # @ingroup l3_hypos_netgen
4724 def SetOptimize(self, theVal):
4725 self.Parameters().SetOptimize(theVal)
4728 # @param theFineness is:
4729 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4730 # Parameter of FULL_NETGEN
4731 # @ingroup l3_hypos_netgen
4732 def SetFineness(self, theFineness):
4733 self.Parameters().SetFineness(theFineness)
4736 # Parameter of FULL_NETGEN
4737 # @ingroup l3_hypos_netgen
4738 def SetGrowthRate(self, theRate):
4739 self.Parameters().SetGrowthRate(theRate)
4741 ## Sets NbSegPerEdge
4742 # Parameter of FULL_NETGEN
4743 # @ingroup l3_hypos_netgen
4744 def SetNbSegPerEdge(self, theVal):
4745 self.Parameters().SetNbSegPerEdge(theVal)
4747 ## Sets NbSegPerRadius
4748 # Parameter of FULL_NETGEN
4749 # @ingroup l3_hypos_netgen
4750 def SetNbSegPerRadius(self, theVal):
4751 self.Parameters().SetNbSegPerRadius(theVal)
4753 ## Sets number of segments overriding value set by SetLocalLength()
4754 # Only for algoType == NETGEN_FULL
4755 # @ingroup l3_hypos_netgen
4756 def SetNumberOfSegments(self, theVal):
4757 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4759 ## Sets number of segments overriding value set by SetNumberOfSegments()
4760 # Only for algoType == NETGEN_FULL
4761 # @ingroup l3_hypos_netgen
4762 def SetLocalLength(self, theVal):
4763 self.Parameters(SIMPLE).SetLocalLength(theVal)
4765 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4766 # Overrides value set by LengthFromEdges()
4767 # Only for algoType == NETGEN_FULL
4768 # @ingroup l3_hypos_netgen
4769 def MaxElementArea(self, area):
4770 self.Parameters(SIMPLE).SetMaxElementArea(area)
4772 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4773 # Overrides value set by MaxElementArea()
4774 # Only for algoType == NETGEN_FULL
4775 # @ingroup l3_hypos_netgen
4776 def LengthFromEdges(self):
4777 self.Parameters(SIMPLE).LengthFromEdges()
4779 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4780 # Overrides value set by MaxElementVolume()
4781 # Only for algoType == NETGEN_FULL
4782 # @ingroup l3_hypos_netgen
4783 def LengthFromFaces(self):
4784 self.Parameters(SIMPLE).LengthFromFaces()
4786 ## To mesh "holes" in a solid or not. Default is to mesh.
4787 # @ingroup l3_hypos_ghs3dh
4788 def SetToMeshHoles(self, toMesh):
4789 # Parameter of GHS3D
4790 self.Parameters().SetToMeshHoles(toMesh)
4792 ## Set Optimization level:
4793 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4794 # Strong_Optimization.
4795 # Default is Standard_Optimization
4796 # @ingroup l3_hypos_ghs3dh
4797 def SetOptimizationLevel(self, level):
4798 # Parameter of GHS3D
4799 self.Parameters().SetOptimizationLevel(level)
4801 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4802 # @ingroup l3_hypos_ghs3dh
4803 def SetMaximumMemory(self, MB):
4804 # Advanced parameter of GHS3D
4805 self.Parameters().SetMaximumMemory(MB)
4807 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4808 # automatic memory adjustment mode.
4809 # @ingroup l3_hypos_ghs3dh
4810 def SetInitialMemory(self, MB):
4811 # Advanced parameter of GHS3D
4812 self.Parameters().SetInitialMemory(MB)
4814 ## Path to working directory.
4815 # @ingroup l3_hypos_ghs3dh
4816 def SetWorkingDirectory(self, path):
4817 # Advanced parameter of GHS3D
4818 self.Parameters().SetWorkingDirectory(path)
4820 ## To keep working files or remove them. Log file remains in case of errors anyway.
4821 # @ingroup l3_hypos_ghs3dh
4822 def SetKeepFiles(self, toKeep):
4823 # Advanced parameter of GHS3D and GHS3DPRL
4824 self.Parameters().SetKeepFiles(toKeep)
4826 ## To set verbose level [0-10]. <ul>
4827 #<li> 0 - no standard output,
4828 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4829 # indicates when the final mesh is being saved. In addition the software
4830 # gives indication regarding the CPU time.
4831 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4832 # histogram of the skin mesh, quality statistics histogram together with
4833 # the characteristics of the final mesh.</ul>
4834 # @ingroup l3_hypos_ghs3dh
4835 def SetVerboseLevel(self, level):
4836 # Advanced parameter of GHS3D
4837 self.Parameters().SetVerboseLevel(level)
4839 ## To create new nodes.
4840 # @ingroup l3_hypos_ghs3dh
4841 def SetToCreateNewNodes(self, toCreate):
4842 # Advanced parameter of GHS3D
4843 self.Parameters().SetToCreateNewNodes(toCreate)
4845 ## To use boundary recovery version which tries to create mesh on a very poor
4846 # quality surface mesh.
4847 # @ingroup l3_hypos_ghs3dh
4848 def SetToUseBoundaryRecoveryVersion(self, toUse):
4849 # Advanced parameter of GHS3D
4850 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4852 ## Sets command line option as text.
4853 # @ingroup l3_hypos_ghs3dh
4854 def SetTextOption(self, option):
4855 # Advanced parameter of GHS3D
4856 self.Parameters().SetTextOption(option)
4858 ## Sets MED files name and path.
4859 def SetMEDName(self, value):
4860 self.Parameters().SetMEDName(value)
4862 ## Sets the number of partition of the initial mesh
4863 def SetNbPart(self, value):
4864 self.Parameters().SetNbPart(value)
4866 ## When big mesh, start tepal in background
4867 def SetBackground(self, value):
4868 self.Parameters().SetBackground(value)
4870 # Public class: Mesh_Hexahedron
4871 # ------------------------------
4873 ## Defines a hexahedron 3D algorithm
4875 # @ingroup l3_algos_basic
4876 class Mesh_Hexahedron(Mesh_Algorithm):
4881 ## Private constructor.
4882 def __init__(self, mesh, algoType=Hexa, geom=0):
4883 Mesh_Algorithm.__init__(self)
4885 self.algoType = algoType
4887 if algoType == Hexa:
4888 self.Create(mesh, geom, "Hexa_3D")
4891 elif algoType == Hexotic:
4892 CheckPlugin(Hexotic)
4893 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4896 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4897 # @ingroup l3_hypos_hexotic
4898 def MinMaxQuad(self, min=3, max=8, quad=True):
4899 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4901 self.params.SetHexesMinLevel(min)
4902 self.params.SetHexesMaxLevel(max)
4903 self.params.SetHexoticQuadrangles(quad)
4906 # Deprecated, only for compatibility!
4907 # Public class: Mesh_Netgen
4908 # ------------------------------
4910 ## Defines a NETGEN-based 2D or 3D algorithm
4911 # that needs no discrete boundary (i.e. independent)
4913 # This class is deprecated, only for compatibility!
4916 # @ingroup l3_algos_basic
4917 class Mesh_Netgen(Mesh_Algorithm):
4921 ## Private constructor.
4922 def __init__(self, mesh, is3D, geom=0):
4923 Mesh_Algorithm.__init__(self)
4929 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4933 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4936 ## Defines the hypothesis containing parameters of the algorithm
4937 def Parameters(self):
4939 hyp = self.Hypothesis("NETGEN_Parameters", [],
4940 "libNETGENEngine.so", UseExisting=0)
4942 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4943 "libNETGENEngine.so", UseExisting=0)
4946 # Public class: Mesh_Projection1D
4947 # ------------------------------
4949 ## Defines a projection 1D algorithm
4950 # @ingroup l3_algos_proj
4952 class Mesh_Projection1D(Mesh_Algorithm):
4954 ## Private constructor.
4955 def __init__(self, mesh, geom=0):
4956 Mesh_Algorithm.__init__(self)
4957 self.Create(mesh, geom, "Projection_1D")
4959 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4960 # a mesh pattern is taken, and, optionally, the association of vertices
4961 # between the source edge and a target edge (to which a hypothesis is assigned)
4962 # @param edge from which nodes distribution is taken
4963 # @param mesh from which nodes distribution is taken (optional)
4964 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4965 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4966 # to associate with \a srcV (optional)
4967 # @param UseExisting if ==true - searches for the existing hypothesis created with
4968 # the same parameters, else (default) - creates a new one
4969 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4970 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4972 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4973 hyp.SetSourceEdge( edge )
4974 if not mesh is None and isinstance(mesh, Mesh):
4975 mesh = mesh.GetMesh()
4976 hyp.SetSourceMesh( mesh )
4977 hyp.SetVertexAssociation( srcV, tgtV )
4980 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4981 #def CompareSourceEdge(self, hyp, args):
4982 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4986 # Public class: Mesh_Projection2D
4987 # ------------------------------
4989 ## Defines a projection 2D algorithm
4990 # @ingroup l3_algos_proj
4992 class Mesh_Projection2D(Mesh_Algorithm):
4994 ## Private constructor.
4995 def __init__(self, mesh, geom=0):
4996 Mesh_Algorithm.__init__(self)
4997 self.Create(mesh, geom, "Projection_2D")
4999 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5000 # a mesh pattern is taken, and, optionally, the association of vertices
5001 # between the source face and the target face (to which a hypothesis is assigned)
5002 # @param face from which the mesh pattern is taken
5003 # @param mesh from which the mesh pattern is taken (optional)
5004 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5005 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5006 # to associate with \a srcV1 (optional)
5007 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5008 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5009 # to associate with \a srcV2 (optional)
5010 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5011 # the same parameters, else (default) - forces the creation a new one
5013 # Note: all association vertices must belong to one edge of a face
5014 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5015 srcV2=None, tgtV2=None, UseExisting=0):
5016 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5018 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5019 hyp.SetSourceFace( face )
5020 if not mesh is None and isinstance(mesh, Mesh):
5021 mesh = mesh.GetMesh()
5022 hyp.SetSourceMesh( mesh )
5023 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5026 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5027 #def CompareSourceFace(self, hyp, args):
5028 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5031 # Public class: Mesh_Projection3D
5032 # ------------------------------
5034 ## Defines a projection 3D algorithm
5035 # @ingroup l3_algos_proj
5037 class Mesh_Projection3D(Mesh_Algorithm):
5039 ## Private constructor.
5040 def __init__(self, mesh, geom=0):
5041 Mesh_Algorithm.__init__(self)
5042 self.Create(mesh, geom, "Projection_3D")
5044 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5045 # the mesh pattern is taken, and, optionally, the association of vertices
5046 # between the source and the target solid (to which a hipothesis is assigned)
5047 # @param solid from where the mesh pattern is taken
5048 # @param mesh from where the mesh pattern is taken (optional)
5049 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5050 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5051 # to associate with \a srcV1 (optional)
5052 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5053 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5054 # to associate with \a srcV2 (optional)
5055 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5056 # the same parameters, else (default) - creates a new one
5058 # Note: association vertices must belong to one edge of a solid
5059 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5060 srcV2=0, tgtV2=0, UseExisting=0):
5061 hyp = self.Hypothesis("ProjectionSource3D",
5062 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5064 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5065 hyp.SetSource3DShape( solid )
5066 if not mesh is None and isinstance(mesh, Mesh):
5067 mesh = mesh.GetMesh()
5068 hyp.SetSourceMesh( mesh )
5069 if srcV1 and srcV2 and tgtV1 and tgtV2:
5070 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5071 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5074 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5075 #def CompareSourceShape3D(self, hyp, args):
5076 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5080 # Public class: Mesh_Prism
5081 # ------------------------
5083 ## Defines a 3D extrusion algorithm
5084 # @ingroup l3_algos_3dextr
5086 class Mesh_Prism3D(Mesh_Algorithm):
5088 ## Private constructor.
5089 def __init__(self, mesh, geom=0):
5090 Mesh_Algorithm.__init__(self)
5091 self.Create(mesh, geom, "Prism_3D")
5093 # Public class: Mesh_RadialPrism
5094 # -------------------------------
5096 ## Defines a Radial Prism 3D algorithm
5097 # @ingroup l3_algos_radialp
5099 class Mesh_RadialPrism3D(Mesh_Algorithm):
5101 ## Private constructor.
5102 def __init__(self, mesh, geom=0):
5103 Mesh_Algorithm.__init__(self)
5104 self.Create(mesh, geom, "RadialPrism_3D")
5106 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5107 self.nbLayers = None
5109 ## Return 3D hypothesis holding the 1D one
5110 def Get3DHypothesis(self):
5111 return self.distribHyp
5113 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5114 # hypothesis. Returns the created hypothesis
5115 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5116 #print "OwnHypothesis",hypType
5117 if not self.nbLayers is None:
5118 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5119 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5120 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5121 self.mesh.smeshpyD.SetCurrentStudy( None )
5122 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5123 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5124 self.distribHyp.SetLayerDistribution( hyp )
5127 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5128 # prisms to build between the inner and outer shells
5129 # @param n number of layers
5130 # @param UseExisting if ==true - searches for the existing hypothesis created with
5131 # the same parameters, else (default) - creates a new one
5132 def NumberOfLayers(self, n, UseExisting=0):
5133 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5134 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5135 CompareMethod=self.CompareNumberOfLayers)
5136 self.nbLayers.SetNumberOfLayers( n )
5137 return self.nbLayers
5139 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5140 def CompareNumberOfLayers(self, hyp, args):
5141 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5143 ## Defines "LocalLength" hypothesis, specifying the segment length
5144 # to build between the inner and the outer shells
5145 # @param l the length of segments
5146 # @param p the precision of rounding
5147 def LocalLength(self, l, p=1e-07):
5148 hyp = self.OwnHypothesis("LocalLength", [l,p])
5153 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5154 # prisms to build between the inner and the outer shells.
5155 # @param n the number of layers
5156 # @param s the scale factor (optional)
5157 def NumberOfSegments(self, n, s=[]):
5159 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5161 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5162 hyp.SetDistrType( 1 )
5163 hyp.SetScaleFactor(s)
5164 hyp.SetNumberOfSegments(n)
5167 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5168 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5169 # @param start the length of the first segment
5170 # @param end the length of the last segment
5171 def Arithmetic1D(self, start, end ):
5172 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5173 hyp.SetLength(start, 1)
5174 hyp.SetLength(end , 0)
5177 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5178 # to build between the inner and the outer shells as geometric length increasing
5179 # @param start for the length of the first segment
5180 # @param end for the length of the last segment
5181 def StartEndLength(self, start, end):
5182 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5183 hyp.SetLength(start, 1)
5184 hyp.SetLength(end , 0)
5187 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5188 # to build between the inner and outer shells
5189 # @param fineness defines the quality of the mesh within the range [0-1]
5190 def AutomaticLength(self, fineness=0):
5191 hyp = self.OwnHypothesis("AutomaticLength")
5192 hyp.SetFineness( fineness )
5195 # Public class: Mesh_RadialQuadrangle1D2D
5196 # -------------------------------
5198 ## Defines a Radial Quadrangle 1D2D algorithm
5199 # @ingroup l2_algos_radialq
5201 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5203 ## Private constructor.
5204 def __init__(self, mesh, geom=0):
5205 Mesh_Algorithm.__init__(self)
5206 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5208 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5209 self.nbLayers = None
5211 ## Return 2D hypothesis holding the 1D one
5212 def Get2DHypothesis(self):
5213 return self.distribHyp
5215 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5216 # hypothesis. Returns the created hypothesis
5217 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5218 #print "OwnHypothesis",hypType
5220 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5221 if self.distribHyp is None:
5222 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5224 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5225 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5226 self.mesh.smeshpyD.SetCurrentStudy( None )
5227 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5228 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5229 self.distribHyp.SetLayerDistribution( hyp )
5232 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5233 # @param n number of layers
5234 # @param UseExisting if ==true - searches for the existing hypothesis created with
5235 # the same parameters, else (default) - creates a new one
5236 def NumberOfLayers(self, n, UseExisting=0):
5238 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5239 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5240 CompareMethod=self.CompareNumberOfLayers)
5241 self.nbLayers.SetNumberOfLayers( n )
5242 return self.nbLayers
5244 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5245 def CompareNumberOfLayers(self, hyp, args):
5246 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5248 ## Defines "LocalLength" hypothesis, specifying the segment length
5249 # @param l the length of segments
5250 # @param p the precision of rounding
5251 def LocalLength(self, l, p=1e-07):
5252 hyp = self.OwnHypothesis("LocalLength", [l,p])
5257 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5258 # @param n the number of layers
5259 # @param s the scale factor (optional)
5260 def NumberOfSegments(self, n, s=[]):
5262 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5264 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5265 hyp.SetDistrType( 1 )
5266 hyp.SetScaleFactor(s)
5267 hyp.SetNumberOfSegments(n)
5270 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5271 # with a length that changes in arithmetic progression
5272 # @param start the length of the first segment
5273 # @param end the length of the last segment
5274 def Arithmetic1D(self, start, end ):
5275 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5276 hyp.SetLength(start, 1)
5277 hyp.SetLength(end , 0)
5280 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5281 # as geometric length increasing
5282 # @param start for the length of the first segment
5283 # @param end for the length of the last segment
5284 def StartEndLength(self, start, end):
5285 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5286 hyp.SetLength(start, 1)
5287 hyp.SetLength(end , 0)
5290 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5291 # @param fineness defines the quality of the mesh within the range [0-1]
5292 def AutomaticLength(self, fineness=0):
5293 hyp = self.OwnHypothesis("AutomaticLength")
5294 hyp.SetFineness( fineness )
5298 # Private class: Mesh_UseExisting
5299 # -------------------------------
5300 class Mesh_UseExisting(Mesh_Algorithm):
5302 def __init__(self, dim, mesh, geom=0):
5304 self.Create(mesh, geom, "UseExisting_1D")
5306 self.Create(mesh, geom, "UseExisting_2D")
5309 import salome_notebook
5310 notebook = salome_notebook.notebook
5312 ##Return values of the notebook variables
5313 def ParseParameters(last, nbParams,nbParam, value):
5317 listSize = len(last)
5318 for n in range(0,nbParams):
5320 if counter < listSize:
5321 strResult = strResult + last[counter]
5323 strResult = strResult + ""
5325 if isinstance(value, str):
5326 if notebook.isVariable(value):
5327 result = notebook.get(value)
5328 strResult=strResult+value
5330 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5332 strResult=strResult+str(value)
5334 if nbParams - 1 != counter:
5335 strResult=strResult+var_separator #":"
5337 return result, strResult
5339 #Wrapper class for StdMeshers_LocalLength hypothesis
5340 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5342 ## Set Length parameter value
5343 # @param length numerical value or name of variable from notebook
5344 def SetLength(self, length):
5345 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5346 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5347 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5349 ## Set Precision parameter value
5350 # @param precision numerical value or name of variable from notebook
5351 def SetPrecision(self, precision):
5352 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5353 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5354 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5356 #Registering the new proxy for LocalLength
5357 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5360 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5361 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5363 def SetLayerDistribution(self, hypo):
5364 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5365 hypo.ClearParameters();
5366 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5368 #Registering the new proxy for LayerDistribution
5369 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5371 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5372 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5374 ## Set Length parameter value
5375 # @param length numerical value or name of variable from notebook
5376 def SetLength(self, length):
5377 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5378 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5379 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5381 #Registering the new proxy for SegmentLengthAroundVertex
5382 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5385 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5386 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5388 ## Set Length parameter value
5389 # @param length numerical value or name of variable from notebook
5390 # @param isStart true is length is Start Length, otherwise false
5391 def SetLength(self, length, isStart):
5395 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5396 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5397 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5399 #Registering the new proxy for Arithmetic1D
5400 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5402 #Wrapper class for StdMeshers_Deflection1D hypothesis
5403 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5405 ## Set Deflection parameter value
5406 # @param deflection numerical value or name of variable from notebook
5407 def SetDeflection(self, deflection):
5408 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5409 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5410 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5412 #Registering the new proxy for Deflection1D
5413 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5415 #Wrapper class for StdMeshers_StartEndLength hypothesis
5416 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5418 ## Set Length parameter value
5419 # @param length numerical value or name of variable from notebook
5420 # @param isStart true is length is Start Length, otherwise false
5421 def SetLength(self, length, isStart):
5425 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5426 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5427 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5429 #Registering the new proxy for StartEndLength
5430 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5432 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5433 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5435 ## Set Max Element Area parameter value
5436 # @param area numerical value or name of variable from notebook
5437 def SetMaxElementArea(self, area):
5438 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5439 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5440 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5442 #Registering the new proxy for MaxElementArea
5443 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5446 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5447 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5449 ## Set Max Element Volume parameter value
5450 # @param volume numerical value or name of variable from notebook
5451 def SetMaxElementVolume(self, volume):
5452 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5453 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5454 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5456 #Registering the new proxy for MaxElementVolume
5457 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5460 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5461 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5463 ## Set Number Of Layers parameter value
5464 # @param nbLayers numerical value or name of variable from notebook
5465 def SetNumberOfLayers(self, nbLayers):
5466 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5467 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5468 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5470 #Registering the new proxy for NumberOfLayers
5471 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5473 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5474 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5476 ## Set Number Of Segments parameter value
5477 # @param nbSeg numerical value or name of variable from notebook
5478 def SetNumberOfSegments(self, nbSeg):
5479 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5480 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5481 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5482 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5484 ## Set Scale Factor parameter value
5485 # @param factor numerical value or name of variable from notebook
5486 def SetScaleFactor(self, factor):
5487 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5488 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5489 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5491 #Registering the new proxy for NumberOfSegments
5492 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5494 if not noNETGENPlugin:
5495 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5496 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5498 ## Set Max Size parameter value
5499 # @param maxsize numerical value or name of variable from notebook
5500 def SetMaxSize(self, maxsize):
5501 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5502 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5503 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5504 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5506 ## Set Growth Rate parameter value
5507 # @param value numerical value or name of variable from notebook
5508 def SetGrowthRate(self, value):
5509 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5510 value, parameters = ParseParameters(lastParameters,4,2,value)
5511 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5512 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5514 ## Set Number of Segments per Edge parameter value
5515 # @param value numerical value or name of variable from notebook
5516 def SetNbSegPerEdge(self, value):
5517 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5518 value, parameters = ParseParameters(lastParameters,4,3,value)
5519 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5520 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5522 ## Set Number of Segments per Radius parameter value
5523 # @param value numerical value or name of variable from notebook
5524 def SetNbSegPerRadius(self, value):
5525 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5526 value, parameters = ParseParameters(lastParameters,4,4,value)
5527 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5528 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5530 #Registering the new proxy for NETGENPlugin_Hypothesis
5531 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5534 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5535 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5538 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5539 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5541 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5542 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5544 ## Set Number of Segments parameter value
5545 # @param nbSeg numerical value or name of variable from notebook
5546 def SetNumberOfSegments(self, nbSeg):
5547 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5548 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5549 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5550 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5552 ## Set Local Length parameter value
5553 # @param length numerical value or name of variable from notebook
5554 def SetLocalLength(self, length):
5555 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5556 length, parameters = ParseParameters(lastParameters,2,1,length)
5557 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5558 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5560 ## Set Max Element Area parameter value
5561 # @param area numerical value or name of variable from notebook
5562 def SetMaxElementArea(self, area):
5563 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5564 area, parameters = ParseParameters(lastParameters,2,2,area)
5565 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5566 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5568 def LengthFromEdges(self):
5569 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5571 value, parameters = ParseParameters(lastParameters,2,2,value)
5572 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5573 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5575 #Registering the new proxy for NETGEN_SimpleParameters_2D
5576 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5579 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5580 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5581 ## Set Max Element Volume parameter value
5582 # @param volume numerical value or name of variable from notebook
5583 def SetMaxElementVolume(self, volume):
5584 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5585 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5586 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5587 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5589 def LengthFromFaces(self):
5590 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5592 value, parameters = ParseParameters(lastParameters,3,3,value)
5593 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5594 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5596 #Registering the new proxy for NETGEN_SimpleParameters_3D
5597 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5599 pass # if not noNETGENPlugin:
5601 class Pattern(SMESH._objref_SMESH_Pattern):
5603 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5605 if isinstance(theNodeIndexOnKeyPoint1,str):
5607 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5609 theNodeIndexOnKeyPoint1 -= 1
5610 theMesh.SetParameters(Parameters)
5611 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5613 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5616 if isinstance(theNode000Index,str):
5618 if isinstance(theNode001Index,str):
5620 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5622 theNode000Index -= 1
5624 theNode001Index -= 1
5625 theMesh.SetParameters(Parameters)
5626 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5628 #Registering the new proxy for Pattern
5629 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)