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 ## Returns a string representation of the color.
517 # To be used with filters.
518 # @param c color value (SALOMEDS.Color)
519 # @ingroup l1_controls
520 def ColorToString(self,c):
522 if isinstance(c, SALOMEDS.Color):
523 val = "%s;%s;%s" % (c.R, c.G, c.B)
524 elif isinstance(c, str):
527 raise ValueError, "Color value should be of string or SALOMEDS.Color type"
530 ## Gets PointStruct from vertex
531 # @param theVertex a GEOM object(vertex)
532 # @return SMESH.PointStruct
533 # @ingroup l1_auxiliary
534 def GetPointStruct(self,theVertex):
535 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
536 return PointStruct(x,y,z)
538 ## Gets DirStruct from vector
539 # @param theVector a GEOM object(vector)
540 # @return SMESH.DirStruct
541 # @ingroup l1_auxiliary
542 def GetDirStruct(self,theVector):
543 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
544 if(len(vertices) != 2):
545 print "Error: vector object is incorrect."
547 p1 = self.geompyD.PointCoordinates(vertices[0])
548 p2 = self.geompyD.PointCoordinates(vertices[1])
549 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
550 dirst = DirStruct(pnt)
553 ## Makes DirStruct from a triplet
554 # @param x,y,z vector components
555 # @return SMESH.DirStruct
556 # @ingroup l1_auxiliary
557 def MakeDirStruct(self,x,y,z):
558 pnt = PointStruct(x,y,z)
559 return DirStruct(pnt)
561 ## Get AxisStruct from object
562 # @param theObj a GEOM object (line or plane)
563 # @return SMESH.AxisStruct
564 # @ingroup l1_auxiliary
565 def GetAxisStruct(self,theObj):
566 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
568 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
569 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
570 vertex1 = self.geompyD.PointCoordinates(vertex1)
571 vertex2 = self.geompyD.PointCoordinates(vertex2)
572 vertex3 = self.geompyD.PointCoordinates(vertex3)
573 vertex4 = self.geompyD.PointCoordinates(vertex4)
574 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
575 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
576 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] ]
577 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
579 elif len(edges) == 1:
580 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
581 p1 = self.geompyD.PointCoordinates( vertex1 )
582 p2 = self.geompyD.PointCoordinates( vertex2 )
583 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
587 # From SMESH_Gen interface:
588 # ------------------------
590 ## Sets the given name to the object
591 # @param obj the object to rename
592 # @param name a new object name
593 # @ingroup l1_auxiliary
594 def SetName(self, obj, name):
595 if isinstance( obj, Mesh ):
597 elif isinstance( obj, Mesh_Algorithm ):
598 obj = obj.GetAlgorithm()
599 ior = salome.orb.object_to_string(obj)
600 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
602 ## Sets the current mode
603 # @ingroup l1_auxiliary
604 def SetEmbeddedMode( self,theMode ):
605 #self.SetEmbeddedMode(theMode)
606 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
608 ## Gets the current mode
609 # @ingroup l1_auxiliary
610 def IsEmbeddedMode(self):
611 #return self.IsEmbeddedMode()
612 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
614 ## Sets the current study
615 # @ingroup l1_auxiliary
616 def SetCurrentStudy( self, theStudy, geompyD = None ):
617 #self.SetCurrentStudy(theStudy)
620 geompyD = geompy.geom
623 self.SetGeomEngine(geompyD)
624 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
626 ## Gets the current study
627 # @ingroup l1_auxiliary
628 def GetCurrentStudy(self):
629 #return self.GetCurrentStudy()
630 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
632 ## Creates a Mesh object importing data from the given UNV file
633 # @return an instance of Mesh class
635 def CreateMeshesFromUNV( self,theFileName ):
636 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
637 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
640 ## Creates a Mesh object(s) importing data from the given MED file
641 # @return a list of Mesh class instances
643 def CreateMeshesFromMED( self,theFileName ):
644 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
646 for iMesh in range(len(aSmeshMeshes)) :
647 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
648 aMeshes.append(aMesh)
649 return aMeshes, aStatus
651 ## Creates a Mesh object importing data from the given STL file
652 # @return an instance of Mesh class
654 def CreateMeshesFromSTL( self, theFileName ):
655 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
656 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
659 ## From SMESH_Gen interface
660 # @return the list of integer values
661 # @ingroup l1_auxiliary
662 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
663 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
665 ## From SMESH_Gen interface. Creates a pattern
666 # @return an instance of SMESH_Pattern
668 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
669 # @ingroup l2_modif_patterns
670 def GetPattern(self):
671 return SMESH._objref_SMESH_Gen.GetPattern(self)
673 ## Sets number of segments per diagonal of boundary box of geometry by which
674 # default segment length of appropriate 1D hypotheses is defined.
675 # Default value is 10
676 # @ingroup l1_auxiliary
677 def SetBoundaryBoxSegmentation(self, nbSegments):
678 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
680 ## Concatenate the given meshes into one mesh.
681 # @return an instance of Mesh class
682 # @param meshes the meshes to combine into one mesh
683 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
684 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
685 # @param mergeTolerance tolerance for merging nodes
686 # @param allGroups forces creation of groups of all elements
687 def Concatenate( self, meshes, uniteIdenticalGroups,
688 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
689 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
691 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
692 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
694 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
695 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
696 aSmeshMesh.SetParameters(Parameters)
697 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
700 # Filtering. Auxiliary functions:
701 # ------------------------------
703 ## Creates an empty criterion
704 # @return SMESH.Filter.Criterion
705 # @ingroup l1_controls
706 def GetEmptyCriterion(self):
707 Type = self.EnumToLong(FT_Undefined)
708 Compare = self.EnumToLong(FT_Undefined)
712 UnaryOp = self.EnumToLong(FT_Undefined)
713 BinaryOp = self.EnumToLong(FT_Undefined)
716 Precision = -1 ##@1e-07
717 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
718 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
720 ## Creates a criterion by the given parameters
721 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
722 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
723 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
724 # @param Treshold the threshold value (range of ids as string, shape, numeric)
725 # @param UnaryOp FT_LogicalNOT or FT_Undefined
726 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
727 # FT_Undefined (must be for the last criterion of all criteria)
728 # @return SMESH.Filter.Criterion
729 # @ingroup l1_controls
730 def GetCriterion(self,elementType,
732 Compare = FT_EqualTo,
734 UnaryOp=FT_Undefined,
735 BinaryOp=FT_Undefined):
736 aCriterion = self.GetEmptyCriterion()
737 aCriterion.TypeOfElement = elementType
738 aCriterion.Type = self.EnumToLong(CritType)
742 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
743 aCriterion.Compare = self.EnumToLong(Compare)
744 elif Compare == "=" or Compare == "==":
745 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
747 aCriterion.Compare = self.EnumToLong(FT_LessThan)
749 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
751 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
754 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
755 FT_BelongToCylinder, FT_LyingOnGeom]:
756 # Checks the treshold
757 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
758 aCriterion.ThresholdStr = GetName(aTreshold)
759 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
761 print "Error: The treshold should be a shape."
763 elif CritType == FT_RangeOfIds:
764 # Checks the treshold
765 if isinstance(aTreshold, str):
766 aCriterion.ThresholdStr = aTreshold
768 print "Error: The treshold should be a string."
770 elif CritType == FT_ElemGeomType:
771 # Checks the treshold
773 aCriterion.Threshold = self.EnumToLong(aTreshold)
775 if isinstance(aTreshold, int):
776 aCriterion.Threshold = aTreshold
778 print "Error: The treshold should be an integer or SMESH.GeometryType."
782 elif CritType == FT_GroupColor:
783 # Checks the treshold
785 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
787 print "Error: The threshold value should be of SALOMEDS.Color type"
790 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
791 FT_FreeFaces, FT_LinearOrQuadratic]:
792 # At this point the treshold is unnecessary
793 if aTreshold == FT_LogicalNOT:
794 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
795 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
796 aCriterion.BinaryOp = aTreshold
800 aTreshold = float(aTreshold)
801 aCriterion.Threshold = aTreshold
803 print "Error: The treshold should be a number."
806 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
807 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
809 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
810 aCriterion.BinaryOp = self.EnumToLong(Treshold)
812 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
813 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
815 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
816 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
820 ## Creates a filter with the given parameters
821 # @param elementType the type of elements in the group
822 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
823 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
824 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
825 # @param UnaryOp FT_LogicalNOT or FT_Undefined
826 # @return SMESH_Filter
827 # @ingroup l1_controls
828 def GetFilter(self,elementType,
829 CritType=FT_Undefined,
832 UnaryOp=FT_Undefined):
833 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
834 aFilterMgr = self.CreateFilterManager()
835 aFilter = aFilterMgr.CreateFilter()
837 aCriteria.append(aCriterion)
838 aFilter.SetCriteria(aCriteria)
841 ## Creates a numerical functor by its type
842 # @param theCriterion FT_...; functor type
843 # @return SMESH_NumericalFunctor
844 # @ingroup l1_controls
845 def GetFunctor(self,theCriterion):
846 aFilterMgr = self.CreateFilterManager()
847 if theCriterion == FT_AspectRatio:
848 return aFilterMgr.CreateAspectRatio()
849 elif theCriterion == FT_AspectRatio3D:
850 return aFilterMgr.CreateAspectRatio3D()
851 elif theCriterion == FT_Warping:
852 return aFilterMgr.CreateWarping()
853 elif theCriterion == FT_MinimumAngle:
854 return aFilterMgr.CreateMinimumAngle()
855 elif theCriterion == FT_Taper:
856 return aFilterMgr.CreateTaper()
857 elif theCriterion == FT_Skew:
858 return aFilterMgr.CreateSkew()
859 elif theCriterion == FT_Area:
860 return aFilterMgr.CreateArea()
861 elif theCriterion == FT_Volume3D:
862 return aFilterMgr.CreateVolume3D()
863 elif theCriterion == FT_MultiConnection:
864 return aFilterMgr.CreateMultiConnection()
865 elif theCriterion == FT_MultiConnection2D:
866 return aFilterMgr.CreateMultiConnection2D()
867 elif theCriterion == FT_Length:
868 return aFilterMgr.CreateLength()
869 elif theCriterion == FT_Length2D:
870 return aFilterMgr.CreateLength2D()
872 print "Error: given parameter is not numerucal functor type."
874 ## Creates hypothesis
875 # @param theHType mesh hypothesis type (string)
876 # @param theLibName mesh plug-in library name
877 # @return created hypothesis instance
878 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
879 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
881 ## Gets the mesh stattistic
882 # @return dictionary type element - count of elements
883 # @ingroup l1_meshinfo
884 def GetMeshInfo(self, obj):
885 if isinstance( obj, Mesh ):
888 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
889 values = obj.GetMeshInfo()
890 for i in range(SMESH.Entity_Last._v):
891 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
896 #Registering the new proxy for SMESH_Gen
897 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
903 ## This class allows defining and managing a mesh.
904 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
905 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
906 # new nodes and elements and by changing the existing entities), to get information
907 # about a mesh and to export a mesh into different formats.
916 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
917 # sets the GUI name of this mesh to \a name.
918 # @param smeshpyD an instance of smeshDC class
919 # @param geompyD an instance of geompyDC class
920 # @param obj Shape to be meshed or SMESH_Mesh object
921 # @param name Study name of the mesh
922 # @ingroup l2_construct
923 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
924 self.smeshpyD=smeshpyD
929 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
931 self.mesh = self.smeshpyD.CreateMesh(self.geom)
932 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
935 self.mesh = self.smeshpyD.CreateEmptyMesh()
937 self.smeshpyD.SetName(self.mesh, name)
939 self.smeshpyD.SetName(self.mesh, GetName(obj))
942 self.geom = self.mesh.GetShapeToMesh()
944 self.editor = self.mesh.GetMeshEditor()
946 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
947 # @param theMesh a SMESH_Mesh object
948 # @ingroup l2_construct
949 def SetMesh(self, theMesh):
951 self.geom = self.mesh.GetShapeToMesh()
953 ## Returns the mesh, that is an instance of SMESH_Mesh interface
954 # @return a SMESH_Mesh object
955 # @ingroup l2_construct
959 ## Gets the name of the mesh
960 # @return the name of the mesh as a string
961 # @ingroup l2_construct
963 name = GetName(self.GetMesh())
966 ## Sets a name to the mesh
967 # @param name a new name of the mesh
968 # @ingroup l2_construct
969 def SetName(self, name):
970 self.smeshpyD.SetName(self.GetMesh(), name)
972 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
973 # The subMesh object gives access to the IDs of nodes and elements.
974 # @param theSubObject a geometrical object (shape)
975 # @param theName a name for the submesh
976 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
977 # @ingroup l2_submeshes
978 def GetSubMesh(self, theSubObject, theName):
979 submesh = self.mesh.GetSubMesh(theSubObject, theName)
982 ## Returns the shape associated to the mesh
983 # @return a GEOM_Object
984 # @ingroup l2_construct
988 ## Associates the given shape to the mesh (entails the recreation of the mesh)
989 # @param geom the shape to be meshed (GEOM_Object)
990 # @ingroup l2_construct
991 def SetShape(self, geom):
992 self.mesh = self.smeshpyD.CreateMesh(geom)
994 ## Returns true if the hypotheses are defined well
995 # @param theSubObject a subshape of a mesh shape
996 # @return True or False
997 # @ingroup l2_construct
998 def IsReadyToCompute(self, theSubObject):
999 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1001 ## Returns errors of hypotheses definition.
1002 # The list of errors is empty if everything is OK.
1003 # @param theSubObject a subshape of a mesh shape
1004 # @return a list of errors
1005 # @ingroup l2_construct
1006 def GetAlgoState(self, theSubObject):
1007 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1009 ## Returns a geometrical object on which the given element was built.
1010 # The returned geometrical object, if not nil, is either found in the
1011 # study or published by this method with the given name
1012 # @param theElementID the id of the mesh element
1013 # @param theGeomName the user-defined name of the geometrical object
1014 # @return GEOM::GEOM_Object instance
1015 # @ingroup l2_construct
1016 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1017 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1019 ## Returns the mesh dimension depending on the dimension of the underlying shape
1020 # @return mesh dimension as an integer value [0,3]
1021 # @ingroup l1_auxiliary
1022 def MeshDimension(self):
1023 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1024 if len( shells ) > 0 :
1026 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1028 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1034 ## Creates a segment discretization 1D algorithm.
1035 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1036 # \n If the optional \a geom parameter is not set, this algorithm is global.
1037 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1038 # @param algo the type of the required algorithm. Possible values are:
1040 # - smesh.PYTHON for discretization via a python function,
1041 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1042 # @param geom If defined is the subshape to be meshed
1043 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1044 # @ingroup l3_algos_basic
1045 def Segment(self, algo=REGULAR, geom=0):
1046 ## if Segment(geom) is called by mistake
1047 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1048 algo, geom = geom, algo
1049 if not algo: algo = REGULAR
1052 return Mesh_Segment(self, geom)
1053 elif algo == PYTHON:
1054 return Mesh_Segment_Python(self, geom)
1055 elif algo == COMPOSITE:
1056 return Mesh_CompositeSegment(self, geom)
1058 return Mesh_Segment(self, geom)
1060 ## Enables creation of nodes and segments usable by 2D algoritms.
1061 # The added nodes and segments must be bound to edges and vertices by
1062 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1063 # If the optional \a geom parameter is not set, this algorithm is global.
1064 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1065 # @param geom the subshape to be manually meshed
1066 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1067 # @ingroup l3_algos_basic
1068 def UseExistingSegments(self, geom=0):
1069 algo = Mesh_UseExisting(1,self,geom)
1070 return algo.GetAlgorithm()
1072 ## Enables creation of nodes and faces usable by 3D algoritms.
1073 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1074 # and SetMeshElementOnShape()
1075 # If the optional \a geom parameter is not set, this algorithm is global.
1076 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1077 # @param geom the subshape to be manually meshed
1078 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1079 # @ingroup l3_algos_basic
1080 def UseExistingFaces(self, geom=0):
1081 algo = Mesh_UseExisting(2,self,geom)
1082 return algo.GetAlgorithm()
1084 ## Creates a triangle 2D algorithm for faces.
1085 # If the optional \a geom parameter is not set, this algorithm is global.
1086 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1087 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1088 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1089 # @return an instance of Mesh_Triangle algorithm
1090 # @ingroup l3_algos_basic
1091 def Triangle(self, algo=MEFISTO, geom=0):
1092 ## if Triangle(geom) is called by mistake
1093 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1096 return Mesh_Triangle(self, algo, geom)
1098 ## Creates a quadrangle 2D algorithm for faces.
1099 # If the optional \a geom parameter is not set, this algorithm is global.
1100 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1101 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1102 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1103 # @return an instance of Mesh_Quadrangle algorithm
1104 # @ingroup l3_algos_basic
1105 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1106 if algo==RADIAL_QUAD:
1107 return Mesh_RadialQuadrangle1D2D(self,geom)
1109 return Mesh_Quadrangle(self, geom)
1111 ## Creates a tetrahedron 3D algorithm for solids.
1112 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1113 # If the optional \a geom parameter is not set, this algorithm is global.
1114 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1115 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1116 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1117 # @return an instance of Mesh_Tetrahedron algorithm
1118 # @ingroup l3_algos_basic
1119 def Tetrahedron(self, algo=NETGEN, geom=0):
1120 ## if Tetrahedron(geom) is called by mistake
1121 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1122 algo, geom = geom, algo
1123 if not algo: algo = NETGEN
1125 return Mesh_Tetrahedron(self, algo, geom)
1127 ## Creates a hexahedron 3D algorithm for solids.
1128 # If the optional \a geom parameter is not set, this algorithm is global.
1129 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1130 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1131 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1132 # @return an instance of Mesh_Hexahedron algorithm
1133 # @ingroup l3_algos_basic
1134 def Hexahedron(self, algo=Hexa, geom=0):
1135 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1136 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1137 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1138 elif geom == 0: algo, geom = Hexa, algo
1139 return Mesh_Hexahedron(self, algo, geom)
1141 ## Deprecated, used only for compatibility!
1142 # @return an instance of Mesh_Netgen algorithm
1143 # @ingroup l3_algos_basic
1144 def Netgen(self, is3D, geom=0):
1145 return Mesh_Netgen(self, is3D, geom)
1147 ## Creates a projection 1D algorithm for edges.
1148 # If the optional \a geom parameter is not set, this algorithm is global.
1149 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1150 # @param geom If defined, the subshape to be meshed
1151 # @return an instance of Mesh_Projection1D algorithm
1152 # @ingroup l3_algos_proj
1153 def Projection1D(self, geom=0):
1154 return Mesh_Projection1D(self, geom)
1156 ## Creates a projection 2D algorithm for faces.
1157 # If the optional \a geom parameter is not set, this algorithm is global.
1158 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1159 # @param geom If defined, the subshape to be meshed
1160 # @return an instance of Mesh_Projection2D algorithm
1161 # @ingroup l3_algos_proj
1162 def Projection2D(self, geom=0):
1163 return Mesh_Projection2D(self, geom)
1165 ## Creates a projection 3D algorithm for solids.
1166 # If the optional \a geom parameter is not set, this algorithm is global.
1167 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1168 # @param geom If defined, the subshape to be meshed
1169 # @return an instance of Mesh_Projection3D algorithm
1170 # @ingroup l3_algos_proj
1171 def Projection3D(self, geom=0):
1172 return Mesh_Projection3D(self, geom)
1174 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1175 # If the optional \a geom parameter is not set, this algorithm is global.
1176 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1177 # @param geom If defined, the subshape to be meshed
1178 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1179 # @ingroup l3_algos_radialp l3_algos_3dextr
1180 def Prism(self, geom=0):
1184 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1185 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1186 if nbSolids == 0 or nbSolids == nbShells:
1187 return Mesh_Prism3D(self, geom)
1188 return Mesh_RadialPrism3D(self, geom)
1190 ## Evaluates size of prospective mesh on a shape
1191 # @return True or False
1192 def Evaluate(self, geom=0):
1193 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1195 geom = self.mesh.GetShapeToMesh()
1198 return self.smeshpyD.Evaluate(self.mesh, geom)
1201 ## Computes the mesh and returns the status of the computation
1202 # @param geom geomtrical shape on which mesh data should be computed
1203 # @param discardModifs if True and the mesh has been edited since
1204 # a last total re-compute and that may prevent successful partial re-compute,
1205 # then the mesh is cleaned before Compute()
1206 # @return True or False
1207 # @ingroup l2_construct
1208 def Compute(self, geom=0, discardModifs=False):
1209 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1211 geom = self.mesh.GetShapeToMesh()
1216 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1218 ok = self.smeshpyD.Compute(self.mesh, geom)
1219 except SALOME.SALOME_Exception, ex:
1220 print "Mesh computation failed, exception caught:"
1221 print " ", ex.details.text
1224 print "Mesh computation failed, exception caught:"
1225 traceback.print_exc()
1229 # Treat compute errors
1230 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1231 for err in computeErrors:
1233 if self.mesh.HasShapeToMesh():
1235 mainIOR = salome.orb.object_to_string(geom)
1236 for sname in salome.myStudyManager.GetOpenStudies():
1237 s = salome.myStudyManager.GetStudyByName(sname)
1239 mainSO = s.FindObjectIOR(mainIOR)
1240 if not mainSO: continue
1241 if err.subShapeID == 1:
1242 shapeText = ' on "%s"' % mainSO.GetName()
1243 subIt = s.NewChildIterator(mainSO)
1245 subSO = subIt.Value()
1247 obj = subSO.GetObject()
1248 if not obj: continue
1249 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1251 ids = go.GetSubShapeIndices()
1252 if len(ids) == 1 and ids[0] == err.subShapeID:
1253 shapeText = ' on "%s"' % subSO.GetName()
1256 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1258 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1260 shapeText = " on subshape #%s" % (err.subShapeID)
1262 shapeText = " on subshape #%s" % (err.subShapeID)
1264 stdErrors = ["OK", #COMPERR_OK
1265 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1266 "std::exception", #COMPERR_STD_EXCEPTION
1267 "OCC exception", #COMPERR_OCC_EXCEPTION
1268 "SALOME exception", #COMPERR_SLM_EXCEPTION
1269 "Unknown exception", #COMPERR_EXCEPTION
1270 "Memory allocation problem", #COMPERR_MEMORY_PB
1271 "Algorithm failed", #COMPERR_ALGO_FAILED
1272 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1274 if err.code < len(stdErrors): errText = stdErrors[err.code]
1276 errText = "code %s" % -err.code
1277 if errText: errText += ". "
1278 errText += err.comment
1279 if allReasons != "":allReasons += "\n"
1280 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1284 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1286 if err.isGlobalAlgo:
1294 reason = '%s %sD algorithm is missing' % (glob, dim)
1295 elif err.state == HYP_MISSING:
1296 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1297 % (glob, dim, name, dim))
1298 elif err.state == HYP_NOTCONFORM:
1299 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1300 elif err.state == HYP_BAD_PARAMETER:
1301 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1302 % ( glob, dim, name ))
1303 elif err.state == HYP_BAD_GEOMETRY:
1304 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1305 'geometry' % ( glob, dim, name ))
1307 reason = "For unknown reason."+\
1308 " Revise Mesh.Compute() implementation in smeshDC.py!"
1310 if allReasons != "":allReasons += "\n"
1311 allReasons += reason
1313 if allReasons != "":
1314 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1318 print '"' + GetName(self.mesh) + '"',"has not been computed."
1321 if salome.sg.hasDesktop():
1322 smeshgui = salome.ImportComponentGUI("SMESH")
1323 smeshgui.Init(self.mesh.GetStudyId())
1324 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1325 salome.sg.updateObjBrowser(1)
1329 ## Return submesh objects list in meshing order
1330 # @return list of list of submesh objects
1331 # @ingroup l2_construct
1332 def GetMeshOrder(self):
1333 return self.mesh.GetMeshOrder()
1335 ## Return submesh objects list in meshing order
1336 # @return list of list of submesh objects
1337 # @ingroup l2_construct
1338 def SetMeshOrder(self, submeshes):
1339 return self.mesh.SetMeshOrder(submeshes)
1341 ## Removes all nodes and elements
1342 # @ingroup l2_construct
1345 if salome.sg.hasDesktop():
1346 smeshgui = salome.ImportComponentGUI("SMESH")
1347 smeshgui.Init(self.mesh.GetStudyId())
1348 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1349 salome.sg.updateObjBrowser(1)
1351 ## Removes all nodes and elements of indicated shape
1352 # @ingroup l2_construct
1353 def ClearSubMesh(self, geomId):
1354 self.mesh.ClearSubMesh(geomId)
1355 if salome.sg.hasDesktop():
1356 smeshgui = salome.ImportComponentGUI("SMESH")
1357 smeshgui.Init(self.mesh.GetStudyId())
1358 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1359 salome.sg.updateObjBrowser(1)
1361 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1362 # @param fineness [0,-1] defines mesh fineness
1363 # @return True or False
1364 # @ingroup l3_algos_basic
1365 def AutomaticTetrahedralization(self, fineness=0):
1366 dim = self.MeshDimension()
1368 self.RemoveGlobalHypotheses()
1369 self.Segment().AutomaticLength(fineness)
1371 self.Triangle().LengthFromEdges()
1374 self.Tetrahedron(NETGEN)
1376 return self.Compute()
1378 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1379 # @param fineness [0,-1] defines mesh fineness
1380 # @return True or False
1381 # @ingroup l3_algos_basic
1382 def AutomaticHexahedralization(self, fineness=0):
1383 dim = self.MeshDimension()
1384 # assign the hypotheses
1385 self.RemoveGlobalHypotheses()
1386 self.Segment().AutomaticLength(fineness)
1393 return self.Compute()
1395 ## Assigns a hypothesis
1396 # @param hyp a hypothesis to assign
1397 # @param geom a subhape of mesh geometry
1398 # @return SMESH.Hypothesis_Status
1399 # @ingroup l2_hypotheses
1400 def AddHypothesis(self, hyp, geom=0):
1401 if isinstance( hyp, Mesh_Algorithm ):
1402 hyp = hyp.GetAlgorithm()
1407 geom = self.mesh.GetShapeToMesh()
1409 status = self.mesh.AddHypothesis(geom, hyp)
1410 isAlgo = hyp._narrow( SMESH_Algo )
1411 hyp_name = GetName( hyp )
1414 geom_name = GetName( geom )
1415 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1418 ## Unassigns a hypothesis
1419 # @param hyp a hypothesis to unassign
1420 # @param geom a subshape of mesh geometry
1421 # @return SMESH.Hypothesis_Status
1422 # @ingroup l2_hypotheses
1423 def RemoveHypothesis(self, hyp, geom=0):
1424 if isinstance( hyp, Mesh_Algorithm ):
1425 hyp = hyp.GetAlgorithm()
1430 status = self.mesh.RemoveHypothesis(geom, hyp)
1433 ## Gets the list of hypotheses added on a geometry
1434 # @param geom a subshape of mesh geometry
1435 # @return the sequence of SMESH_Hypothesis
1436 # @ingroup l2_hypotheses
1437 def GetHypothesisList(self, geom):
1438 return self.mesh.GetHypothesisList( geom )
1440 ## Removes all global hypotheses
1441 # @ingroup l2_hypotheses
1442 def RemoveGlobalHypotheses(self):
1443 current_hyps = self.mesh.GetHypothesisList( self.geom )
1444 for hyp in current_hyps:
1445 self.mesh.RemoveHypothesis( self.geom, hyp )
1449 ## Creates a mesh group based on the geometric object \a grp
1450 # and gives a \a name, \n if this parameter is not defined
1451 # the name is the same as the geometric group name \n
1452 # Note: Works like GroupOnGeom().
1453 # @param grp a geometric group, a vertex, an edge, a face or a solid
1454 # @param name the name of the mesh group
1455 # @return SMESH_GroupOnGeom
1456 # @ingroup l2_grps_create
1457 def Group(self, grp, name=""):
1458 return self.GroupOnGeom(grp, name)
1460 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1461 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1462 ## allowing to overwrite the file if it exists or add the exported data to its contents
1463 # @param f the file name
1464 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1465 # @param opt boolean parameter for creating/not creating
1466 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1467 # @param overwrite boolean parameter for overwriting/not overwriting the file
1468 # @ingroup l2_impexp
1469 def ExportToMED(self, f, version, opt=0, overwrite=1):
1470 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1472 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1473 ## allowing to overwrite the file if it exists or add the exported data to its contents
1474 # @param f is the file name
1475 # @param auto_groups boolean parameter for creating/not creating
1476 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1477 # the typical use is auto_groups=false.
1478 # @param version MED format version(MED_V2_1 or MED_V2_2)
1479 # @param overwrite boolean parameter for overwriting/not overwriting the file
1480 # @ingroup l2_impexp
1481 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1482 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1484 ## Exports the mesh in a file in DAT format
1485 # @param f the file name
1486 # @ingroup l2_impexp
1487 def ExportDAT(self, f):
1488 self.mesh.ExportDAT(f)
1490 ## Exports the mesh in a file in UNV format
1491 # @param f the file name
1492 # @ingroup l2_impexp
1493 def ExportUNV(self, f):
1494 self.mesh.ExportUNV(f)
1496 ## Export the mesh in a file in STL format
1497 # @param f the file name
1498 # @param ascii defines the file encoding
1499 # @ingroup l2_impexp
1500 def ExportSTL(self, f, ascii=1):
1501 self.mesh.ExportSTL(f, ascii)
1504 # Operations with groups:
1505 # ----------------------
1507 ## Creates an empty mesh group
1508 # @param elementType the type of elements in the group
1509 # @param name the name of the mesh group
1510 # @return SMESH_Group
1511 # @ingroup l2_grps_create
1512 def CreateEmptyGroup(self, elementType, name):
1513 return self.mesh.CreateGroup(elementType, name)
1515 ## Creates a mesh group based on the geometrical object \a grp
1516 # and gives a \a name, \n if this parameter is not defined
1517 # the name is the same as the geometrical group name
1518 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1519 # @param name the name of the mesh group
1520 # @param typ the type of elements in the group. If not set, it is
1521 # automatically detected by the type of the geometry
1522 # @return SMESH_GroupOnGeom
1523 # @ingroup l2_grps_create
1524 def GroupOnGeom(self, grp, name="", typ=None):
1526 name = grp.GetName()
1529 tgeo = str(grp.GetShapeType())
1530 if tgeo == "VERTEX":
1532 elif tgeo == "EDGE":
1534 elif tgeo == "FACE":
1536 elif tgeo == "SOLID":
1538 elif tgeo == "SHELL":
1540 elif tgeo == "COMPOUND":
1541 try: # it raises on a compound of compounds
1542 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1543 print "Mesh.Group: empty geometric group", GetName( grp )
1548 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1550 tgeo = self.geompyD.GetType(grp)
1551 if tgeo == geompyDC.ShapeType["VERTEX"]:
1553 elif tgeo == geompyDC.ShapeType["EDGE"]:
1555 elif tgeo == geompyDC.ShapeType["FACE"]:
1557 elif tgeo == geompyDC.ShapeType["SOLID"]:
1563 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1564 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1565 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1573 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1576 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1578 ## Creates a mesh group by the given ids of elements
1579 # @param groupName the name of the mesh group
1580 # @param elementType the type of elements in the group
1581 # @param elemIDs the list of ids
1582 # @return SMESH_Group
1583 # @ingroup l2_grps_create
1584 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1585 group = self.mesh.CreateGroup(elementType, groupName)
1589 ## Creates a mesh group by the given conditions
1590 # @param groupName the name of the mesh group
1591 # @param elementType the type of elements in the group
1592 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1593 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1594 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1595 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1596 # @return SMESH_Group
1597 # @ingroup l2_grps_create
1601 CritType=FT_Undefined,
1604 UnaryOp=FT_Undefined):
1605 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1606 group = self.MakeGroupByCriterion(groupName, aCriterion)
1609 ## Creates a mesh group by the given criterion
1610 # @param groupName the name of the mesh group
1611 # @param Criterion the instance of Criterion class
1612 # @return SMESH_Group
1613 # @ingroup l2_grps_create
1614 def MakeGroupByCriterion(self, groupName, Criterion):
1615 aFilterMgr = self.smeshpyD.CreateFilterManager()
1616 aFilter = aFilterMgr.CreateFilter()
1618 aCriteria.append(Criterion)
1619 aFilter.SetCriteria(aCriteria)
1620 group = self.MakeGroupByFilter(groupName, aFilter)
1623 ## Creates a mesh group by the given criteria (list of criteria)
1624 # @param groupName the name of the mesh group
1625 # @param theCriteria the list of criteria
1626 # @return SMESH_Group
1627 # @ingroup l2_grps_create
1628 def MakeGroupByCriteria(self, groupName, theCriteria):
1629 aFilterMgr = self.smeshpyD.CreateFilterManager()
1630 aFilter = aFilterMgr.CreateFilter()
1631 aFilter.SetCriteria(theCriteria)
1632 group = self.MakeGroupByFilter(groupName, aFilter)
1635 ## Creates a mesh group by the given filter
1636 # @param groupName the name of the mesh group
1637 # @param theFilter the instance of Filter class
1638 # @return SMESH_Group
1639 # @ingroup l2_grps_create
1640 def MakeGroupByFilter(self, groupName, theFilter):
1641 anIds = theFilter.GetElementsId(self.mesh)
1642 anElemType = theFilter.GetElementType()
1643 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1646 ## Passes mesh elements through the given filter and return IDs of fitting elements
1647 # @param theFilter SMESH_Filter
1648 # @return a list of ids
1649 # @ingroup l1_controls
1650 def GetIdsFromFilter(self, theFilter):
1651 return theFilter.GetElementsId(self.mesh)
1653 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1654 # Returns a list of special structures (borders).
1655 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1656 # @ingroup l1_controls
1657 def GetFreeBorders(self):
1658 aFilterMgr = self.smeshpyD.CreateFilterManager()
1659 aPredicate = aFilterMgr.CreateFreeEdges()
1660 aPredicate.SetMesh(self.mesh)
1661 aBorders = aPredicate.GetBorders()
1665 # @ingroup l2_grps_delete
1666 def RemoveGroup(self, group):
1667 self.mesh.RemoveGroup(group)
1669 ## Removes a group with its contents
1670 # @ingroup l2_grps_delete
1671 def RemoveGroupWithContents(self, group):
1672 self.mesh.RemoveGroupWithContents(group)
1674 ## Gets the list of groups existing in the mesh
1675 # @return a sequence of SMESH_GroupBase
1676 # @ingroup l2_grps_create
1677 def GetGroups(self):
1678 return self.mesh.GetGroups()
1680 ## Gets the number of groups existing in the mesh
1681 # @return the quantity of groups as an integer value
1682 # @ingroup l2_grps_create
1684 return self.mesh.NbGroups()
1686 ## Gets the list of names of groups existing in the mesh
1687 # @return list of strings
1688 # @ingroup l2_grps_create
1689 def GetGroupNames(self):
1690 groups = self.GetGroups()
1692 for group in groups:
1693 names.append(group.GetName())
1696 ## Produces a union of two groups
1697 # A new group is created. All mesh elements that are
1698 # present in the initial groups are added to the new one
1699 # @return an instance of SMESH_Group
1700 # @ingroup l2_grps_operon
1701 def UnionGroups(self, group1, group2, name):
1702 return self.mesh.UnionGroups(group1, group2, name)
1704 ## Produces a union list of groups
1705 # New group is created. All mesh elements that are present in
1706 # initial groups are added to the new one
1707 # @return an instance of SMESH_Group
1708 # @ingroup l2_grps_operon
1709 def UnionListOfGroups(self, groups, name):
1710 return self.mesh.UnionListOfGroups(groups, name)
1712 ## Prodices an intersection of two groups
1713 # A new group is created. All mesh elements that are common
1714 # for the two initial groups are added to the new one.
1715 # @return an instance of SMESH_Group
1716 # @ingroup l2_grps_operon
1717 def IntersectGroups(self, group1, group2, name):
1718 return self.mesh.IntersectGroups(group1, group2, name)
1720 ## Produces an intersection of groups
1721 # New group is created. All mesh elements that are present in all
1722 # initial groups simultaneously are added to the new one
1723 # @return an instance of SMESH_Group
1724 # @ingroup l2_grps_operon
1725 def IntersectListOfGroups(self, groups, name):
1726 return self.mesh.IntersectListOfGroups(groups, name)
1728 ## Produces a cut of two groups
1729 # A new group is created. All mesh elements that are present in
1730 # the main group but are not present in the tool group are added to the new one
1731 # @return an instance of SMESH_Group
1732 # @ingroup l2_grps_operon
1733 def CutGroups(self, main_group, tool_group, name):
1734 return self.mesh.CutGroups(main_group, tool_group, name)
1736 ## Produces a cut of groups
1737 # A new group is created. All mesh elements that are present in main groups
1738 # but do not present in tool groups are added to the new one
1739 # @return an instance of SMESH_Group
1740 # @ingroup l2_grps_operon
1741 def CutListOfGroups(self, main_groups, tool_groups, name):
1742 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1744 ## Produces a group of elements with specified element type using list of existing groups
1745 # A new group is created. System
1746 # 1) extract all nodes on which groups elements are built
1747 # 2) combine all elements of specified dimension laying on these nodes
1748 # @return an instance of SMESH_Group
1749 # @ingroup l2_grps_operon
1750 def CreateDimGroup(self, groups, elem_type, name):
1751 return self.mesh.CreateDimGroup(groups, elem_type, name)
1754 ## Convert group on geom into standalone group
1755 # @ingroup l2_grps_delete
1756 def ConvertToStandalone(self, group):
1757 return self.mesh.ConvertToStandalone(group)
1759 # Get some info about mesh:
1760 # ------------------------
1762 ## Returns the log of nodes and elements added or removed
1763 # since the previous clear of the log.
1764 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1765 # @return list of log_block structures:
1770 # @ingroup l1_auxiliary
1771 def GetLog(self, clearAfterGet):
1772 return self.mesh.GetLog(clearAfterGet)
1774 ## Clears the log of nodes and elements added or removed since the previous
1775 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1776 # @ingroup l1_auxiliary
1778 self.mesh.ClearLog()
1780 ## Toggles auto color mode on the object.
1781 # @param theAutoColor the flag which toggles auto color mode.
1782 # @ingroup l1_auxiliary
1783 def SetAutoColor(self, theAutoColor):
1784 self.mesh.SetAutoColor(theAutoColor)
1786 ## Gets flag of object auto color mode.
1787 # @return True or False
1788 # @ingroup l1_auxiliary
1789 def GetAutoColor(self):
1790 return self.mesh.GetAutoColor()
1792 ## Gets the internal ID
1793 # @return integer value, which is the internal Id of the mesh
1794 # @ingroup l1_auxiliary
1796 return self.mesh.GetId()
1799 # @return integer value, which is the study Id of the mesh
1800 # @ingroup l1_auxiliary
1801 def GetStudyId(self):
1802 return self.mesh.GetStudyId()
1804 ## Checks the group names for duplications.
1805 # Consider the maximum group name length stored in MED file.
1806 # @return True or False
1807 # @ingroup l1_auxiliary
1808 def HasDuplicatedGroupNamesMED(self):
1809 return self.mesh.HasDuplicatedGroupNamesMED()
1811 ## Obtains the mesh editor tool
1812 # @return an instance of SMESH_MeshEditor
1813 # @ingroup l1_modifying
1814 def GetMeshEditor(self):
1815 return self.mesh.GetMeshEditor()
1818 # @return an instance of SALOME_MED::MESH
1819 # @ingroup l1_auxiliary
1820 def GetMEDMesh(self):
1821 return self.mesh.GetMEDMesh()
1824 # Get informations about mesh contents:
1825 # ------------------------------------
1827 ## Gets the mesh stattistic
1828 # @return dictionary type element - count of elements
1829 # @ingroup l1_meshinfo
1830 def GetMeshInfo(self, obj = None):
1831 if not obj: obj = self.mesh
1832 return self.smeshpyD.GetMeshInfo(obj)
1834 ## Returns the number of nodes in the mesh
1835 # @return an integer value
1836 # @ingroup l1_meshinfo
1838 return self.mesh.NbNodes()
1840 ## Returns the number of elements in the mesh
1841 # @return an integer value
1842 # @ingroup l1_meshinfo
1843 def NbElements(self):
1844 return self.mesh.NbElements()
1846 ## Returns the number of 0d elements in the mesh
1847 # @return an integer value
1848 # @ingroup l1_meshinfo
1849 def Nb0DElements(self):
1850 return self.mesh.Nb0DElements()
1852 ## Returns the number of edges in the mesh
1853 # @return an integer value
1854 # @ingroup l1_meshinfo
1856 return self.mesh.NbEdges()
1858 ## Returns the number of edges with the given order in the mesh
1859 # @param elementOrder the order of elements:
1860 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1861 # @return an integer value
1862 # @ingroup l1_meshinfo
1863 def NbEdgesOfOrder(self, elementOrder):
1864 return self.mesh.NbEdgesOfOrder(elementOrder)
1866 ## Returns the number of faces in the mesh
1867 # @return an integer value
1868 # @ingroup l1_meshinfo
1870 return self.mesh.NbFaces()
1872 ## Returns the number of faces with the given order in the mesh
1873 # @param elementOrder the order of elements:
1874 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1875 # @return an integer value
1876 # @ingroup l1_meshinfo
1877 def NbFacesOfOrder(self, elementOrder):
1878 return self.mesh.NbFacesOfOrder(elementOrder)
1880 ## Returns the number of triangles in the mesh
1881 # @return an integer value
1882 # @ingroup l1_meshinfo
1883 def NbTriangles(self):
1884 return self.mesh.NbTriangles()
1886 ## Returns the number of triangles with the given order in the mesh
1887 # @param elementOrder is the order of elements:
1888 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1889 # @return an integer value
1890 # @ingroup l1_meshinfo
1891 def NbTrianglesOfOrder(self, elementOrder):
1892 return self.mesh.NbTrianglesOfOrder(elementOrder)
1894 ## Returns the number of quadrangles in the mesh
1895 # @return an integer value
1896 # @ingroup l1_meshinfo
1897 def NbQuadrangles(self):
1898 return self.mesh.NbQuadrangles()
1900 ## Returns the number of quadrangles with the given order in the mesh
1901 # @param elementOrder the order of elements:
1902 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1903 # @return an integer value
1904 # @ingroup l1_meshinfo
1905 def NbQuadranglesOfOrder(self, elementOrder):
1906 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1908 ## Returns the number of polygons in the mesh
1909 # @return an integer value
1910 # @ingroup l1_meshinfo
1911 def NbPolygons(self):
1912 return self.mesh.NbPolygons()
1914 ## Returns the number of volumes in the mesh
1915 # @return an integer value
1916 # @ingroup l1_meshinfo
1917 def NbVolumes(self):
1918 return self.mesh.NbVolumes()
1920 ## Returns the number of volumes with the given order in the mesh
1921 # @param elementOrder the order of elements:
1922 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1923 # @return an integer value
1924 # @ingroup l1_meshinfo
1925 def NbVolumesOfOrder(self, elementOrder):
1926 return self.mesh.NbVolumesOfOrder(elementOrder)
1928 ## Returns the number of tetrahedrons in the mesh
1929 # @return an integer value
1930 # @ingroup l1_meshinfo
1932 return self.mesh.NbTetras()
1934 ## Returns the number of tetrahedrons with the given order in the mesh
1935 # @param elementOrder the order of elements:
1936 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1937 # @return an integer value
1938 # @ingroup l1_meshinfo
1939 def NbTetrasOfOrder(self, elementOrder):
1940 return self.mesh.NbTetrasOfOrder(elementOrder)
1942 ## Returns the number of hexahedrons in the mesh
1943 # @return an integer value
1944 # @ingroup l1_meshinfo
1946 return self.mesh.NbHexas()
1948 ## Returns the number of hexahedrons with the given order in the mesh
1949 # @param elementOrder the order of elements:
1950 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1951 # @return an integer value
1952 # @ingroup l1_meshinfo
1953 def NbHexasOfOrder(self, elementOrder):
1954 return self.mesh.NbHexasOfOrder(elementOrder)
1956 ## Returns the number of pyramids in the mesh
1957 # @return an integer value
1958 # @ingroup l1_meshinfo
1959 def NbPyramids(self):
1960 return self.mesh.NbPyramids()
1962 ## Returns the number of pyramids with the given order in the mesh
1963 # @param elementOrder the order of elements:
1964 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1965 # @return an integer value
1966 # @ingroup l1_meshinfo
1967 def NbPyramidsOfOrder(self, elementOrder):
1968 return self.mesh.NbPyramidsOfOrder(elementOrder)
1970 ## Returns the number of prisms in the mesh
1971 # @return an integer value
1972 # @ingroup l1_meshinfo
1974 return self.mesh.NbPrisms()
1976 ## Returns the number of prisms with the given order in the mesh
1977 # @param elementOrder the order of elements:
1978 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1979 # @return an integer value
1980 # @ingroup l1_meshinfo
1981 def NbPrismsOfOrder(self, elementOrder):
1982 return self.mesh.NbPrismsOfOrder(elementOrder)
1984 ## Returns the number of polyhedrons in the mesh
1985 # @return an integer value
1986 # @ingroup l1_meshinfo
1987 def NbPolyhedrons(self):
1988 return self.mesh.NbPolyhedrons()
1990 ## Returns the number of submeshes in the mesh
1991 # @return an integer value
1992 # @ingroup l1_meshinfo
1993 def NbSubMesh(self):
1994 return self.mesh.NbSubMesh()
1996 ## Returns the list of mesh elements IDs
1997 # @return the list of integer values
1998 # @ingroup l1_meshinfo
1999 def GetElementsId(self):
2000 return self.mesh.GetElementsId()
2002 ## Returns the list of IDs of mesh elements with the given type
2003 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2004 # @return list of integer values
2005 # @ingroup l1_meshinfo
2006 def GetElementsByType(self, elementType):
2007 return self.mesh.GetElementsByType(elementType)
2009 ## Returns the list of mesh nodes IDs
2010 # @return the list of integer values
2011 # @ingroup l1_meshinfo
2012 def GetNodesId(self):
2013 return self.mesh.GetNodesId()
2015 # Get the information about mesh elements:
2016 # ------------------------------------
2018 ## Returns the type of mesh element
2019 # @return the value from SMESH::ElementType enumeration
2020 # @ingroup l1_meshinfo
2021 def GetElementType(self, id, iselem):
2022 return self.mesh.GetElementType(id, iselem)
2024 ## Returns the geometric type of mesh element
2025 # @return the value from SMESH::EntityType enumeration
2026 # @ingroup l1_meshinfo
2027 def GetElementGeomType(self, id):
2028 return self.mesh.GetElementGeomType(id)
2030 ## Returns the list of submesh elements IDs
2031 # @param Shape a geom object(subshape) IOR
2032 # Shape must be the subshape of a ShapeToMesh()
2033 # @return the list of integer values
2034 # @ingroup l1_meshinfo
2035 def GetSubMeshElementsId(self, Shape):
2036 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2037 ShapeID = Shape.GetSubShapeIndices()[0]
2040 return self.mesh.GetSubMeshElementsId(ShapeID)
2042 ## Returns the list of submesh nodes IDs
2043 # @param Shape a geom object(subshape) IOR
2044 # Shape must be the subshape of a ShapeToMesh()
2045 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2046 # @return the list of integer values
2047 # @ingroup l1_meshinfo
2048 def GetSubMeshNodesId(self, Shape, all):
2049 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2050 ShapeID = Shape.GetSubShapeIndices()[0]
2053 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2055 ## Returns type of elements on given shape
2056 # @param Shape a geom object(subshape) IOR
2057 # Shape must be a subshape of a ShapeToMesh()
2058 # @return element type
2059 # @ingroup l1_meshinfo
2060 def GetSubMeshElementType(self, Shape):
2061 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2062 ShapeID = Shape.GetSubShapeIndices()[0]
2065 return self.mesh.GetSubMeshElementType(ShapeID)
2067 ## Gets the mesh description
2068 # @return string value
2069 # @ingroup l1_meshinfo
2071 return self.mesh.Dump()
2074 # Get the information about nodes and elements of a mesh by its IDs:
2075 # -----------------------------------------------------------
2077 ## Gets XYZ coordinates of a node
2078 # \n If there is no nodes for the given ID - returns an empty list
2079 # @return a list of double precision values
2080 # @ingroup l1_meshinfo
2081 def GetNodeXYZ(self, id):
2082 return self.mesh.GetNodeXYZ(id)
2084 ## Returns list of IDs of inverse elements for the given node
2085 # \n If there is no node for the given ID - returns an empty list
2086 # @return a list of integer values
2087 # @ingroup l1_meshinfo
2088 def GetNodeInverseElements(self, id):
2089 return self.mesh.GetNodeInverseElements(id)
2091 ## @brief Returns the position of a node on the shape
2092 # @return SMESH::NodePosition
2093 # @ingroup l1_meshinfo
2094 def GetNodePosition(self,NodeID):
2095 return self.mesh.GetNodePosition(NodeID)
2097 ## If the given element is a node, returns the ID of shape
2098 # \n If there is no node for the given ID - returns -1
2099 # @return an integer value
2100 # @ingroup l1_meshinfo
2101 def GetShapeID(self, id):
2102 return self.mesh.GetShapeID(id)
2104 ## Returns the ID of the result shape after
2105 # FindShape() from SMESH_MeshEditor for the given element
2106 # \n If there is no element for the given ID - returns -1
2107 # @return an integer value
2108 # @ingroup l1_meshinfo
2109 def GetShapeIDForElem(self,id):
2110 return self.mesh.GetShapeIDForElem(id)
2112 ## Returns the number of nodes for the given element
2113 # \n If there is no element for the given ID - returns -1
2114 # @return an integer value
2115 # @ingroup l1_meshinfo
2116 def GetElemNbNodes(self, id):
2117 return self.mesh.GetElemNbNodes(id)
2119 ## Returns the node ID the given index for the given element
2120 # \n If there is no element for the given ID - returns -1
2121 # \n If there is no node for the given index - returns -2
2122 # @return an integer value
2123 # @ingroup l1_meshinfo
2124 def GetElemNode(self, id, index):
2125 return self.mesh.GetElemNode(id, index)
2127 ## Returns the IDs of nodes of the given element
2128 # @return a list of integer values
2129 # @ingroup l1_meshinfo
2130 def GetElemNodes(self, id):
2131 return self.mesh.GetElemNodes(id)
2133 ## Returns true if the given node is the medium node in the given quadratic element
2134 # @ingroup l1_meshinfo
2135 def IsMediumNode(self, elementID, nodeID):
2136 return self.mesh.IsMediumNode(elementID, nodeID)
2138 ## Returns true if the given node is the medium node in one of quadratic elements
2139 # @ingroup l1_meshinfo
2140 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2141 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2143 ## Returns the number of edges for the given element
2144 # @ingroup l1_meshinfo
2145 def ElemNbEdges(self, id):
2146 return self.mesh.ElemNbEdges(id)
2148 ## Returns the number of faces for the given element
2149 # @ingroup l1_meshinfo
2150 def ElemNbFaces(self, id):
2151 return self.mesh.ElemNbFaces(id)
2153 ## Returns nodes of given face (counted from zero) for given volumic element.
2154 # @ingroup l1_meshinfo
2155 def GetElemFaceNodes(self,elemId, faceIndex):
2156 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2158 ## Returns an element based on all given nodes.
2159 # @ingroup l1_meshinfo
2160 def FindElementByNodes(self,nodes):
2161 return self.mesh.FindElementByNodes(nodes)
2163 ## Returns true if the given element is a polygon
2164 # @ingroup l1_meshinfo
2165 def IsPoly(self, id):
2166 return self.mesh.IsPoly(id)
2168 ## Returns true if the given element is quadratic
2169 # @ingroup l1_meshinfo
2170 def IsQuadratic(self, id):
2171 return self.mesh.IsQuadratic(id)
2173 ## Returns XYZ coordinates of the barycenter of the given element
2174 # \n If there is no element for the given ID - returns an empty list
2175 # @return a list of three double values
2176 # @ingroup l1_meshinfo
2177 def BaryCenter(self, id):
2178 return self.mesh.BaryCenter(id)
2181 # Mesh edition (SMESH_MeshEditor functionality):
2182 # ---------------------------------------------
2184 ## Removes the elements from the mesh by ids
2185 # @param IDsOfElements is a list of ids of elements to remove
2186 # @return True or False
2187 # @ingroup l2_modif_del
2188 def RemoveElements(self, IDsOfElements):
2189 return self.editor.RemoveElements(IDsOfElements)
2191 ## Removes nodes from mesh by ids
2192 # @param IDsOfNodes is a list of ids of nodes to remove
2193 # @return True or False
2194 # @ingroup l2_modif_del
2195 def RemoveNodes(self, IDsOfNodes):
2196 return self.editor.RemoveNodes(IDsOfNodes)
2198 ## Removes all orphan (free) nodes from mesh
2199 # @return number of the removed nodes
2200 # @ingroup l2_modif_del
2201 def RemoveOrphanNodes(self):
2202 return self.editor.RemoveOrphanNodes()
2204 ## Add a node to the mesh by coordinates
2205 # @return Id of the new node
2206 # @ingroup l2_modif_add
2207 def AddNode(self, x, y, z):
2208 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2209 self.mesh.SetParameters(Parameters)
2210 return self.editor.AddNode( x, y, z)
2212 ## Creates a 0D element on a node with given number.
2213 # @param IDOfNode the ID of node for creation of the element.
2214 # @return the Id of the new 0D element
2215 # @ingroup l2_modif_add
2216 def Add0DElement(self, IDOfNode):
2217 return self.editor.Add0DElement(IDOfNode)
2219 ## Creates a linear or quadratic edge (this is determined
2220 # by the number of given nodes).
2221 # @param IDsOfNodes the list of node IDs for creation of the element.
2222 # The order of nodes in this list should correspond to the description
2223 # of MED. \n This description is located by the following link:
2224 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2225 # @return the Id of the new edge
2226 # @ingroup l2_modif_add
2227 def AddEdge(self, IDsOfNodes):
2228 return self.editor.AddEdge(IDsOfNodes)
2230 ## Creates a linear or quadratic face (this is determined
2231 # by the number of given nodes).
2232 # @param IDsOfNodes the list of node IDs for creation of the element.
2233 # The order of nodes in this list should correspond to the description
2234 # of MED. \n This description is located by the following link:
2235 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2236 # @return the Id of the new face
2237 # @ingroup l2_modif_add
2238 def AddFace(self, IDsOfNodes):
2239 return self.editor.AddFace(IDsOfNodes)
2241 ## Adds a polygonal face to the mesh by the list of node IDs
2242 # @param IdsOfNodes the list of node IDs for creation of the element.
2243 # @return the Id of the new face
2244 # @ingroup l2_modif_add
2245 def AddPolygonalFace(self, IdsOfNodes):
2246 return self.editor.AddPolygonalFace(IdsOfNodes)
2248 ## Creates both simple and quadratic volume (this is determined
2249 # by the number of given nodes).
2250 # @param IDsOfNodes the list of node IDs for creation of the element.
2251 # The order of nodes in this list should correspond to the description
2252 # of MED. \n This description is located by the following link:
2253 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2254 # @return the Id of the new volumic element
2255 # @ingroup l2_modif_add
2256 def AddVolume(self, IDsOfNodes):
2257 return self.editor.AddVolume(IDsOfNodes)
2259 ## Creates a volume of many faces, giving nodes for each face.
2260 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2261 # @param Quantities the list of integer values, Quantities[i]
2262 # gives the quantity of nodes in face number i.
2263 # @return the Id of the new volumic element
2264 # @ingroup l2_modif_add
2265 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2266 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2268 ## Creates a volume of many faces, giving the IDs of the existing faces.
2269 # @param IdsOfFaces the list of face IDs for volume creation.
2271 # Note: The created volume will refer only to the nodes
2272 # of the given faces, not to the faces themselves.
2273 # @return the Id of the new volumic element
2274 # @ingroup l2_modif_add
2275 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2276 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2279 ## @brief Binds a node to a vertex
2280 # @param NodeID a node ID
2281 # @param Vertex a vertex or vertex ID
2282 # @return True if succeed else raises an exception
2283 # @ingroup l2_modif_add
2284 def SetNodeOnVertex(self, NodeID, Vertex):
2285 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2286 VertexID = Vertex.GetSubShapeIndices()[0]
2290 self.editor.SetNodeOnVertex(NodeID, VertexID)
2291 except SALOME.SALOME_Exception, inst:
2292 raise ValueError, inst.details.text
2296 ## @brief Stores the node position on an edge
2297 # @param NodeID a node ID
2298 # @param Edge an edge or edge ID
2299 # @param paramOnEdge a parameter on the edge where the node is located
2300 # @return True if succeed else raises an exception
2301 # @ingroup l2_modif_add
2302 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2303 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2304 EdgeID = Edge.GetSubShapeIndices()[0]
2308 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2309 except SALOME.SALOME_Exception, inst:
2310 raise ValueError, inst.details.text
2313 ## @brief Stores node position on a face
2314 # @param NodeID a node ID
2315 # @param Face a face or face ID
2316 # @param u U parameter on the face where the node is located
2317 # @param v V parameter on the face where the node is located
2318 # @return True if succeed else raises an exception
2319 # @ingroup l2_modif_add
2320 def SetNodeOnFace(self, NodeID, Face, u, v):
2321 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2322 FaceID = Face.GetSubShapeIndices()[0]
2326 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2327 except SALOME.SALOME_Exception, inst:
2328 raise ValueError, inst.details.text
2331 ## @brief Binds a node to a solid
2332 # @param NodeID a node ID
2333 # @param Solid a solid or solid ID
2334 # @return True if succeed else raises an exception
2335 # @ingroup l2_modif_add
2336 def SetNodeInVolume(self, NodeID, Solid):
2337 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2338 SolidID = Solid.GetSubShapeIndices()[0]
2342 self.editor.SetNodeInVolume(NodeID, SolidID)
2343 except SALOME.SALOME_Exception, inst:
2344 raise ValueError, inst.details.text
2347 ## @brief Bind an element to a shape
2348 # @param ElementID an element ID
2349 # @param Shape a shape or shape ID
2350 # @return True if succeed else raises an exception
2351 # @ingroup l2_modif_add
2352 def SetMeshElementOnShape(self, ElementID, Shape):
2353 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2354 ShapeID = Shape.GetSubShapeIndices()[0]
2358 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2359 except SALOME.SALOME_Exception, inst:
2360 raise ValueError, inst.details.text
2364 ## Moves the node with the given id
2365 # @param NodeID the id of the node
2366 # @param x a new X coordinate
2367 # @param y a new Y coordinate
2368 # @param z a new Z coordinate
2369 # @return True if succeed else False
2370 # @ingroup l2_modif_movenode
2371 def MoveNode(self, NodeID, x, y, z):
2372 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2373 self.mesh.SetParameters(Parameters)
2374 return self.editor.MoveNode(NodeID, x, y, z)
2376 ## Finds the node closest to a point and moves it to a point location
2377 # @param x the X coordinate of a point
2378 # @param y the Y coordinate of a point
2379 # @param z the Z coordinate of a point
2380 # @param NodeID if specified (>0), the node with this ID is moved,
2381 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2382 # @return the ID of a node
2383 # @ingroup l2_modif_throughp
2384 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2385 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2386 self.mesh.SetParameters(Parameters)
2387 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2389 ## Finds the node closest to a point
2390 # @param x the X coordinate of a point
2391 # @param y the Y coordinate of a point
2392 # @param z the Z coordinate of a point
2393 # @return the ID of a node
2394 # @ingroup l2_modif_throughp
2395 def FindNodeClosestTo(self, x, y, z):
2396 #preview = self.mesh.GetMeshEditPreviewer()
2397 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2398 return self.editor.FindNodeClosestTo(x, y, z)
2400 ## Finds the elements where a point lays IN or ON
2401 # @param x the X coordinate of a point
2402 # @param y the Y coordinate of a point
2403 # @param z the Z coordinate of a point
2404 # @param elementType type of elements to find (SMESH.ALL type
2405 # means elements of any type excluding nodes and 0D elements)
2406 # @return list of IDs of found elements
2407 # @ingroup l2_modif_throughp
2408 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2409 return self.editor.FindElementsByPoint(x, y, z, elementType)
2411 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2412 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2414 def GetPointState(self, x, y, z):
2415 return self.editor.GetPointState(x, y, z)
2417 ## Finds the node closest to a point and moves it to a point location
2418 # @param x the X coordinate of a point
2419 # @param y the Y coordinate of a point
2420 # @param z the Z coordinate of a point
2421 # @return the ID of a moved node
2422 # @ingroup l2_modif_throughp
2423 def MeshToPassThroughAPoint(self, x, y, z):
2424 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2426 ## Replaces two neighbour triangles sharing Node1-Node2 link
2427 # with the triangles built on the same 4 nodes but having other common link.
2428 # @param NodeID1 the ID of the first node
2429 # @param NodeID2 the ID of the second node
2430 # @return false if proper faces were not found
2431 # @ingroup l2_modif_invdiag
2432 def InverseDiag(self, NodeID1, NodeID2):
2433 return self.editor.InverseDiag(NodeID1, NodeID2)
2435 ## Replaces two neighbour triangles sharing Node1-Node2 link
2436 # with a quadrangle built on the same 4 nodes.
2437 # @param NodeID1 the ID of the first node
2438 # @param NodeID2 the ID of the second node
2439 # @return false if proper faces were not found
2440 # @ingroup l2_modif_unitetri
2441 def DeleteDiag(self, NodeID1, NodeID2):
2442 return self.editor.DeleteDiag(NodeID1, NodeID2)
2444 ## Reorients elements by ids
2445 # @param IDsOfElements if undefined reorients all mesh elements
2446 # @return True if succeed else False
2447 # @ingroup l2_modif_changori
2448 def Reorient(self, IDsOfElements=None):
2449 if IDsOfElements == None:
2450 IDsOfElements = self.GetElementsId()
2451 return self.editor.Reorient(IDsOfElements)
2453 ## Reorients all elements of the object
2454 # @param theObject mesh, submesh or group
2455 # @return True if succeed else False
2456 # @ingroup l2_modif_changori
2457 def ReorientObject(self, theObject):
2458 if ( isinstance( theObject, Mesh )):
2459 theObject = theObject.GetMesh()
2460 return self.editor.ReorientObject(theObject)
2462 ## Fuses the neighbouring triangles into quadrangles.
2463 # @param IDsOfElements The triangles to be fused,
2464 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2465 # @param MaxAngle is the maximum angle between element normals at which the fusion
2466 # is still performed; theMaxAngle is mesured in radians.
2467 # Also it could be a name of variable which defines angle in degrees.
2468 # @return TRUE in case of success, FALSE otherwise.
2469 # @ingroup l2_modif_unitetri
2470 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2472 if isinstance(MaxAngle,str):
2474 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2476 MaxAngle = DegreesToRadians(MaxAngle)
2477 if IDsOfElements == []:
2478 IDsOfElements = self.GetElementsId()
2479 self.mesh.SetParameters(Parameters)
2481 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2482 Functor = theCriterion
2484 Functor = self.smeshpyD.GetFunctor(theCriterion)
2485 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2487 ## Fuses the neighbouring triangles of the object into quadrangles
2488 # @param theObject is mesh, submesh or group
2489 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2490 # @param MaxAngle a max angle between element normals at which the fusion
2491 # is still performed; theMaxAngle is mesured in radians.
2492 # @return TRUE in case of success, FALSE otherwise.
2493 # @ingroup l2_modif_unitetri
2494 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2495 if ( isinstance( theObject, Mesh )):
2496 theObject = theObject.GetMesh()
2497 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2499 ## Splits quadrangles into triangles.
2500 # @param IDsOfElements the faces to be splitted.
2501 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2502 # @return TRUE in case of success, FALSE otherwise.
2503 # @ingroup l2_modif_cutquadr
2504 def QuadToTri (self, IDsOfElements, theCriterion):
2505 if IDsOfElements == []:
2506 IDsOfElements = self.GetElementsId()
2507 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2509 ## Splits quadrangles into triangles.
2510 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2511 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2512 # @return TRUE in case of success, FALSE otherwise.
2513 # @ingroup l2_modif_cutquadr
2514 def QuadToTriObject (self, theObject, theCriterion):
2515 if ( isinstance( theObject, Mesh )):
2516 theObject = theObject.GetMesh()
2517 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2519 ## Splits quadrangles into triangles.
2520 # @param IDsOfElements the faces to be splitted
2521 # @param Diag13 is used to choose a diagonal for splitting.
2522 # @return TRUE in case of success, FALSE otherwise.
2523 # @ingroup l2_modif_cutquadr
2524 def SplitQuad (self, IDsOfElements, Diag13):
2525 if IDsOfElements == []:
2526 IDsOfElements = self.GetElementsId()
2527 return self.editor.SplitQuad(IDsOfElements, Diag13)
2529 ## Splits quadrangles into triangles.
2530 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2531 # @param Diag13 is used to choose a diagonal for splitting.
2532 # @return TRUE in case of success, FALSE otherwise.
2533 # @ingroup l2_modif_cutquadr
2534 def SplitQuadObject (self, theObject, Diag13):
2535 if ( isinstance( theObject, Mesh )):
2536 theObject = theObject.GetMesh()
2537 return self.editor.SplitQuadObject(theObject, Diag13)
2539 ## Finds a better splitting of the given quadrangle.
2540 # @param IDOfQuad the ID of the quadrangle to be splitted.
2541 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2542 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2543 # diagonal is better, 0 if error occurs.
2544 # @ingroup l2_modif_cutquadr
2545 def BestSplit (self, IDOfQuad, theCriterion):
2546 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2548 ## Splits volumic elements into tetrahedrons
2549 # @param elemIDs either list of elements or mesh or group or submesh
2550 # @param method flags passing splitting method:
2551 # 1 - split the hexahedron into 5 tetrahedrons
2552 # 2 - split the hexahedron into 6 tetrahedrons
2553 # @ingroup l2_modif_cutquadr
2554 def SplitVolumesIntoTetra(self, elemIDs, method=1 ):
2555 if isinstance( elemIDs, Mesh ):
2556 elemIDs = elemIDs.GetMesh()
2557 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2559 ## Splits quadrangle faces near triangular facets of volumes
2561 # @ingroup l1_auxiliary
2562 def SplitQuadsNearTriangularFacets(self):
2563 faces_array = self.GetElementsByType(SMESH.FACE)
2564 for face_id in faces_array:
2565 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2566 quad_nodes = self.mesh.GetElemNodes(face_id)
2567 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2568 isVolumeFound = False
2569 for node1_elem in node1_elems:
2570 if not isVolumeFound:
2571 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2572 nb_nodes = self.GetElemNbNodes(node1_elem)
2573 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2574 volume_elem = node1_elem
2575 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2576 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2577 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2578 isVolumeFound = True
2579 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2580 self.SplitQuad([face_id], False) # diagonal 2-4
2581 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2582 isVolumeFound = True
2583 self.SplitQuad([face_id], True) # diagonal 1-3
2584 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2585 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2586 isVolumeFound = True
2587 self.SplitQuad([face_id], True) # diagonal 1-3
2589 ## @brief Splits hexahedrons into tetrahedrons.
2591 # This operation uses pattern mapping functionality for splitting.
2592 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2593 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2594 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2595 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2596 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2597 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2598 # @return TRUE in case of success, FALSE otherwise.
2599 # @ingroup l1_auxiliary
2600 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2601 # Pattern: 5.---------.6
2606 # (0,0,1) 4.---------.7 * |
2613 # (0,0,0) 0.---------.3
2614 pattern_tetra = "!!! Nb of points: \n 8 \n\
2624 !!! Indices of points of 6 tetras: \n\
2632 pattern = self.smeshpyD.GetPattern()
2633 isDone = pattern.LoadFromFile(pattern_tetra)
2635 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2638 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2639 isDone = pattern.MakeMesh(self.mesh, False, False)
2640 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2642 # split quafrangle faces near triangular facets of volumes
2643 self.SplitQuadsNearTriangularFacets()
2647 ## @brief Split hexahedrons into prisms.
2649 # Uses the pattern mapping functionality for splitting.
2650 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2651 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2652 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2653 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2654 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2655 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2656 # @return TRUE in case of success, FALSE otherwise.
2657 # @ingroup l1_auxiliary
2658 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2659 # Pattern: 5.---------.6
2664 # (0,0,1) 4.---------.7 |
2671 # (0,0,0) 0.---------.3
2672 pattern_prism = "!!! Nb of points: \n 8 \n\
2682 !!! Indices of points of 2 prisms: \n\
2686 pattern = self.smeshpyD.GetPattern()
2687 isDone = pattern.LoadFromFile(pattern_prism)
2689 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2692 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2693 isDone = pattern.MakeMesh(self.mesh, False, False)
2694 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2696 # Splits quafrangle faces near triangular facets of volumes
2697 self.SplitQuadsNearTriangularFacets()
2701 ## Smoothes elements
2702 # @param IDsOfElements the list if ids of elements to smooth
2703 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2704 # Note that nodes built on edges and boundary nodes are always fixed.
2705 # @param MaxNbOfIterations the maximum number of iterations
2706 # @param MaxAspectRatio varies in range [1.0, inf]
2707 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2708 # @return TRUE in case of success, FALSE otherwise.
2709 # @ingroup l2_modif_smooth
2710 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2711 MaxNbOfIterations, MaxAspectRatio, Method):
2712 if IDsOfElements == []:
2713 IDsOfElements = self.GetElementsId()
2714 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2715 self.mesh.SetParameters(Parameters)
2716 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2717 MaxNbOfIterations, MaxAspectRatio, Method)
2719 ## Smoothes elements which belong to the given object
2720 # @param theObject the object to smooth
2721 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2722 # Note that nodes built on edges and boundary nodes are always fixed.
2723 # @param MaxNbOfIterations the maximum number of iterations
2724 # @param MaxAspectRatio varies in range [1.0, inf]
2725 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2726 # @return TRUE in case of success, FALSE otherwise.
2727 # @ingroup l2_modif_smooth
2728 def SmoothObject(self, theObject, IDsOfFixedNodes,
2729 MaxNbOfIterations, MaxAspectRatio, Method):
2730 if ( isinstance( theObject, Mesh )):
2731 theObject = theObject.GetMesh()
2732 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2733 MaxNbOfIterations, MaxAspectRatio, Method)
2735 ## Parametrically smoothes the given elements
2736 # @param IDsOfElements the list if ids of elements to smooth
2737 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2738 # Note that nodes built on edges and boundary nodes are always fixed.
2739 # @param MaxNbOfIterations the maximum number of iterations
2740 # @param MaxAspectRatio varies in range [1.0, inf]
2741 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2742 # @return TRUE in case of success, FALSE otherwise.
2743 # @ingroup l2_modif_smooth
2744 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2745 MaxNbOfIterations, MaxAspectRatio, Method):
2746 if IDsOfElements == []:
2747 IDsOfElements = self.GetElementsId()
2748 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2749 self.mesh.SetParameters(Parameters)
2750 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2751 MaxNbOfIterations, MaxAspectRatio, Method)
2753 ## Parametrically smoothes the elements which belong to the given object
2754 # @param theObject the object to smooth
2755 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2756 # Note that nodes built on edges and boundary nodes are always fixed.
2757 # @param MaxNbOfIterations the maximum number of iterations
2758 # @param MaxAspectRatio varies in range [1.0, inf]
2759 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2760 # @return TRUE in case of success, FALSE otherwise.
2761 # @ingroup l2_modif_smooth
2762 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2763 MaxNbOfIterations, MaxAspectRatio, Method):
2764 if ( isinstance( theObject, Mesh )):
2765 theObject = theObject.GetMesh()
2766 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2767 MaxNbOfIterations, MaxAspectRatio, Method)
2769 ## Converts the mesh to quadratic, deletes old elements, replacing
2770 # them with quadratic with the same id.
2771 # @param theForce3d new node creation method:
2772 # 0 - the medium node lies at the geometrical edge from which the mesh element is built
2773 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
2774 # @ingroup l2_modif_tofromqu
2775 def ConvertToQuadratic(self, theForce3d):
2776 self.editor.ConvertToQuadratic(theForce3d)
2778 ## Converts the mesh from quadratic to ordinary,
2779 # deletes old quadratic elements, \n replacing
2780 # them with ordinary mesh elements with the same id.
2781 # @return TRUE in case of success, FALSE otherwise.
2782 # @ingroup l2_modif_tofromqu
2783 def ConvertFromQuadratic(self):
2784 return self.editor.ConvertFromQuadratic()
2786 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2787 # @return TRUE if operation has been completed successfully, FALSE otherwise
2788 # @ingroup l2_modif_edit
2789 def Make2DMeshFrom3D(self):
2790 return self.editor. Make2DMeshFrom3D()
2792 ## Renumber mesh nodes
2793 # @ingroup l2_modif_renumber
2794 def RenumberNodes(self):
2795 self.editor.RenumberNodes()
2797 ## Renumber mesh elements
2798 # @ingroup l2_modif_renumber
2799 def RenumberElements(self):
2800 self.editor.RenumberElements()
2802 ## Generates new elements by rotation of the elements around the axis
2803 # @param IDsOfElements the list of ids of elements to sweep
2804 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2805 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2806 # @param NbOfSteps the number of steps
2807 # @param Tolerance tolerance
2808 # @param MakeGroups forces the generation of new groups from existing ones
2809 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2810 # of all steps, else - size of each step
2811 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2812 # @ingroup l2_modif_extrurev
2813 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2814 MakeGroups=False, TotalAngle=False):
2816 if isinstance(AngleInRadians,str):
2818 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2820 AngleInRadians = DegreesToRadians(AngleInRadians)
2821 if IDsOfElements == []:
2822 IDsOfElements = self.GetElementsId()
2823 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2824 Axis = self.smeshpyD.GetAxisStruct(Axis)
2825 Axis,AxisParameters = ParseAxisStruct(Axis)
2826 if TotalAngle and NbOfSteps:
2827 AngleInRadians /= NbOfSteps
2828 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2829 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2830 self.mesh.SetParameters(Parameters)
2832 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2833 AngleInRadians, NbOfSteps, Tolerance)
2834 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2837 ## Generates new elements by rotation of the elements of object around the axis
2838 # @param theObject object which elements should be sweeped
2839 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2840 # @param AngleInRadians the angle of Rotation
2841 # @param NbOfSteps number of steps
2842 # @param Tolerance tolerance
2843 # @param MakeGroups forces the generation of new groups from existing ones
2844 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2845 # of all steps, else - size of each step
2846 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2847 # @ingroup l2_modif_extrurev
2848 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2849 MakeGroups=False, TotalAngle=False):
2851 if isinstance(AngleInRadians,str):
2853 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2855 AngleInRadians = DegreesToRadians(AngleInRadians)
2856 if ( isinstance( theObject, Mesh )):
2857 theObject = theObject.GetMesh()
2858 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2859 Axis = self.smeshpyD.GetAxisStruct(Axis)
2860 Axis,AxisParameters = ParseAxisStruct(Axis)
2861 if TotalAngle and NbOfSteps:
2862 AngleInRadians /= NbOfSteps
2863 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2864 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2865 self.mesh.SetParameters(Parameters)
2867 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2868 NbOfSteps, Tolerance)
2869 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2872 ## Generates new elements by rotation of the elements of object around the axis
2873 # @param theObject object which elements should be sweeped
2874 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2875 # @param AngleInRadians the angle of Rotation
2876 # @param NbOfSteps number of steps
2877 # @param Tolerance tolerance
2878 # @param MakeGroups forces the generation of new groups from existing ones
2879 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2880 # of all steps, else - size of each step
2881 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2882 # @ingroup l2_modif_extrurev
2883 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2884 MakeGroups=False, TotalAngle=False):
2886 if isinstance(AngleInRadians,str):
2888 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2890 AngleInRadians = DegreesToRadians(AngleInRadians)
2891 if ( isinstance( theObject, Mesh )):
2892 theObject = theObject.GetMesh()
2893 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2894 Axis = self.smeshpyD.GetAxisStruct(Axis)
2895 Axis,AxisParameters = ParseAxisStruct(Axis)
2896 if TotalAngle and NbOfSteps:
2897 AngleInRadians /= NbOfSteps
2898 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2899 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2900 self.mesh.SetParameters(Parameters)
2902 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2903 NbOfSteps, Tolerance)
2904 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2907 ## Generates new elements by rotation of the elements of object around the axis
2908 # @param theObject object which elements should be sweeped
2909 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2910 # @param AngleInRadians the angle of Rotation
2911 # @param NbOfSteps number of steps
2912 # @param Tolerance tolerance
2913 # @param MakeGroups forces the generation of new groups from existing ones
2914 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2915 # of all steps, else - size of each step
2916 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2917 # @ingroup l2_modif_extrurev
2918 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2919 MakeGroups=False, TotalAngle=False):
2921 if isinstance(AngleInRadians,str):
2923 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2925 AngleInRadians = DegreesToRadians(AngleInRadians)
2926 if ( isinstance( theObject, Mesh )):
2927 theObject = theObject.GetMesh()
2928 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2929 Axis = self.smeshpyD.GetAxisStruct(Axis)
2930 Axis,AxisParameters = ParseAxisStruct(Axis)
2931 if TotalAngle and NbOfSteps:
2932 AngleInRadians /= NbOfSteps
2933 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2934 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2935 self.mesh.SetParameters(Parameters)
2937 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2938 NbOfSteps, Tolerance)
2939 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2942 ## Generates new elements by extrusion of the elements with given ids
2943 # @param IDsOfElements the list of elements ids for extrusion
2944 # @param StepVector vector, defining the direction and value of extrusion
2945 # @param NbOfSteps the number of steps
2946 # @param MakeGroups forces the generation of new groups from existing ones
2947 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2948 # @ingroup l2_modif_extrurev
2949 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2950 if IDsOfElements == []:
2951 IDsOfElements = self.GetElementsId()
2952 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2953 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2954 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2955 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2956 Parameters = StepVectorParameters + var_separator + Parameters
2957 self.mesh.SetParameters(Parameters)
2959 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2960 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2963 ## Generates new elements by extrusion of the elements with given ids
2964 # @param IDsOfElements is ids of elements
2965 # @param StepVector vector, defining the direction and value of extrusion
2966 # @param NbOfSteps the number of steps
2967 # @param ExtrFlags sets flags for extrusion
2968 # @param SewTolerance uses for comparing locations of nodes if flag
2969 # EXTRUSION_FLAG_SEW is set
2970 # @param MakeGroups forces the generation of new groups from existing ones
2971 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2972 # @ingroup l2_modif_extrurev
2973 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2974 ExtrFlags, SewTolerance, MakeGroups=False):
2975 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2976 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2978 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2979 ExtrFlags, SewTolerance)
2980 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2981 ExtrFlags, SewTolerance)
2984 ## Generates new elements by extrusion of the elements which belong to the object
2985 # @param theObject the object which elements should be processed
2986 # @param StepVector vector, defining the direction and value of extrusion
2987 # @param NbOfSteps the number of steps
2988 # @param MakeGroups forces the generation of new groups from existing ones
2989 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2990 # @ingroup l2_modif_extrurev
2991 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2992 if ( isinstance( theObject, Mesh )):
2993 theObject = theObject.GetMesh()
2994 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2995 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2996 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2997 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2998 Parameters = StepVectorParameters + var_separator + Parameters
2999 self.mesh.SetParameters(Parameters)
3001 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3002 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3005 ## Generates new elements by extrusion of the elements which belong to the object
3006 # @param theObject object which elements should be processed
3007 # @param StepVector vector, defining the direction and value of extrusion
3008 # @param NbOfSteps the number of steps
3009 # @param MakeGroups to generate new groups from existing ones
3010 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3011 # @ingroup l2_modif_extrurev
3012 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3013 if ( isinstance( theObject, Mesh )):
3014 theObject = theObject.GetMesh()
3015 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3016 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3017 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3018 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3019 Parameters = StepVectorParameters + var_separator + Parameters
3020 self.mesh.SetParameters(Parameters)
3022 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3023 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3026 ## Generates new elements by extrusion of the elements which belong to the object
3027 # @param theObject object which elements should be processed
3028 # @param StepVector vector, defining the direction and value of extrusion
3029 # @param NbOfSteps the number of steps
3030 # @param MakeGroups forces the generation of new groups from existing ones
3031 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3032 # @ingroup l2_modif_extrurev
3033 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3034 if ( isinstance( theObject, Mesh )):
3035 theObject = theObject.GetMesh()
3036 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3037 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3038 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3039 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3040 Parameters = StepVectorParameters + var_separator + Parameters
3041 self.mesh.SetParameters(Parameters)
3043 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3044 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3049 ## Generates new elements by extrusion of the given elements
3050 # The path of extrusion must be a meshed edge.
3051 # @param Base mesh or list of ids of elements for extrusion
3052 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3053 # @param NodeStart the start node from Path. Defines the direction of extrusion
3054 # @param HasAngles allows the shape to be rotated around the path
3055 # to get the resulting mesh in a helical fashion
3056 # @param Angles list of angles in radians
3057 # @param LinearVariation forces the computation of rotation angles as linear
3058 # variation of the given Angles along path steps
3059 # @param HasRefPoint allows using the reference point
3060 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3061 # The User can specify any point as the Reference Point.
3062 # @param MakeGroups forces the generation of new groups from existing ones
3063 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3064 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3065 # only SMESH::Extrusion_Error otherwise
3066 # @ingroup l2_modif_extrurev
3067 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3068 HasAngles, Angles, LinearVariation,
3069 HasRefPoint, RefPoint, MakeGroups, ElemType):
3070 Angles,AnglesParameters = ParseAngles(Angles)
3071 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3072 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3073 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3075 Parameters = AnglesParameters + var_separator + RefPointParameters
3076 self.mesh.SetParameters(Parameters)
3078 if isinstance(Base,list):
3080 if Base == []: IDsOfElements = self.GetElementsId()
3081 else: IDsOfElements = Base
3082 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3083 HasAngles, Angles, LinearVariation,
3084 HasRefPoint, RefPoint, MakeGroups, ElemType)
3086 if isinstance(Base,Mesh):
3087 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3088 HasAngles, Angles, LinearVariation,
3089 HasRefPoint, RefPoint, MakeGroups, ElemType)
3091 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3094 ## Generates new elements by extrusion of the given elements
3095 # The path of extrusion must be a meshed edge.
3096 # @param IDsOfElements ids of elements
3097 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3098 # @param PathShape shape(edge) defines the sub-mesh for the path
3099 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3100 # @param HasAngles allows the shape to be rotated around the path
3101 # to get the resulting mesh in a helical fashion
3102 # @param Angles list of angles in radians
3103 # @param HasRefPoint allows using the reference point
3104 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3105 # The User can specify any point as the Reference Point.
3106 # @param MakeGroups forces the generation of new groups from existing ones
3107 # @param LinearVariation forces the computation of rotation angles as linear
3108 # variation of the given Angles along path steps
3109 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3110 # only SMESH::Extrusion_Error otherwise
3111 # @ingroup l2_modif_extrurev
3112 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3113 HasAngles, Angles, HasRefPoint, RefPoint,
3114 MakeGroups=False, LinearVariation=False):
3115 Angles,AnglesParameters = ParseAngles(Angles)
3116 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3117 if IDsOfElements == []:
3118 IDsOfElements = self.GetElementsId()
3119 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3120 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3122 if ( isinstance( PathMesh, Mesh )):
3123 PathMesh = PathMesh.GetMesh()
3124 if HasAngles and Angles and LinearVariation:
3125 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3127 Parameters = AnglesParameters + var_separator + RefPointParameters
3128 self.mesh.SetParameters(Parameters)
3130 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3131 PathShape, NodeStart, HasAngles,
3132 Angles, HasRefPoint, RefPoint)
3133 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3134 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3136 ## Generates new elements by extrusion of the elements which belong to the object
3137 # The path of extrusion must be a meshed edge.
3138 # @param theObject the object which elements should be processed
3139 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3140 # @param PathShape shape(edge) defines the sub-mesh for the path
3141 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3142 # @param HasAngles allows the shape to be rotated around the path
3143 # to get the resulting mesh in a helical fashion
3144 # @param Angles list of angles
3145 # @param HasRefPoint allows using the reference point
3146 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3147 # The User can specify any point as the Reference Point.
3148 # @param MakeGroups forces the generation of new groups from existing ones
3149 # @param LinearVariation forces the computation of rotation angles as linear
3150 # variation of the given Angles along path steps
3151 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3152 # only SMESH::Extrusion_Error otherwise
3153 # @ingroup l2_modif_extrurev
3154 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3155 HasAngles, Angles, HasRefPoint, RefPoint,
3156 MakeGroups=False, LinearVariation=False):
3157 Angles,AnglesParameters = ParseAngles(Angles)
3158 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3159 if ( isinstance( theObject, Mesh )):
3160 theObject = theObject.GetMesh()
3161 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3162 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3163 if ( isinstance( PathMesh, Mesh )):
3164 PathMesh = PathMesh.GetMesh()
3165 if HasAngles and Angles and LinearVariation:
3166 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3168 Parameters = AnglesParameters + var_separator + RefPointParameters
3169 self.mesh.SetParameters(Parameters)
3171 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3172 PathShape, NodeStart, HasAngles,
3173 Angles, HasRefPoint, RefPoint)
3174 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3175 NodeStart, HasAngles, Angles, HasRefPoint,
3178 ## Generates new elements by extrusion of the elements which belong to the object
3179 # The path of extrusion must be a meshed edge.
3180 # @param theObject the object which elements should be processed
3181 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3182 # @param PathShape shape(edge) defines the sub-mesh for the path
3183 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3184 # @param HasAngles allows the shape to be rotated around the path
3185 # to get the resulting mesh in a helical fashion
3186 # @param Angles list of angles
3187 # @param HasRefPoint allows using the reference point
3188 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3189 # The User can specify any point as the Reference Point.
3190 # @param MakeGroups forces the generation of new groups from existing ones
3191 # @param LinearVariation forces the computation of rotation angles as linear
3192 # variation of the given Angles along path steps
3193 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3194 # only SMESH::Extrusion_Error otherwise
3195 # @ingroup l2_modif_extrurev
3196 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3197 HasAngles, Angles, HasRefPoint, RefPoint,
3198 MakeGroups=False, LinearVariation=False):
3199 Angles,AnglesParameters = ParseAngles(Angles)
3200 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3201 if ( isinstance( theObject, Mesh )):
3202 theObject = theObject.GetMesh()
3203 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3204 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3205 if ( isinstance( PathMesh, Mesh )):
3206 PathMesh = PathMesh.GetMesh()
3207 if HasAngles and Angles and LinearVariation:
3208 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3210 Parameters = AnglesParameters + var_separator + RefPointParameters
3211 self.mesh.SetParameters(Parameters)
3213 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3214 PathShape, NodeStart, HasAngles,
3215 Angles, HasRefPoint, RefPoint)
3216 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3217 NodeStart, HasAngles, Angles, HasRefPoint,
3220 ## Generates new elements by extrusion of the elements which belong to the object
3221 # The path of extrusion must be a meshed edge.
3222 # @param theObject the object which elements should be processed
3223 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3224 # @param PathShape shape(edge) defines the sub-mesh for the path
3225 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3226 # @param HasAngles allows the shape to be rotated around the path
3227 # to get the resulting mesh in a helical fashion
3228 # @param Angles list of angles
3229 # @param HasRefPoint allows using the reference point
3230 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3231 # The User can specify any point as the Reference Point.
3232 # @param MakeGroups forces the generation of new groups from existing ones
3233 # @param LinearVariation forces the computation of rotation angles as linear
3234 # variation of the given Angles along path steps
3235 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3236 # only SMESH::Extrusion_Error otherwise
3237 # @ingroup l2_modif_extrurev
3238 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3239 HasAngles, Angles, HasRefPoint, RefPoint,
3240 MakeGroups=False, LinearVariation=False):
3241 Angles,AnglesParameters = ParseAngles(Angles)
3242 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3243 if ( isinstance( theObject, Mesh )):
3244 theObject = theObject.GetMesh()
3245 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3246 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3247 if ( isinstance( PathMesh, Mesh )):
3248 PathMesh = PathMesh.GetMesh()
3249 if HasAngles and Angles and LinearVariation:
3250 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3252 Parameters = AnglesParameters + var_separator + RefPointParameters
3253 self.mesh.SetParameters(Parameters)
3255 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3256 PathShape, NodeStart, HasAngles,
3257 Angles, HasRefPoint, RefPoint)
3258 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3259 NodeStart, HasAngles, Angles, HasRefPoint,
3262 ## Creates a symmetrical copy of mesh elements
3263 # @param IDsOfElements list of elements ids
3264 # @param Mirror is AxisStruct or geom object(point, line, plane)
3265 # @param theMirrorType is POINT, AXIS or PLANE
3266 # If the Mirror is a geom object this parameter is unnecessary
3267 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3268 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3269 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3270 # @ingroup l2_modif_trsf
3271 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3272 if IDsOfElements == []:
3273 IDsOfElements = self.GetElementsId()
3274 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3275 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3276 Mirror,Parameters = ParseAxisStruct(Mirror)
3277 self.mesh.SetParameters(Parameters)
3278 if Copy and MakeGroups:
3279 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3280 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3283 ## Creates a new mesh by a symmetrical copy of mesh elements
3284 # @param IDsOfElements the list of elements ids
3285 # @param Mirror is AxisStruct or geom object (point, line, plane)
3286 # @param theMirrorType is POINT, AXIS or PLANE
3287 # If the Mirror is a geom object this parameter is unnecessary
3288 # @param MakeGroups to generate new groups from existing ones
3289 # @param NewMeshName a name of the new mesh to create
3290 # @return instance of Mesh class
3291 # @ingroup l2_modif_trsf
3292 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3293 if IDsOfElements == []:
3294 IDsOfElements = self.GetElementsId()
3295 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3296 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3297 Mirror,Parameters = ParseAxisStruct(Mirror)
3298 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3299 MakeGroups, NewMeshName)
3300 mesh.SetParameters(Parameters)
3301 return Mesh(self.smeshpyD,self.geompyD,mesh)
3303 ## Creates a symmetrical copy of the object
3304 # @param theObject mesh, submesh or group
3305 # @param Mirror AxisStruct or geom object (point, line, plane)
3306 # @param theMirrorType is POINT, AXIS or PLANE
3307 # If the Mirror is a geom object this parameter is unnecessary
3308 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3309 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3310 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3311 # @ingroup l2_modif_trsf
3312 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3313 if ( isinstance( theObject, Mesh )):
3314 theObject = theObject.GetMesh()
3315 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3316 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3317 Mirror,Parameters = ParseAxisStruct(Mirror)
3318 self.mesh.SetParameters(Parameters)
3319 if Copy and MakeGroups:
3320 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3321 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3324 ## Creates a new mesh by a symmetrical copy of the object
3325 # @param theObject mesh, submesh or group
3326 # @param Mirror AxisStruct or geom object (point, line, plane)
3327 # @param theMirrorType POINT, AXIS or PLANE
3328 # If the Mirror is a geom object this parameter is unnecessary
3329 # @param MakeGroups forces the generation of new groups from existing ones
3330 # @param NewMeshName the name of the new mesh to create
3331 # @return instance of Mesh class
3332 # @ingroup l2_modif_trsf
3333 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3334 if ( isinstance( theObject, Mesh )):
3335 theObject = theObject.GetMesh()
3336 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3337 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3338 Mirror,Parameters = ParseAxisStruct(Mirror)
3339 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3340 MakeGroups, NewMeshName)
3341 mesh.SetParameters(Parameters)
3342 return Mesh( self.smeshpyD,self.geompyD,mesh )
3344 ## Translates the elements
3345 # @param IDsOfElements list of elements ids
3346 # @param Vector the direction of translation (DirStruct or vector)
3347 # @param Copy allows copying the translated elements
3348 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3349 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3350 # @ingroup l2_modif_trsf
3351 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3352 if IDsOfElements == []:
3353 IDsOfElements = self.GetElementsId()
3354 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3355 Vector = self.smeshpyD.GetDirStruct(Vector)
3356 Vector,Parameters = ParseDirStruct(Vector)
3357 self.mesh.SetParameters(Parameters)
3358 if Copy and MakeGroups:
3359 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3360 self.editor.Translate(IDsOfElements, Vector, Copy)
3363 ## Creates a new mesh of translated elements
3364 # @param IDsOfElements list of elements ids
3365 # @param Vector the direction of translation (DirStruct or vector)
3366 # @param MakeGroups forces the generation of new groups from existing ones
3367 # @param NewMeshName the name of the newly created mesh
3368 # @return instance of Mesh class
3369 # @ingroup l2_modif_trsf
3370 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3371 if IDsOfElements == []:
3372 IDsOfElements = self.GetElementsId()
3373 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3374 Vector = self.smeshpyD.GetDirStruct(Vector)
3375 Vector,Parameters = ParseDirStruct(Vector)
3376 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3377 mesh.SetParameters(Parameters)
3378 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3380 ## Translates the object
3381 # @param theObject the object to translate (mesh, submesh, or group)
3382 # @param Vector direction of translation (DirStruct or geom vector)
3383 # @param Copy allows copying the translated elements
3384 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3385 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3386 # @ingroup l2_modif_trsf
3387 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3388 if ( isinstance( theObject, Mesh )):
3389 theObject = theObject.GetMesh()
3390 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3391 Vector = self.smeshpyD.GetDirStruct(Vector)
3392 Vector,Parameters = ParseDirStruct(Vector)
3393 self.mesh.SetParameters(Parameters)
3394 if Copy and MakeGroups:
3395 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3396 self.editor.TranslateObject(theObject, Vector, Copy)
3399 ## Creates a new mesh from the translated object
3400 # @param theObject the object to translate (mesh, submesh, or group)
3401 # @param Vector the direction of translation (DirStruct or geom vector)
3402 # @param MakeGroups forces the generation of new groups from existing ones
3403 # @param NewMeshName the name of the newly created mesh
3404 # @return instance of Mesh class
3405 # @ingroup l2_modif_trsf
3406 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3407 if (isinstance(theObject, Mesh)):
3408 theObject = theObject.GetMesh()
3409 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3410 Vector = self.smeshpyD.GetDirStruct(Vector)
3411 Vector,Parameters = ParseDirStruct(Vector)
3412 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3413 mesh.SetParameters(Parameters)
3414 return Mesh( self.smeshpyD, self.geompyD, mesh )
3418 ## Scales the object
3419 # @param theObject - the object to translate (mesh, submesh, or group)
3420 # @param thePoint - base point for scale
3421 # @param theScaleFact - list of 1-3 scale factors for axises
3422 # @param Copy - allows copying the translated elements
3423 # @param MakeGroups - forces the generation of new groups from existing
3425 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3426 # empty list otherwise
3427 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3428 if ( isinstance( theObject, Mesh )):
3429 theObject = theObject.GetMesh()
3430 if ( isinstance( theObject, list )):
3431 theObject = self.editor.MakeIDSource(theObject)
3433 thePoint, Parameters = ParsePointStruct(thePoint)
3434 self.mesh.SetParameters(Parameters)
3436 if Copy and MakeGroups:
3437 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3438 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3441 ## Creates a new mesh from the translated object
3442 # @param theObject - the object to translate (mesh, submesh, or group)
3443 # @param thePoint - base point for scale
3444 # @param theScaleFact - list of 1-3 scale factors for axises
3445 # @param MakeGroups - forces the generation of new groups from existing ones
3446 # @param NewMeshName - the name of the newly created mesh
3447 # @return instance of Mesh class
3448 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3449 if (isinstance(theObject, Mesh)):
3450 theObject = theObject.GetMesh()
3451 if ( isinstance( theObject, list )):
3452 theObject = self.editor.MakeIDSource(theObject)
3454 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3455 MakeGroups, NewMeshName)
3456 #mesh.SetParameters(Parameters)
3457 return Mesh( self.smeshpyD, self.geompyD, mesh )
3461 ## Rotates the elements
3462 # @param IDsOfElements list of elements ids
3463 # @param Axis the axis of rotation (AxisStruct or geom line)
3464 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3465 # @param Copy allows copying the rotated elements
3466 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3467 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3468 # @ingroup l2_modif_trsf
3469 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3471 if isinstance(AngleInRadians,str):
3473 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3475 AngleInRadians = DegreesToRadians(AngleInRadians)
3476 if IDsOfElements == []:
3477 IDsOfElements = self.GetElementsId()
3478 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3479 Axis = self.smeshpyD.GetAxisStruct(Axis)
3480 Axis,AxisParameters = ParseAxisStruct(Axis)
3481 Parameters = AxisParameters + var_separator + Parameters
3482 self.mesh.SetParameters(Parameters)
3483 if Copy and MakeGroups:
3484 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3485 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3488 ## Creates a new mesh of rotated elements
3489 # @param IDsOfElements list of element ids
3490 # @param Axis the axis of rotation (AxisStruct or geom line)
3491 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3492 # @param MakeGroups forces the generation of new groups from existing ones
3493 # @param NewMeshName the name of the newly created mesh
3494 # @return instance of Mesh class
3495 # @ingroup l2_modif_trsf
3496 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3498 if isinstance(AngleInRadians,str):
3500 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3502 AngleInRadians = DegreesToRadians(AngleInRadians)
3503 if IDsOfElements == []:
3504 IDsOfElements = self.GetElementsId()
3505 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3506 Axis = self.smeshpyD.GetAxisStruct(Axis)
3507 Axis,AxisParameters = ParseAxisStruct(Axis)
3508 Parameters = AxisParameters + var_separator + Parameters
3509 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3510 MakeGroups, NewMeshName)
3511 mesh.SetParameters(Parameters)
3512 return Mesh( self.smeshpyD, self.geompyD, mesh )
3514 ## Rotates the object
3515 # @param theObject the object to rotate( mesh, submesh, or group)
3516 # @param Axis the axis of rotation (AxisStruct or geom line)
3517 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3518 # @param Copy allows copying the rotated elements
3519 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3520 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3521 # @ingroup l2_modif_trsf
3522 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3524 if isinstance(AngleInRadians,str):
3526 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3528 AngleInRadians = DegreesToRadians(AngleInRadians)
3529 if (isinstance(theObject, Mesh)):
3530 theObject = theObject.GetMesh()
3531 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3532 Axis = self.smeshpyD.GetAxisStruct(Axis)
3533 Axis,AxisParameters = ParseAxisStruct(Axis)
3534 Parameters = AxisParameters + ":" + Parameters
3535 self.mesh.SetParameters(Parameters)
3536 if Copy and MakeGroups:
3537 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3538 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3541 ## Creates a new mesh from the rotated object
3542 # @param theObject the object to rotate (mesh, submesh, or group)
3543 # @param Axis the axis of rotation (AxisStruct or geom line)
3544 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3545 # @param MakeGroups forces the generation of new groups from existing ones
3546 # @param NewMeshName the name of the newly created mesh
3547 # @return instance of Mesh class
3548 # @ingroup l2_modif_trsf
3549 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3551 if isinstance(AngleInRadians,str):
3553 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3555 AngleInRadians = DegreesToRadians(AngleInRadians)
3556 if (isinstance( theObject, Mesh )):
3557 theObject = theObject.GetMesh()
3558 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3559 Axis = self.smeshpyD.GetAxisStruct(Axis)
3560 Axis,AxisParameters = ParseAxisStruct(Axis)
3561 Parameters = AxisParameters + ":" + Parameters
3562 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3563 MakeGroups, NewMeshName)
3564 mesh.SetParameters(Parameters)
3565 return Mesh( self.smeshpyD, self.geompyD, mesh )
3567 ## Finds groups of ajacent nodes within Tolerance.
3568 # @param Tolerance the value of tolerance
3569 # @return the list of groups of nodes
3570 # @ingroup l2_modif_trsf
3571 def FindCoincidentNodes (self, Tolerance):
3572 return self.editor.FindCoincidentNodes(Tolerance)
3574 ## Finds groups of ajacent nodes within Tolerance.
3575 # @param Tolerance the value of tolerance
3576 # @param SubMeshOrGroup SubMesh or Group
3577 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3578 # @return the list of groups of nodes
3579 # @ingroup l2_modif_trsf
3580 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3581 if (isinstance( SubMeshOrGroup, Mesh )):
3582 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3583 if not isinstance( ExceptSubMeshOrGroups, list):
3584 ExceptSubMeshOrGroups = [ ExceptSubMeshOrGroups ]
3585 if ExceptSubMeshOrGroups and isinstance( ExceptSubMeshOrGroups[0], int):
3586 ExceptSubMeshOrGroups = [ self.editor.MakeIDSource( ExceptSubMeshOrGroups, SMESH.NODE)]
3587 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,ExceptSubMeshOrGroups)
3590 # @param GroupsOfNodes the list of groups of nodes
3591 # @ingroup l2_modif_trsf
3592 def MergeNodes (self, GroupsOfNodes):
3593 self.editor.MergeNodes(GroupsOfNodes)
3595 ## Finds the elements built on the same nodes.
3596 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3597 # @return a list of groups of equal elements
3598 # @ingroup l2_modif_trsf
3599 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3600 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3601 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3602 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3604 ## Merges elements in each given group.
3605 # @param GroupsOfElementsID groups of elements for merging
3606 # @ingroup l2_modif_trsf
3607 def MergeElements(self, GroupsOfElementsID):
3608 self.editor.MergeElements(GroupsOfElementsID)
3610 ## Leaves one element and removes all other elements built on the same nodes.
3611 # @ingroup l2_modif_trsf
3612 def MergeEqualElements(self):
3613 self.editor.MergeEqualElements()
3615 ## Sews free borders
3616 # @return SMESH::Sew_Error
3617 # @ingroup l2_modif_trsf
3618 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3619 FirstNodeID2, SecondNodeID2, LastNodeID2,
3620 CreatePolygons, CreatePolyedrs):
3621 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3622 FirstNodeID2, SecondNodeID2, LastNodeID2,
3623 CreatePolygons, CreatePolyedrs)
3625 ## Sews conform free borders
3626 # @return SMESH::Sew_Error
3627 # @ingroup l2_modif_trsf
3628 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3629 FirstNodeID2, SecondNodeID2):
3630 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3631 FirstNodeID2, SecondNodeID2)
3633 ## Sews border to side
3634 # @return SMESH::Sew_Error
3635 # @ingroup l2_modif_trsf
3636 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3637 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3638 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3639 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3641 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3642 # merged with the nodes of elements of Side2.
3643 # The number of elements in theSide1 and in theSide2 must be
3644 # equal and they should have similar nodal connectivity.
3645 # The nodes to merge should belong to side borders and
3646 # the first node should be linked to the second.
3647 # @return SMESH::Sew_Error
3648 # @ingroup l2_modif_trsf
3649 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3650 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3651 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3652 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3653 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3654 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3656 ## Sets new nodes for the given element.
3657 # @param ide the element id
3658 # @param newIDs nodes ids
3659 # @return If the number of nodes does not correspond to the type of element - returns false
3660 # @ingroup l2_modif_edit
3661 def ChangeElemNodes(self, ide, newIDs):
3662 return self.editor.ChangeElemNodes(ide, newIDs)
3664 ## If during the last operation of MeshEditor some nodes were
3665 # created, this method returns the list of their IDs, \n
3666 # if new nodes were not created - returns empty list
3667 # @return the list of integer values (can be empty)
3668 # @ingroup l1_auxiliary
3669 def GetLastCreatedNodes(self):
3670 return self.editor.GetLastCreatedNodes()
3672 ## If during the last operation of MeshEditor some elements were
3673 # created this method returns the list of their IDs, \n
3674 # if new elements were not created - returns empty list
3675 # @return the list of integer values (can be empty)
3676 # @ingroup l1_auxiliary
3677 def GetLastCreatedElems(self):
3678 return self.editor.GetLastCreatedElems()
3680 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3681 # @param theNodes identifiers of nodes to be doubled
3682 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3683 # nodes. If list of element identifiers is empty then nodes are doubled but
3684 # they not assigned to elements
3685 # @return TRUE if operation has been completed successfully, FALSE otherwise
3686 # @ingroup l2_modif_edit
3687 def DoubleNodes(self, theNodes, theModifiedElems):
3688 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3690 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3691 # This method provided for convenience works as DoubleNodes() described above.
3692 # @param theNodeId identifiers of node to be doubled
3693 # @param theModifiedElems identifiers of elements to be updated
3694 # @return TRUE if operation has been completed successfully, FALSE otherwise
3695 # @ingroup l2_modif_edit
3696 def DoubleNode(self, theNodeId, theModifiedElems):
3697 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3699 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3700 # This method provided for convenience works as DoubleNodes() described above.
3701 # @param theNodes group of nodes to be doubled
3702 # @param theModifiedElems group of elements to be updated.
3703 # @param theMakeGroup forces the generation of a group containing new nodes.
3704 # @return TRUE or a created group if operation has been completed successfully,
3705 # FALSE or None otherwise
3706 # @ingroup l2_modif_edit
3707 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
3709 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
3710 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3712 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3713 # This method provided for convenience works as DoubleNodes() described above.
3714 # @param theNodes list of groups of nodes to be doubled
3715 # @param theModifiedElems list of groups of elements to be updated.
3716 # @return TRUE if operation has been completed successfully, FALSE otherwise
3717 # @ingroup l2_modif_edit
3718 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3719 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3721 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3722 # @param theElems - the list of elements (edges or faces) to be replicated
3723 # The nodes for duplication could be found from these elements
3724 # @param theNodesNot - list of nodes to NOT replicate
3725 # @param theAffectedElems - the list of elements (cells and edges) to which the
3726 # replicated nodes should be associated to.
3727 # @return TRUE if operation has been completed successfully, FALSE otherwise
3728 # @ingroup l2_modif_edit
3729 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3730 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3732 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3733 # @param theElems - the list of elements (edges or faces) to be replicated
3734 # The nodes for duplication could be found from these elements
3735 # @param theNodesNot - list of nodes to NOT replicate
3736 # @param theShape - shape to detect affected elements (element which geometric center
3737 # located on or inside shape).
3738 # The replicated nodes should be associated to affected elements.
3739 # @return TRUE if operation has been completed successfully, FALSE otherwise
3740 # @ingroup l2_modif_edit
3741 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3742 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3744 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3745 # This method provided for convenience works as DoubleNodes() described above.
3746 # @param theElems - group of of elements (edges or faces) to be replicated
3747 # @param theNodesNot - group of nodes not to replicated
3748 # @param theAffectedElems - group of elements to which the replicated nodes
3749 # should be associated to.
3750 # @param theMakeGroup forces the generation of a group containing new elements.
3751 # @ingroup l2_modif_edit
3752 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
3754 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
3755 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3757 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3758 # This method provided for convenience works as DoubleNodes() described above.
3759 # @param theElems - group of of elements (edges or faces) to be replicated
3760 # @param theNodesNot - group of nodes not to replicated
3761 # @param theShape - shape to detect affected elements (element which geometric center
3762 # located on or inside shape).
3763 # The replicated nodes should be associated to affected elements.
3764 # @ingroup l2_modif_edit
3765 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3766 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3768 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3769 # This method provided for convenience works as DoubleNodes() described above.
3770 # @param theElems - list of groups of elements (edges or faces) to be replicated
3771 # @param theNodesNot - list of groups of nodes not to replicated
3772 # @param theAffectedElems - group of elements to which the replicated nodes
3773 # should be associated to.
3774 # @return TRUE if operation has been completed successfully, FALSE otherwise
3775 # @ingroup l2_modif_edit
3776 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3777 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3779 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3780 # This method provided for convenience works as DoubleNodes() described above.
3781 # @param theElems - list of groups of elements (edges or faces) to be replicated
3782 # @param theNodesNot - list of groups of nodes not to replicated
3783 # @param theShape - shape to detect affected elements (element which geometric center
3784 # located on or inside shape).
3785 # The replicated nodes should be associated to affected elements.
3786 # @return TRUE if operation has been completed successfully, FALSE otherwise
3787 # @ingroup l2_modif_edit
3788 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3789 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3791 ## The mother class to define algorithm, it is not recommended to use it directly.
3794 # @ingroup l2_algorithms
3795 class Mesh_Algorithm:
3796 # @class Mesh_Algorithm
3797 # @brief Class Mesh_Algorithm
3799 #def __init__(self,smesh):
3807 ## Finds a hypothesis in the study by its type name and parameters.
3808 # Finds only the hypotheses created in smeshpyD engine.
3809 # @return SMESH.SMESH_Hypothesis
3810 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3811 study = smeshpyD.GetCurrentStudy()
3812 #to do: find component by smeshpyD object, not by its data type
3813 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3814 if scomp is not None:
3815 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3816 # Check if the root label of the hypotheses exists
3817 if res and hypRoot is not None:
3818 iter = study.NewChildIterator(hypRoot)
3819 # Check all published hypotheses
3821 hypo_so_i = iter.Value()
3822 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3823 if attr is not None:
3824 anIOR = attr.Value()
3825 hypo_o_i = salome.orb.string_to_object(anIOR)
3826 if hypo_o_i is not None:
3827 # Check if this is a hypothesis
3828 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3829 if hypo_i is not None:
3830 # Check if the hypothesis belongs to current engine
3831 if smeshpyD.GetObjectId(hypo_i) > 0:
3832 # Check if this is the required hypothesis
3833 if hypo_i.GetName() == hypname:
3835 if CompareMethod(hypo_i, args):
3849 ## Finds the algorithm in the study by its type name.
3850 # Finds only the algorithms, which have been created in smeshpyD engine.
3851 # @return SMESH.SMESH_Algo
3852 def FindAlgorithm (self, algoname, smeshpyD):
3853 study = smeshpyD.GetCurrentStudy()
3854 #to do: find component by smeshpyD object, not by its data type
3855 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3856 if scomp is not None:
3857 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3858 # Check if the root label of the algorithms exists
3859 if res and hypRoot is not None:
3860 iter = study.NewChildIterator(hypRoot)
3861 # Check all published algorithms
3863 algo_so_i = iter.Value()
3864 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3865 if attr is not None:
3866 anIOR = attr.Value()
3867 algo_o_i = salome.orb.string_to_object(anIOR)
3868 if algo_o_i is not None:
3869 # Check if this is an algorithm
3870 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3871 if algo_i is not None:
3872 # Checks if the algorithm belongs to the current engine
3873 if smeshpyD.GetObjectId(algo_i) > 0:
3874 # Check if this is the required algorithm
3875 if algo_i.GetName() == algoname:
3888 ## If the algorithm is global, returns 0; \n
3889 # else returns the submesh associated to this algorithm.
3890 def GetSubMesh(self):
3893 ## Returns the wrapped mesher.
3894 def GetAlgorithm(self):
3897 ## Gets the list of hypothesis that can be used with this algorithm
3898 def GetCompatibleHypothesis(self):
3901 mylist = self.algo.GetCompatibleHypothesis()
3904 ## Gets the name of the algorithm
3908 ## Sets the name to the algorithm
3909 def SetName(self, name):
3910 self.mesh.smeshpyD.SetName(self.algo, name)
3912 ## Gets the id of the algorithm
3914 return self.algo.GetId()
3917 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3919 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3920 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3922 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3924 self.Assign(algo, mesh, geom)
3928 def Assign(self, algo, mesh, geom):
3930 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3939 name = GetName(geom)
3942 name = mesh.geompyD.SubShapeName(geom, piece)
3943 mesh.geompyD.addToStudyInFather(piece, geom, name)
3945 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3948 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3949 TreatHypoStatus( status, algo.GetName(), name, True )
3951 def CompareHyp (self, hyp, args):
3952 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3955 def CompareEqualHyp (self, hyp, args):
3959 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3960 UseExisting=0, CompareMethod=""):
3963 if CompareMethod == "": CompareMethod = self.CompareHyp
3964 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3967 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3973 a = a + s + str(args[i])
3977 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3979 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3980 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3983 ## Returns entry of the shape to mesh in the study
3984 def MainShapeEntry(self):
3986 if not self.mesh or not self.mesh.GetMesh(): return entry
3987 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3988 study = self.mesh.smeshpyD.GetCurrentStudy()
3989 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3990 sobj = study.FindObjectIOR(ior)
3991 if sobj: entry = sobj.GetID()
3992 if not entry: return ""
3995 # Public class: Mesh_Segment
3996 # --------------------------
3998 ## Class to define a segment 1D algorithm for discretization
4001 # @ingroup l3_algos_basic
4002 class Mesh_Segment(Mesh_Algorithm):
4004 ## Private constructor.
4005 def __init__(self, mesh, geom=0):
4006 Mesh_Algorithm.__init__(self)
4007 self.Create(mesh, geom, "Regular_1D")
4009 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4010 # @param l for the length of segments that cut an edge
4011 # @param UseExisting if ==true - searches for an existing hypothesis created with
4012 # the same parameters, else (default) - creates a new one
4013 # @param p precision, used for calculation of the number of segments.
4014 # The precision should be a positive, meaningful value within the range [0,1].
4015 # In general, the number of segments is calculated with the formula:
4016 # nb = ceil((edge_length / l) - p)
4017 # Function ceil rounds its argument to the higher integer.
4018 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4019 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4020 # p=1 means rounding of (edge_length / l) to the lower integer.
4021 # Default value is 1e-07.
4022 # @return an instance of StdMeshers_LocalLength hypothesis
4023 # @ingroup l3_hypos_1dhyps
4024 def LocalLength(self, l, UseExisting=0, p=1e-07):
4025 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4026 CompareMethod=self.CompareLocalLength)
4032 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4033 def CompareLocalLength(self, hyp, args):
4034 if IsEqual(hyp.GetLength(), args[0]):
4035 return IsEqual(hyp.GetPrecision(), args[1])
4038 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4039 # @param length is optional maximal allowed length of segment, if it is omitted
4040 # the preestimated length is used that depends on geometry size
4041 # @param UseExisting if ==true - searches for an existing hypothesis created with
4042 # the same parameters, else (default) - create a new one
4043 # @return an instance of StdMeshers_MaxLength hypothesis
4044 # @ingroup l3_hypos_1dhyps
4045 def MaxSize(self, length=0.0, UseExisting=0):
4046 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4049 hyp.SetLength(length)
4051 # set preestimated length
4052 gen = self.mesh.smeshpyD
4053 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4054 self.mesh.GetMesh(), self.mesh.GetShape(),
4056 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4058 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4061 hyp.SetUsePreestimatedLength( length == 0.0 )
4064 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4065 # @param n for the number of segments that cut an edge
4066 # @param s for the scale factor (optional)
4067 # @param reversedEdges is a list of edges to mesh using reversed orientation
4068 # @param UseExisting if ==true - searches for an existing hypothesis created with
4069 # the same parameters, else (default) - create a new one
4070 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4071 # @ingroup l3_hypos_1dhyps
4072 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4073 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4074 reversedEdges, UseExisting = [], reversedEdges
4075 entry = self.MainShapeEntry()
4077 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4078 UseExisting=UseExisting,
4079 CompareMethod=self.CompareNumberOfSegments)
4081 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4082 UseExisting=UseExisting,
4083 CompareMethod=self.CompareNumberOfSegments)
4084 hyp.SetDistrType( 1 )
4085 hyp.SetScaleFactor(s)
4086 hyp.SetNumberOfSegments(n)
4087 hyp.SetReversedEdges( reversedEdges )
4088 hyp.SetObjectEntry( entry )
4092 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4093 def CompareNumberOfSegments(self, hyp, args):
4094 if hyp.GetNumberOfSegments() == args[0]:
4096 if hyp.GetReversedEdges() == args[1]:
4097 if not args[1] or hyp.GetObjectEntry() == args[2]:
4100 if hyp.GetReversedEdges() == args[2]:
4101 if not args[2] or hyp.GetObjectEntry() == args[3]:
4102 if hyp.GetDistrType() == 1:
4103 if IsEqual(hyp.GetScaleFactor(), args[1]):
4107 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4108 # @param start defines the length of the first segment
4109 # @param end defines the length of the last segment
4110 # @param reversedEdges is a list of edges to mesh using reversed orientation
4111 # @param UseExisting if ==true - searches for an existing hypothesis created with
4112 # the same parameters, else (default) - creates a new one
4113 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4114 # @ingroup l3_hypos_1dhyps
4115 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4116 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4117 reversedEdges, UseExisting = [], reversedEdges
4118 entry = self.MainShapeEntry()
4119 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4120 UseExisting=UseExisting,
4121 CompareMethod=self.CompareArithmetic1D)
4122 hyp.SetStartLength(start)
4123 hyp.SetEndLength(end)
4124 hyp.SetReversedEdges( reversedEdges )
4125 hyp.SetObjectEntry( entry )
4129 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4130 def CompareArithmetic1D(self, hyp, args):
4131 if IsEqual(hyp.GetLength(1), args[0]):
4132 if IsEqual(hyp.GetLength(0), args[1]):
4133 if hyp.GetReversedEdges() == args[2]:
4134 if not args[2] or hyp.GetObjectEntry() == args[3]:
4139 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4140 # on curve from 0 to 1 (additionally it is neecessary to check
4141 # orientation of edges and create list of reversed edges if it is
4142 # needed) and sets numbers of segments between given points (default
4143 # values are equals 1
4144 # @param points defines the list of parameters on curve
4145 # @param nbSegs defines the list of numbers of segments
4146 # @param reversedEdges is a list of edges to mesh using reversed orientation
4147 # @param UseExisting if ==true - searches for an existing hypothesis created with
4148 # the same parameters, else (default) - creates a new one
4149 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4150 # @ingroup l3_hypos_1dhyps
4151 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4152 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4153 reversedEdges, UseExisting = [], reversedEdges
4154 if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4155 for i in range( len( reversedEdges )):
4156 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4157 entry = self.MainShapeEntry()
4158 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4159 UseExisting=UseExisting,
4160 CompareMethod=self.CompareFixedPoints1D)
4161 hyp.SetPoints(points)
4162 hyp.SetNbSegments(nbSegs)
4163 hyp.SetReversedEdges(reversedEdges)
4164 hyp.SetObjectEntry(entry)
4168 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4169 ## as the given arguments
4170 def CompareFixedPoints1D(self, hyp, args):
4171 if hyp.GetPoints() == args[0]:
4172 if hyp.GetNbSegments() == args[1]:
4173 if hyp.GetReversedEdges() == args[2]:
4174 if not args[2] or hyp.GetObjectEntry() == args[3]:
4180 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4181 # @param start defines the length of the first segment
4182 # @param end defines the length of the last segment
4183 # @param reversedEdges is a list of edges to mesh using reversed orientation
4184 # @param UseExisting if ==true - searches for an existing hypothesis created with
4185 # the same parameters, else (default) - creates a new one
4186 # @return an instance of StdMeshers_StartEndLength hypothesis
4187 # @ingroup l3_hypos_1dhyps
4188 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4189 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4190 reversedEdges, UseExisting = [], reversedEdges
4191 entry = self.MainShapeEntry()
4192 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4193 UseExisting=UseExisting,
4194 CompareMethod=self.CompareStartEndLength)
4195 hyp.SetStartLength(start)
4196 hyp.SetEndLength(end)
4197 hyp.SetReversedEdges( reversedEdges )
4198 hyp.SetObjectEntry( entry )
4201 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4202 def CompareStartEndLength(self, hyp, args):
4203 if IsEqual(hyp.GetLength(1), args[0]):
4204 if IsEqual(hyp.GetLength(0), args[1]):
4205 if hyp.GetReversedEdges() == args[2]:
4206 if not args[2] or hyp.GetObjectEntry() == args[3]:
4210 ## Defines "Deflection1D" hypothesis
4211 # @param d for the deflection
4212 # @param UseExisting if ==true - searches for an existing hypothesis created with
4213 # the same parameters, else (default) - create a new one
4214 # @ingroup l3_hypos_1dhyps
4215 def Deflection1D(self, d, UseExisting=0):
4216 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4217 CompareMethod=self.CompareDeflection1D)
4218 hyp.SetDeflection(d)
4221 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4222 def CompareDeflection1D(self, hyp, args):
4223 return IsEqual(hyp.GetDeflection(), args[0])
4225 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4226 # the opposite side in case of quadrangular faces
4227 # @ingroup l3_hypos_additi
4228 def Propagation(self):
4229 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4231 ## Defines "AutomaticLength" hypothesis
4232 # @param fineness for the fineness [0-1]
4233 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4234 # same parameters, else (default) - create a new one
4235 # @ingroup l3_hypos_1dhyps
4236 def AutomaticLength(self, fineness=0, UseExisting=0):
4237 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4238 CompareMethod=self.CompareAutomaticLength)
4239 hyp.SetFineness( fineness )
4242 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4243 def CompareAutomaticLength(self, hyp, args):
4244 return IsEqual(hyp.GetFineness(), args[0])
4246 ## Defines "SegmentLengthAroundVertex" hypothesis
4247 # @param length for the segment length
4248 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4249 # Any other integer value means that the hypothesis will be set on the
4250 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4251 # @param UseExisting if ==true - searches for an existing hypothesis created with
4252 # the same parameters, else (default) - creates a new one
4253 # @ingroup l3_algos_segmarv
4254 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4256 store_geom = self.geom
4257 if type(vertex) is types.IntType:
4258 if vertex == 0 or vertex == 1:
4259 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4267 if self.geom is None:
4268 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4270 name = GetName(self.geom)
4273 piece = self.mesh.geom
4274 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4275 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4277 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4279 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4281 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4282 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4284 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4285 CompareMethod=self.CompareLengthNearVertex)
4286 self.geom = store_geom
4287 hyp.SetLength( length )
4290 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4291 # @ingroup l3_algos_segmarv
4292 def CompareLengthNearVertex(self, hyp, args):
4293 return IsEqual(hyp.GetLength(), args[0])
4295 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4296 # If the 2D mesher sees that all boundary edges are quadratic,
4297 # it generates quadratic faces, else it generates linear faces using
4298 # medium nodes as if they are vertices.
4299 # The 3D mesher generates quadratic volumes only if all boundary faces
4300 # are quadratic, else it fails.
4302 # @ingroup l3_hypos_additi
4303 def QuadraticMesh(self):
4304 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4307 # Public class: Mesh_CompositeSegment
4308 # --------------------------
4310 ## Defines a segment 1D algorithm for discretization
4312 # @ingroup l3_algos_basic
4313 class Mesh_CompositeSegment(Mesh_Segment):
4315 ## Private constructor.
4316 def __init__(self, mesh, geom=0):
4317 self.Create(mesh, geom, "CompositeSegment_1D")
4320 # Public class: Mesh_Segment_Python
4321 # ---------------------------------
4323 ## Defines a segment 1D algorithm for discretization with python function
4325 # @ingroup l3_algos_basic
4326 class Mesh_Segment_Python(Mesh_Segment):
4328 ## Private constructor.
4329 def __init__(self, mesh, geom=0):
4330 import Python1dPlugin
4331 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4333 ## Defines "PythonSplit1D" hypothesis
4334 # @param n for the number of segments that cut an edge
4335 # @param func for the python function that calculates the length of all segments
4336 # @param UseExisting if ==true - searches for the existing hypothesis created with
4337 # the same parameters, else (default) - creates a new one
4338 # @ingroup l3_hypos_1dhyps
4339 def PythonSplit1D(self, n, func, UseExisting=0):
4340 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4341 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4342 hyp.SetNumberOfSegments(n)
4343 hyp.SetPythonLog10RatioFunction(func)
4346 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4347 def ComparePythonSplit1D(self, hyp, args):
4348 #if hyp.GetNumberOfSegments() == args[0]:
4349 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4353 # Public class: Mesh_Triangle
4354 # ---------------------------
4356 ## Defines a triangle 2D algorithm
4358 # @ingroup l3_algos_basic
4359 class Mesh_Triangle(Mesh_Algorithm):
4368 ## Private constructor.
4369 def __init__(self, mesh, algoType, geom=0):
4370 Mesh_Algorithm.__init__(self)
4372 self.algoType = algoType
4373 if algoType == MEFISTO:
4374 self.Create(mesh, geom, "MEFISTO_2D")
4376 elif algoType == BLSURF:
4378 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4379 #self.SetPhysicalMesh() - PAL19680
4380 elif algoType == NETGEN:
4382 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4384 elif algoType == NETGEN_2D:
4386 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4389 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4390 # @param area for the maximum area of each triangle
4391 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4392 # same parameters, else (default) - creates a new one
4394 # Only for algoType == MEFISTO || NETGEN_2D
4395 # @ingroup l3_hypos_2dhyps
4396 def MaxElementArea(self, area, UseExisting=0):
4397 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4398 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4399 CompareMethod=self.CompareMaxElementArea)
4400 elif self.algoType == NETGEN:
4401 hyp = self.Parameters(SIMPLE)
4402 hyp.SetMaxElementArea(area)
4405 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4406 def CompareMaxElementArea(self, hyp, args):
4407 return IsEqual(hyp.GetMaxElementArea(), args[0])
4409 ## Defines "LengthFromEdges" hypothesis to build triangles
4410 # based on the length of the edges taken from the wire
4412 # Only for algoType == MEFISTO || NETGEN_2D
4413 # @ingroup l3_hypos_2dhyps
4414 def LengthFromEdges(self):
4415 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4416 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4418 elif self.algoType == NETGEN:
4419 hyp = self.Parameters(SIMPLE)
4420 hyp.LengthFromEdges()
4423 ## Sets a way to define size of mesh elements to generate.
4424 # @param thePhysicalMesh is: DefaultSize or Custom.
4425 # @ingroup l3_hypos_blsurf
4426 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4427 # Parameter of BLSURF algo
4428 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4430 ## Sets size of mesh elements to generate.
4431 # @ingroup l3_hypos_blsurf
4432 def SetPhySize(self, theVal):
4433 # Parameter of BLSURF algo
4434 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4435 self.Parameters().SetPhySize(theVal)
4437 ## Sets lower boundary of mesh element size (PhySize).
4438 # @ingroup l3_hypos_blsurf
4439 def SetPhyMin(self, theVal=-1):
4440 # Parameter of BLSURF algo
4441 self.Parameters().SetPhyMin(theVal)
4443 ## Sets upper boundary of mesh element size (PhySize).
4444 # @ingroup l3_hypos_blsurf
4445 def SetPhyMax(self, theVal=-1):
4446 # Parameter of BLSURF algo
4447 self.Parameters().SetPhyMax(theVal)
4449 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4450 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4451 # @ingroup l3_hypos_blsurf
4452 def SetGeometricMesh(self, theGeometricMesh=0):
4453 # Parameter of BLSURF algo
4454 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4455 self.params.SetGeometricMesh(theGeometricMesh)
4457 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4458 # @ingroup l3_hypos_blsurf
4459 def SetAngleMeshS(self, theVal=_angleMeshS):
4460 # Parameter of BLSURF algo
4461 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4462 self.params.SetAngleMeshS(theVal)
4464 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4465 # @ingroup l3_hypos_blsurf
4466 def SetAngleMeshC(self, theVal=_angleMeshS):
4467 # Parameter of BLSURF algo
4468 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4469 self.params.SetAngleMeshC(theVal)
4471 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4472 # @ingroup l3_hypos_blsurf
4473 def SetGeoMin(self, theVal=-1):
4474 # Parameter of BLSURF algo
4475 self.Parameters().SetGeoMin(theVal)
4477 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4478 # @ingroup l3_hypos_blsurf
4479 def SetGeoMax(self, theVal=-1):
4480 # Parameter of BLSURF algo
4481 self.Parameters().SetGeoMax(theVal)
4483 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4484 # @ingroup l3_hypos_blsurf
4485 def SetGradation(self, theVal=_gradation):
4486 # Parameter of BLSURF algo
4487 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4488 self.params.SetGradation(theVal)
4490 ## Sets topology usage way.
4491 # @param way defines how mesh conformity is assured <ul>
4492 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4493 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4494 # @ingroup l3_hypos_blsurf
4495 def SetTopology(self, way):
4496 # Parameter of BLSURF algo
4497 self.Parameters().SetTopology(way)
4499 ## To respect geometrical edges or not.
4500 # @ingroup l3_hypos_blsurf
4501 def SetDecimesh(self, toIgnoreEdges=False):
4502 # Parameter of BLSURF algo
4503 self.Parameters().SetDecimesh(toIgnoreEdges)
4505 ## Sets verbosity level in the range 0 to 100.
4506 # @ingroup l3_hypos_blsurf
4507 def SetVerbosity(self, level):
4508 # Parameter of BLSURF algo
4509 self.Parameters().SetVerbosity(level)
4511 ## Sets advanced option value.
4512 # @ingroup l3_hypos_blsurf
4513 def SetOptionValue(self, optionName, level):
4514 # Parameter of BLSURF algo
4515 self.Parameters().SetOptionValue(optionName,level)
4517 ## Sets QuadAllowed flag.
4518 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4519 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4520 def SetQuadAllowed(self, toAllow=True):
4521 if self.algoType == NETGEN_2D:
4522 if toAllow: # add QuadranglePreference
4523 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4524 else: # remove QuadranglePreference
4525 for hyp in self.mesh.GetHypothesisList( self.geom ):
4526 if hyp.GetName() == "QuadranglePreference":
4527 self.mesh.RemoveHypothesis( self.geom, hyp )
4532 if self.Parameters():
4533 self.params.SetQuadAllowed(toAllow)
4536 ## Defines hypothesis having several parameters
4538 # @ingroup l3_hypos_netgen
4539 def Parameters(self, which=SOLE):
4542 if self.algoType == NETGEN:
4544 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4545 "libNETGENEngine.so", UseExisting=0)
4547 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4548 "libNETGENEngine.so", UseExisting=0)
4550 elif self.algoType == MEFISTO:
4551 print "Mefisto algo support no multi-parameter hypothesis"
4553 elif self.algoType == NETGEN_2D:
4554 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4555 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4557 elif self.algoType == BLSURF:
4558 self.params = self.Hypothesis("BLSURF_Parameters", [],
4559 "libBLSURFEngine.so", UseExisting=0)
4562 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4567 # Only for algoType == NETGEN
4568 # @ingroup l3_hypos_netgen
4569 def SetMaxSize(self, theSize):
4570 if self.Parameters():
4571 self.params.SetMaxSize(theSize)
4573 ## Sets SecondOrder flag
4575 # Only for algoType == NETGEN
4576 # @ingroup l3_hypos_netgen
4577 def SetSecondOrder(self, theVal):
4578 if self.Parameters():
4579 self.params.SetSecondOrder(theVal)
4581 ## Sets Optimize flag
4583 # Only for algoType == NETGEN
4584 # @ingroup l3_hypos_netgen
4585 def SetOptimize(self, theVal):
4586 if self.Parameters():
4587 self.params.SetOptimize(theVal)
4590 # @param theFineness is:
4591 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4593 # Only for algoType == NETGEN
4594 # @ingroup l3_hypos_netgen
4595 def SetFineness(self, theFineness):
4596 if self.Parameters():
4597 self.params.SetFineness(theFineness)
4601 # Only for algoType == NETGEN
4602 # @ingroup l3_hypos_netgen
4603 def SetGrowthRate(self, theRate):
4604 if self.Parameters():
4605 self.params.SetGrowthRate(theRate)
4607 ## Sets NbSegPerEdge
4609 # Only for algoType == NETGEN
4610 # @ingroup l3_hypos_netgen
4611 def SetNbSegPerEdge(self, theVal):
4612 if self.Parameters():
4613 self.params.SetNbSegPerEdge(theVal)
4615 ## Sets NbSegPerRadius
4617 # Only for algoType == NETGEN
4618 # @ingroup l3_hypos_netgen
4619 def SetNbSegPerRadius(self, theVal):
4620 if self.Parameters():
4621 self.params.SetNbSegPerRadius(theVal)
4623 ## Sets number of segments overriding value set by SetLocalLength()
4625 # Only for algoType == NETGEN
4626 # @ingroup l3_hypos_netgen
4627 def SetNumberOfSegments(self, theVal):
4628 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4630 ## Sets number of segments overriding value set by SetNumberOfSegments()
4632 # Only for algoType == NETGEN
4633 # @ingroup l3_hypos_netgen
4634 def SetLocalLength(self, theVal):
4635 self.Parameters(SIMPLE).SetLocalLength(theVal)
4640 # Public class: Mesh_Quadrangle
4641 # -----------------------------
4643 ## Defines a quadrangle 2D algorithm
4645 # @ingroup l3_algos_basic
4646 class Mesh_Quadrangle(Mesh_Algorithm):
4648 ## Private constructor.
4649 def __init__(self, mesh, geom=0):
4650 Mesh_Algorithm.__init__(self)
4651 self.Create(mesh, geom, "Quadrangle_2D")
4653 ## Defines "QuadranglePreference" hypothesis, forcing construction
4654 # of quadrangles if the number of nodes on the opposite edges is not the same
4655 # while the total number of nodes on edges is even
4657 # @ingroup l3_hypos_additi
4658 def QuadranglePreference(self):
4659 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4660 CompareMethod=self.CompareEqualHyp)
4663 ## Defines "TrianglePreference" hypothesis, forcing construction
4664 # of triangles in the refinement area if the number of nodes
4665 # on the opposite edges is not the same
4667 # @ingroup l3_hypos_additi
4668 def TrianglePreference(self):
4669 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4670 CompareMethod=self.CompareEqualHyp)
4673 ## Defines "QuadrangleParams" hypothesis
4674 # @param vertex: vertex of a trilateral geometrical face, around which triangles
4675 # will be created while other elements will be quadrangles.
4676 # Vertex can be either a GEOM_Object or a vertex ID within the
4678 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4679 # the same parameters, else (default) - creates a new one
4681 # @ingroup l3_hypos_additi
4682 def TriangleVertex(self, vertex, UseExisting=0):
4684 if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4685 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4686 hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4687 CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4688 hyp.SetTriaVertex( vertexID )
4692 # Public class: Mesh_Tetrahedron
4693 # ------------------------------
4695 ## Defines a tetrahedron 3D algorithm
4697 # @ingroup l3_algos_basic
4698 class Mesh_Tetrahedron(Mesh_Algorithm):
4703 ## Private constructor.
4704 def __init__(self, mesh, algoType, geom=0):
4705 Mesh_Algorithm.__init__(self)
4707 if algoType == NETGEN:
4709 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4712 elif algoType == FULL_NETGEN:
4714 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4717 elif algoType == GHS3D:
4719 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4722 elif algoType == GHS3DPRL:
4723 CheckPlugin(GHS3DPRL)
4724 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4727 self.algoType = algoType
4729 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4730 # @param vol for the maximum volume of each tetrahedron
4731 # @param UseExisting if ==true - searches for the existing hypothesis created with
4732 # the same parameters, else (default) - creates a new one
4733 # @ingroup l3_hypos_maxvol
4734 def MaxElementVolume(self, vol, UseExisting=0):
4735 if self.algoType == NETGEN:
4736 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4737 CompareMethod=self.CompareMaxElementVolume)
4738 hyp.SetMaxElementVolume(vol)
4740 elif self.algoType == FULL_NETGEN:
4741 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4744 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4745 def CompareMaxElementVolume(self, hyp, args):
4746 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4748 ## Defines hypothesis having several parameters
4750 # @ingroup l3_hypos_netgen
4751 def Parameters(self, which=SOLE):
4755 if self.algoType == FULL_NETGEN:
4757 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4758 "libNETGENEngine.so", UseExisting=0)
4760 self.params = self.Hypothesis("NETGEN_Parameters", [],
4761 "libNETGENEngine.so", UseExisting=0)
4764 if self.algoType == GHS3D:
4765 self.params = self.Hypothesis("GHS3D_Parameters", [],
4766 "libGHS3DEngine.so", UseExisting=0)
4769 if self.algoType == GHS3DPRL:
4770 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4771 "libGHS3DPRLEngine.so", UseExisting=0)
4774 print "Algo supports no multi-parameter hypothesis"
4778 # Parameter of FULL_NETGEN
4779 # @ingroup l3_hypos_netgen
4780 def SetMaxSize(self, theSize):
4781 self.Parameters().SetMaxSize(theSize)
4783 ## Sets SecondOrder flag
4784 # Parameter of FULL_NETGEN
4785 # @ingroup l3_hypos_netgen
4786 def SetSecondOrder(self, theVal):
4787 self.Parameters().SetSecondOrder(theVal)
4789 ## Sets Optimize flag
4790 # Parameter of FULL_NETGEN
4791 # @ingroup l3_hypos_netgen
4792 def SetOptimize(self, theVal):
4793 self.Parameters().SetOptimize(theVal)
4796 # @param theFineness is:
4797 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4798 # Parameter of FULL_NETGEN
4799 # @ingroup l3_hypos_netgen
4800 def SetFineness(self, theFineness):
4801 self.Parameters().SetFineness(theFineness)
4804 # Parameter of FULL_NETGEN
4805 # @ingroup l3_hypos_netgen
4806 def SetGrowthRate(self, theRate):
4807 self.Parameters().SetGrowthRate(theRate)
4809 ## Sets NbSegPerEdge
4810 # Parameter of FULL_NETGEN
4811 # @ingroup l3_hypos_netgen
4812 def SetNbSegPerEdge(self, theVal):
4813 self.Parameters().SetNbSegPerEdge(theVal)
4815 ## Sets NbSegPerRadius
4816 # Parameter of FULL_NETGEN
4817 # @ingroup l3_hypos_netgen
4818 def SetNbSegPerRadius(self, theVal):
4819 self.Parameters().SetNbSegPerRadius(theVal)
4821 ## Sets number of segments overriding value set by SetLocalLength()
4822 # Only for algoType == NETGEN_FULL
4823 # @ingroup l3_hypos_netgen
4824 def SetNumberOfSegments(self, theVal):
4825 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4827 ## Sets number of segments overriding value set by SetNumberOfSegments()
4828 # Only for algoType == NETGEN_FULL
4829 # @ingroup l3_hypos_netgen
4830 def SetLocalLength(self, theVal):
4831 self.Parameters(SIMPLE).SetLocalLength(theVal)
4833 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4834 # Overrides value set by LengthFromEdges()
4835 # Only for algoType == NETGEN_FULL
4836 # @ingroup l3_hypos_netgen
4837 def MaxElementArea(self, area):
4838 self.Parameters(SIMPLE).SetMaxElementArea(area)
4840 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4841 # Overrides value set by MaxElementArea()
4842 # Only for algoType == NETGEN_FULL
4843 # @ingroup l3_hypos_netgen
4844 def LengthFromEdges(self):
4845 self.Parameters(SIMPLE).LengthFromEdges()
4847 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4848 # Overrides value set by MaxElementVolume()
4849 # Only for algoType == NETGEN_FULL
4850 # @ingroup l3_hypos_netgen
4851 def LengthFromFaces(self):
4852 self.Parameters(SIMPLE).LengthFromFaces()
4854 ## To mesh "holes" in a solid or not. Default is to mesh.
4855 # @ingroup l3_hypos_ghs3dh
4856 def SetToMeshHoles(self, toMesh):
4857 # Parameter of GHS3D
4858 self.Parameters().SetToMeshHoles(toMesh)
4860 ## Set Optimization level:
4861 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4862 # Strong_Optimization.
4863 # Default is Standard_Optimization
4864 # @ingroup l3_hypos_ghs3dh
4865 def SetOptimizationLevel(self, level):
4866 # Parameter of GHS3D
4867 self.Parameters().SetOptimizationLevel(level)
4869 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4870 # @ingroup l3_hypos_ghs3dh
4871 def SetMaximumMemory(self, MB):
4872 # Advanced parameter of GHS3D
4873 self.Parameters().SetMaximumMemory(MB)
4875 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4876 # automatic memory adjustment mode.
4877 # @ingroup l3_hypos_ghs3dh
4878 def SetInitialMemory(self, MB):
4879 # Advanced parameter of GHS3D
4880 self.Parameters().SetInitialMemory(MB)
4882 ## Path to working directory.
4883 # @ingroup l3_hypos_ghs3dh
4884 def SetWorkingDirectory(self, path):
4885 # Advanced parameter of GHS3D
4886 self.Parameters().SetWorkingDirectory(path)
4888 ## To keep working files or remove them. Log file remains in case of errors anyway.
4889 # @ingroup l3_hypos_ghs3dh
4890 def SetKeepFiles(self, toKeep):
4891 # Advanced parameter of GHS3D and GHS3DPRL
4892 self.Parameters().SetKeepFiles(toKeep)
4894 ## To set verbose level [0-10]. <ul>
4895 #<li> 0 - no standard output,
4896 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4897 # indicates when the final mesh is being saved. In addition the software
4898 # gives indication regarding the CPU time.
4899 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4900 # histogram of the skin mesh, quality statistics histogram together with
4901 # the characteristics of the final mesh.</ul>
4902 # @ingroup l3_hypos_ghs3dh
4903 def SetVerboseLevel(self, level):
4904 # Advanced parameter of GHS3D
4905 self.Parameters().SetVerboseLevel(level)
4907 ## To create new nodes.
4908 # @ingroup l3_hypos_ghs3dh
4909 def SetToCreateNewNodes(self, toCreate):
4910 # Advanced parameter of GHS3D
4911 self.Parameters().SetToCreateNewNodes(toCreate)
4913 ## To use boundary recovery version which tries to create mesh on a very poor
4914 # quality surface mesh.
4915 # @ingroup l3_hypos_ghs3dh
4916 def SetToUseBoundaryRecoveryVersion(self, toUse):
4917 # Advanced parameter of GHS3D
4918 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4920 ## Sets command line option as text.
4921 # @ingroup l3_hypos_ghs3dh
4922 def SetTextOption(self, option):
4923 # Advanced parameter of GHS3D
4924 self.Parameters().SetTextOption(option)
4926 ## Sets MED files name and path.
4927 def SetMEDName(self, value):
4928 self.Parameters().SetMEDName(value)
4930 ## Sets the number of partition of the initial mesh
4931 def SetNbPart(self, value):
4932 self.Parameters().SetNbPart(value)
4934 ## When big mesh, start tepal in background
4935 def SetBackground(self, value):
4936 self.Parameters().SetBackground(value)
4938 # Public class: Mesh_Hexahedron
4939 # ------------------------------
4941 ## Defines a hexahedron 3D algorithm
4943 # @ingroup l3_algos_basic
4944 class Mesh_Hexahedron(Mesh_Algorithm):
4949 ## Private constructor.
4950 def __init__(self, mesh, algoType=Hexa, geom=0):
4951 Mesh_Algorithm.__init__(self)
4953 self.algoType = algoType
4955 if algoType == Hexa:
4956 self.Create(mesh, geom, "Hexa_3D")
4959 elif algoType == Hexotic:
4960 CheckPlugin(Hexotic)
4961 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4964 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4965 # @ingroup l3_hypos_hexotic
4966 def MinMaxQuad(self, min=3, max=8, quad=True):
4967 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4969 self.params.SetHexesMinLevel(min)
4970 self.params.SetHexesMaxLevel(max)
4971 self.params.SetHexoticQuadrangles(quad)
4974 # Deprecated, only for compatibility!
4975 # Public class: Mesh_Netgen
4976 # ------------------------------
4978 ## Defines a NETGEN-based 2D or 3D algorithm
4979 # that needs no discrete boundary (i.e. independent)
4981 # This class is deprecated, only for compatibility!
4984 # @ingroup l3_algos_basic
4985 class Mesh_Netgen(Mesh_Algorithm):
4989 ## Private constructor.
4990 def __init__(self, mesh, is3D, geom=0):
4991 Mesh_Algorithm.__init__(self)
4997 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5001 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5004 ## Defines the hypothesis containing parameters of the algorithm
5005 def Parameters(self):
5007 hyp = self.Hypothesis("NETGEN_Parameters", [],
5008 "libNETGENEngine.so", UseExisting=0)
5010 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5011 "libNETGENEngine.so", UseExisting=0)
5014 # Public class: Mesh_Projection1D
5015 # ------------------------------
5017 ## Defines a projection 1D algorithm
5018 # @ingroup l3_algos_proj
5020 class Mesh_Projection1D(Mesh_Algorithm):
5022 ## Private constructor.
5023 def __init__(self, mesh, geom=0):
5024 Mesh_Algorithm.__init__(self)
5025 self.Create(mesh, geom, "Projection_1D")
5027 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5028 # a mesh pattern is taken, and, optionally, the association of vertices
5029 # between the source edge and a target edge (to which a hypothesis is assigned)
5030 # @param edge from which nodes distribution is taken
5031 # @param mesh from which nodes distribution is taken (optional)
5032 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5033 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5034 # to associate with \a srcV (optional)
5035 # @param UseExisting if ==true - searches for the existing hypothesis created with
5036 # the same parameters, else (default) - creates a new one
5037 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5038 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5040 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5041 hyp.SetSourceEdge( edge )
5042 if not mesh is None and isinstance(mesh, Mesh):
5043 mesh = mesh.GetMesh()
5044 hyp.SetSourceMesh( mesh )
5045 hyp.SetVertexAssociation( srcV, tgtV )
5048 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5049 #def CompareSourceEdge(self, hyp, args):
5050 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5054 # Public class: Mesh_Projection2D
5055 # ------------------------------
5057 ## Defines a projection 2D algorithm
5058 # @ingroup l3_algos_proj
5060 class Mesh_Projection2D(Mesh_Algorithm):
5062 ## Private constructor.
5063 def __init__(self, mesh, geom=0):
5064 Mesh_Algorithm.__init__(self)
5065 self.Create(mesh, geom, "Projection_2D")
5067 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5068 # a mesh pattern is taken, and, optionally, the association of vertices
5069 # between the source face and the target face (to which a hypothesis is assigned)
5070 # @param face from which the mesh pattern is taken
5071 # @param mesh from which the mesh pattern is taken (optional)
5072 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5073 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5074 # to associate with \a srcV1 (optional)
5075 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5076 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5077 # to associate with \a srcV2 (optional)
5078 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5079 # the same parameters, else (default) - forces the creation a new one
5081 # Note: all association vertices must belong to one edge of a face
5082 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5083 srcV2=None, tgtV2=None, UseExisting=0):
5084 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5086 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5087 hyp.SetSourceFace( face )
5088 if not mesh is None and isinstance(mesh, Mesh):
5089 mesh = mesh.GetMesh()
5090 hyp.SetSourceMesh( mesh )
5091 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5094 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5095 #def CompareSourceFace(self, hyp, args):
5096 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5099 # Public class: Mesh_Projection3D
5100 # ------------------------------
5102 ## Defines a projection 3D algorithm
5103 # @ingroup l3_algos_proj
5105 class Mesh_Projection3D(Mesh_Algorithm):
5107 ## Private constructor.
5108 def __init__(self, mesh, geom=0):
5109 Mesh_Algorithm.__init__(self)
5110 self.Create(mesh, geom, "Projection_3D")
5112 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5113 # the mesh pattern is taken, and, optionally, the association of vertices
5114 # between the source and the target solid (to which a hipothesis is assigned)
5115 # @param solid from where the mesh pattern is taken
5116 # @param mesh from where the mesh pattern is taken (optional)
5117 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5118 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5119 # to associate with \a srcV1 (optional)
5120 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5121 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5122 # to associate with \a srcV2 (optional)
5123 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5124 # the same parameters, else (default) - creates a new one
5126 # Note: association vertices must belong to one edge of a solid
5127 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5128 srcV2=0, tgtV2=0, UseExisting=0):
5129 hyp = self.Hypothesis("ProjectionSource3D",
5130 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5132 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5133 hyp.SetSource3DShape( solid )
5134 if not mesh is None and isinstance(mesh, Mesh):
5135 mesh = mesh.GetMesh()
5136 hyp.SetSourceMesh( mesh )
5137 if srcV1 and srcV2 and tgtV1 and tgtV2:
5138 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5139 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5142 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5143 #def CompareSourceShape3D(self, hyp, args):
5144 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5148 # Public class: Mesh_Prism
5149 # ------------------------
5151 ## Defines a 3D extrusion algorithm
5152 # @ingroup l3_algos_3dextr
5154 class Mesh_Prism3D(Mesh_Algorithm):
5156 ## Private constructor.
5157 def __init__(self, mesh, geom=0):
5158 Mesh_Algorithm.__init__(self)
5159 self.Create(mesh, geom, "Prism_3D")
5161 # Public class: Mesh_RadialPrism
5162 # -------------------------------
5164 ## Defines a Radial Prism 3D algorithm
5165 # @ingroup l3_algos_radialp
5167 class Mesh_RadialPrism3D(Mesh_Algorithm):
5169 ## Private constructor.
5170 def __init__(self, mesh, geom=0):
5171 Mesh_Algorithm.__init__(self)
5172 self.Create(mesh, geom, "RadialPrism_3D")
5174 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5175 self.nbLayers = None
5177 ## Return 3D hypothesis holding the 1D one
5178 def Get3DHypothesis(self):
5179 return self.distribHyp
5181 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5182 # hypothesis. Returns the created hypothesis
5183 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5184 #print "OwnHypothesis",hypType
5185 if not self.nbLayers is None:
5186 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5187 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5188 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5189 self.mesh.smeshpyD.SetCurrentStudy( None )
5190 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5191 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5192 self.distribHyp.SetLayerDistribution( hyp )
5195 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5196 # prisms to build between the inner and outer shells
5197 # @param n number of layers
5198 # @param UseExisting if ==true - searches for the existing hypothesis created with
5199 # the same parameters, else (default) - creates a new one
5200 def NumberOfLayers(self, n, UseExisting=0):
5201 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5202 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5203 CompareMethod=self.CompareNumberOfLayers)
5204 self.nbLayers.SetNumberOfLayers( n )
5205 return self.nbLayers
5207 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5208 def CompareNumberOfLayers(self, hyp, args):
5209 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5211 ## Defines "LocalLength" hypothesis, specifying the segment length
5212 # to build between the inner and the outer shells
5213 # @param l the length of segments
5214 # @param p the precision of rounding
5215 def LocalLength(self, l, p=1e-07):
5216 hyp = self.OwnHypothesis("LocalLength", [l,p])
5221 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5222 # prisms to build between the inner and the outer shells.
5223 # @param n the number of layers
5224 # @param s the scale factor (optional)
5225 def NumberOfSegments(self, n, s=[]):
5227 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5229 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5230 hyp.SetDistrType( 1 )
5231 hyp.SetScaleFactor(s)
5232 hyp.SetNumberOfSegments(n)
5235 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5236 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5237 # @param start the length of the first segment
5238 # @param end the length of the last segment
5239 def Arithmetic1D(self, start, end ):
5240 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5241 hyp.SetLength(start, 1)
5242 hyp.SetLength(end , 0)
5245 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5246 # to build between the inner and the outer shells as geometric length increasing
5247 # @param start for the length of the first segment
5248 # @param end for the length of the last segment
5249 def StartEndLength(self, start, end):
5250 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5251 hyp.SetLength(start, 1)
5252 hyp.SetLength(end , 0)
5255 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5256 # to build between the inner and outer shells
5257 # @param fineness defines the quality of the mesh within the range [0-1]
5258 def AutomaticLength(self, fineness=0):
5259 hyp = self.OwnHypothesis("AutomaticLength")
5260 hyp.SetFineness( fineness )
5263 # Public class: Mesh_RadialQuadrangle1D2D
5264 # -------------------------------
5266 ## Defines a Radial Quadrangle 1D2D algorithm
5267 # @ingroup l2_algos_radialq
5269 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5271 ## Private constructor.
5272 def __init__(self, mesh, geom=0):
5273 Mesh_Algorithm.__init__(self)
5274 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5276 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5277 self.nbLayers = None
5279 ## Return 2D hypothesis holding the 1D one
5280 def Get2DHypothesis(self):
5281 return self.distribHyp
5283 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5284 # hypothesis. Returns the created hypothesis
5285 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5286 #print "OwnHypothesis",hypType
5288 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5289 if self.distribHyp is None:
5290 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5292 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5293 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5294 self.mesh.smeshpyD.SetCurrentStudy( None )
5295 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5296 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5297 self.distribHyp.SetLayerDistribution( hyp )
5300 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5301 # @param n number of layers
5302 # @param UseExisting if ==true - searches for the existing hypothesis created with
5303 # the same parameters, else (default) - creates a new one
5304 def NumberOfLayers(self, n, UseExisting=0):
5306 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5307 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5308 CompareMethod=self.CompareNumberOfLayers)
5309 self.nbLayers.SetNumberOfLayers( n )
5310 return self.nbLayers
5312 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5313 def CompareNumberOfLayers(self, hyp, args):
5314 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5316 ## Defines "LocalLength" hypothesis, specifying the segment length
5317 # @param l the length of segments
5318 # @param p the precision of rounding
5319 def LocalLength(self, l, p=1e-07):
5320 hyp = self.OwnHypothesis("LocalLength", [l,p])
5325 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5326 # @param n the number of layers
5327 # @param s the scale factor (optional)
5328 def NumberOfSegments(self, n, s=[]):
5330 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5332 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5333 hyp.SetDistrType( 1 )
5334 hyp.SetScaleFactor(s)
5335 hyp.SetNumberOfSegments(n)
5338 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5339 # with a length that changes in arithmetic progression
5340 # @param start the length of the first segment
5341 # @param end the length of the last segment
5342 def Arithmetic1D(self, start, end ):
5343 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5344 hyp.SetLength(start, 1)
5345 hyp.SetLength(end , 0)
5348 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5349 # as geometric length increasing
5350 # @param start for the length of the first segment
5351 # @param end for the length of the last segment
5352 def StartEndLength(self, start, end):
5353 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5354 hyp.SetLength(start, 1)
5355 hyp.SetLength(end , 0)
5358 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5359 # @param fineness defines the quality of the mesh within the range [0-1]
5360 def AutomaticLength(self, fineness=0):
5361 hyp = self.OwnHypothesis("AutomaticLength")
5362 hyp.SetFineness( fineness )
5366 # Private class: Mesh_UseExisting
5367 # -------------------------------
5368 class Mesh_UseExisting(Mesh_Algorithm):
5370 def __init__(self, dim, mesh, geom=0):
5372 self.Create(mesh, geom, "UseExisting_1D")
5374 self.Create(mesh, geom, "UseExisting_2D")
5377 import salome_notebook
5378 notebook = salome_notebook.notebook
5380 ##Return values of the notebook variables
5381 def ParseParameters(last, nbParams,nbParam, value):
5385 listSize = len(last)
5386 for n in range(0,nbParams):
5388 if counter < listSize:
5389 strResult = strResult + last[counter]
5391 strResult = strResult + ""
5393 if isinstance(value, str):
5394 if notebook.isVariable(value):
5395 result = notebook.get(value)
5396 strResult=strResult+value
5398 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5400 strResult=strResult+str(value)
5402 if nbParams - 1 != counter:
5403 strResult=strResult+var_separator #":"
5405 return result, strResult
5407 #Wrapper class for StdMeshers_LocalLength hypothesis
5408 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5410 ## Set Length parameter value
5411 # @param length numerical value or name of variable from notebook
5412 def SetLength(self, length):
5413 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5414 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5415 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5417 ## Set Precision parameter value
5418 # @param precision numerical value or name of variable from notebook
5419 def SetPrecision(self, precision):
5420 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5421 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5422 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5424 #Registering the new proxy for LocalLength
5425 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5428 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5429 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5431 def SetLayerDistribution(self, hypo):
5432 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5433 hypo.ClearParameters();
5434 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5436 #Registering the new proxy for LayerDistribution
5437 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5439 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5440 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5442 ## Set Length parameter value
5443 # @param length numerical value or name of variable from notebook
5444 def SetLength(self, length):
5445 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5446 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5447 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5449 #Registering the new proxy for SegmentLengthAroundVertex
5450 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5453 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5454 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5456 ## Set Length parameter value
5457 # @param length numerical value or name of variable from notebook
5458 # @param isStart true is length is Start Length, otherwise false
5459 def SetLength(self, length, isStart):
5463 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5464 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5465 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5467 #Registering the new proxy for Arithmetic1D
5468 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5470 #Wrapper class for StdMeshers_Deflection1D hypothesis
5471 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5473 ## Set Deflection parameter value
5474 # @param deflection numerical value or name of variable from notebook
5475 def SetDeflection(self, deflection):
5476 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5477 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5478 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5480 #Registering the new proxy for Deflection1D
5481 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5483 #Wrapper class for StdMeshers_StartEndLength hypothesis
5484 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5486 ## Set Length parameter value
5487 # @param length numerical value or name of variable from notebook
5488 # @param isStart true is length is Start Length, otherwise false
5489 def SetLength(self, length, isStart):
5493 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5494 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5495 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5497 #Registering the new proxy for StartEndLength
5498 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5500 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5501 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5503 ## Set Max Element Area parameter value
5504 # @param area numerical value or name of variable from notebook
5505 def SetMaxElementArea(self, area):
5506 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5507 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5508 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5510 #Registering the new proxy for MaxElementArea
5511 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5514 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5515 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5517 ## Set Max Element Volume parameter value
5518 # @param volume numerical value or name of variable from notebook
5519 def SetMaxElementVolume(self, volume):
5520 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5521 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5522 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5524 #Registering the new proxy for MaxElementVolume
5525 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5528 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5529 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5531 ## Set Number Of Layers parameter value
5532 # @param nbLayers numerical value or name of variable from notebook
5533 def SetNumberOfLayers(self, nbLayers):
5534 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5535 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5536 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5538 #Registering the new proxy for NumberOfLayers
5539 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5541 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5542 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5544 ## Set Number Of Segments parameter value
5545 # @param nbSeg numerical value or name of variable from notebook
5546 def SetNumberOfSegments(self, nbSeg):
5547 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5548 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5549 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5550 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5552 ## Set Scale Factor parameter value
5553 # @param factor numerical value or name of variable from notebook
5554 def SetScaleFactor(self, factor):
5555 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5556 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5557 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5559 #Registering the new proxy for NumberOfSegments
5560 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5562 if not noNETGENPlugin:
5563 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5564 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5566 ## Set Max Size parameter value
5567 # @param maxsize numerical value or name of variable from notebook
5568 def SetMaxSize(self, maxsize):
5569 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5570 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5571 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5572 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5574 ## Set Growth Rate parameter value
5575 # @param value numerical value or name of variable from notebook
5576 def SetGrowthRate(self, value):
5577 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5578 value, parameters = ParseParameters(lastParameters,4,2,value)
5579 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5580 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5582 ## Set Number of Segments per Edge parameter value
5583 # @param value numerical value or name of variable from notebook
5584 def SetNbSegPerEdge(self, value):
5585 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5586 value, parameters = ParseParameters(lastParameters,4,3,value)
5587 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5588 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5590 ## Set Number of Segments per Radius parameter value
5591 # @param value numerical value or name of variable from notebook
5592 def SetNbSegPerRadius(self, value):
5593 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5594 value, parameters = ParseParameters(lastParameters,4,4,value)
5595 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5596 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5598 #Registering the new proxy for NETGENPlugin_Hypothesis
5599 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5602 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5603 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5606 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5607 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5609 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5610 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5612 ## Set Number of Segments parameter value
5613 # @param nbSeg numerical value or name of variable from notebook
5614 def SetNumberOfSegments(self, nbSeg):
5615 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5616 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5617 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5618 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5620 ## Set Local Length parameter value
5621 # @param length numerical value or name of variable from notebook
5622 def SetLocalLength(self, length):
5623 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5624 length, parameters = ParseParameters(lastParameters,2,1,length)
5625 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5626 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5628 ## Set Max Element Area parameter value
5629 # @param area numerical value or name of variable from notebook
5630 def SetMaxElementArea(self, area):
5631 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5632 area, parameters = ParseParameters(lastParameters,2,2,area)
5633 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5634 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5636 def LengthFromEdges(self):
5637 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5639 value, parameters = ParseParameters(lastParameters,2,2,value)
5640 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5641 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5643 #Registering the new proxy for NETGEN_SimpleParameters_2D
5644 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5647 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5648 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5649 ## Set Max Element Volume parameter value
5650 # @param volume numerical value or name of variable from notebook
5651 def SetMaxElementVolume(self, volume):
5652 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5653 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5654 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5655 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5657 def LengthFromFaces(self):
5658 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5660 value, parameters = ParseParameters(lastParameters,3,3,value)
5661 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5662 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5664 #Registering the new proxy for NETGEN_SimpleParameters_3D
5665 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5667 pass # if not noNETGENPlugin:
5669 class Pattern(SMESH._objref_SMESH_Pattern):
5671 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5673 if isinstance(theNodeIndexOnKeyPoint1,str):
5675 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5677 theNodeIndexOnKeyPoint1 -= 1
5678 theMesh.SetParameters(Parameters)
5679 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5681 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5684 if isinstance(theNode000Index,str):
5686 if isinstance(theNode001Index,str):
5688 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5690 theNode000Index -= 1
5692 theNode001Index -= 1
5693 theMesh.SetParameters(Parameters)
5694 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5696 #Registering the new proxy for Pattern
5697 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)