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 if isAlgo: return # it does not influence anything
442 reason = hypType + " of the same dimension is already assigned to this shape"
443 elif status == HYP_BAD_DIM :
444 reason = hypType + " mismatches the shape"
445 elif status == HYP_CONCURENT :
446 reason = "there are concurrent hypotheses on sub-shapes"
447 elif status == HYP_BAD_SUBSHAPE :
448 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
449 elif status == HYP_BAD_GEOMETRY:
450 reason = "geometry mismatches the expectation of the algorithm"
451 elif status == HYP_HIDDEN_ALGO:
452 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
453 elif status == HYP_HIDING_ALGO:
454 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
455 elif status == HYP_NEED_SHAPE:
456 reason = "Algorithm can't work without shape"
459 hypName = '"' + hypName + '"'
460 geomName= '"' + geomName+ '"'
461 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
462 print hypName, "was assigned to", geomName,"but", reason
463 elif not geomName == '""':
464 print hypName, "was not assigned to",geomName,":", reason
466 print hypName, "was not assigned:", reason
469 ## Check meshing plugin availability
470 def CheckPlugin(plugin):
471 if plugin == NETGEN and noNETGENPlugin:
472 print "Warning: NETGENPlugin module unavailable"
474 elif plugin == GHS3D and noGHS3DPlugin:
475 print "Warning: GHS3DPlugin module unavailable"
477 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
478 print "Warning: GHS3DPRLPlugin module unavailable"
480 elif plugin == Hexotic and noHexoticPlugin:
481 print "Warning: HexoticPlugin module unavailable"
483 elif plugin == BLSURF and noBLSURFPlugin:
484 print "Warning: BLSURFPlugin module unavailable"
488 # end of l1_auxiliary
491 # All methods of this class are accessible directly from the smesh.py package.
492 class smeshDC(SMESH._objref_SMESH_Gen):
494 ## Sets the current study and Geometry component
495 # @ingroup l1_auxiliary
496 def init_smesh(self,theStudy,geompyD):
497 self.SetCurrentStudy(theStudy,geompyD)
499 ## Creates an empty Mesh. This mesh can have an underlying geometry.
500 # @param obj the Geometrical object on which the mesh is built. If not defined,
501 # the mesh will have no underlying geometry.
502 # @param name the name for the new mesh.
503 # @return an instance of Mesh class.
504 # @ingroup l2_construct
505 def Mesh(self, obj=0, name=0):
506 if isinstance(obj,str):
508 return Mesh(self,self.geompyD,obj,name)
510 ## Returns a long value from enumeration
511 # Should be used for SMESH.FunctorType enumeration
512 # @ingroup l1_controls
513 def EnumToLong(self,theItem):
516 ## Gets PointStruct from vertex
517 # @param theVertex a GEOM object(vertex)
518 # @return SMESH.PointStruct
519 # @ingroup l1_auxiliary
520 def GetPointStruct(self,theVertex):
521 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
522 return PointStruct(x,y,z)
524 ## Gets DirStruct from vector
525 # @param theVector a GEOM object(vector)
526 # @return SMESH.DirStruct
527 # @ingroup l1_auxiliary
528 def GetDirStruct(self,theVector):
529 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
530 if(len(vertices) != 2):
531 print "Error: vector object is incorrect."
533 p1 = self.geompyD.PointCoordinates(vertices[0])
534 p2 = self.geompyD.PointCoordinates(vertices[1])
535 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
536 dirst = DirStruct(pnt)
539 ## Makes DirStruct from a triplet
540 # @param x,y,z vector components
541 # @return SMESH.DirStruct
542 # @ingroup l1_auxiliary
543 def MakeDirStruct(self,x,y,z):
544 pnt = PointStruct(x,y,z)
545 return DirStruct(pnt)
547 ## Get AxisStruct from object
548 # @param theObj a GEOM object (line or plane)
549 # @return SMESH.AxisStruct
550 # @ingroup l1_auxiliary
551 def GetAxisStruct(self,theObj):
552 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
554 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
555 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
556 vertex1 = self.geompyD.PointCoordinates(vertex1)
557 vertex2 = self.geompyD.PointCoordinates(vertex2)
558 vertex3 = self.geompyD.PointCoordinates(vertex3)
559 vertex4 = self.geompyD.PointCoordinates(vertex4)
560 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
561 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
562 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] ]
563 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
565 elif len(edges) == 1:
566 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
567 p1 = self.geompyD.PointCoordinates( vertex1 )
568 p2 = self.geompyD.PointCoordinates( vertex2 )
569 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
573 # From SMESH_Gen interface:
574 # ------------------------
576 ## Sets the given name to the object
577 # @param obj the object to rename
578 # @param name a new object name
579 # @ingroup l1_auxiliary
580 def SetName(self, obj, name):
581 if isinstance( obj, Mesh ):
583 elif isinstance( obj, Mesh_Algorithm ):
584 obj = obj.GetAlgorithm()
585 ior = salome.orb.object_to_string(obj)
586 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
588 ## Sets the current mode
589 # @ingroup l1_auxiliary
590 def SetEmbeddedMode( self,theMode ):
591 #self.SetEmbeddedMode(theMode)
592 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
594 ## Gets the current mode
595 # @ingroup l1_auxiliary
596 def IsEmbeddedMode(self):
597 #return self.IsEmbeddedMode()
598 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
600 ## Sets the current study
601 # @ingroup l1_auxiliary
602 def SetCurrentStudy( self, theStudy, geompyD = None ):
603 #self.SetCurrentStudy(theStudy)
606 geompyD = geompy.geom
609 self.SetGeomEngine(geompyD)
610 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
612 ## Gets the current study
613 # @ingroup l1_auxiliary
614 def GetCurrentStudy(self):
615 #return self.GetCurrentStudy()
616 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
618 ## Creates a Mesh object importing data from the given UNV file
619 # @return an instance of Mesh class
621 def CreateMeshesFromUNV( self,theFileName ):
622 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
623 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
626 ## Creates a Mesh object(s) importing data from the given MED file
627 # @return a list of Mesh class instances
629 def CreateMeshesFromMED( self,theFileName ):
630 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
632 for iMesh in range(len(aSmeshMeshes)) :
633 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
634 aMeshes.append(aMesh)
635 return aMeshes, aStatus
637 ## Creates a Mesh object importing data from the given STL file
638 # @return an instance of Mesh class
640 def CreateMeshesFromSTL( self, theFileName ):
641 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
642 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
645 ## From SMESH_Gen interface
646 # @return the list of integer values
647 # @ingroup l1_auxiliary
648 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
649 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
651 ## From SMESH_Gen interface. Creates a pattern
652 # @return an instance of SMESH_Pattern
654 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
655 # @ingroup l2_modif_patterns
656 def GetPattern(self):
657 return SMESH._objref_SMESH_Gen.GetPattern(self)
659 ## Sets number of segments per diagonal of boundary box of geometry by which
660 # default segment length of appropriate 1D hypotheses is defined.
661 # Default value is 10
662 # @ingroup l1_auxiliary
663 def SetBoundaryBoxSegmentation(self, nbSegments):
664 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
666 ## Concatenate the given meshes into one mesh.
667 # @return an instance of Mesh class
668 # @param meshes the meshes to combine into one mesh
669 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
670 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
671 # @param mergeTolerance tolerance for merging nodes
672 # @param allGroups forces creation of groups of all elements
673 def Concatenate( self, meshes, uniteIdenticalGroups,
674 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
675 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
677 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
678 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
680 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
681 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
682 aSmeshMesh.SetParameters(Parameters)
683 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
686 # Filtering. Auxiliary functions:
687 # ------------------------------
689 ## Creates an empty criterion
690 # @return SMESH.Filter.Criterion
691 # @ingroup l1_controls
692 def GetEmptyCriterion(self):
693 Type = self.EnumToLong(FT_Undefined)
694 Compare = self.EnumToLong(FT_Undefined)
698 UnaryOp = self.EnumToLong(FT_Undefined)
699 BinaryOp = self.EnumToLong(FT_Undefined)
702 Precision = -1 ##@1e-07
703 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
704 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
706 ## Creates a criterion by the given parameters
707 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
708 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
709 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
710 # @param Treshold the threshold value (range of ids as string, shape, numeric)
711 # @param UnaryOp FT_LogicalNOT or FT_Undefined
712 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
713 # FT_Undefined (must be for the last criterion of all criteria)
714 # @return SMESH.Filter.Criterion
715 # @ingroup l1_controls
716 def GetCriterion(self,elementType,
718 Compare = FT_EqualTo,
720 UnaryOp=FT_Undefined,
721 BinaryOp=FT_Undefined):
722 aCriterion = self.GetEmptyCriterion()
723 aCriterion.TypeOfElement = elementType
724 aCriterion.Type = self.EnumToLong(CritType)
728 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
729 aCriterion.Compare = self.EnumToLong(Compare)
730 elif Compare == "=" or Compare == "==":
731 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
733 aCriterion.Compare = self.EnumToLong(FT_LessThan)
735 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
737 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
740 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
741 FT_BelongToCylinder, FT_LyingOnGeom]:
742 # Checks the treshold
743 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
744 aCriterion.ThresholdStr = GetName(aTreshold)
745 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
747 print "Error: The treshold should be a shape."
749 elif CritType == FT_RangeOfIds:
750 # Checks the treshold
751 if isinstance(aTreshold, str):
752 aCriterion.ThresholdStr = aTreshold
754 print "Error: The treshold should be a string."
756 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
757 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
758 # At this point the treshold is unnecessary
759 if aTreshold == FT_LogicalNOT:
760 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
761 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
762 aCriterion.BinaryOp = aTreshold
766 aTreshold = float(aTreshold)
767 aCriterion.Threshold = aTreshold
769 print "Error: The treshold should be a number."
772 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
773 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
775 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
776 aCriterion.BinaryOp = self.EnumToLong(Treshold)
778 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
779 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
781 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
782 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
786 ## Creates a filter with the given parameters
787 # @param elementType the type of elements in the group
788 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
789 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
790 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
791 # @param UnaryOp FT_LogicalNOT or FT_Undefined
792 # @return SMESH_Filter
793 # @ingroup l1_controls
794 def GetFilter(self,elementType,
795 CritType=FT_Undefined,
798 UnaryOp=FT_Undefined):
799 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
800 aFilterMgr = self.CreateFilterManager()
801 aFilter = aFilterMgr.CreateFilter()
803 aCriteria.append(aCriterion)
804 aFilter.SetCriteria(aCriteria)
807 ## Creates a numerical functor by its type
808 # @param theCriterion FT_...; functor type
809 # @return SMESH_NumericalFunctor
810 # @ingroup l1_controls
811 def GetFunctor(self,theCriterion):
812 aFilterMgr = self.CreateFilterManager()
813 if theCriterion == FT_AspectRatio:
814 return aFilterMgr.CreateAspectRatio()
815 elif theCriterion == FT_AspectRatio3D:
816 return aFilterMgr.CreateAspectRatio3D()
817 elif theCriterion == FT_Warping:
818 return aFilterMgr.CreateWarping()
819 elif theCriterion == FT_MinimumAngle:
820 return aFilterMgr.CreateMinimumAngle()
821 elif theCriterion == FT_Taper:
822 return aFilterMgr.CreateTaper()
823 elif theCriterion == FT_Skew:
824 return aFilterMgr.CreateSkew()
825 elif theCriterion == FT_Area:
826 return aFilterMgr.CreateArea()
827 elif theCriterion == FT_Volume3D:
828 return aFilterMgr.CreateVolume3D()
829 elif theCriterion == FT_MultiConnection:
830 return aFilterMgr.CreateMultiConnection()
831 elif theCriterion == FT_MultiConnection2D:
832 return aFilterMgr.CreateMultiConnection2D()
833 elif theCriterion == FT_Length:
834 return aFilterMgr.CreateLength()
835 elif theCriterion == FT_Length2D:
836 return aFilterMgr.CreateLength2D()
838 print "Error: given parameter is not numerucal functor type."
840 ## Creates hypothesis
841 # @param theHType mesh hypothesis type (string)
842 # @param theLibName mesh plug-in library name
843 # @return created hypothesis instance
844 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
845 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
847 ## Gets the mesh stattistic
848 # @return dictionary type element - count of elements
849 # @ingroup l1_meshinfo
850 def GetMeshInfo(self, obj):
851 if isinstance( obj, Mesh ):
854 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
855 values = obj.GetMeshInfo()
856 for i in range(SMESH.Entity_Last._v):
857 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
862 #Registering the new proxy for SMESH_Gen
863 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
869 ## This class allows defining and managing a mesh.
870 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
871 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
872 # new nodes and elements and by changing the existing entities), to get information
873 # about a mesh and to export a mesh into different formats.
882 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
883 # sets the GUI name of this mesh to \a name.
884 # @param smeshpyD an instance of smeshDC class
885 # @param geompyD an instance of geompyDC class
886 # @param obj Shape to be meshed or SMESH_Mesh object
887 # @param name Study name of the mesh
888 # @ingroup l2_construct
889 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
890 self.smeshpyD=smeshpyD
895 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
897 self.mesh = self.smeshpyD.CreateMesh(self.geom)
898 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
901 self.mesh = self.smeshpyD.CreateEmptyMesh()
903 self.smeshpyD.SetName(self.mesh, name)
905 self.smeshpyD.SetName(self.mesh, GetName(obj))
908 self.geom = self.mesh.GetShapeToMesh()
910 self.editor = self.mesh.GetMeshEditor()
912 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
913 # @param theMesh a SMESH_Mesh object
914 # @ingroup l2_construct
915 def SetMesh(self, theMesh):
917 self.geom = self.mesh.GetShapeToMesh()
919 ## Returns the mesh, that is an instance of SMESH_Mesh interface
920 # @return a SMESH_Mesh object
921 # @ingroup l2_construct
925 ## Gets the name of the mesh
926 # @return the name of the mesh as a string
927 # @ingroup l2_construct
929 name = GetName(self.GetMesh())
932 ## Sets a name to the mesh
933 # @param name a new name of the mesh
934 # @ingroup l2_construct
935 def SetName(self, name):
936 self.smeshpyD.SetName(self.GetMesh(), name)
938 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
939 # The subMesh object gives access to the IDs of nodes and elements.
940 # @param theSubObject a geometrical object (shape)
941 # @param theName a name for the submesh
942 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
943 # @ingroup l2_submeshes
944 def GetSubMesh(self, theSubObject, theName):
945 submesh = self.mesh.GetSubMesh(theSubObject, theName)
948 ## Returns the shape associated to the mesh
949 # @return a GEOM_Object
950 # @ingroup l2_construct
954 ## Associates the given shape to the mesh (entails the recreation of the mesh)
955 # @param geom the shape to be meshed (GEOM_Object)
956 # @ingroup l2_construct
957 def SetShape(self, geom):
958 self.mesh = self.smeshpyD.CreateMesh(geom)
960 ## Returns true if the hypotheses are defined well
961 # @param theSubObject a subshape of a mesh shape
962 # @return True or False
963 # @ingroup l2_construct
964 def IsReadyToCompute(self, theSubObject):
965 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
967 ## Returns errors of hypotheses definition.
968 # The list of errors is empty if everything is OK.
969 # @param theSubObject a subshape of a mesh shape
970 # @return a list of errors
971 # @ingroup l2_construct
972 def GetAlgoState(self, theSubObject):
973 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
975 ## Returns a geometrical object on which the given element was built.
976 # The returned geometrical object, if not nil, is either found in the
977 # study or published by this method with the given name
978 # @param theElementID the id of the mesh element
979 # @param theGeomName the user-defined name of the geometrical object
980 # @return GEOM::GEOM_Object instance
981 # @ingroup l2_construct
982 def GetGeometryByMeshElement(self, theElementID, theGeomName):
983 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
985 ## Returns the mesh dimension depending on the dimension of the underlying shape
986 # @return mesh dimension as an integer value [0,3]
987 # @ingroup l1_auxiliary
988 def MeshDimension(self):
989 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
990 if len( shells ) > 0 :
992 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
994 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1000 ## Creates a segment discretization 1D algorithm.
1001 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1002 # \n If the optional \a geom parameter is not set, this algorithm is global.
1003 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1004 # @param algo the type of the required algorithm. Possible values are:
1006 # - smesh.PYTHON for discretization via a python function,
1007 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1008 # @param geom If defined is the subshape to be meshed
1009 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1010 # @ingroup l3_algos_basic
1011 def Segment(self, algo=REGULAR, geom=0):
1012 ## if Segment(geom) is called by mistake
1013 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1014 algo, geom = geom, algo
1015 if not algo: algo = REGULAR
1018 return Mesh_Segment(self, geom)
1019 elif algo == PYTHON:
1020 return Mesh_Segment_Python(self, geom)
1021 elif algo == COMPOSITE:
1022 return Mesh_CompositeSegment(self, geom)
1024 return Mesh_Segment(self, geom)
1026 ## Enables creation of nodes and segments usable by 2D algoritms.
1027 # The added nodes and segments must be bound to edges and vertices by
1028 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1029 # If the optional \a geom parameter is not set, this algorithm is global.
1030 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1031 # @param geom the subshape to be manually meshed
1032 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1033 # @ingroup l3_algos_basic
1034 def UseExistingSegments(self, geom=0):
1035 algo = Mesh_UseExisting(1,self,geom)
1036 return algo.GetAlgorithm()
1038 ## Enables creation of nodes and faces usable by 3D algoritms.
1039 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1040 # and SetMeshElementOnShape()
1041 # If the optional \a geom parameter is not set, this algorithm is global.
1042 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1043 # @param geom the subshape to be manually meshed
1044 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1045 # @ingroup l3_algos_basic
1046 def UseExistingFaces(self, geom=0):
1047 algo = Mesh_UseExisting(2,self,geom)
1048 return algo.GetAlgorithm()
1050 ## Creates a triangle 2D algorithm for faces.
1051 # If the optional \a geom parameter is not set, this algorithm is global.
1052 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1053 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1054 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1055 # @return an instance of Mesh_Triangle algorithm
1056 # @ingroup l3_algos_basic
1057 def Triangle(self, algo=MEFISTO, geom=0):
1058 ## if Triangle(geom) is called by mistake
1059 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1062 return Mesh_Triangle(self, algo, geom)
1064 ## Creates a quadrangle 2D algorithm for faces.
1065 # If the optional \a geom parameter is not set, this algorithm is global.
1066 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1067 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1068 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1069 # @return an instance of Mesh_Quadrangle algorithm
1070 # @ingroup l3_algos_basic
1071 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1072 if algo==RADIAL_QUAD:
1073 return Mesh_RadialQuadrangle1D2D(self,geom)
1075 return Mesh_Quadrangle(self, geom)
1077 ## Creates a tetrahedron 3D algorithm for solids.
1078 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1079 # If the optional \a geom parameter is not set, this algorithm is global.
1080 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1081 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1082 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1083 # @return an instance of Mesh_Tetrahedron algorithm
1084 # @ingroup l3_algos_basic
1085 def Tetrahedron(self, algo=NETGEN, geom=0):
1086 ## if Tetrahedron(geom) is called by mistake
1087 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1088 algo, geom = geom, algo
1089 if not algo: algo = NETGEN
1091 return Mesh_Tetrahedron(self, algo, geom)
1093 ## Creates a hexahedron 3D algorithm for solids.
1094 # If the optional \a geom parameter is not set, this algorithm is global.
1095 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1096 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1097 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1098 # @return an instance of Mesh_Hexahedron algorithm
1099 # @ingroup l3_algos_basic
1100 def Hexahedron(self, algo=Hexa, geom=0):
1101 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1102 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1103 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1104 elif geom == 0: algo, geom = Hexa, algo
1105 return Mesh_Hexahedron(self, algo, geom)
1107 ## Deprecated, used only for compatibility!
1108 # @return an instance of Mesh_Netgen algorithm
1109 # @ingroup l3_algos_basic
1110 def Netgen(self, is3D, geom=0):
1111 return Mesh_Netgen(self, is3D, geom)
1113 ## Creates a projection 1D algorithm for edges.
1114 # If the optional \a geom parameter is not set, this algorithm is global.
1115 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1116 # @param geom If defined, the subshape to be meshed
1117 # @return an instance of Mesh_Projection1D algorithm
1118 # @ingroup l3_algos_proj
1119 def Projection1D(self, geom=0):
1120 return Mesh_Projection1D(self, geom)
1122 ## Creates a projection 2D algorithm for faces.
1123 # If the optional \a geom parameter is not set, this algorithm is global.
1124 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1125 # @param geom If defined, the subshape to be meshed
1126 # @return an instance of Mesh_Projection2D algorithm
1127 # @ingroup l3_algos_proj
1128 def Projection2D(self, geom=0):
1129 return Mesh_Projection2D(self, geom)
1131 ## Creates a projection 3D algorithm for solids.
1132 # If the optional \a geom parameter is not set, this algorithm is global.
1133 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1134 # @param geom If defined, the subshape to be meshed
1135 # @return an instance of Mesh_Projection3D algorithm
1136 # @ingroup l3_algos_proj
1137 def Projection3D(self, geom=0):
1138 return Mesh_Projection3D(self, geom)
1140 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1141 # If the optional \a geom parameter is not set, this algorithm is global.
1142 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1143 # @param geom If defined, the subshape to be meshed
1144 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1145 # @ingroup l3_algos_radialp l3_algos_3dextr
1146 def Prism(self, geom=0):
1150 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1151 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1152 if nbSolids == 0 or nbSolids == nbShells:
1153 return Mesh_Prism3D(self, geom)
1154 return Mesh_RadialPrism3D(self, geom)
1156 ## Evaluates size of prospective mesh on a shape
1157 # @return True or False
1158 def Evaluate(self, geom=0):
1159 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1161 geom = self.mesh.GetShapeToMesh()
1164 return self.smeshpyD.Evaluate(self.mesh, geom)
1167 ## Computes the mesh and returns the status of the computation
1168 # @param discardModifs if True and the mesh has been edited since
1169 # a last total re-compute and that may prevent successful partial re-compute,
1170 # then the mesh is cleaned before Compute()
1171 # @return True or False
1172 # @ingroup l2_construct
1173 def Compute(self, geom=0, discardModifs=False):
1174 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1176 geom = self.mesh.GetShapeToMesh()
1181 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1183 ok = self.smeshpyD.Compute(self.mesh, geom)
1184 except SALOME.SALOME_Exception, ex:
1185 print "Mesh computation failed, exception caught:"
1186 print " ", ex.details.text
1189 print "Mesh computation failed, exception caught:"
1190 traceback.print_exc()
1194 # Treat compute errors
1195 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1196 for err in computeErrors:
1198 if self.mesh.HasShapeToMesh():
1200 mainIOR = salome.orb.object_to_string(geom)
1201 for sname in salome.myStudyManager.GetOpenStudies():
1202 s = salome.myStudyManager.GetStudyByName(sname)
1204 mainSO = s.FindObjectIOR(mainIOR)
1205 if not mainSO: continue
1206 if err.subShapeID == 1:
1207 shapeText = ' on "%s"' % mainSO.GetName()
1208 subIt = s.NewChildIterator(mainSO)
1210 subSO = subIt.Value()
1212 obj = subSO.GetObject()
1213 if not obj: continue
1214 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1216 ids = go.GetSubShapeIndices()
1217 if len(ids) == 1 and ids[0] == err.subShapeID:
1218 shapeText = ' on "%s"' % subSO.GetName()
1221 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1223 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1225 shapeText = " on subshape #%s" % (err.subShapeID)
1227 shapeText = " on subshape #%s" % (err.subShapeID)
1229 stdErrors = ["OK", #COMPERR_OK
1230 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1231 "std::exception", #COMPERR_STD_EXCEPTION
1232 "OCC exception", #COMPERR_OCC_EXCEPTION
1233 "SALOME exception", #COMPERR_SLM_EXCEPTION
1234 "Unknown exception", #COMPERR_EXCEPTION
1235 "Memory allocation problem", #COMPERR_MEMORY_PB
1236 "Algorithm failed", #COMPERR_ALGO_FAILED
1237 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1239 if err.code < len(stdErrors): errText = stdErrors[err.code]
1241 errText = "code %s" % -err.code
1242 if errText: errText += ". "
1243 errText += err.comment
1244 if allReasons != "":allReasons += "\n"
1245 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1249 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1251 if err.isGlobalAlgo:
1259 reason = '%s %sD algorithm is missing' % (glob, dim)
1260 elif err.state == HYP_MISSING:
1261 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1262 % (glob, dim, name, dim))
1263 elif err.state == HYP_NOTCONFORM:
1264 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1265 elif err.state == HYP_BAD_PARAMETER:
1266 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1267 % ( glob, dim, name ))
1268 elif err.state == HYP_BAD_GEOMETRY:
1269 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1270 'geometry' % ( glob, dim, name ))
1272 reason = "For unknown reason."+\
1273 " Revise Mesh.Compute() implementation in smeshDC.py!"
1275 if allReasons != "":allReasons += "\n"
1276 allReasons += reason
1278 if allReasons != "":
1279 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1283 print '"' + GetName(self.mesh) + '"',"has not been computed."
1286 if salome.sg.hasDesktop():
1287 smeshgui = salome.ImportComponentGUI("SMESH")
1288 smeshgui.Init(self.mesh.GetStudyId())
1289 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1290 salome.sg.updateObjBrowser(1)
1294 ## Return submesh objects list in meshing order
1295 # @return list of list of submesh objects
1296 # @ingroup l2_construct
1297 def GetMeshOrder(self):
1298 return self.mesh.GetMeshOrder()
1300 ## Return submesh objects list in meshing order
1301 # @return list of list of submesh objects
1302 # @ingroup l2_construct
1303 def SetMeshOrder(self, submeshes):
1304 return self.mesh.SetMeshOrder(submeshes)
1306 ## Removes all nodes and elements
1307 # @ingroup l2_construct
1310 if salome.sg.hasDesktop():
1311 smeshgui = salome.ImportComponentGUI("SMESH")
1312 smeshgui.Init(self.mesh.GetStudyId())
1313 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1314 salome.sg.updateObjBrowser(1)
1316 ## Removes all nodes and elements of indicated shape
1317 # @ingroup l2_construct
1318 def ClearSubMesh(self, geomId):
1319 self.mesh.ClearSubMesh(geomId)
1320 if salome.sg.hasDesktop():
1321 smeshgui = salome.ImportComponentGUI("SMESH")
1322 smeshgui.Init(self.mesh.GetStudyId())
1323 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1324 salome.sg.updateObjBrowser(1)
1326 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1327 # @param fineness [0,-1] defines mesh fineness
1328 # @return True or False
1329 # @ingroup l3_algos_basic
1330 def AutomaticTetrahedralization(self, fineness=0):
1331 dim = self.MeshDimension()
1333 self.RemoveGlobalHypotheses()
1334 self.Segment().AutomaticLength(fineness)
1336 self.Triangle().LengthFromEdges()
1339 self.Tetrahedron(NETGEN)
1341 return self.Compute()
1343 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1344 # @param fineness [0,-1] defines mesh fineness
1345 # @return True or False
1346 # @ingroup l3_algos_basic
1347 def AutomaticHexahedralization(self, fineness=0):
1348 dim = self.MeshDimension()
1349 # assign the hypotheses
1350 self.RemoveGlobalHypotheses()
1351 self.Segment().AutomaticLength(fineness)
1358 return self.Compute()
1360 ## Assigns a hypothesis
1361 # @param hyp a hypothesis to assign
1362 # @param geom a subhape of mesh geometry
1363 # @return SMESH.Hypothesis_Status
1364 # @ingroup l2_hypotheses
1365 def AddHypothesis(self, hyp, geom=0):
1366 if isinstance( hyp, Mesh_Algorithm ):
1367 hyp = hyp.GetAlgorithm()
1372 geom = self.mesh.GetShapeToMesh()
1374 status = self.mesh.AddHypothesis(geom, hyp)
1375 isAlgo = hyp._narrow( SMESH_Algo )
1376 hyp_name = GetName( hyp )
1379 geom_name = GetName( geom )
1380 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1383 ## Unassigns a hypothesis
1384 # @param hyp a hypothesis to unassign
1385 # @param geom a subshape of mesh geometry
1386 # @return SMESH.Hypothesis_Status
1387 # @ingroup l2_hypotheses
1388 def RemoveHypothesis(self, hyp, geom=0):
1389 if isinstance( hyp, Mesh_Algorithm ):
1390 hyp = hyp.GetAlgorithm()
1395 status = self.mesh.RemoveHypothesis(geom, hyp)
1398 ## Gets the list of hypotheses added on a geometry
1399 # @param geom a subshape of mesh geometry
1400 # @return the sequence of SMESH_Hypothesis
1401 # @ingroup l2_hypotheses
1402 def GetHypothesisList(self, geom):
1403 return self.mesh.GetHypothesisList( geom )
1405 ## Removes all global hypotheses
1406 # @ingroup l2_hypotheses
1407 def RemoveGlobalHypotheses(self):
1408 current_hyps = self.mesh.GetHypothesisList( self.geom )
1409 for hyp in current_hyps:
1410 self.mesh.RemoveHypothesis( self.geom, hyp )
1414 ## Creates a mesh group based on the geometric object \a grp
1415 # and gives a \a name, \n if this parameter is not defined
1416 # the name is the same as the geometric group name \n
1417 # Note: Works like GroupOnGeom().
1418 # @param grp a geometric group, a vertex, an edge, a face or a solid
1419 # @param name the name of the mesh group
1420 # @return SMESH_GroupOnGeom
1421 # @ingroup l2_grps_create
1422 def Group(self, grp, name=""):
1423 return self.GroupOnGeom(grp, name)
1425 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1426 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1427 ## allowing to overwrite the file if it exists or add the exported data to its contents
1428 # @param f the file name
1429 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1430 # @param opt boolean parameter for creating/not creating
1431 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1432 # @param overwrite boolean parameter for overwriting/not overwriting the file
1433 # @ingroup l2_impexp
1434 def ExportToMED(self, f, version, opt=0, overwrite=1):
1435 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1437 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1438 ## allowing to overwrite the file if it exists or add the exported data to its contents
1439 # @param f is the file name
1440 # @param auto_groups boolean parameter for creating/not creating
1441 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1442 # the typical use is auto_groups=false.
1443 # @param version MED format version(MED_V2_1 or MED_V2_2)
1444 # @param overwrite boolean parameter for overwriting/not overwriting the file
1445 # @ingroup l2_impexp
1446 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1447 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1449 ## Exports the mesh in a file in DAT format
1450 # @param f the file name
1451 # @ingroup l2_impexp
1452 def ExportDAT(self, f):
1453 self.mesh.ExportDAT(f)
1455 ## Exports the mesh in a file in UNV format
1456 # @param f the file name
1457 # @ingroup l2_impexp
1458 def ExportUNV(self, f):
1459 self.mesh.ExportUNV(f)
1461 ## Export the mesh in a file in STL format
1462 # @param f the file name
1463 # @param ascii defines the file encoding
1464 # @ingroup l2_impexp
1465 def ExportSTL(self, f, ascii=1):
1466 self.mesh.ExportSTL(f, ascii)
1469 # Operations with groups:
1470 # ----------------------
1472 ## Creates an empty mesh group
1473 # @param elementType the type of elements in the group
1474 # @param name the name of the mesh group
1475 # @return SMESH_Group
1476 # @ingroup l2_grps_create
1477 def CreateEmptyGroup(self, elementType, name):
1478 return self.mesh.CreateGroup(elementType, name)
1480 ## Creates a mesh group based on the geometrical object \a grp
1481 # and gives a \a name, \n if this parameter is not defined
1482 # the name is the same as the geometrical group name
1483 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1484 # @param name the name of the mesh group
1485 # @param typ the type of elements in the group. If not set, it is
1486 # automatically detected by the type of the geometry
1487 # @return SMESH_GroupOnGeom
1488 # @ingroup l2_grps_create
1489 def GroupOnGeom(self, grp, name="", typ=None):
1491 name = grp.GetName()
1494 tgeo = str(grp.GetShapeType())
1495 if tgeo == "VERTEX":
1497 elif tgeo == "EDGE":
1499 elif tgeo == "FACE":
1501 elif tgeo == "SOLID":
1503 elif tgeo == "SHELL":
1505 elif tgeo == "COMPOUND":
1506 try: # it raises on a compound of compounds
1507 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1508 print "Mesh.Group: empty geometric group", GetName( grp )
1513 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1515 tgeo = self.geompyD.GetType(grp)
1516 if tgeo == geompyDC.ShapeType["VERTEX"]:
1518 elif tgeo == geompyDC.ShapeType["EDGE"]:
1520 elif tgeo == geompyDC.ShapeType["FACE"]:
1522 elif tgeo == geompyDC.ShapeType["SOLID"]:
1528 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1529 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1530 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1538 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1541 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1543 ## Creates a mesh group by the given ids of elements
1544 # @param groupName the name of the mesh group
1545 # @param elementType the type of elements in the group
1546 # @param elemIDs the list of ids
1547 # @return SMESH_Group
1548 # @ingroup l2_grps_create
1549 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1550 group = self.mesh.CreateGroup(elementType, groupName)
1554 ## Creates a mesh group by the given conditions
1555 # @param groupName the name of the mesh group
1556 # @param elementType the type of elements in the group
1557 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1558 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1559 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1560 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1561 # @return SMESH_Group
1562 # @ingroup l2_grps_create
1566 CritType=FT_Undefined,
1569 UnaryOp=FT_Undefined):
1570 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1571 group = self.MakeGroupByCriterion(groupName, aCriterion)
1574 ## Creates a mesh group by the given criterion
1575 # @param groupName the name of the mesh group
1576 # @param Criterion the instance of Criterion class
1577 # @return SMESH_Group
1578 # @ingroup l2_grps_create
1579 def MakeGroupByCriterion(self, groupName, Criterion):
1580 aFilterMgr = self.smeshpyD.CreateFilterManager()
1581 aFilter = aFilterMgr.CreateFilter()
1583 aCriteria.append(Criterion)
1584 aFilter.SetCriteria(aCriteria)
1585 group = self.MakeGroupByFilter(groupName, aFilter)
1588 ## Creates a mesh group by the given criteria (list of criteria)
1589 # @param groupName the name of the mesh group
1590 # @param theCriteria the list of criteria
1591 # @return SMESH_Group
1592 # @ingroup l2_grps_create
1593 def MakeGroupByCriteria(self, groupName, theCriteria):
1594 aFilterMgr = self.smeshpyD.CreateFilterManager()
1595 aFilter = aFilterMgr.CreateFilter()
1596 aFilter.SetCriteria(theCriteria)
1597 group = self.MakeGroupByFilter(groupName, aFilter)
1600 ## Creates a mesh group by the given filter
1601 # @param groupName the name of the mesh group
1602 # @param theFilter the instance of Filter class
1603 # @return SMESH_Group
1604 # @ingroup l2_grps_create
1605 def MakeGroupByFilter(self, groupName, theFilter):
1606 anIds = theFilter.GetElementsId(self.mesh)
1607 anElemType = theFilter.GetElementType()
1608 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1611 ## Passes mesh elements through the given filter and return IDs of fitting elements
1612 # @param theFilter SMESH_Filter
1613 # @return a list of ids
1614 # @ingroup l1_controls
1615 def GetIdsFromFilter(self, theFilter):
1616 return theFilter.GetElementsId(self.mesh)
1618 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1619 # Returns a list of special structures (borders).
1620 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1621 # @ingroup l1_controls
1622 def GetFreeBorders(self):
1623 aFilterMgr = self.smeshpyD.CreateFilterManager()
1624 aPredicate = aFilterMgr.CreateFreeEdges()
1625 aPredicate.SetMesh(self.mesh)
1626 aBorders = aPredicate.GetBorders()
1630 # @ingroup l2_grps_delete
1631 def RemoveGroup(self, group):
1632 self.mesh.RemoveGroup(group)
1634 ## Removes a group with its contents
1635 # @ingroup l2_grps_delete
1636 def RemoveGroupWithContents(self, group):
1637 self.mesh.RemoveGroupWithContents(group)
1639 ## Gets the list of groups existing in the mesh
1640 # @return a sequence of SMESH_GroupBase
1641 # @ingroup l2_grps_create
1642 def GetGroups(self):
1643 return self.mesh.GetGroups()
1645 ## Gets the number of groups existing in the mesh
1646 # @return the quantity of groups as an integer value
1647 # @ingroup l2_grps_create
1649 return self.mesh.NbGroups()
1651 ## Gets the list of names of groups existing in the mesh
1652 # @return list of strings
1653 # @ingroup l2_grps_create
1654 def GetGroupNames(self):
1655 groups = self.GetGroups()
1657 for group in groups:
1658 names.append(group.GetName())
1661 ## Produces a union of two groups
1662 # A new group is created. All mesh elements that are
1663 # present in the initial groups are added to the new one
1664 # @return an instance of SMESH_Group
1665 # @ingroup l2_grps_operon
1666 def UnionGroups(self, group1, group2, name):
1667 return self.mesh.UnionGroups(group1, group2, name)
1669 ## Produces a union list of groups
1670 # New group is created. All mesh elements that are present in
1671 # initial groups are added to the new one
1672 # @return an instance of SMESH_Group
1673 # @ingroup l2_grps_operon
1674 def UnionListOfGroups(self, groups, name):
1675 return self.mesh.UnionListOfGroups(groups, name)
1677 ## Prodices an intersection of two groups
1678 # A new group is created. All mesh elements that are common
1679 # for the two initial groups are added to the new one.
1680 # @return an instance of SMESH_Group
1681 # @ingroup l2_grps_operon
1682 def IntersectGroups(self, group1, group2, name):
1683 return self.mesh.IntersectGroups(group1, group2, name)
1685 ## Produces an intersection of groups
1686 # New group is created. All mesh elements that are present in all
1687 # initial groups simultaneously are added to the new one
1688 # @return an instance of SMESH_Group
1689 # @ingroup l2_grps_operon
1690 def IntersectListOfGroups(self, groups, name):
1691 return self.mesh.IntersectListOfGroups(groups, name)
1693 ## Produces a cut of two groups
1694 # A new group is created. All mesh elements that are present in
1695 # the main group but are not present in the tool group are added to the new one
1696 # @return an instance of SMESH_Group
1697 # @ingroup l2_grps_operon
1698 def CutGroups(self, main_group, tool_group, name):
1699 return self.mesh.CutGroups(main_group, tool_group, name)
1701 ## Produces a cut of groups
1702 # A new group is created. All mesh elements that are present in main groups
1703 # but do not present in tool groups are added to the new one
1704 # @return an instance of SMESH_Group
1705 # @ingroup l2_grps_operon
1706 def CutListOfGroups(self, main_groups, tool_groups, name):
1707 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1709 ## Produces a group of elements with specified element type using list of existing groups
1710 # A new group is created. System
1711 # 1) extract all nodes on which groups elements are built
1712 # 2) combine all elements of specified dimension laying on these nodes
1713 # @return an instance of SMESH_Group
1714 # @ingroup l2_grps_operon
1715 def CreateDimGroup(self, groups, elem_type, name):
1716 return self.mesh.CreateDimGroup(groups, elem_type, name)
1719 ## Convert group on geom into standalone group
1720 # @ingroup l2_grps_delete
1721 def ConvertToStandalone(self, group):
1722 return self.mesh.ConvertToStandalone(group)
1724 # Get some info about mesh:
1725 # ------------------------
1727 ## Returns the log of nodes and elements added or removed
1728 # since the previous clear of the log.
1729 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1730 # @return list of log_block structures:
1735 # @ingroup l1_auxiliary
1736 def GetLog(self, clearAfterGet):
1737 return self.mesh.GetLog(clearAfterGet)
1739 ## Clears the log of nodes and elements added or removed since the previous
1740 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1741 # @ingroup l1_auxiliary
1743 self.mesh.ClearLog()
1745 ## Toggles auto color mode on the object.
1746 # @param theAutoColor the flag which toggles auto color mode.
1747 # @ingroup l1_auxiliary
1748 def SetAutoColor(self, theAutoColor):
1749 self.mesh.SetAutoColor(theAutoColor)
1751 ## Gets flag of object auto color mode.
1752 # @return True or False
1753 # @ingroup l1_auxiliary
1754 def GetAutoColor(self):
1755 return self.mesh.GetAutoColor()
1757 ## Gets the internal ID
1758 # @return integer value, which is the internal Id of the mesh
1759 # @ingroup l1_auxiliary
1761 return self.mesh.GetId()
1764 # @return integer value, which is the study Id of the mesh
1765 # @ingroup l1_auxiliary
1766 def GetStudyId(self):
1767 return self.mesh.GetStudyId()
1769 ## Checks the group names for duplications.
1770 # Consider the maximum group name length stored in MED file.
1771 # @return True or False
1772 # @ingroup l1_auxiliary
1773 def HasDuplicatedGroupNamesMED(self):
1774 return self.mesh.HasDuplicatedGroupNamesMED()
1776 ## Obtains the mesh editor tool
1777 # @return an instance of SMESH_MeshEditor
1778 # @ingroup l1_modifying
1779 def GetMeshEditor(self):
1780 return self.mesh.GetMeshEditor()
1783 # @return an instance of SALOME_MED::MESH
1784 # @ingroup l1_auxiliary
1785 def GetMEDMesh(self):
1786 return self.mesh.GetMEDMesh()
1789 # Get informations about mesh contents:
1790 # ------------------------------------
1792 ## Gets the mesh stattistic
1793 # @return dictionary type element - count of elements
1794 # @ingroup l1_meshinfo
1795 def GetMeshInfo(self, obj = None):
1796 if not obj: obj = self.mesh
1797 return self.smeshpyD.GetMeshInfo(obj)
1799 ## Returns the number of nodes in the mesh
1800 # @return an integer value
1801 # @ingroup l1_meshinfo
1803 return self.mesh.NbNodes()
1805 ## Returns the number of elements in the mesh
1806 # @return an integer value
1807 # @ingroup l1_meshinfo
1808 def NbElements(self):
1809 return self.mesh.NbElements()
1811 ## Returns the number of 0d elements in the mesh
1812 # @return an integer value
1813 # @ingroup l1_meshinfo
1814 def Nb0DElements(self):
1815 return self.mesh.Nb0DElements()
1817 ## Returns the number of edges in the mesh
1818 # @return an integer value
1819 # @ingroup l1_meshinfo
1821 return self.mesh.NbEdges()
1823 ## Returns the number of edges with the given order in the mesh
1824 # @param elementOrder the order of elements:
1825 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1826 # @return an integer value
1827 # @ingroup l1_meshinfo
1828 def NbEdgesOfOrder(self, elementOrder):
1829 return self.mesh.NbEdgesOfOrder(elementOrder)
1831 ## Returns the number of faces in the mesh
1832 # @return an integer value
1833 # @ingroup l1_meshinfo
1835 return self.mesh.NbFaces()
1837 ## Returns the number of faces with the given order in the mesh
1838 # @param elementOrder the order of elements:
1839 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1840 # @return an integer value
1841 # @ingroup l1_meshinfo
1842 def NbFacesOfOrder(self, elementOrder):
1843 return self.mesh.NbFacesOfOrder(elementOrder)
1845 ## Returns the number of triangles in the mesh
1846 # @return an integer value
1847 # @ingroup l1_meshinfo
1848 def NbTriangles(self):
1849 return self.mesh.NbTriangles()
1851 ## Returns the number of triangles with the given order in the mesh
1852 # @param elementOrder is the order of elements:
1853 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1854 # @return an integer value
1855 # @ingroup l1_meshinfo
1856 def NbTrianglesOfOrder(self, elementOrder):
1857 return self.mesh.NbTrianglesOfOrder(elementOrder)
1859 ## Returns the number of quadrangles in the mesh
1860 # @return an integer value
1861 # @ingroup l1_meshinfo
1862 def NbQuadrangles(self):
1863 return self.mesh.NbQuadrangles()
1865 ## Returns the number of quadrangles with the given order in the mesh
1866 # @param elementOrder the order of elements:
1867 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1868 # @return an integer value
1869 # @ingroup l1_meshinfo
1870 def NbQuadranglesOfOrder(self, elementOrder):
1871 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1873 ## Returns the number of polygons in the mesh
1874 # @return an integer value
1875 # @ingroup l1_meshinfo
1876 def NbPolygons(self):
1877 return self.mesh.NbPolygons()
1879 ## Returns the number of volumes in the mesh
1880 # @return an integer value
1881 # @ingroup l1_meshinfo
1882 def NbVolumes(self):
1883 return self.mesh.NbVolumes()
1885 ## Returns the number of volumes with the given order in the mesh
1886 # @param elementOrder the order of elements:
1887 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1888 # @return an integer value
1889 # @ingroup l1_meshinfo
1890 def NbVolumesOfOrder(self, elementOrder):
1891 return self.mesh.NbVolumesOfOrder(elementOrder)
1893 ## Returns the number of tetrahedrons in the mesh
1894 # @return an integer value
1895 # @ingroup l1_meshinfo
1897 return self.mesh.NbTetras()
1899 ## Returns the number of tetrahedrons with the given order in the mesh
1900 # @param elementOrder the order of elements:
1901 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1902 # @return an integer value
1903 # @ingroup l1_meshinfo
1904 def NbTetrasOfOrder(self, elementOrder):
1905 return self.mesh.NbTetrasOfOrder(elementOrder)
1907 ## Returns the number of hexahedrons in the mesh
1908 # @return an integer value
1909 # @ingroup l1_meshinfo
1911 return self.mesh.NbHexas()
1913 ## Returns the number of hexahedrons with the given order in the mesh
1914 # @param elementOrder the order of elements:
1915 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1916 # @return an integer value
1917 # @ingroup l1_meshinfo
1918 def NbHexasOfOrder(self, elementOrder):
1919 return self.mesh.NbHexasOfOrder(elementOrder)
1921 ## Returns the number of pyramids in the mesh
1922 # @return an integer value
1923 # @ingroup l1_meshinfo
1924 def NbPyramids(self):
1925 return self.mesh.NbPyramids()
1927 ## Returns the number of pyramids with the given order in the mesh
1928 # @param elementOrder the order of elements:
1929 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1930 # @return an integer value
1931 # @ingroup l1_meshinfo
1932 def NbPyramidsOfOrder(self, elementOrder):
1933 return self.mesh.NbPyramidsOfOrder(elementOrder)
1935 ## Returns the number of prisms in the mesh
1936 # @return an integer value
1937 # @ingroup l1_meshinfo
1939 return self.mesh.NbPrisms()
1941 ## Returns the number of prisms with the given order in the mesh
1942 # @param elementOrder the order of elements:
1943 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1944 # @return an integer value
1945 # @ingroup l1_meshinfo
1946 def NbPrismsOfOrder(self, elementOrder):
1947 return self.mesh.NbPrismsOfOrder(elementOrder)
1949 ## Returns the number of polyhedrons in the mesh
1950 # @return an integer value
1951 # @ingroup l1_meshinfo
1952 def NbPolyhedrons(self):
1953 return self.mesh.NbPolyhedrons()
1955 ## Returns the number of submeshes in the mesh
1956 # @return an integer value
1957 # @ingroup l1_meshinfo
1958 def NbSubMesh(self):
1959 return self.mesh.NbSubMesh()
1961 ## Returns the list of mesh elements IDs
1962 # @return the list of integer values
1963 # @ingroup l1_meshinfo
1964 def GetElementsId(self):
1965 return self.mesh.GetElementsId()
1967 ## Returns the list of IDs of mesh elements with the given type
1968 # @param elementType the required type of elements
1969 # @return list of integer values
1970 # @ingroup l1_meshinfo
1971 def GetElementsByType(self, elementType):
1972 return self.mesh.GetElementsByType(elementType)
1974 ## Returns the list of mesh nodes IDs
1975 # @return the list of integer values
1976 # @ingroup l1_meshinfo
1977 def GetNodesId(self):
1978 return self.mesh.GetNodesId()
1980 # Get the information about mesh elements:
1981 # ------------------------------------
1983 ## Returns the type of mesh element
1984 # @return the value from SMESH::ElementType enumeration
1985 # @ingroup l1_meshinfo
1986 def GetElementType(self, id, iselem):
1987 return self.mesh.GetElementType(id, iselem)
1989 ## Returns the geometric type of mesh element
1990 # @return the value from SMESH::EntityType enumeration
1991 # @ingroup l1_meshinfo
1992 def GetElementGeomType(self, id):
1993 return self.mesh.GetElementGeomType(id)
1995 ## Returns the list of submesh elements IDs
1996 # @param Shape a geom object(subshape) IOR
1997 # Shape must be the subshape of a ShapeToMesh()
1998 # @return the list of integer values
1999 # @ingroup l1_meshinfo
2000 def GetSubMeshElementsId(self, Shape):
2001 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2002 ShapeID = Shape.GetSubShapeIndices()[0]
2005 return self.mesh.GetSubMeshElementsId(ShapeID)
2007 ## Returns the list of submesh nodes IDs
2008 # @param Shape a geom object(subshape) IOR
2009 # Shape must be the subshape of a ShapeToMesh()
2010 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2011 # @return the list of integer values
2012 # @ingroup l1_meshinfo
2013 def GetSubMeshNodesId(self, Shape, all):
2014 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2015 ShapeID = Shape.GetSubShapeIndices()[0]
2018 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2020 ## Returns type of elements on given shape
2021 # @param Shape a geom object(subshape) IOR
2022 # Shape must be a subshape of a ShapeToMesh()
2023 # @return element type
2024 # @ingroup l1_meshinfo
2025 def GetSubMeshElementType(self, Shape):
2026 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2027 ShapeID = Shape.GetSubShapeIndices()[0]
2030 return self.mesh.GetSubMeshElementType(ShapeID)
2032 ## Gets the mesh description
2033 # @return string value
2034 # @ingroup l1_meshinfo
2036 return self.mesh.Dump()
2039 # Get the information about nodes and elements of a mesh by its IDs:
2040 # -----------------------------------------------------------
2042 ## Gets XYZ coordinates of a node
2043 # \n If there is no nodes for the given ID - returns an empty list
2044 # @return a list of double precision values
2045 # @ingroup l1_meshinfo
2046 def GetNodeXYZ(self, id):
2047 return self.mesh.GetNodeXYZ(id)
2049 ## Returns list of IDs of inverse elements for the given node
2050 # \n If there is no node for the given ID - returns an empty list
2051 # @return a list of integer values
2052 # @ingroup l1_meshinfo
2053 def GetNodeInverseElements(self, id):
2054 return self.mesh.GetNodeInverseElements(id)
2056 ## @brief Returns the position of a node on the shape
2057 # @return SMESH::NodePosition
2058 # @ingroup l1_meshinfo
2059 def GetNodePosition(self,NodeID):
2060 return self.mesh.GetNodePosition(NodeID)
2062 ## If the given element is a node, returns the ID of shape
2063 # \n If there is no node for the given ID - returns -1
2064 # @return an integer value
2065 # @ingroup l1_meshinfo
2066 def GetShapeID(self, id):
2067 return self.mesh.GetShapeID(id)
2069 ## Returns the ID of the result shape after
2070 # FindShape() from SMESH_MeshEditor for the given element
2071 # \n If there is no element for the given ID - returns -1
2072 # @return an integer value
2073 # @ingroup l1_meshinfo
2074 def GetShapeIDForElem(self,id):
2075 return self.mesh.GetShapeIDForElem(id)
2077 ## Returns the number of nodes for the given element
2078 # \n If there is no element for the given ID - returns -1
2079 # @return an integer value
2080 # @ingroup l1_meshinfo
2081 def GetElemNbNodes(self, id):
2082 return self.mesh.GetElemNbNodes(id)
2084 ## Returns the node ID the given index for the given element
2085 # \n If there is no element for the given ID - returns -1
2086 # \n If there is no node for the given index - returns -2
2087 # @return an integer value
2088 # @ingroup l1_meshinfo
2089 def GetElemNode(self, id, index):
2090 return self.mesh.GetElemNode(id, index)
2092 ## Returns the IDs of nodes of the given element
2093 # @return a list of integer values
2094 # @ingroup l1_meshinfo
2095 def GetElemNodes(self, id):
2096 return self.mesh.GetElemNodes(id)
2098 ## Returns true if the given node is the medium node in the given quadratic element
2099 # @ingroup l1_meshinfo
2100 def IsMediumNode(self, elementID, nodeID):
2101 return self.mesh.IsMediumNode(elementID, nodeID)
2103 ## Returns true if the given node is the medium node in one of quadratic elements
2104 # @ingroup l1_meshinfo
2105 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2106 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2108 ## Returns the number of edges for the given element
2109 # @ingroup l1_meshinfo
2110 def ElemNbEdges(self, id):
2111 return self.mesh.ElemNbEdges(id)
2113 ## Returns the number of faces for the given element
2114 # @ingroup l1_meshinfo
2115 def ElemNbFaces(self, id):
2116 return self.mesh.ElemNbFaces(id)
2118 ## Returns nodes of given face (counted from zero) for given volumic element.
2119 # @ingroup l1_meshinfo
2120 def GetElemFaceNodes(self,elemId, faceIndex):
2121 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2123 ## Returns an element based on all given nodes.
2124 # @ingroup l1_meshinfo
2125 def FindElementByNodes(self,nodes):
2126 return self.mesh.FindElementByNodes(nodes)
2128 ## Returns true if the given element is a polygon
2129 # @ingroup l1_meshinfo
2130 def IsPoly(self, id):
2131 return self.mesh.IsPoly(id)
2133 ## Returns true if the given element is quadratic
2134 # @ingroup l1_meshinfo
2135 def IsQuadratic(self, id):
2136 return self.mesh.IsQuadratic(id)
2138 ## Returns XYZ coordinates of the barycenter of the given element
2139 # \n If there is no element for the given ID - returns an empty list
2140 # @return a list of three double values
2141 # @ingroup l1_meshinfo
2142 def BaryCenter(self, id):
2143 return self.mesh.BaryCenter(id)
2146 # Mesh edition (SMESH_MeshEditor functionality):
2147 # ---------------------------------------------
2149 ## Removes the elements from the mesh by ids
2150 # @param IDsOfElements is a list of ids of elements to remove
2151 # @return True or False
2152 # @ingroup l2_modif_del
2153 def RemoveElements(self, IDsOfElements):
2154 return self.editor.RemoveElements(IDsOfElements)
2156 ## Removes nodes from mesh by ids
2157 # @param IDsOfNodes is a list of ids of nodes to remove
2158 # @return True or False
2159 # @ingroup l2_modif_del
2160 def RemoveNodes(self, IDsOfNodes):
2161 return self.editor.RemoveNodes(IDsOfNodes)
2163 ## Removes all orphan (free) nodes from mesh
2164 # @return number of the removed nodes
2165 # @ingroup l2_modif_del
2166 def RemoveOrphanNodes(self):
2167 return self.editor.RemoveOrphanNodes()
2169 ## Add a node to the mesh by coordinates
2170 # @return Id of the new node
2171 # @ingroup l2_modif_add
2172 def AddNode(self, x, y, z):
2173 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2174 self.mesh.SetParameters(Parameters)
2175 return self.editor.AddNode( x, y, z)
2177 ## Creates a 0D element on a node with given number.
2178 # @param IDOfNode the ID of node for creation of the element.
2179 # @return the Id of the new 0D element
2180 # @ingroup l2_modif_add
2181 def Add0DElement(self, IDOfNode):
2182 return self.editor.Add0DElement(IDOfNode)
2184 ## Creates a linear or quadratic edge (this is determined
2185 # by the number of given nodes).
2186 # @param IDsOfNodes the list of node IDs for creation of the element.
2187 # The order of nodes in this list should correspond to the description
2188 # of MED. \n This description is located by the following link:
2189 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2190 # @return the Id of the new edge
2191 # @ingroup l2_modif_add
2192 def AddEdge(self, IDsOfNodes):
2193 return self.editor.AddEdge(IDsOfNodes)
2195 ## Creates a linear or quadratic face (this is determined
2196 # by the number of given nodes).
2197 # @param IDsOfNodes the list of node IDs for creation of the element.
2198 # The order of nodes in this list should correspond to the description
2199 # of MED. \n This description is located by the following link:
2200 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2201 # @return the Id of the new face
2202 # @ingroup l2_modif_add
2203 def AddFace(self, IDsOfNodes):
2204 return self.editor.AddFace(IDsOfNodes)
2206 ## Adds a polygonal face to the mesh by the list of node IDs
2207 # @param IdsOfNodes the list of node IDs for creation of the element.
2208 # @return the Id of the new face
2209 # @ingroup l2_modif_add
2210 def AddPolygonalFace(self, IdsOfNodes):
2211 return self.editor.AddPolygonalFace(IdsOfNodes)
2213 ## Creates both simple and quadratic volume (this is determined
2214 # by the number of given nodes).
2215 # @param IDsOfNodes the list of node IDs for creation of the element.
2216 # The order of nodes in this list should correspond to the description
2217 # of MED. \n This description is located by the following link:
2218 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2219 # @return the Id of the new volumic element
2220 # @ingroup l2_modif_add
2221 def AddVolume(self, IDsOfNodes):
2222 return self.editor.AddVolume(IDsOfNodes)
2224 ## Creates a volume of many faces, giving nodes for each face.
2225 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2226 # @param Quantities the list of integer values, Quantities[i]
2227 # gives the quantity of nodes in face number i.
2228 # @return the Id of the new volumic element
2229 # @ingroup l2_modif_add
2230 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2231 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2233 ## Creates a volume of many faces, giving the IDs of the existing faces.
2234 # @param IdsOfFaces the list of face IDs for volume creation.
2236 # Note: The created volume will refer only to the nodes
2237 # of the given faces, not to the faces themselves.
2238 # @return the Id of the new volumic element
2239 # @ingroup l2_modif_add
2240 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2241 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2244 ## @brief Binds a node to a vertex
2245 # @param NodeID a node ID
2246 # @param Vertex a vertex or vertex ID
2247 # @return True if succeed else raises an exception
2248 # @ingroup l2_modif_add
2249 def SetNodeOnVertex(self, NodeID, Vertex):
2250 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2251 VertexID = Vertex.GetSubShapeIndices()[0]
2255 self.editor.SetNodeOnVertex(NodeID, VertexID)
2256 except SALOME.SALOME_Exception, inst:
2257 raise ValueError, inst.details.text
2261 ## @brief Stores the node position on an edge
2262 # @param NodeID a node ID
2263 # @param Edge an edge or edge ID
2264 # @param paramOnEdge a parameter on the edge where the node is located
2265 # @return True if succeed else raises an exception
2266 # @ingroup l2_modif_add
2267 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2268 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2269 EdgeID = Edge.GetSubShapeIndices()[0]
2273 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2274 except SALOME.SALOME_Exception, inst:
2275 raise ValueError, inst.details.text
2278 ## @brief Stores node position on a face
2279 # @param NodeID a node ID
2280 # @param Face a face or face ID
2281 # @param u U parameter on the face where the node is located
2282 # @param v V parameter on the face where the node is located
2283 # @return True if succeed else raises an exception
2284 # @ingroup l2_modif_add
2285 def SetNodeOnFace(self, NodeID, Face, u, v):
2286 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2287 FaceID = Face.GetSubShapeIndices()[0]
2291 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2292 except SALOME.SALOME_Exception, inst:
2293 raise ValueError, inst.details.text
2296 ## @brief Binds a node to a solid
2297 # @param NodeID a node ID
2298 # @param Solid a solid or solid ID
2299 # @return True if succeed else raises an exception
2300 # @ingroup l2_modif_add
2301 def SetNodeInVolume(self, NodeID, Solid):
2302 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2303 SolidID = Solid.GetSubShapeIndices()[0]
2307 self.editor.SetNodeInVolume(NodeID, SolidID)
2308 except SALOME.SALOME_Exception, inst:
2309 raise ValueError, inst.details.text
2312 ## @brief Bind an element to a shape
2313 # @param ElementID an element ID
2314 # @param Shape a shape or shape ID
2315 # @return True if succeed else raises an exception
2316 # @ingroup l2_modif_add
2317 def SetMeshElementOnShape(self, ElementID, Shape):
2318 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2319 ShapeID = Shape.GetSubShapeIndices()[0]
2323 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2324 except SALOME.SALOME_Exception, inst:
2325 raise ValueError, inst.details.text
2329 ## Moves the node with the given id
2330 # @param NodeID the id of the node
2331 # @param x a new X coordinate
2332 # @param y a new Y coordinate
2333 # @param z a new Z coordinate
2334 # @return True if succeed else False
2335 # @ingroup l2_modif_movenode
2336 def MoveNode(self, NodeID, x, y, z):
2337 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2338 self.mesh.SetParameters(Parameters)
2339 return self.editor.MoveNode(NodeID, x, y, z)
2341 ## Finds the node closest to a point and moves it to a point location
2342 # @param x the X coordinate of a point
2343 # @param y the Y coordinate of a point
2344 # @param z the Z coordinate of a point
2345 # @param NodeID if specified (>0), the node with this ID is moved,
2346 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2347 # @return the ID of a node
2348 # @ingroup l2_modif_throughp
2349 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2350 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2351 self.mesh.SetParameters(Parameters)
2352 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2354 ## Finds the node closest to a point
2355 # @param x the X coordinate of a point
2356 # @param y the Y coordinate of a point
2357 # @param z the Z coordinate of a point
2358 # @return the ID of a node
2359 # @ingroup l2_modif_throughp
2360 def FindNodeClosestTo(self, x, y, z):
2361 #preview = self.mesh.GetMeshEditPreviewer()
2362 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2363 return self.editor.FindNodeClosestTo(x, y, z)
2365 ## Finds the elements where a point lays IN or ON
2366 # @param x the X coordinate of a point
2367 # @param y the Y coordinate of a point
2368 # @param z the Z coordinate of a point
2369 # @param elementType type of elements to find (SMESH.ALL type
2370 # means elements of any type excluding nodes and 0D elements)
2371 # @return list of IDs of found elements
2372 # @ingroup l2_modif_throughp
2373 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2374 return self.editor.FindElementsByPoint(x, y, z, elementType)
2376 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2377 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2379 def GetPointState(self, x, y, z):
2380 return self.editor.GetPointState(x, y, z)
2382 ## Finds the node closest to a point and moves it to a point location
2383 # @param x the X coordinate of a point
2384 # @param y the Y coordinate of a point
2385 # @param z the Z coordinate of a point
2386 # @return the ID of a moved node
2387 # @ingroup l2_modif_throughp
2388 def MeshToPassThroughAPoint(self, x, y, z):
2389 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2391 ## Replaces two neighbour triangles sharing Node1-Node2 link
2392 # with the triangles built on the same 4 nodes but having other common link.
2393 # @param NodeID1 the ID of the first node
2394 # @param NodeID2 the ID of the second node
2395 # @return false if proper faces were not found
2396 # @ingroup l2_modif_invdiag
2397 def InverseDiag(self, NodeID1, NodeID2):
2398 return self.editor.InverseDiag(NodeID1, NodeID2)
2400 ## Replaces two neighbour triangles sharing Node1-Node2 link
2401 # with a quadrangle built on the same 4 nodes.
2402 # @param NodeID1 the ID of the first node
2403 # @param NodeID2 the ID of the second node
2404 # @return false if proper faces were not found
2405 # @ingroup l2_modif_unitetri
2406 def DeleteDiag(self, NodeID1, NodeID2):
2407 return self.editor.DeleteDiag(NodeID1, NodeID2)
2409 ## Reorients elements by ids
2410 # @param IDsOfElements if undefined reorients all mesh elements
2411 # @return True if succeed else False
2412 # @ingroup l2_modif_changori
2413 def Reorient(self, IDsOfElements=None):
2414 if IDsOfElements == None:
2415 IDsOfElements = self.GetElementsId()
2416 return self.editor.Reorient(IDsOfElements)
2418 ## Reorients all elements of the object
2419 # @param theObject mesh, submesh or group
2420 # @return True if succeed else False
2421 # @ingroup l2_modif_changori
2422 def ReorientObject(self, theObject):
2423 if ( isinstance( theObject, Mesh )):
2424 theObject = theObject.GetMesh()
2425 return self.editor.ReorientObject(theObject)
2427 ## Fuses the neighbouring triangles into quadrangles.
2428 # @param IDsOfElements The triangles to be fused,
2429 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2430 # @param MaxAngle is the maximum angle between element normals at which the fusion
2431 # is still performed; theMaxAngle is mesured in radians.
2432 # Also it could be a name of variable which defines angle in degrees.
2433 # @return TRUE in case of success, FALSE otherwise.
2434 # @ingroup l2_modif_unitetri
2435 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2437 if isinstance(MaxAngle,str):
2439 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2441 MaxAngle = DegreesToRadians(MaxAngle)
2442 if IDsOfElements == []:
2443 IDsOfElements = self.GetElementsId()
2444 self.mesh.SetParameters(Parameters)
2446 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2447 Functor = theCriterion
2449 Functor = self.smeshpyD.GetFunctor(theCriterion)
2450 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2452 ## Fuses the neighbouring triangles of the object into quadrangles
2453 # @param theObject is mesh, submesh or group
2454 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2455 # @param MaxAngle a max angle between element normals at which the fusion
2456 # is still performed; theMaxAngle is mesured in radians.
2457 # @return TRUE in case of success, FALSE otherwise.
2458 # @ingroup l2_modif_unitetri
2459 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2460 if ( isinstance( theObject, Mesh )):
2461 theObject = theObject.GetMesh()
2462 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2464 ## Splits quadrangles into triangles.
2465 # @param IDsOfElements the faces to be splitted.
2466 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2467 # @return TRUE in case of success, FALSE otherwise.
2468 # @ingroup l2_modif_cutquadr
2469 def QuadToTri (self, IDsOfElements, theCriterion):
2470 if IDsOfElements == []:
2471 IDsOfElements = self.GetElementsId()
2472 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2474 ## Splits quadrangles into triangles.
2475 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2476 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2477 # @return TRUE in case of success, FALSE otherwise.
2478 # @ingroup l2_modif_cutquadr
2479 def QuadToTriObject (self, theObject, theCriterion):
2480 if ( isinstance( theObject, Mesh )):
2481 theObject = theObject.GetMesh()
2482 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2484 ## Splits quadrangles into triangles.
2485 # @param IDsOfElements the faces to be splitted
2486 # @param Diag13 is used to choose a diagonal for splitting.
2487 # @return TRUE in case of success, FALSE otherwise.
2488 # @ingroup l2_modif_cutquadr
2489 def SplitQuad (self, IDsOfElements, Diag13):
2490 if IDsOfElements == []:
2491 IDsOfElements = self.GetElementsId()
2492 return self.editor.SplitQuad(IDsOfElements, Diag13)
2494 ## Splits quadrangles into triangles.
2495 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2496 # @param Diag13 is used to choose a diagonal for splitting.
2497 # @return TRUE in case of success, FALSE otherwise.
2498 # @ingroup l2_modif_cutquadr
2499 def SplitQuadObject (self, theObject, Diag13):
2500 if ( isinstance( theObject, Mesh )):
2501 theObject = theObject.GetMesh()
2502 return self.editor.SplitQuadObject(theObject, Diag13)
2504 ## Finds a better splitting of the given quadrangle.
2505 # @param IDOfQuad the ID of the quadrangle to be splitted.
2506 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2507 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2508 # diagonal is better, 0 if error occurs.
2509 # @ingroup l2_modif_cutquadr
2510 def BestSplit (self, IDOfQuad, theCriterion):
2511 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2513 ## Splits volumic elements into tetrahedrons
2514 # @param elemIDs either list of elements or mesh or group or submesh
2515 # @param method flags passing splitting method:
2516 # 1 - split the hexahedron into 5 tetrahedrons
2517 # 2 - split the hexahedron into 6 tetrahedrons
2518 # @ingroup l2_modif_cutquadr
2519 def SplitVolumesIntoTetra(self, elemIDs, method=1 ):
2520 if isinstance( elemIDs, Mesh ):
2521 elemIDs = elemIDs.GetMesh()
2522 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2524 ## Splits quadrangle faces near triangular facets of volumes
2526 # @ingroup l1_auxiliary
2527 def SplitQuadsNearTriangularFacets(self):
2528 faces_array = self.GetElementsByType(SMESH.FACE)
2529 for face_id in faces_array:
2530 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2531 quad_nodes = self.mesh.GetElemNodes(face_id)
2532 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2533 isVolumeFound = False
2534 for node1_elem in node1_elems:
2535 if not isVolumeFound:
2536 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2537 nb_nodes = self.GetElemNbNodes(node1_elem)
2538 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2539 volume_elem = node1_elem
2540 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2541 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2542 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2543 isVolumeFound = True
2544 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2545 self.SplitQuad([face_id], False) # diagonal 2-4
2546 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2547 isVolumeFound = True
2548 self.SplitQuad([face_id], True) # diagonal 1-3
2549 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2550 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2551 isVolumeFound = True
2552 self.SplitQuad([face_id], True) # diagonal 1-3
2554 ## @brief Splits hexahedrons into tetrahedrons.
2556 # This operation uses pattern mapping functionality for splitting.
2557 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2558 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2559 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2560 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2561 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2562 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2563 # @return TRUE in case of success, FALSE otherwise.
2564 # @ingroup l1_auxiliary
2565 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2566 # Pattern: 5.---------.6
2571 # (0,0,1) 4.---------.7 * |
2578 # (0,0,0) 0.---------.3
2579 pattern_tetra = "!!! Nb of points: \n 8 \n\
2589 !!! Indices of points of 6 tetras: \n\
2597 pattern = self.smeshpyD.GetPattern()
2598 isDone = pattern.LoadFromFile(pattern_tetra)
2600 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2603 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2604 isDone = pattern.MakeMesh(self.mesh, False, False)
2605 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2607 # split quafrangle faces near triangular facets of volumes
2608 self.SplitQuadsNearTriangularFacets()
2612 ## @brief Split hexahedrons into prisms.
2614 # Uses the pattern mapping functionality for splitting.
2615 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2616 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2617 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2618 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2619 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2620 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2621 # @return TRUE in case of success, FALSE otherwise.
2622 # @ingroup l1_auxiliary
2623 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2624 # Pattern: 5.---------.6
2629 # (0,0,1) 4.---------.7 |
2636 # (0,0,0) 0.---------.3
2637 pattern_prism = "!!! Nb of points: \n 8 \n\
2647 !!! Indices of points of 2 prisms: \n\
2651 pattern = self.smeshpyD.GetPattern()
2652 isDone = pattern.LoadFromFile(pattern_prism)
2654 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2657 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2658 isDone = pattern.MakeMesh(self.mesh, False, False)
2659 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2661 # Splits quafrangle faces near triangular facets of volumes
2662 self.SplitQuadsNearTriangularFacets()
2666 ## Smoothes elements
2667 # @param IDsOfElements the list if ids of elements to smooth
2668 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2669 # Note that nodes built on edges and boundary nodes are always fixed.
2670 # @param MaxNbOfIterations the maximum number of iterations
2671 # @param MaxAspectRatio varies in range [1.0, inf]
2672 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2673 # @return TRUE in case of success, FALSE otherwise.
2674 # @ingroup l2_modif_smooth
2675 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2676 MaxNbOfIterations, MaxAspectRatio, Method):
2677 if IDsOfElements == []:
2678 IDsOfElements = self.GetElementsId()
2679 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2680 self.mesh.SetParameters(Parameters)
2681 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2682 MaxNbOfIterations, MaxAspectRatio, Method)
2684 ## Smoothes elements which belong to the given object
2685 # @param theObject the object 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 SmoothObject(self, theObject, IDsOfFixedNodes,
2694 MaxNbOfIterations, MaxAspectRatio, Method):
2695 if ( isinstance( theObject, Mesh )):
2696 theObject = theObject.GetMesh()
2697 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2698 MaxNbOfIterations, MaxAspectRatio, Method)
2700 ## Parametrically smoothes the given elements
2701 # @param IDsOfElements the list if ids of elements to smooth
2702 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2703 # Note that nodes built on edges and boundary nodes are always fixed.
2704 # @param MaxNbOfIterations the maximum number of iterations
2705 # @param MaxAspectRatio varies in range [1.0, inf]
2706 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2707 # @return TRUE in case of success, FALSE otherwise.
2708 # @ingroup l2_modif_smooth
2709 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2710 MaxNbOfIterations, MaxAspectRatio, Method):
2711 if IDsOfElements == []:
2712 IDsOfElements = self.GetElementsId()
2713 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2714 self.mesh.SetParameters(Parameters)
2715 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2716 MaxNbOfIterations, MaxAspectRatio, Method)
2718 ## Parametrically smoothes the elements which belong to the given object
2719 # @param theObject the object to smooth
2720 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2721 # Note that nodes built on edges and boundary nodes are always fixed.
2722 # @param MaxNbOfIterations the maximum number of iterations
2723 # @param MaxAspectRatio varies in range [1.0, inf]
2724 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2725 # @return TRUE in case of success, FALSE otherwise.
2726 # @ingroup l2_modif_smooth
2727 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2728 MaxNbOfIterations, MaxAspectRatio, Method):
2729 if ( isinstance( theObject, Mesh )):
2730 theObject = theObject.GetMesh()
2731 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2732 MaxNbOfIterations, MaxAspectRatio, Method)
2734 ## Converts the mesh to quadratic, deletes old elements, replacing
2735 # them with quadratic with the same id.
2736 # @ingroup l2_modif_tofromqu
2737 def ConvertToQuadratic(self, theForce3d):
2738 self.editor.ConvertToQuadratic(theForce3d)
2740 ## Converts the mesh from quadratic to ordinary,
2741 # deletes old quadratic elements, \n replacing
2742 # them with ordinary mesh elements with the same id.
2743 # @return TRUE in case of success, FALSE otherwise.
2744 # @ingroup l2_modif_tofromqu
2745 def ConvertFromQuadratic(self):
2746 return self.editor.ConvertFromQuadratic()
2748 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2749 # @return TRUE if operation has been completed successfully, FALSE otherwise
2750 # @ingroup l2_modif_edit
2751 def Make2DMeshFrom3D(self):
2752 return self.editor. Make2DMeshFrom3D()
2754 ## Renumber mesh nodes
2755 # @ingroup l2_modif_renumber
2756 def RenumberNodes(self):
2757 self.editor.RenumberNodes()
2759 ## Renumber mesh elements
2760 # @ingroup l2_modif_renumber
2761 def RenumberElements(self):
2762 self.editor.RenumberElements()
2764 ## Generates new elements by rotation of the elements around the axis
2765 # @param IDsOfElements the list of ids of elements to sweep
2766 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2767 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2768 # @param NbOfSteps the number of steps
2769 # @param Tolerance tolerance
2770 # @param MakeGroups forces the generation of new groups from existing ones
2771 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2772 # of all steps, else - size of each step
2773 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2774 # @ingroup l2_modif_extrurev
2775 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2776 MakeGroups=False, TotalAngle=False):
2778 if isinstance(AngleInRadians,str):
2780 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2782 AngleInRadians = DegreesToRadians(AngleInRadians)
2783 if IDsOfElements == []:
2784 IDsOfElements = self.GetElementsId()
2785 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2786 Axis = self.smeshpyD.GetAxisStruct(Axis)
2787 Axis,AxisParameters = ParseAxisStruct(Axis)
2788 if TotalAngle and NbOfSteps:
2789 AngleInRadians /= NbOfSteps
2790 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2791 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2792 self.mesh.SetParameters(Parameters)
2794 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2795 AngleInRadians, NbOfSteps, Tolerance)
2796 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2799 ## Generates new elements by rotation of the elements of object around the axis
2800 # @param theObject object which elements should be sweeped
2801 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2802 # @param AngleInRadians the angle of Rotation
2803 # @param NbOfSteps number of steps
2804 # @param Tolerance tolerance
2805 # @param MakeGroups forces the generation of new groups from existing ones
2806 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2807 # of all steps, else - size of each step
2808 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2809 # @ingroup l2_modif_extrurev
2810 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2811 MakeGroups=False, TotalAngle=False):
2813 if isinstance(AngleInRadians,str):
2815 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2817 AngleInRadians = DegreesToRadians(AngleInRadians)
2818 if ( isinstance( theObject, Mesh )):
2819 theObject = theObject.GetMesh()
2820 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2821 Axis = self.smeshpyD.GetAxisStruct(Axis)
2822 Axis,AxisParameters = ParseAxisStruct(Axis)
2823 if TotalAngle and NbOfSteps:
2824 AngleInRadians /= NbOfSteps
2825 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2826 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2827 self.mesh.SetParameters(Parameters)
2829 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2830 NbOfSteps, Tolerance)
2831 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2834 ## Generates new elements by rotation of the elements of object around the axis
2835 # @param theObject object which elements should be sweeped
2836 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2837 # @param AngleInRadians the angle of Rotation
2838 # @param NbOfSteps number of steps
2839 # @param Tolerance tolerance
2840 # @param MakeGroups forces the generation of new groups from existing ones
2841 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2842 # of all steps, else - size of each step
2843 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2844 # @ingroup l2_modif_extrurev
2845 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2846 MakeGroups=False, TotalAngle=False):
2848 if isinstance(AngleInRadians,str):
2850 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2852 AngleInRadians = DegreesToRadians(AngleInRadians)
2853 if ( isinstance( theObject, Mesh )):
2854 theObject = theObject.GetMesh()
2855 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2856 Axis = self.smeshpyD.GetAxisStruct(Axis)
2857 Axis,AxisParameters = ParseAxisStruct(Axis)
2858 if TotalAngle and NbOfSteps:
2859 AngleInRadians /= NbOfSteps
2860 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2861 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2862 self.mesh.SetParameters(Parameters)
2864 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2865 NbOfSteps, Tolerance)
2866 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2869 ## Generates new elements by rotation of the elements of object around the axis
2870 # @param theObject object which elements should be sweeped
2871 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2872 # @param AngleInRadians the angle of Rotation
2873 # @param NbOfSteps number of steps
2874 # @param Tolerance tolerance
2875 # @param MakeGroups forces the generation of new groups from existing ones
2876 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2877 # of all steps, else - size of each step
2878 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2879 # @ingroup l2_modif_extrurev
2880 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2881 MakeGroups=False, TotalAngle=False):
2883 if isinstance(AngleInRadians,str):
2885 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2887 AngleInRadians = DegreesToRadians(AngleInRadians)
2888 if ( isinstance( theObject, Mesh )):
2889 theObject = theObject.GetMesh()
2890 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2891 Axis = self.smeshpyD.GetAxisStruct(Axis)
2892 Axis,AxisParameters = ParseAxisStruct(Axis)
2893 if TotalAngle and NbOfSteps:
2894 AngleInRadians /= NbOfSteps
2895 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2896 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2897 self.mesh.SetParameters(Parameters)
2899 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2900 NbOfSteps, Tolerance)
2901 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2904 ## Generates new elements by extrusion of the elements with given ids
2905 # @param IDsOfElements the list of elements ids for extrusion
2906 # @param StepVector vector, defining the direction and value of extrusion
2907 # @param NbOfSteps the number of steps
2908 # @param MakeGroups forces the generation of new groups from existing ones
2909 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2910 # @ingroup l2_modif_extrurev
2911 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2912 if IDsOfElements == []:
2913 IDsOfElements = self.GetElementsId()
2914 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2915 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2916 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2917 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2918 Parameters = StepVectorParameters + var_separator + Parameters
2919 self.mesh.SetParameters(Parameters)
2921 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2922 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2925 ## Generates new elements by extrusion of the elements with given ids
2926 # @param IDsOfElements is ids of elements
2927 # @param StepVector vector, defining the direction and value of extrusion
2928 # @param NbOfSteps the number of steps
2929 # @param ExtrFlags sets flags for extrusion
2930 # @param SewTolerance uses for comparing locations of nodes if flag
2931 # EXTRUSION_FLAG_SEW is set
2932 # @param MakeGroups forces the generation of new groups from existing ones
2933 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2934 # @ingroup l2_modif_extrurev
2935 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2936 ExtrFlags, SewTolerance, MakeGroups=False):
2937 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2938 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2940 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2941 ExtrFlags, SewTolerance)
2942 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2943 ExtrFlags, SewTolerance)
2946 ## Generates new elements by extrusion of the elements which belong to the object
2947 # @param theObject the object which elements should be processed
2948 # @param StepVector vector, defining the direction and value of extrusion
2949 # @param NbOfSteps the number of steps
2950 # @param MakeGroups forces the generation of new groups from existing ones
2951 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2952 # @ingroup l2_modif_extrurev
2953 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2954 if ( isinstance( theObject, Mesh )):
2955 theObject = theObject.GetMesh()
2956 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2957 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2958 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2959 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2960 Parameters = StepVectorParameters + var_separator + Parameters
2961 self.mesh.SetParameters(Parameters)
2963 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2964 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2967 ## Generates new elements by extrusion of the elements which belong to the object
2968 # @param theObject object which elements should be processed
2969 # @param StepVector vector, defining the direction and value of extrusion
2970 # @param NbOfSteps the number of steps
2971 # @param MakeGroups to generate new groups from existing ones
2972 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2973 # @ingroup l2_modif_extrurev
2974 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2975 if ( isinstance( theObject, Mesh )):
2976 theObject = theObject.GetMesh()
2977 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2978 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2979 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2980 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2981 Parameters = StepVectorParameters + var_separator + Parameters
2982 self.mesh.SetParameters(Parameters)
2984 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2985 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2988 ## Generates new elements by extrusion of the elements which belong to the object
2989 # @param theObject object which elements should be processed
2990 # @param StepVector vector, defining the direction and value of extrusion
2991 # @param NbOfSteps the number of steps
2992 # @param MakeGroups forces the generation of new groups from existing ones
2993 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2994 # @ingroup l2_modif_extrurev
2995 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2996 if ( isinstance( theObject, Mesh )):
2997 theObject = theObject.GetMesh()
2998 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2999 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3000 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3001 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3002 Parameters = StepVectorParameters + var_separator + Parameters
3003 self.mesh.SetParameters(Parameters)
3005 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3006 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3011 ## Generates new elements by extrusion of the given elements
3012 # The path of extrusion must be a meshed edge.
3013 # @param Base mesh or list of ids of elements for extrusion
3014 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3015 # @param NodeStart the start node from Path. Defines the direction of extrusion
3016 # @param HasAngles allows the shape to be rotated around the path
3017 # to get the resulting mesh in a helical fashion
3018 # @param Angles list of angles in radians
3019 # @param LinearVariation forces the computation of rotation angles as linear
3020 # variation of the given Angles along path steps
3021 # @param HasRefPoint allows using the reference point
3022 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3023 # The User can specify any point as the Reference Point.
3024 # @param MakeGroups forces the generation of new groups from existing ones
3025 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3026 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3027 # only SMESH::Extrusion_Error otherwise
3028 # @ingroup l2_modif_extrurev
3029 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3030 HasAngles, Angles, LinearVariation,
3031 HasRefPoint, RefPoint, MakeGroups, ElemType):
3032 Angles,AnglesParameters = ParseAngles(Angles)
3033 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3034 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3035 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3037 Parameters = AnglesParameters + var_separator + RefPointParameters
3038 self.mesh.SetParameters(Parameters)
3040 if isinstance(Base,list):
3042 if Base == []: IDsOfElements = self.GetElementsId()
3043 else: IDsOfElements = Base
3044 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3045 HasAngles, Angles, LinearVariation,
3046 HasRefPoint, RefPoint, MakeGroups, ElemType)
3048 if isinstance(Base,Mesh):
3049 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3050 HasAngles, Angles, LinearVariation,
3051 HasRefPoint, RefPoint, MakeGroups, ElemType)
3053 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3056 ## Generates new elements by extrusion of the given elements
3057 # The path of extrusion must be a meshed edge.
3058 # @param IDsOfElements ids of elements
3059 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3060 # @param PathShape shape(edge) defines the sub-mesh for the path
3061 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3062 # @param HasAngles allows the shape to be rotated around the path
3063 # to get the resulting mesh in a helical fashion
3064 # @param Angles list of angles in radians
3065 # @param HasRefPoint allows using the reference point
3066 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3067 # The User can specify any point as the Reference Point.
3068 # @param MakeGroups forces the generation of new groups from existing ones
3069 # @param LinearVariation forces the computation of rotation angles as linear
3070 # variation of the given Angles along path steps
3071 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3072 # only SMESH::Extrusion_Error otherwise
3073 # @ingroup l2_modif_extrurev
3074 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3075 HasAngles, Angles, HasRefPoint, RefPoint,
3076 MakeGroups=False, LinearVariation=False):
3077 Angles,AnglesParameters = ParseAngles(Angles)
3078 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3079 if IDsOfElements == []:
3080 IDsOfElements = self.GetElementsId()
3081 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3082 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3084 if ( isinstance( PathMesh, Mesh )):
3085 PathMesh = PathMesh.GetMesh()
3086 if HasAngles and Angles and LinearVariation:
3087 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3089 Parameters = AnglesParameters + var_separator + RefPointParameters
3090 self.mesh.SetParameters(Parameters)
3092 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3093 PathShape, NodeStart, HasAngles,
3094 Angles, HasRefPoint, RefPoint)
3095 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3096 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3098 ## Generates new elements by extrusion of the elements which belong to the object
3099 # The path of extrusion must be a meshed edge.
3100 # @param theObject the object which elements should be processed
3101 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3102 # @param PathShape shape(edge) defines the sub-mesh for the path
3103 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3104 # @param HasAngles allows the shape to be rotated around the path
3105 # to get the resulting mesh in a helical fashion
3106 # @param Angles list of angles
3107 # @param HasRefPoint allows using the reference point
3108 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3109 # The User can specify any point as the Reference Point.
3110 # @param MakeGroups forces the generation of new groups from existing ones
3111 # @param LinearVariation forces the computation of rotation angles as linear
3112 # variation of the given Angles along path steps
3113 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3114 # only SMESH::Extrusion_Error otherwise
3115 # @ingroup l2_modif_extrurev
3116 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3117 HasAngles, Angles, HasRefPoint, RefPoint,
3118 MakeGroups=False, LinearVariation=False):
3119 Angles,AnglesParameters = ParseAngles(Angles)
3120 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3121 if ( isinstance( theObject, Mesh )):
3122 theObject = theObject.GetMesh()
3123 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3124 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3125 if ( isinstance( PathMesh, Mesh )):
3126 PathMesh = PathMesh.GetMesh()
3127 if HasAngles and Angles and LinearVariation:
3128 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3130 Parameters = AnglesParameters + var_separator + RefPointParameters
3131 self.mesh.SetParameters(Parameters)
3133 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3134 PathShape, NodeStart, HasAngles,
3135 Angles, HasRefPoint, RefPoint)
3136 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3137 NodeStart, HasAngles, Angles, HasRefPoint,
3140 ## Generates new elements by extrusion of the elements which belong to the object
3141 # The path of extrusion must be a meshed edge.
3142 # @param theObject the object which elements should be processed
3143 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3144 # @param PathShape shape(edge) defines the sub-mesh for the path
3145 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3146 # @param HasAngles allows the shape to be rotated around the path
3147 # to get the resulting mesh in a helical fashion
3148 # @param Angles list of angles
3149 # @param HasRefPoint allows using the reference point
3150 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3151 # The User can specify any point as the Reference Point.
3152 # @param MakeGroups forces the generation of new groups from existing ones
3153 # @param LinearVariation forces the computation of rotation angles as linear
3154 # variation of the given Angles along path steps
3155 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3156 # only SMESH::Extrusion_Error otherwise
3157 # @ingroup l2_modif_extrurev
3158 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3159 HasAngles, Angles, HasRefPoint, RefPoint,
3160 MakeGroups=False, LinearVariation=False):
3161 Angles,AnglesParameters = ParseAngles(Angles)
3162 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3163 if ( isinstance( theObject, Mesh )):
3164 theObject = theObject.GetMesh()
3165 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3166 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3167 if ( isinstance( PathMesh, Mesh )):
3168 PathMesh = PathMesh.GetMesh()
3169 if HasAngles and Angles and LinearVariation:
3170 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3172 Parameters = AnglesParameters + var_separator + RefPointParameters
3173 self.mesh.SetParameters(Parameters)
3175 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3176 PathShape, NodeStart, HasAngles,
3177 Angles, HasRefPoint, RefPoint)
3178 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3179 NodeStart, HasAngles, Angles, HasRefPoint,
3182 ## Generates new elements by extrusion of the elements which belong to the object
3183 # The path of extrusion must be a meshed edge.
3184 # @param theObject the object which elements should be processed
3185 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3186 # @param PathShape shape(edge) defines the sub-mesh for the path
3187 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3188 # @param HasAngles allows the shape to be rotated around the path
3189 # to get the resulting mesh in a helical fashion
3190 # @param Angles list of angles
3191 # @param HasRefPoint allows using the reference point
3192 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3193 # The User can specify any point as the Reference Point.
3194 # @param MakeGroups forces the generation of new groups from existing ones
3195 # @param LinearVariation forces the computation of rotation angles as linear
3196 # variation of the given Angles along path steps
3197 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3198 # only SMESH::Extrusion_Error otherwise
3199 # @ingroup l2_modif_extrurev
3200 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3201 HasAngles, Angles, HasRefPoint, RefPoint,
3202 MakeGroups=False, LinearVariation=False):
3203 Angles,AnglesParameters = ParseAngles(Angles)
3204 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3205 if ( isinstance( theObject, Mesh )):
3206 theObject = theObject.GetMesh()
3207 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3208 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3209 if ( isinstance( PathMesh, Mesh )):
3210 PathMesh = PathMesh.GetMesh()
3211 if HasAngles and Angles and LinearVariation:
3212 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3214 Parameters = AnglesParameters + var_separator + RefPointParameters
3215 self.mesh.SetParameters(Parameters)
3217 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3218 PathShape, NodeStart, HasAngles,
3219 Angles, HasRefPoint, RefPoint)
3220 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3221 NodeStart, HasAngles, Angles, HasRefPoint,
3224 ## Creates a symmetrical copy of mesh elements
3225 # @param IDsOfElements list of elements ids
3226 # @param Mirror is AxisStruct or geom object(point, line, plane)
3227 # @param theMirrorType is POINT, AXIS or PLANE
3228 # If the Mirror is a geom object this parameter is unnecessary
3229 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3230 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3231 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3232 # @ingroup l2_modif_trsf
3233 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3234 if IDsOfElements == []:
3235 IDsOfElements = self.GetElementsId()
3236 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3237 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3238 Mirror,Parameters = ParseAxisStruct(Mirror)
3239 self.mesh.SetParameters(Parameters)
3240 if Copy and MakeGroups:
3241 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3242 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3245 ## Creates a new mesh by a symmetrical copy of mesh elements
3246 # @param IDsOfElements the list of elements ids
3247 # @param Mirror is AxisStruct or geom object (point, line, plane)
3248 # @param theMirrorType is POINT, AXIS or PLANE
3249 # If the Mirror is a geom object this parameter is unnecessary
3250 # @param MakeGroups to generate new groups from existing ones
3251 # @param NewMeshName a name of the new mesh to create
3252 # @return instance of Mesh class
3253 # @ingroup l2_modif_trsf
3254 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3255 if IDsOfElements == []:
3256 IDsOfElements = self.GetElementsId()
3257 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3258 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3259 Mirror,Parameters = ParseAxisStruct(Mirror)
3260 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3261 MakeGroups, NewMeshName)
3262 mesh.SetParameters(Parameters)
3263 return Mesh(self.smeshpyD,self.geompyD,mesh)
3265 ## Creates a symmetrical copy of the object
3266 # @param theObject mesh, submesh or group
3267 # @param Mirror AxisStruct or geom object (point, line, plane)
3268 # @param theMirrorType is POINT, AXIS or PLANE
3269 # If the Mirror is a geom object this parameter is unnecessary
3270 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3271 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3272 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3273 # @ingroup l2_modif_trsf
3274 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3275 if ( isinstance( theObject, Mesh )):
3276 theObject = theObject.GetMesh()
3277 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3278 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3279 Mirror,Parameters = ParseAxisStruct(Mirror)
3280 self.mesh.SetParameters(Parameters)
3281 if Copy and MakeGroups:
3282 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3283 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3286 ## Creates a new mesh by a symmetrical copy of the object
3287 # @param theObject mesh, submesh or group
3288 # @param Mirror AxisStruct or geom object (point, line, plane)
3289 # @param theMirrorType POINT, AXIS or PLANE
3290 # If the Mirror is a geom object this parameter is unnecessary
3291 # @param MakeGroups forces the generation of new groups from existing ones
3292 # @param NewMeshName the name of the new mesh to create
3293 # @return instance of Mesh class
3294 # @ingroup l2_modif_trsf
3295 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3296 if ( isinstance( theObject, Mesh )):
3297 theObject = theObject.GetMesh()
3298 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3299 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3300 Mirror,Parameters = ParseAxisStruct(Mirror)
3301 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3302 MakeGroups, NewMeshName)
3303 mesh.SetParameters(Parameters)
3304 return Mesh( self.smeshpyD,self.geompyD,mesh )
3306 ## Translates the elements
3307 # @param IDsOfElements list of elements ids
3308 # @param Vector the direction of translation (DirStruct or vector)
3309 # @param Copy allows copying the translated elements
3310 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3311 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3312 # @ingroup l2_modif_trsf
3313 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3314 if IDsOfElements == []:
3315 IDsOfElements = self.GetElementsId()
3316 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3317 Vector = self.smeshpyD.GetDirStruct(Vector)
3318 Vector,Parameters = ParseDirStruct(Vector)
3319 self.mesh.SetParameters(Parameters)
3320 if Copy and MakeGroups:
3321 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3322 self.editor.Translate(IDsOfElements, Vector, Copy)
3325 ## Creates a new mesh of translated elements
3326 # @param IDsOfElements list of elements ids
3327 # @param Vector the direction of translation (DirStruct or vector)
3328 # @param MakeGroups forces the generation of new groups from existing ones
3329 # @param NewMeshName the name of the newly created mesh
3330 # @return instance of Mesh class
3331 # @ingroup l2_modif_trsf
3332 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3333 if IDsOfElements == []:
3334 IDsOfElements = self.GetElementsId()
3335 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3336 Vector = self.smeshpyD.GetDirStruct(Vector)
3337 Vector,Parameters = ParseDirStruct(Vector)
3338 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3339 mesh.SetParameters(Parameters)
3340 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3342 ## Translates the object
3343 # @param theObject the object to translate (mesh, submesh, or group)
3344 # @param Vector direction of translation (DirStruct or geom vector)
3345 # @param Copy allows copying the translated elements
3346 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3347 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3348 # @ingroup l2_modif_trsf
3349 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3350 if ( isinstance( theObject, Mesh )):
3351 theObject = theObject.GetMesh()
3352 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3353 Vector = self.smeshpyD.GetDirStruct(Vector)
3354 Vector,Parameters = ParseDirStruct(Vector)
3355 self.mesh.SetParameters(Parameters)
3356 if Copy and MakeGroups:
3357 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3358 self.editor.TranslateObject(theObject, Vector, Copy)
3361 ## Creates a new mesh from the translated object
3362 # @param theObject the object to translate (mesh, submesh, or group)
3363 # @param Vector the direction of translation (DirStruct or geom vector)
3364 # @param MakeGroups forces the generation of new groups from existing ones
3365 # @param NewMeshName the name of the newly created mesh
3366 # @return instance of Mesh class
3367 # @ingroup l2_modif_trsf
3368 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3369 if (isinstance(theObject, Mesh)):
3370 theObject = theObject.GetMesh()
3371 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3372 Vector = self.smeshpyD.GetDirStruct(Vector)
3373 Vector,Parameters = ParseDirStruct(Vector)
3374 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3375 mesh.SetParameters(Parameters)
3376 return Mesh( self.smeshpyD, self.geompyD, mesh )
3380 ## Scales the object
3381 # @param theObject - the object to translate (mesh, submesh, or group)
3382 # @param thePoint - base point for scale
3383 # @param theScaleFact - scale factors for axises
3384 # @param Copy - allows copying the translated elements
3385 # @param MakeGroups - forces the generation of new groups from existing
3387 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3388 # empty list otherwise
3389 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3390 if ( isinstance( theObject, Mesh )):
3391 theObject = theObject.GetMesh()
3392 if ( isinstance( theObject, list )):
3393 theObject = self.editor.MakeIDSource(theObject)
3395 thePoint, Parameters = ParsePointStruct(thePoint)
3396 self.mesh.SetParameters(Parameters)
3398 if Copy and MakeGroups:
3399 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3400 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3403 ## Creates a new mesh from the translated object
3404 # @param theObject - the object to translate (mesh, submesh, or group)
3405 # @param thePoint - base point for scale
3406 # @param theScaleFact - scale factors for axises
3407 # @param MakeGroups - forces the generation of new groups from existing ones
3408 # @param NewMeshName - the name of the newly created mesh
3409 # @return instance of Mesh class
3410 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3411 if (isinstance(theObject, Mesh)):
3412 theObject = theObject.GetMesh()
3413 if ( isinstance( theObject, list )):
3414 theObject = self.editor.MakeIDSource(theObject)
3416 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3417 MakeGroups, NewMeshName)
3418 #mesh.SetParameters(Parameters)
3419 return Mesh( self.smeshpyD, self.geompyD, mesh )
3423 ## Rotates the elements
3424 # @param IDsOfElements list of elements ids
3425 # @param Axis the axis of rotation (AxisStruct or geom line)
3426 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3427 # @param Copy allows copying the rotated elements
3428 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3429 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3430 # @ingroup l2_modif_trsf
3431 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3433 if isinstance(AngleInRadians,str):
3435 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3437 AngleInRadians = DegreesToRadians(AngleInRadians)
3438 if IDsOfElements == []:
3439 IDsOfElements = self.GetElementsId()
3440 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3441 Axis = self.smeshpyD.GetAxisStruct(Axis)
3442 Axis,AxisParameters = ParseAxisStruct(Axis)
3443 Parameters = AxisParameters + var_separator + Parameters
3444 self.mesh.SetParameters(Parameters)
3445 if Copy and MakeGroups:
3446 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3447 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3450 ## Creates a new mesh of rotated elements
3451 # @param IDsOfElements list of element ids
3452 # @param Axis the axis of rotation (AxisStruct or geom line)
3453 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3454 # @param MakeGroups forces the generation of new groups from existing ones
3455 # @param NewMeshName the name of the newly created mesh
3456 # @return instance of Mesh class
3457 # @ingroup l2_modif_trsf
3458 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3460 if isinstance(AngleInRadians,str):
3462 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3464 AngleInRadians = DegreesToRadians(AngleInRadians)
3465 if IDsOfElements == []:
3466 IDsOfElements = self.GetElementsId()
3467 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3468 Axis = self.smeshpyD.GetAxisStruct(Axis)
3469 Axis,AxisParameters = ParseAxisStruct(Axis)
3470 Parameters = AxisParameters + var_separator + Parameters
3471 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3472 MakeGroups, NewMeshName)
3473 mesh.SetParameters(Parameters)
3474 return Mesh( self.smeshpyD, self.geompyD, mesh )
3476 ## Rotates the object
3477 # @param theObject the object to rotate( mesh, submesh, or group)
3478 # @param Axis the axis of rotation (AxisStruct or geom line)
3479 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3480 # @param Copy allows copying the rotated elements
3481 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3482 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3483 # @ingroup l2_modif_trsf
3484 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3486 if isinstance(AngleInRadians,str):
3488 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3490 AngleInRadians = DegreesToRadians(AngleInRadians)
3491 if (isinstance(theObject, Mesh)):
3492 theObject = theObject.GetMesh()
3493 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3494 Axis = self.smeshpyD.GetAxisStruct(Axis)
3495 Axis,AxisParameters = ParseAxisStruct(Axis)
3496 Parameters = AxisParameters + ":" + Parameters
3497 self.mesh.SetParameters(Parameters)
3498 if Copy and MakeGroups:
3499 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3500 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3503 ## Creates a new mesh from the rotated object
3504 # @param theObject the object to rotate (mesh, submesh, or group)
3505 # @param Axis the axis of rotation (AxisStruct or geom line)
3506 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3507 # @param MakeGroups forces the generation of new groups from existing ones
3508 # @param NewMeshName the name of the newly created mesh
3509 # @return instance of Mesh class
3510 # @ingroup l2_modif_trsf
3511 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3513 if isinstance(AngleInRadians,str):
3515 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3517 AngleInRadians = DegreesToRadians(AngleInRadians)
3518 if (isinstance( theObject, Mesh )):
3519 theObject = theObject.GetMesh()
3520 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3521 Axis = self.smeshpyD.GetAxisStruct(Axis)
3522 Axis,AxisParameters = ParseAxisStruct(Axis)
3523 Parameters = AxisParameters + ":" + Parameters
3524 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3525 MakeGroups, NewMeshName)
3526 mesh.SetParameters(Parameters)
3527 return Mesh( self.smeshpyD, self.geompyD, mesh )
3529 ## Finds groups of ajacent nodes within Tolerance.
3530 # @param Tolerance the value of tolerance
3531 # @return the list of groups of nodes
3532 # @ingroup l2_modif_trsf
3533 def FindCoincidentNodes (self, Tolerance):
3534 return self.editor.FindCoincidentNodes(Tolerance)
3536 ## Finds groups of ajacent nodes within Tolerance.
3537 # @param Tolerance the value of tolerance
3538 # @param SubMeshOrGroup SubMesh or Group
3539 # @return the list of groups of nodes
3540 # @ingroup l2_modif_trsf
3541 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3542 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3545 # @param GroupsOfNodes the list of groups of nodes
3546 # @ingroup l2_modif_trsf
3547 def MergeNodes (self, GroupsOfNodes):
3548 self.editor.MergeNodes(GroupsOfNodes)
3550 ## Finds the elements built on the same nodes.
3551 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3552 # @return a list of groups of equal elements
3553 # @ingroup l2_modif_trsf
3554 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3555 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3556 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3557 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3559 ## Merges elements in each given group.
3560 # @param GroupsOfElementsID groups of elements for merging
3561 # @ingroup l2_modif_trsf
3562 def MergeElements(self, GroupsOfElementsID):
3563 self.editor.MergeElements(GroupsOfElementsID)
3565 ## Leaves one element and removes all other elements built on the same nodes.
3566 # @ingroup l2_modif_trsf
3567 def MergeEqualElements(self):
3568 self.editor.MergeEqualElements()
3570 ## Sews free borders
3571 # @return SMESH::Sew_Error
3572 # @ingroup l2_modif_trsf
3573 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3574 FirstNodeID2, SecondNodeID2, LastNodeID2,
3575 CreatePolygons, CreatePolyedrs):
3576 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3577 FirstNodeID2, SecondNodeID2, LastNodeID2,
3578 CreatePolygons, CreatePolyedrs)
3580 ## Sews conform free borders
3581 # @return SMESH::Sew_Error
3582 # @ingroup l2_modif_trsf
3583 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3584 FirstNodeID2, SecondNodeID2):
3585 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3586 FirstNodeID2, SecondNodeID2)
3588 ## Sews border to side
3589 # @return SMESH::Sew_Error
3590 # @ingroup l2_modif_trsf
3591 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3592 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3593 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3594 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3596 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3597 # merged with the nodes of elements of Side2.
3598 # The number of elements in theSide1 and in theSide2 must be
3599 # equal and they should have similar nodal connectivity.
3600 # The nodes to merge should belong to side borders and
3601 # the first node should be linked to the second.
3602 # @return SMESH::Sew_Error
3603 # @ingroup l2_modif_trsf
3604 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3605 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3606 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3607 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3608 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3609 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3611 ## Sets new nodes for the given element.
3612 # @param ide the element id
3613 # @param newIDs nodes ids
3614 # @return If the number of nodes does not correspond to the type of element - returns false
3615 # @ingroup l2_modif_edit
3616 def ChangeElemNodes(self, ide, newIDs):
3617 return self.editor.ChangeElemNodes(ide, newIDs)
3619 ## If during the last operation of MeshEditor some nodes were
3620 # created, this method returns the list of their IDs, \n
3621 # if new nodes were not created - returns empty list
3622 # @return the list of integer values (can be empty)
3623 # @ingroup l1_auxiliary
3624 def GetLastCreatedNodes(self):
3625 return self.editor.GetLastCreatedNodes()
3627 ## If during the last operation of MeshEditor some elements were
3628 # created this method returns the list of their IDs, \n
3629 # if new elements were not created - returns empty list
3630 # @return the list of integer values (can be empty)
3631 # @ingroup l1_auxiliary
3632 def GetLastCreatedElems(self):
3633 return self.editor.GetLastCreatedElems()
3635 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3636 # @param theNodes identifiers of nodes to be doubled
3637 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3638 # nodes. If list of element identifiers is empty then nodes are doubled but
3639 # they not assigned to elements
3640 # @return TRUE if operation has been completed successfully, FALSE otherwise
3641 # @ingroup l2_modif_edit
3642 def DoubleNodes(self, theNodes, theModifiedElems):
3643 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3645 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3646 # This method provided for convenience works as DoubleNodes() described above.
3647 # @param theNodeId identifiers of node to be doubled
3648 # @param theModifiedElems identifiers of elements to be updated
3649 # @return TRUE if operation has been completed successfully, FALSE otherwise
3650 # @ingroup l2_modif_edit
3651 def DoubleNode(self, theNodeId, theModifiedElems):
3652 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3654 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3655 # This method provided for convenience works as DoubleNodes() described above.
3656 # @param theNodes group of nodes to be doubled
3657 # @param theModifiedElems group of elements to be updated.
3658 # @return TRUE if operation has been completed successfully, FALSE otherwise
3659 # @ingroup l2_modif_edit
3660 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3661 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3663 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3664 # This method provided for convenience works as DoubleNodes() described above.
3665 # @param theNodes list of groups of nodes to be doubled
3666 # @param theModifiedElems list of groups of elements to be updated.
3667 # @return TRUE if operation has been completed successfully, FALSE otherwise
3668 # @ingroup l2_modif_edit
3669 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3670 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3672 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3673 # @param theElems - the list of elements (edges or faces) to be replicated
3674 # The nodes for duplication could be found from these elements
3675 # @param theNodesNot - list of nodes to NOT replicate
3676 # @param theAffectedElems - the list of elements (cells and edges) to which the
3677 # replicated nodes should be associated to.
3678 # @return TRUE if operation has been completed successfully, FALSE otherwise
3679 # @ingroup l2_modif_edit
3680 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3681 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3683 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3684 # @param theElems - the list of elements (edges or faces) to be replicated
3685 # The nodes for duplication could be found from these elements
3686 # @param theNodesNot - list of nodes to NOT replicate
3687 # @param theShape - shape to detect affected elements (element which geometric center
3688 # located on or inside shape).
3689 # The replicated nodes should be associated to affected elements.
3690 # @return TRUE if operation has been completed successfully, FALSE otherwise
3691 # @ingroup l2_modif_edit
3692 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3693 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3695 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3696 # This method provided for convenience works as DoubleNodes() described above.
3697 # @param theElems - group of of elements (edges or faces) to be replicated
3698 # @param theNodesNot - group of nodes not to replicated
3699 # @param theAffectedElems - group of elements to which the replicated nodes
3700 # should be associated to.
3701 # @ingroup l2_modif_edit
3702 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
3703 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3705 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3706 # This method provided for convenience works as DoubleNodes() described above.
3707 # @param theElems - group of of elements (edges or faces) to be replicated
3708 # @param theNodesNot - group of nodes not to replicated
3709 # @param theShape - shape to detect affected elements (element which geometric center
3710 # located on or inside shape).
3711 # The replicated nodes should be associated to affected elements.
3712 # @ingroup l2_modif_edit
3713 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3714 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3716 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3717 # This method provided for convenience works as DoubleNodes() described above.
3718 # @param theElems - list of groups of elements (edges or faces) to be replicated
3719 # @param theNodesNot - list of groups of nodes not to replicated
3720 # @param theAffectedElems - group of elements to which the replicated nodes
3721 # should be associated to.
3722 # @return TRUE if operation has been completed successfully, FALSE otherwise
3723 # @ingroup l2_modif_edit
3724 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3725 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3727 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3728 # This method provided for convenience works as DoubleNodes() described above.
3729 # @param theElems - list of groups of elements (edges or faces) to be replicated
3730 # @param theNodesNot - list of groups of nodes not to replicated
3731 # @param theShape - shape to detect affected elements (element which geometric center
3732 # located on or inside shape).
3733 # The replicated nodes should be associated to affected elements.
3734 # @return TRUE if operation has been completed successfully, FALSE otherwise
3735 # @ingroup l2_modif_edit
3736 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3737 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3739 ## The mother class to define algorithm, it is not recommended to use it directly.
3742 # @ingroup l2_algorithms
3743 class Mesh_Algorithm:
3744 # @class Mesh_Algorithm
3745 # @brief Class Mesh_Algorithm
3747 #def __init__(self,smesh):
3755 ## Finds a hypothesis in the study by its type name and parameters.
3756 # Finds only the hypotheses created in smeshpyD engine.
3757 # @return SMESH.SMESH_Hypothesis
3758 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3759 study = smeshpyD.GetCurrentStudy()
3760 #to do: find component by smeshpyD object, not by its data type
3761 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3762 if scomp is not None:
3763 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3764 # Check if the root label of the hypotheses exists
3765 if res and hypRoot is not None:
3766 iter = study.NewChildIterator(hypRoot)
3767 # Check all published hypotheses
3769 hypo_so_i = iter.Value()
3770 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3771 if attr is not None:
3772 anIOR = attr.Value()
3773 hypo_o_i = salome.orb.string_to_object(anIOR)
3774 if hypo_o_i is not None:
3775 # Check if this is a hypothesis
3776 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3777 if hypo_i is not None:
3778 # Check if the hypothesis belongs to current engine
3779 if smeshpyD.GetObjectId(hypo_i) > 0:
3780 # Check if this is the required hypothesis
3781 if hypo_i.GetName() == hypname:
3783 if CompareMethod(hypo_i, args):
3797 ## Finds the algorithm in the study by its type name.
3798 # Finds only the algorithms, which have been created in smeshpyD engine.
3799 # @return SMESH.SMESH_Algo
3800 def FindAlgorithm (self, algoname, smeshpyD):
3801 study = smeshpyD.GetCurrentStudy()
3802 #to do: find component by smeshpyD object, not by its data type
3803 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3804 if scomp is not None:
3805 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3806 # Check if the root label of the algorithms exists
3807 if res and hypRoot is not None:
3808 iter = study.NewChildIterator(hypRoot)
3809 # Check all published algorithms
3811 algo_so_i = iter.Value()
3812 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3813 if attr is not None:
3814 anIOR = attr.Value()
3815 algo_o_i = salome.orb.string_to_object(anIOR)
3816 if algo_o_i is not None:
3817 # Check if this is an algorithm
3818 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3819 if algo_i is not None:
3820 # Checks if the algorithm belongs to the current engine
3821 if smeshpyD.GetObjectId(algo_i) > 0:
3822 # Check if this is the required algorithm
3823 if algo_i.GetName() == algoname:
3836 ## If the algorithm is global, returns 0; \n
3837 # else returns the submesh associated to this algorithm.
3838 def GetSubMesh(self):
3841 ## Returns the wrapped mesher.
3842 def GetAlgorithm(self):
3845 ## Gets the list of hypothesis that can be used with this algorithm
3846 def GetCompatibleHypothesis(self):
3849 mylist = self.algo.GetCompatibleHypothesis()
3852 ## Gets the name of the algorithm
3856 ## Sets the name to the algorithm
3857 def SetName(self, name):
3858 self.mesh.smeshpyD.SetName(self.algo, name)
3860 ## Gets the id of the algorithm
3862 return self.algo.GetId()
3865 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3867 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3868 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3870 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3872 self.Assign(algo, mesh, geom)
3876 def Assign(self, algo, mesh, geom):
3878 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3887 name = GetName(geom)
3890 name = mesh.geompyD.SubShapeName(geom, piece)
3891 mesh.geompyD.addToStudyInFather(piece, geom, name)
3893 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3896 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3897 TreatHypoStatus( status, algo.GetName(), name, True )
3899 def CompareHyp (self, hyp, args):
3900 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3903 def CompareEqualHyp (self, hyp, args):
3907 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3908 UseExisting=0, CompareMethod=""):
3911 if CompareMethod == "": CompareMethod = self.CompareHyp
3912 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3915 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3921 a = a + s + str(args[i])
3925 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3927 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3928 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3931 ## Returns entry of the shape to mesh in the study
3932 def MainShapeEntry(self):
3934 if not self.mesh or not self.mesh.GetMesh(): return entry
3935 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3936 study = self.mesh.smeshpyD.GetCurrentStudy()
3937 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3938 sobj = study.FindObjectIOR(ior)
3939 if sobj: entry = sobj.GetID()
3940 if not entry: return ""
3943 # Public class: Mesh_Segment
3944 # --------------------------
3946 ## Class to define a segment 1D algorithm for discretization
3949 # @ingroup l3_algos_basic
3950 class Mesh_Segment(Mesh_Algorithm):
3952 ## Private constructor.
3953 def __init__(self, mesh, geom=0):
3954 Mesh_Algorithm.__init__(self)
3955 self.Create(mesh, geom, "Regular_1D")
3957 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3958 # @param l for the length of segments that cut an edge
3959 # @param UseExisting if ==true - searches for an existing hypothesis created with
3960 # the same parameters, else (default) - creates a new one
3961 # @param p precision, used for calculation of the number of segments.
3962 # The precision should be a positive, meaningful value within the range [0,1].
3963 # In general, the number of segments is calculated with the formula:
3964 # nb = ceil((edge_length / l) - p)
3965 # Function ceil rounds its argument to the higher integer.
3966 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3967 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3968 # p=1 means rounding of (edge_length / l) to the lower integer.
3969 # Default value is 1e-07.
3970 # @return an instance of StdMeshers_LocalLength hypothesis
3971 # @ingroup l3_hypos_1dhyps
3972 def LocalLength(self, l, UseExisting=0, p=1e-07):
3973 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3974 CompareMethod=self.CompareLocalLength)
3980 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3981 def CompareLocalLength(self, hyp, args):
3982 if IsEqual(hyp.GetLength(), args[0]):
3983 return IsEqual(hyp.GetPrecision(), args[1])
3986 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3987 # @param length is optional maximal allowed length of segment, if it is omitted
3988 # the preestimated length is used that depends on geometry size
3989 # @param UseExisting if ==true - searches for an existing hypothesis created with
3990 # the same parameters, else (default) - create a new one
3991 # @return an instance of StdMeshers_MaxLength hypothesis
3992 # @ingroup l3_hypos_1dhyps
3993 def MaxSize(self, length=0.0, UseExisting=0):
3994 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3997 hyp.SetLength(length)
3999 # set preestimated length
4000 gen = self.mesh.smeshpyD
4001 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4002 self.mesh.GetMesh(), self.mesh.GetShape(),
4004 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4006 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4009 hyp.SetUsePreestimatedLength( length == 0.0 )
4012 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4013 # @param n for the number of segments that cut an edge
4014 # @param s for the scale factor (optional)
4015 # @param reversedEdges is a list of edges to mesh using reversed orientation
4016 # @param UseExisting if ==true - searches for an existing hypothesis created with
4017 # the same parameters, else (default) - create a new one
4018 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4019 # @ingroup l3_hypos_1dhyps
4020 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4021 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4022 reversedEdges, UseExisting = [], reversedEdges
4023 entry = self.MainShapeEntry()
4025 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4026 UseExisting=UseExisting,
4027 CompareMethod=self.CompareNumberOfSegments)
4029 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4030 UseExisting=UseExisting,
4031 CompareMethod=self.CompareNumberOfSegments)
4032 hyp.SetDistrType( 1 )
4033 hyp.SetScaleFactor(s)
4034 hyp.SetNumberOfSegments(n)
4035 hyp.SetReversedEdges( reversedEdges )
4036 hyp.SetObjectEntry( entry )
4040 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4041 def CompareNumberOfSegments(self, hyp, args):
4042 if hyp.GetNumberOfSegments() == args[0]:
4044 if hyp.GetReversedEdges() == args[1]:
4045 if not args[1] or hyp.GetObjectEntry() == args[2]:
4048 if hyp.GetReversedEdges() == args[2]:
4049 if not args[2] or hyp.GetObjectEntry() == args[3]:
4050 if hyp.GetDistrType() == 1:
4051 if IsEqual(hyp.GetScaleFactor(), args[1]):
4055 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4056 # @param start defines the length of the first segment
4057 # @param end defines the length of the last segment
4058 # @param reversedEdges is a list of edges to mesh using reversed orientation
4059 # @param UseExisting if ==true - searches for an existing hypothesis created with
4060 # the same parameters, else (default) - creates a new one
4061 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4062 # @ingroup l3_hypos_1dhyps
4063 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4064 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4065 reversedEdges, UseExisting = [], reversedEdges
4066 entry = self.MainShapeEntry()
4067 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4068 UseExisting=UseExisting,
4069 CompareMethod=self.CompareArithmetic1D)
4070 hyp.SetStartLength(start)
4071 hyp.SetEndLength(end)
4072 hyp.SetReversedEdges( reversedEdges )
4073 hyp.SetObjectEntry( entry )
4077 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4078 def CompareArithmetic1D(self, hyp, args):
4079 if IsEqual(hyp.GetLength(1), args[0]):
4080 if IsEqual(hyp.GetLength(0), args[1]):
4081 if hyp.GetReversedEdges() == args[2]:
4082 if not args[2] or hyp.GetObjectEntry() == args[3]:
4087 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4088 # on curve from 0 to 1 (additionally it is neecessary to check
4089 # orientation of edges and create list of reversed edges if it is
4090 # needed) and sets numbers of segments between given points (default
4091 # values are equals 1
4092 # @param points defines the list of parameters on curve
4093 # @param nbSegs defines the list of numbers of segments
4094 # @param reversedEdges is a list of edges to mesh using reversed orientation
4095 # @param UseExisting if ==true - searches for an existing hypothesis created with
4096 # the same parameters, else (default) - creates a new one
4097 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4098 # @ingroup l3_hypos_1dhyps
4099 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4100 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4101 reversedEdges, UseExisting = [], reversedEdges
4102 if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4103 for i in range( len( reversedEdges )):
4104 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4105 entry = self.MainShapeEntry()
4106 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4107 UseExisting=UseExisting,
4108 CompareMethod=self.CompareFixedPoints1D)
4109 hyp.SetPoints(points)
4110 hyp.SetNbSegments(nbSegs)
4111 hyp.SetReversedEdges(reversedEdges)
4112 hyp.SetObjectEntry(entry)
4116 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4117 ## as the given arguments
4118 def CompareFixedPoints1D(self, hyp, args):
4119 if hyp.GetPoints() == args[0]:
4120 if hyp.GetNbSegments() == args[1]:
4121 if hyp.GetReversedEdges() == args[2]:
4122 if not args[2] or hyp.GetObjectEntry() == args[3]:
4128 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4129 # @param start defines the length of the first segment
4130 # @param end defines the length of the last segment
4131 # @param reversedEdges is a list of edges to mesh using reversed orientation
4132 # @param UseExisting if ==true - searches for an existing hypothesis created with
4133 # the same parameters, else (default) - creates a new one
4134 # @return an instance of StdMeshers_StartEndLength hypothesis
4135 # @ingroup l3_hypos_1dhyps
4136 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4137 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4138 reversedEdges, UseExisting = [], reversedEdges
4139 entry = self.MainShapeEntry()
4140 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4141 UseExisting=UseExisting,
4142 CompareMethod=self.CompareStartEndLength)
4143 hyp.SetStartLength(start)
4144 hyp.SetEndLength(end)
4145 hyp.SetReversedEdges( reversedEdges )
4146 hyp.SetObjectEntry( entry )
4149 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4150 def CompareStartEndLength(self, hyp, args):
4151 if IsEqual(hyp.GetLength(1), args[0]):
4152 if IsEqual(hyp.GetLength(0), args[1]):
4153 if hyp.GetReversedEdges() == args[2]:
4154 if not args[2] or hyp.GetObjectEntry() == args[3]:
4158 ## Defines "Deflection1D" hypothesis
4159 # @param d for the deflection
4160 # @param UseExisting if ==true - searches for an existing hypothesis created with
4161 # the same parameters, else (default) - create a new one
4162 # @ingroup l3_hypos_1dhyps
4163 def Deflection1D(self, d, UseExisting=0):
4164 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4165 CompareMethod=self.CompareDeflection1D)
4166 hyp.SetDeflection(d)
4169 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4170 def CompareDeflection1D(self, hyp, args):
4171 return IsEqual(hyp.GetDeflection(), args[0])
4173 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4174 # the opposite side in case of quadrangular faces
4175 # @ingroup l3_hypos_additi
4176 def Propagation(self):
4177 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4179 ## Defines "AutomaticLength" hypothesis
4180 # @param fineness for the fineness [0-1]
4181 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4182 # same parameters, else (default) - create a new one
4183 # @ingroup l3_hypos_1dhyps
4184 def AutomaticLength(self, fineness=0, UseExisting=0):
4185 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4186 CompareMethod=self.CompareAutomaticLength)
4187 hyp.SetFineness( fineness )
4190 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4191 def CompareAutomaticLength(self, hyp, args):
4192 return IsEqual(hyp.GetFineness(), args[0])
4194 ## Defines "SegmentLengthAroundVertex" hypothesis
4195 # @param length for the segment length
4196 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4197 # Any other integer value means that the hypothesis will be set on the
4198 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4199 # @param UseExisting if ==true - searches for an existing hypothesis created with
4200 # the same parameters, else (default) - creates a new one
4201 # @ingroup l3_algos_segmarv
4202 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4204 store_geom = self.geom
4205 if type(vertex) is types.IntType:
4206 if vertex == 0 or vertex == 1:
4207 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4215 if self.geom is None:
4216 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4218 name = GetName(self.geom)
4221 piece = self.mesh.geom
4222 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4223 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4225 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4227 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4229 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4230 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4232 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4233 CompareMethod=self.CompareLengthNearVertex)
4234 self.geom = store_geom
4235 hyp.SetLength( length )
4238 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4239 # @ingroup l3_algos_segmarv
4240 def CompareLengthNearVertex(self, hyp, args):
4241 return IsEqual(hyp.GetLength(), args[0])
4243 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4244 # If the 2D mesher sees that all boundary edges are quadratic,
4245 # it generates quadratic faces, else it generates linear faces using
4246 # medium nodes as if they are vertices.
4247 # The 3D mesher generates quadratic volumes only if all boundary faces
4248 # are quadratic, else it fails.
4250 # @ingroup l3_hypos_additi
4251 def QuadraticMesh(self):
4252 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4255 # Public class: Mesh_CompositeSegment
4256 # --------------------------
4258 ## Defines a segment 1D algorithm for discretization
4260 # @ingroup l3_algos_basic
4261 class Mesh_CompositeSegment(Mesh_Segment):
4263 ## Private constructor.
4264 def __init__(self, mesh, geom=0):
4265 self.Create(mesh, geom, "CompositeSegment_1D")
4268 # Public class: Mesh_Segment_Python
4269 # ---------------------------------
4271 ## Defines a segment 1D algorithm for discretization with python function
4273 # @ingroup l3_algos_basic
4274 class Mesh_Segment_Python(Mesh_Segment):
4276 ## Private constructor.
4277 def __init__(self, mesh, geom=0):
4278 import Python1dPlugin
4279 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4281 ## Defines "PythonSplit1D" hypothesis
4282 # @param n for the number of segments that cut an edge
4283 # @param func for the python function that calculates the length of all segments
4284 # @param UseExisting if ==true - searches for the existing hypothesis created with
4285 # the same parameters, else (default) - creates a new one
4286 # @ingroup l3_hypos_1dhyps
4287 def PythonSplit1D(self, n, func, UseExisting=0):
4288 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4289 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4290 hyp.SetNumberOfSegments(n)
4291 hyp.SetPythonLog10RatioFunction(func)
4294 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4295 def ComparePythonSplit1D(self, hyp, args):
4296 #if hyp.GetNumberOfSegments() == args[0]:
4297 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4301 # Public class: Mesh_Triangle
4302 # ---------------------------
4304 ## Defines a triangle 2D algorithm
4306 # @ingroup l3_algos_basic
4307 class Mesh_Triangle(Mesh_Algorithm):
4316 ## Private constructor.
4317 def __init__(self, mesh, algoType, geom=0):
4318 Mesh_Algorithm.__init__(self)
4320 self.algoType = algoType
4321 if algoType == MEFISTO:
4322 self.Create(mesh, geom, "MEFISTO_2D")
4324 elif algoType == BLSURF:
4326 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4327 #self.SetPhysicalMesh() - PAL19680
4328 elif algoType == NETGEN:
4330 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4332 elif algoType == NETGEN_2D:
4334 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4337 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4338 # @param area for the maximum area of each triangle
4339 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4340 # same parameters, else (default) - creates a new one
4342 # Only for algoType == MEFISTO || NETGEN_2D
4343 # @ingroup l3_hypos_2dhyps
4344 def MaxElementArea(self, area, UseExisting=0):
4345 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4346 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4347 CompareMethod=self.CompareMaxElementArea)
4348 elif self.algoType == NETGEN:
4349 hyp = self.Parameters(SIMPLE)
4350 hyp.SetMaxElementArea(area)
4353 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4354 def CompareMaxElementArea(self, hyp, args):
4355 return IsEqual(hyp.GetMaxElementArea(), args[0])
4357 ## Defines "LengthFromEdges" hypothesis to build triangles
4358 # based on the length of the edges taken from the wire
4360 # Only for algoType == MEFISTO || NETGEN_2D
4361 # @ingroup l3_hypos_2dhyps
4362 def LengthFromEdges(self):
4363 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4364 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4366 elif self.algoType == NETGEN:
4367 hyp = self.Parameters(SIMPLE)
4368 hyp.LengthFromEdges()
4371 ## Sets a way to define size of mesh elements to generate.
4372 # @param thePhysicalMesh is: DefaultSize or Custom.
4373 # @ingroup l3_hypos_blsurf
4374 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4375 # Parameter of BLSURF algo
4376 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4378 ## Sets size of mesh elements to generate.
4379 # @ingroup l3_hypos_blsurf
4380 def SetPhySize(self, theVal):
4381 # Parameter of BLSURF algo
4382 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4383 self.Parameters().SetPhySize(theVal)
4385 ## Sets lower boundary of mesh element size (PhySize).
4386 # @ingroup l3_hypos_blsurf
4387 def SetPhyMin(self, theVal=-1):
4388 # Parameter of BLSURF algo
4389 self.Parameters().SetPhyMin(theVal)
4391 ## Sets upper boundary of mesh element size (PhySize).
4392 # @ingroup l3_hypos_blsurf
4393 def SetPhyMax(self, theVal=-1):
4394 # Parameter of BLSURF algo
4395 self.Parameters().SetPhyMax(theVal)
4397 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4398 # @param theGeometricMesh is: DefaultGeom or Custom
4399 # @ingroup l3_hypos_blsurf
4400 def SetGeometricMesh(self, theGeometricMesh=0):
4401 # Parameter of BLSURF algo
4402 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4403 self.params.SetGeometricMesh(theGeometricMesh)
4405 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4406 # @ingroup l3_hypos_blsurf
4407 def SetAngleMeshS(self, theVal=_angleMeshS):
4408 # Parameter of BLSURF algo
4409 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4410 self.params.SetAngleMeshS(theVal)
4412 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4413 # @ingroup l3_hypos_blsurf
4414 def SetAngleMeshC(self, theVal=_angleMeshS):
4415 # Parameter of BLSURF algo
4416 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4417 self.params.SetAngleMeshC(theVal)
4419 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4420 # @ingroup l3_hypos_blsurf
4421 def SetGeoMin(self, theVal=-1):
4422 # Parameter of BLSURF algo
4423 self.Parameters().SetGeoMin(theVal)
4425 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4426 # @ingroup l3_hypos_blsurf
4427 def SetGeoMax(self, theVal=-1):
4428 # Parameter of BLSURF algo
4429 self.Parameters().SetGeoMax(theVal)
4431 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4432 # @ingroup l3_hypos_blsurf
4433 def SetGradation(self, theVal=_gradation):
4434 # Parameter of BLSURF algo
4435 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4436 self.params.SetGradation(theVal)
4438 ## Sets topology usage way.
4439 # @param way defines how mesh conformity is assured <ul>
4440 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4441 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4442 # @ingroup l3_hypos_blsurf
4443 def SetTopology(self, way):
4444 # Parameter of BLSURF algo
4445 self.Parameters().SetTopology(way)
4447 ## To respect geometrical edges or not.
4448 # @ingroup l3_hypos_blsurf
4449 def SetDecimesh(self, toIgnoreEdges=False):
4450 # Parameter of BLSURF algo
4451 self.Parameters().SetDecimesh(toIgnoreEdges)
4453 ## Sets verbosity level in the range 0 to 100.
4454 # @ingroup l3_hypos_blsurf
4455 def SetVerbosity(self, level):
4456 # Parameter of BLSURF algo
4457 self.Parameters().SetVerbosity(level)
4459 ## Sets advanced option value.
4460 # @ingroup l3_hypos_blsurf
4461 def SetOptionValue(self, optionName, level):
4462 # Parameter of BLSURF algo
4463 self.Parameters().SetOptionValue(optionName,level)
4465 ## Sets QuadAllowed flag.
4466 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4467 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4468 def SetQuadAllowed(self, toAllow=True):
4469 if self.algoType == NETGEN_2D:
4470 if toAllow: # add QuadranglePreference
4471 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4472 else: # remove QuadranglePreference
4473 for hyp in self.mesh.GetHypothesisList( self.geom ):
4474 if hyp.GetName() == "QuadranglePreference":
4475 self.mesh.RemoveHypothesis( self.geom, hyp )
4480 if self.Parameters():
4481 self.params.SetQuadAllowed(toAllow)
4484 ## Defines hypothesis having several parameters
4486 # @ingroup l3_hypos_netgen
4487 def Parameters(self, which=SOLE):
4490 if self.algoType == NETGEN:
4492 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4493 "libNETGENEngine.so", UseExisting=0)
4495 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4496 "libNETGENEngine.so", UseExisting=0)
4498 elif self.algoType == MEFISTO:
4499 print "Mefisto algo support no multi-parameter hypothesis"
4501 elif self.algoType == NETGEN_2D:
4502 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4503 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4505 elif self.algoType == BLSURF:
4506 self.params = self.Hypothesis("BLSURF_Parameters", [],
4507 "libBLSURFEngine.so", UseExisting=0)
4510 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4515 # Only for algoType == NETGEN
4516 # @ingroup l3_hypos_netgen
4517 def SetMaxSize(self, theSize):
4518 if self.Parameters():
4519 self.params.SetMaxSize(theSize)
4521 ## Sets SecondOrder flag
4523 # Only for algoType == NETGEN
4524 # @ingroup l3_hypos_netgen
4525 def SetSecondOrder(self, theVal):
4526 if self.Parameters():
4527 self.params.SetSecondOrder(theVal)
4529 ## Sets Optimize flag
4531 # Only for algoType == NETGEN
4532 # @ingroup l3_hypos_netgen
4533 def SetOptimize(self, theVal):
4534 if self.Parameters():
4535 self.params.SetOptimize(theVal)
4538 # @param theFineness is:
4539 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4541 # Only for algoType == NETGEN
4542 # @ingroup l3_hypos_netgen
4543 def SetFineness(self, theFineness):
4544 if self.Parameters():
4545 self.params.SetFineness(theFineness)
4549 # Only for algoType == NETGEN
4550 # @ingroup l3_hypos_netgen
4551 def SetGrowthRate(self, theRate):
4552 if self.Parameters():
4553 self.params.SetGrowthRate(theRate)
4555 ## Sets NbSegPerEdge
4557 # Only for algoType == NETGEN
4558 # @ingroup l3_hypos_netgen
4559 def SetNbSegPerEdge(self, theVal):
4560 if self.Parameters():
4561 self.params.SetNbSegPerEdge(theVal)
4563 ## Sets NbSegPerRadius
4565 # Only for algoType == NETGEN
4566 # @ingroup l3_hypos_netgen
4567 def SetNbSegPerRadius(self, theVal):
4568 if self.Parameters():
4569 self.params.SetNbSegPerRadius(theVal)
4571 ## Sets number of segments overriding value set by SetLocalLength()
4573 # Only for algoType == NETGEN
4574 # @ingroup l3_hypos_netgen
4575 def SetNumberOfSegments(self, theVal):
4576 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4578 ## Sets number of segments overriding value set by SetNumberOfSegments()
4580 # Only for algoType == NETGEN
4581 # @ingroup l3_hypos_netgen
4582 def SetLocalLength(self, theVal):
4583 self.Parameters(SIMPLE).SetLocalLength(theVal)
4588 # Public class: Mesh_Quadrangle
4589 # -----------------------------
4591 ## Defines a quadrangle 2D algorithm
4593 # @ingroup l3_algos_basic
4594 class Mesh_Quadrangle(Mesh_Algorithm):
4596 ## Private constructor.
4597 def __init__(self, mesh, geom=0):
4598 Mesh_Algorithm.__init__(self)
4599 self.Create(mesh, geom, "Quadrangle_2D")
4601 ## Defines "QuadranglePreference" hypothesis, forcing construction
4602 # of quadrangles if the number of nodes on the opposite edges is not the same
4603 # while the total number of nodes on edges is even
4605 # @ingroup l3_hypos_additi
4606 def QuadranglePreference(self):
4607 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4608 CompareMethod=self.CompareEqualHyp)
4611 ## Defines "TrianglePreference" hypothesis, forcing construction
4612 # of triangles in the refinement area if the number of nodes
4613 # on the opposite edges is not the same
4615 # @ingroup l3_hypos_additi
4616 def TrianglePreference(self):
4617 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4618 CompareMethod=self.CompareEqualHyp)
4621 ## Defines "QuadrangleParams" hypothesis
4622 # @param vertex: vertex of a trilateral geometrical face, around which triangles
4623 # will be created while other elements will be quadrangles.
4624 # Vertex can be either a GEOM_Object or a vertex ID within the
4626 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4627 # the same parameters, else (default) - creates a new one
4629 # @ingroup l3_hypos_additi
4630 def TriangleVertex(self, vertex, UseExisting=0):
4632 if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4633 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4634 hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4635 CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4636 hyp.SetTriaVertex( vertexID )
4640 # Public class: Mesh_Tetrahedron
4641 # ------------------------------
4643 ## Defines a tetrahedron 3D algorithm
4645 # @ingroup l3_algos_basic
4646 class Mesh_Tetrahedron(Mesh_Algorithm):
4651 ## Private constructor.
4652 def __init__(self, mesh, algoType, geom=0):
4653 Mesh_Algorithm.__init__(self)
4655 if algoType == NETGEN:
4657 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4660 elif algoType == FULL_NETGEN:
4662 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4665 elif algoType == GHS3D:
4667 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4670 elif algoType == GHS3DPRL:
4671 CheckPlugin(GHS3DPRL)
4672 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4675 self.algoType = algoType
4677 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4678 # @param vol for the maximum volume of each tetrahedron
4679 # @param UseExisting if ==true - searches for the existing hypothesis created with
4680 # the same parameters, else (default) - creates a new one
4681 # @ingroup l3_hypos_maxvol
4682 def MaxElementVolume(self, vol, UseExisting=0):
4683 if self.algoType == NETGEN:
4684 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4685 CompareMethod=self.CompareMaxElementVolume)
4686 hyp.SetMaxElementVolume(vol)
4688 elif self.algoType == FULL_NETGEN:
4689 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4692 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4693 def CompareMaxElementVolume(self, hyp, args):
4694 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4696 ## Defines hypothesis having several parameters
4698 # @ingroup l3_hypos_netgen
4699 def Parameters(self, which=SOLE):
4703 if self.algoType == FULL_NETGEN:
4705 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4706 "libNETGENEngine.so", UseExisting=0)
4708 self.params = self.Hypothesis("NETGEN_Parameters", [],
4709 "libNETGENEngine.so", UseExisting=0)
4712 if self.algoType == GHS3D:
4713 self.params = self.Hypothesis("GHS3D_Parameters", [],
4714 "libGHS3DEngine.so", UseExisting=0)
4717 if self.algoType == GHS3DPRL:
4718 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4719 "libGHS3DPRLEngine.so", UseExisting=0)
4722 print "Algo supports no multi-parameter hypothesis"
4726 # Parameter of FULL_NETGEN
4727 # @ingroup l3_hypos_netgen
4728 def SetMaxSize(self, theSize):
4729 self.Parameters().SetMaxSize(theSize)
4731 ## Sets SecondOrder flag
4732 # Parameter of FULL_NETGEN
4733 # @ingroup l3_hypos_netgen
4734 def SetSecondOrder(self, theVal):
4735 self.Parameters().SetSecondOrder(theVal)
4737 ## Sets Optimize flag
4738 # Parameter of FULL_NETGEN
4739 # @ingroup l3_hypos_netgen
4740 def SetOptimize(self, theVal):
4741 self.Parameters().SetOptimize(theVal)
4744 # @param theFineness is:
4745 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4746 # Parameter of FULL_NETGEN
4747 # @ingroup l3_hypos_netgen
4748 def SetFineness(self, theFineness):
4749 self.Parameters().SetFineness(theFineness)
4752 # Parameter of FULL_NETGEN
4753 # @ingroup l3_hypos_netgen
4754 def SetGrowthRate(self, theRate):
4755 self.Parameters().SetGrowthRate(theRate)
4757 ## Sets NbSegPerEdge
4758 # Parameter of FULL_NETGEN
4759 # @ingroup l3_hypos_netgen
4760 def SetNbSegPerEdge(self, theVal):
4761 self.Parameters().SetNbSegPerEdge(theVal)
4763 ## Sets NbSegPerRadius
4764 # Parameter of FULL_NETGEN
4765 # @ingroup l3_hypos_netgen
4766 def SetNbSegPerRadius(self, theVal):
4767 self.Parameters().SetNbSegPerRadius(theVal)
4769 ## Sets number of segments overriding value set by SetLocalLength()
4770 # Only for algoType == NETGEN_FULL
4771 # @ingroup l3_hypos_netgen
4772 def SetNumberOfSegments(self, theVal):
4773 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4775 ## Sets number of segments overriding value set by SetNumberOfSegments()
4776 # Only for algoType == NETGEN_FULL
4777 # @ingroup l3_hypos_netgen
4778 def SetLocalLength(self, theVal):
4779 self.Parameters(SIMPLE).SetLocalLength(theVal)
4781 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4782 # Overrides value set by LengthFromEdges()
4783 # Only for algoType == NETGEN_FULL
4784 # @ingroup l3_hypos_netgen
4785 def MaxElementArea(self, area):
4786 self.Parameters(SIMPLE).SetMaxElementArea(area)
4788 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4789 # Overrides value set by MaxElementArea()
4790 # Only for algoType == NETGEN_FULL
4791 # @ingroup l3_hypos_netgen
4792 def LengthFromEdges(self):
4793 self.Parameters(SIMPLE).LengthFromEdges()
4795 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4796 # Overrides value set by MaxElementVolume()
4797 # Only for algoType == NETGEN_FULL
4798 # @ingroup l3_hypos_netgen
4799 def LengthFromFaces(self):
4800 self.Parameters(SIMPLE).LengthFromFaces()
4802 ## To mesh "holes" in a solid or not. Default is to mesh.
4803 # @ingroup l3_hypos_ghs3dh
4804 def SetToMeshHoles(self, toMesh):
4805 # Parameter of GHS3D
4806 self.Parameters().SetToMeshHoles(toMesh)
4808 ## Set Optimization level:
4809 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4810 # Strong_Optimization.
4811 # Default is Standard_Optimization
4812 # @ingroup l3_hypos_ghs3dh
4813 def SetOptimizationLevel(self, level):
4814 # Parameter of GHS3D
4815 self.Parameters().SetOptimizationLevel(level)
4817 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4818 # @ingroup l3_hypos_ghs3dh
4819 def SetMaximumMemory(self, MB):
4820 # Advanced parameter of GHS3D
4821 self.Parameters().SetMaximumMemory(MB)
4823 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4824 # automatic memory adjustment mode.
4825 # @ingroup l3_hypos_ghs3dh
4826 def SetInitialMemory(self, MB):
4827 # Advanced parameter of GHS3D
4828 self.Parameters().SetInitialMemory(MB)
4830 ## Path to working directory.
4831 # @ingroup l3_hypos_ghs3dh
4832 def SetWorkingDirectory(self, path):
4833 # Advanced parameter of GHS3D
4834 self.Parameters().SetWorkingDirectory(path)
4836 ## To keep working files or remove them. Log file remains in case of errors anyway.
4837 # @ingroup l3_hypos_ghs3dh
4838 def SetKeepFiles(self, toKeep):
4839 # Advanced parameter of GHS3D and GHS3DPRL
4840 self.Parameters().SetKeepFiles(toKeep)
4842 ## To set verbose level [0-10]. <ul>
4843 #<li> 0 - no standard output,
4844 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4845 # indicates when the final mesh is being saved. In addition the software
4846 # gives indication regarding the CPU time.
4847 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4848 # histogram of the skin mesh, quality statistics histogram together with
4849 # the characteristics of the final mesh.</ul>
4850 # @ingroup l3_hypos_ghs3dh
4851 def SetVerboseLevel(self, level):
4852 # Advanced parameter of GHS3D
4853 self.Parameters().SetVerboseLevel(level)
4855 ## To create new nodes.
4856 # @ingroup l3_hypos_ghs3dh
4857 def SetToCreateNewNodes(self, toCreate):
4858 # Advanced parameter of GHS3D
4859 self.Parameters().SetToCreateNewNodes(toCreate)
4861 ## To use boundary recovery version which tries to create mesh on a very poor
4862 # quality surface mesh.
4863 # @ingroup l3_hypos_ghs3dh
4864 def SetToUseBoundaryRecoveryVersion(self, toUse):
4865 # Advanced parameter of GHS3D
4866 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4868 ## Sets command line option as text.
4869 # @ingroup l3_hypos_ghs3dh
4870 def SetTextOption(self, option):
4871 # Advanced parameter of GHS3D
4872 self.Parameters().SetTextOption(option)
4874 ## Sets MED files name and path.
4875 def SetMEDName(self, value):
4876 self.Parameters().SetMEDName(value)
4878 ## Sets the number of partition of the initial mesh
4879 def SetNbPart(self, value):
4880 self.Parameters().SetNbPart(value)
4882 ## When big mesh, start tepal in background
4883 def SetBackground(self, value):
4884 self.Parameters().SetBackground(value)
4886 # Public class: Mesh_Hexahedron
4887 # ------------------------------
4889 ## Defines a hexahedron 3D algorithm
4891 # @ingroup l3_algos_basic
4892 class Mesh_Hexahedron(Mesh_Algorithm):
4897 ## Private constructor.
4898 def __init__(self, mesh, algoType=Hexa, geom=0):
4899 Mesh_Algorithm.__init__(self)
4901 self.algoType = algoType
4903 if algoType == Hexa:
4904 self.Create(mesh, geom, "Hexa_3D")
4907 elif algoType == Hexotic:
4908 CheckPlugin(Hexotic)
4909 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4912 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4913 # @ingroup l3_hypos_hexotic
4914 def MinMaxQuad(self, min=3, max=8, quad=True):
4915 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4917 self.params.SetHexesMinLevel(min)
4918 self.params.SetHexesMaxLevel(max)
4919 self.params.SetHexoticQuadrangles(quad)
4922 # Deprecated, only for compatibility!
4923 # Public class: Mesh_Netgen
4924 # ------------------------------
4926 ## Defines a NETGEN-based 2D or 3D algorithm
4927 # that needs no discrete boundary (i.e. independent)
4929 # This class is deprecated, only for compatibility!
4932 # @ingroup l3_algos_basic
4933 class Mesh_Netgen(Mesh_Algorithm):
4937 ## Private constructor.
4938 def __init__(self, mesh, is3D, geom=0):
4939 Mesh_Algorithm.__init__(self)
4945 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4949 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4952 ## Defines the hypothesis containing parameters of the algorithm
4953 def Parameters(self):
4955 hyp = self.Hypothesis("NETGEN_Parameters", [],
4956 "libNETGENEngine.so", UseExisting=0)
4958 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4959 "libNETGENEngine.so", UseExisting=0)
4962 # Public class: Mesh_Projection1D
4963 # ------------------------------
4965 ## Defines a projection 1D algorithm
4966 # @ingroup l3_algos_proj
4968 class Mesh_Projection1D(Mesh_Algorithm):
4970 ## Private constructor.
4971 def __init__(self, mesh, geom=0):
4972 Mesh_Algorithm.__init__(self)
4973 self.Create(mesh, geom, "Projection_1D")
4975 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4976 # a mesh pattern is taken, and, optionally, the association of vertices
4977 # between the source edge and a target edge (to which a hypothesis is assigned)
4978 # @param edge from which nodes distribution is taken
4979 # @param mesh from which nodes distribution is taken (optional)
4980 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4981 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4982 # to associate with \a srcV (optional)
4983 # @param UseExisting if ==true - searches for the existing hypothesis created with
4984 # the same parameters, else (default) - creates a new one
4985 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4986 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4988 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4989 hyp.SetSourceEdge( edge )
4990 if not mesh is None and isinstance(mesh, Mesh):
4991 mesh = mesh.GetMesh()
4992 hyp.SetSourceMesh( mesh )
4993 hyp.SetVertexAssociation( srcV, tgtV )
4996 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4997 #def CompareSourceEdge(self, hyp, args):
4998 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5002 # Public class: Mesh_Projection2D
5003 # ------------------------------
5005 ## Defines a projection 2D algorithm
5006 # @ingroup l3_algos_proj
5008 class Mesh_Projection2D(Mesh_Algorithm):
5010 ## Private constructor.
5011 def __init__(self, mesh, geom=0):
5012 Mesh_Algorithm.__init__(self)
5013 self.Create(mesh, geom, "Projection_2D")
5015 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5016 # a mesh pattern is taken, and, optionally, the association of vertices
5017 # between the source face and the target face (to which a hypothesis is assigned)
5018 # @param face from which the mesh pattern is taken
5019 # @param mesh from which the mesh pattern is taken (optional)
5020 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5021 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5022 # to associate with \a srcV1 (optional)
5023 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5024 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5025 # to associate with \a srcV2 (optional)
5026 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5027 # the same parameters, else (default) - forces the creation a new one
5029 # Note: all association vertices must belong to one edge of a face
5030 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5031 srcV2=None, tgtV2=None, UseExisting=0):
5032 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5034 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5035 hyp.SetSourceFace( face )
5036 if not mesh is None and isinstance(mesh, Mesh):
5037 mesh = mesh.GetMesh()
5038 hyp.SetSourceMesh( mesh )
5039 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5042 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5043 #def CompareSourceFace(self, hyp, args):
5044 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5047 # Public class: Mesh_Projection3D
5048 # ------------------------------
5050 ## Defines a projection 3D algorithm
5051 # @ingroup l3_algos_proj
5053 class Mesh_Projection3D(Mesh_Algorithm):
5055 ## Private constructor.
5056 def __init__(self, mesh, geom=0):
5057 Mesh_Algorithm.__init__(self)
5058 self.Create(mesh, geom, "Projection_3D")
5060 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5061 # the mesh pattern is taken, and, optionally, the association of vertices
5062 # between the source and the target solid (to which a hipothesis is assigned)
5063 # @param solid from where the mesh pattern is taken
5064 # @param mesh from where the mesh pattern is taken (optional)
5065 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5066 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5067 # to associate with \a srcV1 (optional)
5068 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5069 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5070 # to associate with \a srcV2 (optional)
5071 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5072 # the same parameters, else (default) - creates a new one
5074 # Note: association vertices must belong to one edge of a solid
5075 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5076 srcV2=0, tgtV2=0, UseExisting=0):
5077 hyp = self.Hypothesis("ProjectionSource3D",
5078 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5080 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5081 hyp.SetSource3DShape( solid )
5082 if not mesh is None and isinstance(mesh, Mesh):
5083 mesh = mesh.GetMesh()
5084 hyp.SetSourceMesh( mesh )
5085 if srcV1 and srcV2 and tgtV1 and tgtV2:
5086 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5087 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5090 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5091 #def CompareSourceShape3D(self, hyp, args):
5092 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5096 # Public class: Mesh_Prism
5097 # ------------------------
5099 ## Defines a 3D extrusion algorithm
5100 # @ingroup l3_algos_3dextr
5102 class Mesh_Prism3D(Mesh_Algorithm):
5104 ## Private constructor.
5105 def __init__(self, mesh, geom=0):
5106 Mesh_Algorithm.__init__(self)
5107 self.Create(mesh, geom, "Prism_3D")
5109 # Public class: Mesh_RadialPrism
5110 # -------------------------------
5112 ## Defines a Radial Prism 3D algorithm
5113 # @ingroup l3_algos_radialp
5115 class Mesh_RadialPrism3D(Mesh_Algorithm):
5117 ## Private constructor.
5118 def __init__(self, mesh, geom=0):
5119 Mesh_Algorithm.__init__(self)
5120 self.Create(mesh, geom, "RadialPrism_3D")
5122 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5123 self.nbLayers = None
5125 ## Return 3D hypothesis holding the 1D one
5126 def Get3DHypothesis(self):
5127 return self.distribHyp
5129 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5130 # hypothesis. Returns the created hypothesis
5131 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5132 #print "OwnHypothesis",hypType
5133 if not self.nbLayers is None:
5134 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5135 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5136 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5137 self.mesh.smeshpyD.SetCurrentStudy( None )
5138 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5139 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5140 self.distribHyp.SetLayerDistribution( hyp )
5143 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5144 # prisms to build between the inner and outer shells
5145 # @param n number of layers
5146 # @param UseExisting if ==true - searches for the existing hypothesis created with
5147 # the same parameters, else (default) - creates a new one
5148 def NumberOfLayers(self, n, UseExisting=0):
5149 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5150 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5151 CompareMethod=self.CompareNumberOfLayers)
5152 self.nbLayers.SetNumberOfLayers( n )
5153 return self.nbLayers
5155 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5156 def CompareNumberOfLayers(self, hyp, args):
5157 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5159 ## Defines "LocalLength" hypothesis, specifying the segment length
5160 # to build between the inner and the outer shells
5161 # @param l the length of segments
5162 # @param p the precision of rounding
5163 def LocalLength(self, l, p=1e-07):
5164 hyp = self.OwnHypothesis("LocalLength", [l,p])
5169 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5170 # prisms to build between the inner and the outer shells.
5171 # @param n the number of layers
5172 # @param s the scale factor (optional)
5173 def NumberOfSegments(self, n, s=[]):
5175 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5177 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5178 hyp.SetDistrType( 1 )
5179 hyp.SetScaleFactor(s)
5180 hyp.SetNumberOfSegments(n)
5183 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5184 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5185 # @param start the length of the first segment
5186 # @param end the length of the last segment
5187 def Arithmetic1D(self, start, end ):
5188 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5189 hyp.SetLength(start, 1)
5190 hyp.SetLength(end , 0)
5193 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5194 # to build between the inner and the outer shells as geometric length increasing
5195 # @param start for the length of the first segment
5196 # @param end for the length of the last segment
5197 def StartEndLength(self, start, end):
5198 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5199 hyp.SetLength(start, 1)
5200 hyp.SetLength(end , 0)
5203 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5204 # to build between the inner and outer shells
5205 # @param fineness defines the quality of the mesh within the range [0-1]
5206 def AutomaticLength(self, fineness=0):
5207 hyp = self.OwnHypothesis("AutomaticLength")
5208 hyp.SetFineness( fineness )
5211 # Public class: Mesh_RadialQuadrangle1D2D
5212 # -------------------------------
5214 ## Defines a Radial Quadrangle 1D2D algorithm
5215 # @ingroup l2_algos_radialq
5217 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5219 ## Private constructor.
5220 def __init__(self, mesh, geom=0):
5221 Mesh_Algorithm.__init__(self)
5222 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5224 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5225 self.nbLayers = None
5227 ## Return 2D hypothesis holding the 1D one
5228 def Get2DHypothesis(self):
5229 return self.distribHyp
5231 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5232 # hypothesis. Returns the created hypothesis
5233 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5234 #print "OwnHypothesis",hypType
5236 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5237 if self.distribHyp is None:
5238 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5240 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5241 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5242 self.mesh.smeshpyD.SetCurrentStudy( None )
5243 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5244 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5245 self.distribHyp.SetLayerDistribution( hyp )
5248 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5249 # @param n number of layers
5250 # @param UseExisting if ==true - searches for the existing hypothesis created with
5251 # the same parameters, else (default) - creates a new one
5252 def NumberOfLayers(self, n, UseExisting=0):
5254 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5255 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5256 CompareMethod=self.CompareNumberOfLayers)
5257 self.nbLayers.SetNumberOfLayers( n )
5258 return self.nbLayers
5260 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5261 def CompareNumberOfLayers(self, hyp, args):
5262 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5264 ## Defines "LocalLength" hypothesis, specifying the segment length
5265 # @param l the length of segments
5266 # @param p the precision of rounding
5267 def LocalLength(self, l, p=1e-07):
5268 hyp = self.OwnHypothesis("LocalLength", [l,p])
5273 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5274 # @param n the number of layers
5275 # @param s the scale factor (optional)
5276 def NumberOfSegments(self, n, s=[]):
5278 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5280 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5281 hyp.SetDistrType( 1 )
5282 hyp.SetScaleFactor(s)
5283 hyp.SetNumberOfSegments(n)
5286 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5287 # with a length that changes in arithmetic progression
5288 # @param start the length of the first segment
5289 # @param end the length of the last segment
5290 def Arithmetic1D(self, start, end ):
5291 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5292 hyp.SetLength(start, 1)
5293 hyp.SetLength(end , 0)
5296 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5297 # as geometric length increasing
5298 # @param start for the length of the first segment
5299 # @param end for the length of the last segment
5300 def StartEndLength(self, start, end):
5301 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5302 hyp.SetLength(start, 1)
5303 hyp.SetLength(end , 0)
5306 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5307 # @param fineness defines the quality of the mesh within the range [0-1]
5308 def AutomaticLength(self, fineness=0):
5309 hyp = self.OwnHypothesis("AutomaticLength")
5310 hyp.SetFineness( fineness )
5314 # Private class: Mesh_UseExisting
5315 # -------------------------------
5316 class Mesh_UseExisting(Mesh_Algorithm):
5318 def __init__(self, dim, mesh, geom=0):
5320 self.Create(mesh, geom, "UseExisting_1D")
5322 self.Create(mesh, geom, "UseExisting_2D")
5325 import salome_notebook
5326 notebook = salome_notebook.notebook
5328 ##Return values of the notebook variables
5329 def ParseParameters(last, nbParams,nbParam, value):
5333 listSize = len(last)
5334 for n in range(0,nbParams):
5336 if counter < listSize:
5337 strResult = strResult + last[counter]
5339 strResult = strResult + ""
5341 if isinstance(value, str):
5342 if notebook.isVariable(value):
5343 result = notebook.get(value)
5344 strResult=strResult+value
5346 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5348 strResult=strResult+str(value)
5350 if nbParams - 1 != counter:
5351 strResult=strResult+var_separator #":"
5353 return result, strResult
5355 #Wrapper class for StdMeshers_LocalLength hypothesis
5356 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5358 ## Set Length parameter value
5359 # @param length numerical value or name of variable from notebook
5360 def SetLength(self, length):
5361 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5362 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5363 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5365 ## Set Precision parameter value
5366 # @param precision numerical value or name of variable from notebook
5367 def SetPrecision(self, precision):
5368 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5369 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5370 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5372 #Registering the new proxy for LocalLength
5373 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5376 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5377 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5379 def SetLayerDistribution(self, hypo):
5380 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5381 hypo.ClearParameters();
5382 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5384 #Registering the new proxy for LayerDistribution
5385 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5387 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5388 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5390 ## Set Length parameter value
5391 # @param length numerical value or name of variable from notebook
5392 def SetLength(self, length):
5393 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5394 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5395 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5397 #Registering the new proxy for SegmentLengthAroundVertex
5398 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5401 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5402 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5404 ## Set Length parameter value
5405 # @param length numerical value or name of variable from notebook
5406 # @param isStart true is length is Start Length, otherwise false
5407 def SetLength(self, length, isStart):
5411 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5412 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5413 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5415 #Registering the new proxy for Arithmetic1D
5416 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5418 #Wrapper class for StdMeshers_Deflection1D hypothesis
5419 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5421 ## Set Deflection parameter value
5422 # @param deflection numerical value or name of variable from notebook
5423 def SetDeflection(self, deflection):
5424 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5425 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5426 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5428 #Registering the new proxy for Deflection1D
5429 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5431 #Wrapper class for StdMeshers_StartEndLength hypothesis
5432 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5434 ## Set Length parameter value
5435 # @param length numerical value or name of variable from notebook
5436 # @param isStart true is length is Start Length, otherwise false
5437 def SetLength(self, length, isStart):
5441 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5442 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5443 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5445 #Registering the new proxy for StartEndLength
5446 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5448 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5449 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5451 ## Set Max Element Area parameter value
5452 # @param area numerical value or name of variable from notebook
5453 def SetMaxElementArea(self, area):
5454 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5455 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5456 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5458 #Registering the new proxy for MaxElementArea
5459 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5462 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5463 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5465 ## Set Max Element Volume parameter value
5466 # @param volume numerical value or name of variable from notebook
5467 def SetMaxElementVolume(self, volume):
5468 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5469 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5470 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5472 #Registering the new proxy for MaxElementVolume
5473 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5476 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5477 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5479 ## Set Number Of Layers parameter value
5480 # @param nbLayers numerical value or name of variable from notebook
5481 def SetNumberOfLayers(self, nbLayers):
5482 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5483 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5484 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5486 #Registering the new proxy for NumberOfLayers
5487 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5489 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5490 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5492 ## Set Number Of Segments parameter value
5493 # @param nbSeg numerical value or name of variable from notebook
5494 def SetNumberOfSegments(self, nbSeg):
5495 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5496 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5497 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5498 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5500 ## Set Scale Factor parameter value
5501 # @param factor numerical value or name of variable from notebook
5502 def SetScaleFactor(self, factor):
5503 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5504 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5505 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5507 #Registering the new proxy for NumberOfSegments
5508 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5510 if not noNETGENPlugin:
5511 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5512 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5514 ## Set Max Size parameter value
5515 # @param maxsize numerical value or name of variable from notebook
5516 def SetMaxSize(self, maxsize):
5517 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5518 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5519 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5520 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5522 ## Set Growth Rate parameter value
5523 # @param value numerical value or name of variable from notebook
5524 def SetGrowthRate(self, value):
5525 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5526 value, parameters = ParseParameters(lastParameters,4,2,value)
5527 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5528 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5530 ## Set Number of Segments per Edge parameter value
5531 # @param value numerical value or name of variable from notebook
5532 def SetNbSegPerEdge(self, value):
5533 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5534 value, parameters = ParseParameters(lastParameters,4,3,value)
5535 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5536 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5538 ## Set Number of Segments per Radius parameter value
5539 # @param value numerical value or name of variable from notebook
5540 def SetNbSegPerRadius(self, value):
5541 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5542 value, parameters = ParseParameters(lastParameters,4,4,value)
5543 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5544 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5546 #Registering the new proxy for NETGENPlugin_Hypothesis
5547 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5550 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5551 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5554 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5555 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5557 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5558 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5560 ## Set Number of Segments parameter value
5561 # @param nbSeg numerical value or name of variable from notebook
5562 def SetNumberOfSegments(self, nbSeg):
5563 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5564 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5565 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5566 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5568 ## Set Local Length parameter value
5569 # @param length numerical value or name of variable from notebook
5570 def SetLocalLength(self, length):
5571 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5572 length, parameters = ParseParameters(lastParameters,2,1,length)
5573 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5574 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5576 ## Set Max Element Area parameter value
5577 # @param area numerical value or name of variable from notebook
5578 def SetMaxElementArea(self, area):
5579 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5580 area, parameters = ParseParameters(lastParameters,2,2,area)
5581 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5582 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5584 def LengthFromEdges(self):
5585 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5587 value, parameters = ParseParameters(lastParameters,2,2,value)
5588 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5589 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5591 #Registering the new proxy for NETGEN_SimpleParameters_2D
5592 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5595 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5596 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5597 ## Set Max Element Volume parameter value
5598 # @param volume numerical value or name of variable from notebook
5599 def SetMaxElementVolume(self, volume):
5600 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5601 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5602 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5603 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5605 def LengthFromFaces(self):
5606 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5608 value, parameters = ParseParameters(lastParameters,3,3,value)
5609 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5610 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5612 #Registering the new proxy for NETGEN_SimpleParameters_3D
5613 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5615 pass # if not noNETGENPlugin:
5617 class Pattern(SMESH._objref_SMESH_Pattern):
5619 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5621 if isinstance(theNodeIndexOnKeyPoint1,str):
5623 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5625 theNodeIndexOnKeyPoint1 -= 1
5626 theMesh.SetParameters(Parameters)
5627 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5629 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5632 if isinstance(theNode000Index,str):
5634 if isinstance(theNode001Index,str):
5636 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5638 theNode000Index -= 1
5640 theNode001Index -= 1
5641 theMesh.SetParameters(Parameters)
5642 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5644 #Registering the new proxy for Pattern
5645 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)