1 # Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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
21 # Author : Francis KLOSS, OCC
29 ## @defgroup l1_auxiliary Auxiliary methods and structures
30 ## @defgroup l1_creating Creating meshes
32 ## @defgroup l2_impexp Importing and exporting meshes
33 ## @defgroup l2_construct Constructing meshes
34 ## @defgroup l2_algorithms Defining Algorithms
36 ## @defgroup l3_algos_basic Basic meshing algorithms
37 ## @defgroup l3_algos_proj Projection Algorithms
38 ## @defgroup l3_algos_radialp Radial Prism
39 ## @defgroup l3_algos_segmarv Segments around Vertex
40 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
43 ## @defgroup l2_hypotheses Defining hypotheses
45 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
46 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
47 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
48 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
49 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
50 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
51 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
52 ## @defgroup l3_hypos_additi Additional Hypotheses
55 ## @defgroup l2_submeshes Constructing submeshes
56 ## @defgroup l2_compounds Building Compounds
57 ## @defgroup l2_editing Editing Meshes
60 ## @defgroup l1_meshinfo Mesh Information
61 ## @defgroup l1_controls Quality controls and Filtering
62 ## @defgroup l1_grouping Grouping elements
64 ## @defgroup l2_grps_create Creating groups
65 ## @defgroup l2_grps_edit Editing groups
66 ## @defgroup l2_grps_operon Using operations on groups
67 ## @defgroup l2_grps_delete Deleting Groups
70 ## @defgroup l1_modifying Modifying meshes
72 ## @defgroup l2_modif_add Adding nodes and elements
73 ## @defgroup l2_modif_del Removing nodes and elements
74 ## @defgroup l2_modif_edit Modifying nodes and elements
75 ## @defgroup l2_modif_renumber Renumbering nodes and elements
76 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
77 ## @defgroup l2_modif_movenode Moving nodes
78 ## @defgroup l2_modif_throughp Mesh through point
79 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
80 ## @defgroup l2_modif_unitetri Uniting triangles
81 ## @defgroup l2_modif_changori Changing orientation of elements
82 ## @defgroup l2_modif_cutquadr Cutting quadrangles
83 ## @defgroup l2_modif_smooth Smoothing
84 ## @defgroup l2_modif_extrurev Extrusion and Revolution
85 ## @defgroup l2_modif_patterns Pattern mapping
86 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
93 import SMESH # This is necessary for back compatibility
100 # import NETGENPlugin module if possible
108 ## @addtogroup l1_auxiliary
111 # Types of algorithms
124 NETGEN_1D2D3D = FULL_NETGEN
125 NETGEN_FULL = FULL_NETGEN
130 # MirrorType enumeration
131 POINT = SMESH_MeshEditor.POINT
132 AXIS = SMESH_MeshEditor.AXIS
133 PLANE = SMESH_MeshEditor.PLANE
135 # Smooth_Method enumeration
136 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
137 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
139 # Fineness enumeration (for NETGEN)
147 # Optimization level of GHS3D
148 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
150 # Topology treatment way of BLSURF
151 FromCAD, PreProcess, PreProcessPlus = 0,1,2
153 # Element size flag of BLSURF
154 DefaultSize, DefaultGeom, Custom = 0,0,1
156 PrecisionConfusion = 1e-07
158 ## Converts an angle from degrees to radians
159 def DegreesToRadians(AngleInDegrees):
161 return AngleInDegrees * pi / 180.0
163 # Salome notebook variable separator
166 # Parametrized substitute for PointStruct
167 class PointStructStr:
176 def __init__(self, xStr, yStr, zStr):
180 if isinstance(xStr, str) and notebook.isVariable(xStr):
181 self.x = notebook.get(xStr)
184 if isinstance(yStr, str) and notebook.isVariable(yStr):
185 self.y = notebook.get(yStr)
188 if isinstance(zStr, str) and notebook.isVariable(zStr):
189 self.z = notebook.get(zStr)
193 # Parametrized substitute for PointStruct (with 6 parameters)
194 class PointStructStr6:
209 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
216 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
217 self.x1 = notebook.get(x1Str)
220 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
221 self.x2 = notebook.get(x2Str)
224 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
225 self.y1 = notebook.get(y1Str)
228 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
229 self.y2 = notebook.get(y2Str)
232 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
233 self.z1 = notebook.get(z1Str)
236 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
237 self.z2 = notebook.get(z2Str)
241 # Parametrized substitute for AxisStruct
257 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
264 if isinstance(xStr, str) and notebook.isVariable(xStr):
265 self.x = notebook.get(xStr)
268 if isinstance(yStr, str) and notebook.isVariable(yStr):
269 self.y = notebook.get(yStr)
272 if isinstance(zStr, str) and notebook.isVariable(zStr):
273 self.z = notebook.get(zStr)
276 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
277 self.dx = notebook.get(dxStr)
280 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
281 self.dy = notebook.get(dyStr)
284 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
285 self.dz = notebook.get(dzStr)
289 # Parametrized substitute for DirStruct
292 def __init__(self, pointStruct):
293 self.pointStruct = pointStruct
295 # Returns list of variable values from salome notebook
296 def ParsePointStruct(Point):
297 Parameters = 2*var_separator
298 if isinstance(Point, PointStructStr):
299 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
300 Point = PointStruct(Point.x, Point.y, Point.z)
301 return Point, Parameters
303 # Returns list of variable values from salome notebook
304 def ParseDirStruct(Dir):
305 Parameters = 2*var_separator
306 if isinstance(Dir, DirStructStr):
307 pntStr = Dir.pointStruct
308 if isinstance(pntStr, PointStructStr6):
309 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
310 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
311 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
312 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
314 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
315 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
316 Dir = DirStruct(Point)
317 return Dir, Parameters
319 # Returns list of variable values from salome notebook
320 def ParseAxisStruct(Axis):
321 Parameters = 5*var_separator
322 if isinstance(Axis, AxisStructStr):
323 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
324 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
325 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
326 return Axis, Parameters
328 ## Return list of variable values from salome notebook
329 def ParseAngles(list):
332 for parameter in list:
333 if isinstance(parameter,str) and notebook.isVariable(parameter):
334 Result.append(DegreesToRadians(notebook.get(parameter)))
337 Result.append(parameter)
340 Parameters = Parameters + str(parameter)
341 Parameters = Parameters + var_separator
343 Parameters = Parameters[:len(Parameters)-1]
344 return Result, Parameters
346 def IsEqual(val1, val2, tol=PrecisionConfusion):
347 if abs(val1 - val2) < tol:
355 ior = salome.orb.object_to_string(obj)
356 sobj = salome.myStudy.FindObjectIOR(ior)
360 attr = sobj.FindAttribute("AttributeName")[1]
363 ## Sets a name to the object
364 def SetName(obj, name):
365 ior = salome.orb.object_to_string(obj)
366 sobj = salome.myStudy.FindObjectIOR(ior)
368 attr = sobj.FindAttribute("AttributeName")[1]
371 ## Prints error message if a hypothesis was not assigned.
372 def TreatHypoStatus(status, hypName, geomName, isAlgo):
374 hypType = "algorithm"
376 hypType = "hypothesis"
378 if status == HYP_UNKNOWN_FATAL :
379 reason = "for unknown reason"
380 elif status == HYP_INCOMPATIBLE :
381 reason = "this hypothesis mismatches the algorithm"
382 elif status == HYP_NOTCONFORM :
383 reason = "a non-conform mesh would be built"
384 elif status == HYP_ALREADY_EXIST :
385 reason = hypType + " of the same dimension is already assigned to this shape"
386 elif status == HYP_BAD_DIM :
387 reason = hypType + " mismatches the shape"
388 elif status == HYP_CONCURENT :
389 reason = "there are concurrent hypotheses on sub-shapes"
390 elif status == HYP_BAD_SUBSHAPE :
391 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
392 elif status == HYP_BAD_GEOMETRY:
393 reason = "geometry mismatches the expectation of the algorithm"
394 elif status == HYP_HIDDEN_ALGO:
395 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
396 elif status == HYP_HIDING_ALGO:
397 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
398 elif status == HYP_NEED_SHAPE:
399 reason = "Algorithm can't work without shape"
402 hypName = '"' + hypName + '"'
403 geomName= '"' + geomName+ '"'
404 if status < HYP_UNKNOWN_FATAL:
405 print hypName, "was assigned to", geomName,"but", reason
407 print hypName, "was not assigned to",geomName,":", reason
410 # end of l1_auxiliary
413 # All methods of this class are accessible directly from the smesh.py package.
414 class smeshDC(SMESH._objref_SMESH_Gen):
416 ## Sets the current study and Geometry component
417 # @ingroup l1_auxiliary
418 def init_smesh(self,theStudy,geompyD):
420 self.SetGeomEngine(geompyD)
421 self.SetCurrentStudy(theStudy)
423 ## Creates an empty Mesh. This mesh can have an underlying geometry.
424 # @param obj the Geometrical object on which the mesh is built. If not defined,
425 # the mesh will have no underlying geometry.
426 # @param name the name for the new mesh.
427 # @return an instance of Mesh class.
428 # @ingroup l2_construct
429 def Mesh(self, obj=0, name=0):
430 return Mesh(self,self.geompyD,obj,name)
432 ## Returns a long value from enumeration
433 # Should be used for SMESH.FunctorType enumeration
434 # @ingroup l1_controls
435 def EnumToLong(self,theItem):
438 ## Gets PointStruct from vertex
439 # @param theVertex a GEOM object(vertex)
440 # @return SMESH.PointStruct
441 # @ingroup l1_auxiliary
442 def GetPointStruct(self,theVertex):
443 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
444 return PointStruct(x,y,z)
446 ## Gets DirStruct from vector
447 # @param theVector a GEOM object(vector)
448 # @return SMESH.DirStruct
449 # @ingroup l1_auxiliary
450 def GetDirStruct(self,theVector):
451 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
452 if(len(vertices) != 2):
453 print "Error: vector object is incorrect."
455 p1 = self.geompyD.PointCoordinates(vertices[0])
456 p2 = self.geompyD.PointCoordinates(vertices[1])
457 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
458 dirst = DirStruct(pnt)
461 ## Makes DirStruct from a triplet
462 # @param x,y,z vector components
463 # @return SMESH.DirStruct
464 # @ingroup l1_auxiliary
465 def MakeDirStruct(self,x,y,z):
466 pnt = PointStruct(x,y,z)
467 return DirStruct(pnt)
469 ## Get AxisStruct from object
470 # @param theObj a GEOM object (line or plane)
471 # @return SMESH.AxisStruct
472 # @ingroup l1_auxiliary
473 def GetAxisStruct(self,theObj):
474 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
476 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
477 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
478 vertex1 = self.geompyD.PointCoordinates(vertex1)
479 vertex2 = self.geompyD.PointCoordinates(vertex2)
480 vertex3 = self.geompyD.PointCoordinates(vertex3)
481 vertex4 = self.geompyD.PointCoordinates(vertex4)
482 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
483 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
484 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] ]
485 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
487 elif len(edges) == 1:
488 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
489 p1 = self.geompyD.PointCoordinates( vertex1 )
490 p2 = self.geompyD.PointCoordinates( vertex2 )
491 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
495 # From SMESH_Gen interface:
496 # ------------------------
498 ## Sets the current mode
499 # @ingroup l1_auxiliary
500 def SetEmbeddedMode( self,theMode ):
501 #self.SetEmbeddedMode(theMode)
502 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
504 ## Gets the current mode
505 # @ingroup l1_auxiliary
506 def IsEmbeddedMode(self):
507 #return self.IsEmbeddedMode()
508 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
510 ## Sets the current study
511 # @ingroup l1_auxiliary
512 def SetCurrentStudy( self, theStudy ):
513 #self.SetCurrentStudy(theStudy)
514 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
516 ## Gets the current study
517 # @ingroup l1_auxiliary
518 def GetCurrentStudy(self):
519 #return self.GetCurrentStudy()
520 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
522 ## Creates a Mesh object importing data from the given UNV file
523 # @return an instance of Mesh class
525 def CreateMeshesFromUNV( self,theFileName ):
526 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
527 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
530 ## Creates a Mesh object(s) importing data from the given MED file
531 # @return a list of Mesh class instances
533 def CreateMeshesFromMED( self,theFileName ):
534 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
536 for iMesh in range(len(aSmeshMeshes)) :
537 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
538 aMeshes.append(aMesh)
539 return aMeshes, aStatus
541 ## Creates a Mesh object importing data from the given STL file
542 # @return an instance of Mesh class
544 def CreateMeshesFromSTL( self, theFileName ):
545 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
546 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
549 ## From SMESH_Gen interface
550 # @return the list of integer values
551 # @ingroup l1_auxiliary
552 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
553 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
555 ## From SMESH_Gen interface. Creates a pattern
556 # @return an instance of SMESH_Pattern
558 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
559 # @ingroup l2_modif_patterns
560 def GetPattern(self):
561 return SMESH._objref_SMESH_Gen.GetPattern(self)
563 ## Create a compound of Mesh objects
564 # @param theMeshArray array of Mesh objects
565 # @param theUniteIdenticalGroups flag used to unite identical mesh groups
566 # @param theMergeNodesAndElements flag used to merge mesh nodes and elements
567 # @param theMergeTolerance tolerance of merging
568 # @return a compound of Mesh objects
569 # @ingroup l1_auxiliary
570 def Concatenate( self, theMeshArray, theUniteIdenticalGroups, theMergeNodesAndElements, theMergeTolerance ):
571 theMergeTolerance,Parameters = geompyDC.ParseParameters(theMergeTolerance)
572 aMesh = SMESH._objref_SMESH_Gen.Concatenate( self, theMeshArray, theUniteIdenticalGroups, theMergeNodesAndElements, theMergeTolerance )
573 aMesh.SetParameters(Parameters)
576 ## Create a compound of Mesh objects
577 # @param theMeshArray array of Mesh objects
578 # @param theUniteIdenticalGroups flag used to unite identical mesh groups
579 # @param theMergeNodesAndElements flag used to merge mesh nodes and elements
580 # @param theMergeTolerance tolerance of merging
581 # @return a compound of Mesh objects
582 # @ingroup l1_auxiliary
583 def ConcatenateWithGroups( self, theMeshArray, theUniteIdenticalGroups, theMergeNodesAndElements, theMergeTolerance ):
584 theMergeTolerance,Parameters = geompyDC.ParseParameters(theMergeTolerance)
585 aMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups( self, theMeshArray, theUniteIdenticalGroups, theMergeNodesAndElements, theMergeTolerance )
586 aMesh.SetParameters(Parameters)
590 # Filtering. Auxiliary functions:
591 # ------------------------------
593 ## Creates an empty criterion
594 # @return SMESH.Filter.Criterion
595 # @ingroup l1_controls
596 def GetEmptyCriterion(self):
597 Type = self.EnumToLong(FT_Undefined)
598 Compare = self.EnumToLong(FT_Undefined)
602 UnaryOp = self.EnumToLong(FT_Undefined)
603 BinaryOp = self.EnumToLong(FT_Undefined)
606 Precision = -1 ##@1e-07
607 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
608 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
610 ## Creates a criterion by the given parameters
611 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
612 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
613 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
614 # @param Treshold the threshold value (range of ids as string, shape, numeric)
615 # @param UnaryOp FT_LogicalNOT or FT_Undefined
616 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
617 # FT_Undefined (must be for the last criterion of all criteria)
618 # @return SMESH.Filter.Criterion
619 # @ingroup l1_controls
620 def GetCriterion(self,elementType,
622 Compare = FT_EqualTo,
624 UnaryOp=FT_Undefined,
625 BinaryOp=FT_Undefined):
626 aCriterion = self.GetEmptyCriterion()
627 aCriterion.TypeOfElement = elementType
628 aCriterion.Type = self.EnumToLong(CritType)
632 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
633 aCriterion.Compare = self.EnumToLong(Compare)
634 elif Compare == "=" or Compare == "==":
635 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
637 aCriterion.Compare = self.EnumToLong(FT_LessThan)
639 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
641 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
644 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
645 FT_BelongToCylinder, FT_LyingOnGeom]:
646 # Checks the treshold
647 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
648 aCriterion.ThresholdStr = GetName(aTreshold)
649 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
651 print "Error: The treshold should be a shape."
653 elif CritType == FT_RangeOfIds:
654 # Checks the treshold
655 if isinstance(aTreshold, str):
656 aCriterion.ThresholdStr = aTreshold
658 print "Error: The treshold should be a string."
660 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
661 # At this point the treshold is unnecessary
662 if aTreshold == FT_LogicalNOT:
663 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
664 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
665 aCriterion.BinaryOp = aTreshold
669 aTreshold = float(aTreshold)
670 aCriterion.Threshold = aTreshold
672 print "Error: The treshold should be a number."
675 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
676 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
678 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
679 aCriterion.BinaryOp = self.EnumToLong(Treshold)
681 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
682 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
684 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
685 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
689 ## Creates a filter with the given parameters
690 # @param elementType the type of elements in the group
691 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
692 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
693 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
694 # @param UnaryOp FT_LogicalNOT or FT_Undefined
695 # @return SMESH_Filter
696 # @ingroup l1_controls
697 def GetFilter(self,elementType,
698 CritType=FT_Undefined,
701 UnaryOp=FT_Undefined):
702 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
703 aFilterMgr = self.CreateFilterManager()
704 aFilter = aFilterMgr.CreateFilter()
706 aCriteria.append(aCriterion)
707 aFilter.SetCriteria(aCriteria)
710 ## Creates a numerical functor by its type
711 # @param theCriterion FT_...; functor type
712 # @return SMESH_NumericalFunctor
713 # @ingroup l1_controls
714 def GetFunctor(self,theCriterion):
715 aFilterMgr = self.CreateFilterManager()
716 if theCriterion == FT_AspectRatio:
717 return aFilterMgr.CreateAspectRatio()
718 elif theCriterion == FT_AspectRatio3D:
719 return aFilterMgr.CreateAspectRatio3D()
720 elif theCriterion == FT_Warping:
721 return aFilterMgr.CreateWarping()
722 elif theCriterion == FT_MinimumAngle:
723 return aFilterMgr.CreateMinimumAngle()
724 elif theCriterion == FT_Taper:
725 return aFilterMgr.CreateTaper()
726 elif theCriterion == FT_Skew:
727 return aFilterMgr.CreateSkew()
728 elif theCriterion == FT_Area:
729 return aFilterMgr.CreateArea()
730 elif theCriterion == FT_Volume3D:
731 return aFilterMgr.CreateVolume3D()
732 elif theCriterion == FT_MultiConnection:
733 return aFilterMgr.CreateMultiConnection()
734 elif theCriterion == FT_MultiConnection2D:
735 return aFilterMgr.CreateMultiConnection2D()
736 elif theCriterion == FT_Length:
737 return aFilterMgr.CreateLength()
738 elif theCriterion == FT_Length2D:
739 return aFilterMgr.CreateLength2D()
741 print "Error: given parameter is not numerucal functor type."
745 #Registering the new proxy for SMESH_Gen
746 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
752 ## This class allows defining and managing a mesh.
753 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
754 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
755 # new nodes and elements and by changing the existing entities), to get information
756 # about a mesh and to export a mesh into different formats.
765 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
766 # sets the GUI name of this mesh to \a name.
767 # @param smeshpyD an instance of smeshDC class
768 # @param geompyD an instance of geompyDC class
769 # @param obj Shape to be meshed or SMESH_Mesh object
770 # @param name Study name of the mesh
771 # @ingroup l2_construct
772 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
773 self.smeshpyD=smeshpyD
778 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
780 self.mesh = self.smeshpyD.CreateMesh(self.geom)
781 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
784 self.mesh = self.smeshpyD.CreateEmptyMesh()
786 SetName(self.mesh, name)
788 SetName(self.mesh, GetName(obj))
791 self.geom = self.mesh.GetShapeToMesh()
793 self.editor = self.mesh.GetMeshEditor()
795 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
796 # @param theMesh a SMESH_Mesh object
797 # @ingroup l2_construct
798 def SetMesh(self, theMesh):
800 self.geom = self.mesh.GetShapeToMesh()
802 ## Returns the mesh, that is an instance of SMESH_Mesh interface
803 # @return a SMESH_Mesh object
804 # @ingroup l2_construct
808 ## Gets the name of the mesh
809 # @return the name of the mesh as a string
810 # @ingroup l2_construct
812 name = GetName(self.GetMesh())
815 ## Sets a name to the mesh
816 # @param name a new name of the mesh
817 # @ingroup l2_construct
818 def SetName(self, name):
819 SetName(self.GetMesh(), name)
821 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
822 # The subMesh object gives access to the IDs of nodes and elements.
823 # @param theSubObject a geometrical object (shape)
824 # @param theName a name for the submesh
825 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
826 # @ingroup l2_submeshes
827 def GetSubMesh(self, theSubObject, theName):
828 submesh = self.mesh.GetSubMesh(theSubObject, theName)
831 ## Returns the shape associated to the mesh
832 # @return a GEOM_Object
833 # @ingroup l2_construct
837 ## Associates the given shape to the mesh (entails the recreation of the mesh)
838 # @param geom the shape to be meshed (GEOM_Object)
839 # @ingroup l2_construct
840 def SetShape(self, geom):
841 self.mesh = self.smeshpyD.CreateMesh(geom)
843 ## Returns true if the hypotheses are defined well
844 # @param theSubObject a subshape of a mesh shape
845 # @return True or False
846 # @ingroup l2_construct
847 def IsReadyToCompute(self, theSubObject):
848 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
850 ## Returns errors of hypotheses definition.
851 # The list of errors is empty if everything is OK.
852 # @param theSubObject a subshape of a mesh shape
853 # @return a list of errors
854 # @ingroup l2_construct
855 def GetAlgoState(self, theSubObject):
856 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
858 ## Returns a geometrical object on which the given element was built.
859 # The returned geometrical object, if not nil, is either found in the
860 # study or published by this method with the given name
861 # @param theElementID the id of the mesh element
862 # @param theGeomName the user-defined name of the geometrical object
863 # @return GEOM::GEOM_Object instance
864 # @ingroup l2_construct
865 def GetGeometryByMeshElement(self, theElementID, theGeomName):
866 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
868 ## Returns the mesh dimension depending on the dimension of the underlying shape
869 # @return mesh dimension as an integer value [0,3]
870 # @ingroup l1_auxiliary
871 def MeshDimension(self):
872 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
873 if len( shells ) > 0 :
875 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
877 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
883 ## Creates a segment discretization 1D algorithm.
884 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
885 # \n If the optional \a geom parameter is not set, this algorithm is global.
886 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
887 # @param algo the type of the required algorithm. Possible values are:
889 # - smesh.PYTHON for discretization via a python function,
890 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
891 # @param geom If defined is the subshape to be meshed
892 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
893 # @ingroup l3_algos_basic
894 def Segment(self, algo=REGULAR, geom=0):
895 ## if Segment(geom) is called by mistake
896 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
897 algo, geom = geom, algo
898 if not algo: algo = REGULAR
901 return Mesh_Segment(self, geom)
903 return Mesh_Segment_Python(self, geom)
904 elif algo == COMPOSITE:
905 return Mesh_CompositeSegment(self, geom)
907 return Mesh_Segment(self, geom)
909 ## Enables creation of nodes and segments usable by 2D algoritms.
910 # The added nodes and segments must be bound to edges and vertices by
911 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
912 # If the optional \a geom parameter is not set, this algorithm is global.
913 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
914 # @param geom the subshape to be manually meshed
915 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
916 # @ingroup l3_algos_basic
917 def UseExistingSegments(self, geom=0):
918 algo = Mesh_UseExisting(1,self,geom)
919 return algo.GetAlgorithm()
921 ## Enables creation of nodes and faces usable by 3D algoritms.
922 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
923 # and SetMeshElementOnShape()
924 # If the optional \a geom parameter is not set, this algorithm is global.
925 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
926 # @param geom the subshape to be manually meshed
927 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
928 # @ingroup l3_algos_basic
929 def UseExistingFaces(self, geom=0):
930 algo = Mesh_UseExisting(2,self,geom)
931 return algo.GetAlgorithm()
933 ## Creates a triangle 2D algorithm for faces.
934 # If the optional \a geom parameter is not set, this algorithm is global.
935 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
936 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
937 # @param geom If defined, the subshape to be meshed (GEOM_Object)
938 # @return an instance of Mesh_Triangle algorithm
939 # @ingroup l3_algos_basic
940 def Triangle(self, algo=MEFISTO, geom=0):
941 ## if Triangle(geom) is called by mistake
942 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
946 return Mesh_Triangle(self, algo, geom)
948 ## Creates a quadrangle 2D algorithm for faces.
949 # If the optional \a geom parameter is not set, this algorithm is global.
950 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
951 # @param geom If defined, the subshape to be meshed (GEOM_Object)
952 # @return an instance of Mesh_Quadrangle algorithm
953 # @ingroup l3_algos_basic
954 def Quadrangle(self, geom=0):
955 return Mesh_Quadrangle(self, geom)
957 ## Creates a tetrahedron 3D algorithm for solids.
958 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
959 # If the optional \a geom parameter is not set, this algorithm is global.
960 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
961 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
962 # @param geom If defined, the subshape to be meshed (GEOM_Object)
963 # @return an instance of Mesh_Tetrahedron algorithm
964 # @ingroup l3_algos_basic
965 def Tetrahedron(self, algo=NETGEN, geom=0):
966 ## if Tetrahedron(geom) is called by mistake
967 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
968 algo, geom = geom, algo
969 if not algo: algo = NETGEN
971 return Mesh_Tetrahedron(self, algo, geom)
973 ## Creates a hexahedron 3D algorithm for solids.
974 # If the optional \a geom parameter is not set, this algorithm is global.
975 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
976 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
977 # @param geom If defined, the subshape to be meshed (GEOM_Object)
978 # @return an instance of Mesh_Hexahedron algorithm
979 # @ingroup l3_algos_basic
980 def Hexahedron(self, algo=Hexa, geom=0):
981 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
982 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
983 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
984 elif geom == 0: algo, geom = Hexa, algo
985 return Mesh_Hexahedron(self, algo, geom)
987 ## Deprecated, used only for compatibility!
988 # @return an instance of Mesh_Netgen algorithm
989 # @ingroup l3_algos_basic
990 def Netgen(self, is3D, geom=0):
991 return Mesh_Netgen(self, is3D, geom)
993 ## Creates a projection 1D algorithm for edges.
994 # If the optional \a geom parameter is not set, this algorithm is global.
995 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
996 # @param geom If defined, the subshape to be meshed
997 # @return an instance of Mesh_Projection1D algorithm
998 # @ingroup l3_algos_proj
999 def Projection1D(self, geom=0):
1000 return Mesh_Projection1D(self, geom)
1002 ## Creates a projection 2D algorithm for faces.
1003 # If the optional \a geom parameter is not set, this algorithm is global.
1004 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1005 # @param geom If defined, the subshape to be meshed
1006 # @return an instance of Mesh_Projection2D algorithm
1007 # @ingroup l3_algos_proj
1008 def Projection2D(self, geom=0):
1009 return Mesh_Projection2D(self, geom)
1011 ## Creates a projection 3D algorithm for solids.
1012 # If the optional \a geom parameter is not set, this algorithm is global.
1013 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1014 # @param geom If defined, the subshape to be meshed
1015 # @return an instance of Mesh_Projection3D algorithm
1016 # @ingroup l3_algos_proj
1017 def Projection3D(self, geom=0):
1018 return Mesh_Projection3D(self, geom)
1020 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1021 # If the optional \a geom parameter is not set, this algorithm is global.
1022 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1023 # @param geom If defined, the subshape to be meshed
1024 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1025 # @ingroup l3_algos_radialp l3_algos_3dextr
1026 def Prism(self, geom=0):
1030 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1031 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1032 if nbSolids == 0 or nbSolids == nbShells:
1033 return Mesh_Prism3D(self, geom)
1034 return Mesh_RadialPrism3D(self, geom)
1036 ## Computes the mesh and returns the status of the computation
1037 # @return True or False
1038 # @ingroup l2_construct
1039 def Compute(self, geom=0):
1040 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1042 geom = self.mesh.GetShapeToMesh()
1047 ok = self.smeshpyD.Compute(self.mesh, geom)
1048 except SALOME.SALOME_Exception, ex:
1049 print "Mesh computation failed, exception caught:"
1050 print " ", ex.details.text
1053 print "Mesh computation failed, exception caught:"
1054 traceback.print_exc()
1056 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1059 if err.isGlobalAlgo:
1067 reason = '%s %sD algorithm is missing' % (glob, dim)
1068 elif err.state == HYP_MISSING:
1069 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1070 % (glob, dim, name, dim))
1071 elif err.state == HYP_NOTCONFORM:
1072 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1073 elif err.state == HYP_BAD_PARAMETER:
1074 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1075 % ( glob, dim, name ))
1076 elif err.state == HYP_BAD_GEOMETRY:
1077 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1078 'geometry' % ( glob, dim, name ))
1080 reason = "For unknown reason."+\
1081 " Revise Mesh.Compute() implementation in smeshDC.py!"
1083 if allReasons != "":
1086 allReasons += reason
1088 if allReasons != "":
1089 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1093 print '"' + GetName(self.mesh) + '"',"has not been computed."
1096 if salome.sg.hasDesktop():
1097 smeshgui = salome.ImportComponentGUI("SMESH")
1098 smeshgui.Init(salome.myStudyId)
1099 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1100 salome.sg.updateObjBrowser(1)
1104 ## Removes all nodes and elements
1105 # @ingroup l2_construct
1108 if salome.sg.hasDesktop():
1109 smeshgui = salome.ImportComponentGUI("SMESH")
1110 smeshgui.Init(salome.myStudyId)
1111 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1112 salome.sg.updateObjBrowser(1)
1114 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1115 # @param fineness [0,-1] defines mesh fineness
1116 # @return True or False
1117 # @ingroup l3_algos_basic
1118 def AutomaticTetrahedralization(self, fineness=0):
1119 dim = self.MeshDimension()
1121 self.RemoveGlobalHypotheses()
1122 self.Segment().AutomaticLength(fineness)
1124 self.Triangle().LengthFromEdges()
1127 self.Tetrahedron(NETGEN)
1129 return self.Compute()
1131 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1132 # @param fineness [0,-1] defines mesh fineness
1133 # @return True or False
1134 # @ingroup l3_algos_basic
1135 def AutomaticHexahedralization(self, fineness=0):
1136 dim = self.MeshDimension()
1137 # assign the hypotheses
1138 self.RemoveGlobalHypotheses()
1139 self.Segment().AutomaticLength(fineness)
1146 return self.Compute()
1148 ## Assigns a hypothesis
1149 # @param hyp a hypothesis to assign
1150 # @param geom a subhape of mesh geometry
1151 # @return SMESH.Hypothesis_Status
1152 # @ingroup l2_hypotheses
1153 def AddHypothesis(self, hyp, geom=0):
1154 if isinstance( hyp, Mesh_Algorithm ):
1155 hyp = hyp.GetAlgorithm()
1160 geom = self.mesh.GetShapeToMesh()
1162 status = self.mesh.AddHypothesis(geom, hyp)
1163 isAlgo = hyp._narrow( SMESH_Algo )
1164 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1167 ## Unassigns a hypothesis
1168 # @param hyp a hypothesis to unassign
1169 # @param geom a subshape of mesh geometry
1170 # @return SMESH.Hypothesis_Status
1171 # @ingroup l2_hypotheses
1172 def RemoveHypothesis(self, hyp, geom=0):
1173 if isinstance( hyp, Mesh_Algorithm ):
1174 hyp = hyp.GetAlgorithm()
1179 status = self.mesh.RemoveHypothesis(geom, hyp)
1182 ## Gets the list of hypotheses added on a geometry
1183 # @param geom a subshape of mesh geometry
1184 # @return the sequence of SMESH_Hypothesis
1185 # @ingroup l2_hypotheses
1186 def GetHypothesisList(self, geom):
1187 return self.mesh.GetHypothesisList( geom )
1189 ## Removes all global hypotheses
1190 # @ingroup l2_hypotheses
1191 def RemoveGlobalHypotheses(self):
1192 current_hyps = self.mesh.GetHypothesisList( self.geom )
1193 for hyp in current_hyps:
1194 self.mesh.RemoveHypothesis( self.geom, hyp )
1198 ## Creates a mesh group based on the geometric object \a grp
1199 # and gives a \a name, \n if this parameter is not defined
1200 # the name is the same as the geometric group name \n
1201 # Note: Works like GroupOnGeom().
1202 # @param grp a geometric group, a vertex, an edge, a face or a solid
1203 # @param name the name of the mesh group
1204 # @return SMESH_GroupOnGeom
1205 # @ingroup l2_grps_create
1206 def Group(self, grp, name=""):
1207 return self.GroupOnGeom(grp, name)
1209 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1210 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1211 # @param f the file name
1212 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1213 # @ingroup l2_impexp
1214 def ExportToMED(self, f, version, opt=0):
1215 self.mesh.ExportToMED(f, opt, version)
1217 ## Exports the mesh in a file in MED format
1218 # @param f is the file name
1219 # @param auto_groups boolean parameter for creating/not creating
1220 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1221 # the typical use is auto_groups=false.
1222 # @param version MED format version(MED_V2_1 or MED_V2_2)
1223 # @ingroup l2_impexp
1224 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1225 self.mesh.ExportToMED(f, auto_groups, version)
1227 ## Exports the mesh in a file in DAT format
1228 # @param f the file name
1229 # @ingroup l2_impexp
1230 def ExportDAT(self, f):
1231 self.mesh.ExportDAT(f)
1233 ## Exports the mesh in a file in UNV format
1234 # @param f the file name
1235 # @ingroup l2_impexp
1236 def ExportUNV(self, f):
1237 self.mesh.ExportUNV(f)
1239 ## Export the mesh in a file in STL format
1240 # @param f the file name
1241 # @param ascii defines the file encoding
1242 # @ingroup l2_impexp
1243 def ExportSTL(self, f, ascii=1):
1244 self.mesh.ExportSTL(f, ascii)
1247 # Operations with groups:
1248 # ----------------------
1250 ## Creates an empty mesh group
1251 # @param elementType the type of elements in the group
1252 # @param name the name of the mesh group
1253 # @return SMESH_Group
1254 # @ingroup l2_grps_create
1255 def CreateEmptyGroup(self, elementType, name):
1256 return self.mesh.CreateGroup(elementType, name)
1258 ## Creates a mesh group based on the geometrical object \a grp
1259 # and gives a \a name, \n if this parameter is not defined
1260 # the name is the same as the geometrical group name
1261 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1262 # @param name the name of the mesh group
1263 # @param typ the type of elements in the group. If not set, it is
1264 # automatically detected by the type of the geometry
1265 # @return SMESH_GroupOnGeom
1266 # @ingroup l2_grps_create
1267 def GroupOnGeom(self, grp, name="", typ=None):
1269 name = grp.GetName()
1272 tgeo = str(grp.GetShapeType())
1273 if tgeo == "VERTEX":
1275 elif tgeo == "EDGE":
1277 elif tgeo == "FACE":
1279 elif tgeo == "SOLID":
1281 elif tgeo == "SHELL":
1283 elif tgeo == "COMPOUND":
1284 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1285 print "Mesh.Group: empty geometric group", GetName( grp )
1287 tgeo = self.geompyD.GetType(grp)
1288 if tgeo == geompyDC.ShapeType["VERTEX"]:
1290 elif tgeo == geompyDC.ShapeType["EDGE"]:
1292 elif tgeo == geompyDC.ShapeType["FACE"]:
1294 elif tgeo == geompyDC.ShapeType["SOLID"]:
1298 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1301 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1303 ## Creates a mesh group by the given ids of elements
1304 # @param groupName the name of the mesh group
1305 # @param elementType the type of elements in the group
1306 # @param elemIDs the list of ids
1307 # @return SMESH_Group
1308 # @ingroup l2_grps_create
1309 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1310 group = self.mesh.CreateGroup(elementType, groupName)
1314 ## Creates a mesh group by the given conditions
1315 # @param groupName the name of the mesh group
1316 # @param elementType the type of elements in the group
1317 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1318 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1319 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1320 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1321 # @return SMESH_Group
1322 # @ingroup l2_grps_create
1326 CritType=FT_Undefined,
1329 UnaryOp=FT_Undefined):
1330 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1331 group = self.MakeGroupByCriterion(groupName, aCriterion)
1334 ## Creates a mesh group by the given criterion
1335 # @param groupName the name of the mesh group
1336 # @param Criterion the instance of Criterion class
1337 # @return SMESH_Group
1338 # @ingroup l2_grps_create
1339 def MakeGroupByCriterion(self, groupName, Criterion):
1340 aFilterMgr = self.smeshpyD.CreateFilterManager()
1341 aFilter = aFilterMgr.CreateFilter()
1343 aCriteria.append(Criterion)
1344 aFilter.SetCriteria(aCriteria)
1345 group = self.MakeGroupByFilter(groupName, aFilter)
1348 ## Creates a mesh group by the given criteria (list of criteria)
1349 # @param groupName the name of the mesh group
1350 # @param theCriteria the list of criteria
1351 # @return SMESH_Group
1352 # @ingroup l2_grps_create
1353 def MakeGroupByCriteria(self, groupName, theCriteria):
1354 aFilterMgr = self.smeshpyD.CreateFilterManager()
1355 aFilter = aFilterMgr.CreateFilter()
1356 aFilter.SetCriteria(theCriteria)
1357 group = self.MakeGroupByFilter(groupName, aFilter)
1360 ## Creates a mesh group by the given filter
1361 # @param groupName the name of the mesh group
1362 # @param theFilter the instance of Filter class
1363 # @return SMESH_Group
1364 # @ingroup l2_grps_create
1365 def MakeGroupByFilter(self, groupName, theFilter):
1366 anIds = theFilter.GetElementsId(self.mesh)
1367 anElemType = theFilter.GetElementType()
1368 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1371 ## Passes mesh elements through the given filter and return IDs of fitting elements
1372 # @param theFilter SMESH_Filter
1373 # @return a list of ids
1374 # @ingroup l1_controls
1375 def GetIdsFromFilter(self, theFilter):
1376 return theFilter.GetElementsId(self.mesh)
1378 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1379 # Returns a list of special structures (borders).
1380 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1381 # @ingroup l1_controls
1382 def GetFreeBorders(self):
1383 aFilterMgr = self.smeshpyD.CreateFilterManager()
1384 aPredicate = aFilterMgr.CreateFreeEdges()
1385 aPredicate.SetMesh(self.mesh)
1386 aBorders = aPredicate.GetBorders()
1390 # @ingroup l2_grps_delete
1391 def RemoveGroup(self, group):
1392 self.mesh.RemoveGroup(group)
1394 ## Removes a group with its contents
1395 # @ingroup l2_grps_delete
1396 def RemoveGroupWithContents(self, group):
1397 self.mesh.RemoveGroupWithContents(group)
1399 ## Gets the list of groups existing in the mesh
1400 # @return a sequence of SMESH_GroupBase
1401 # @ingroup l2_grps_create
1402 def GetGroups(self):
1403 return self.mesh.GetGroups()
1405 ## Gets the number of groups existing in the mesh
1406 # @return the quantity of groups as an integer value
1407 # @ingroup l2_grps_create
1409 return self.mesh.NbGroups()
1411 ## Gets the list of names of groups existing in the mesh
1412 # @return list of strings
1413 # @ingroup l2_grps_create
1414 def GetGroupNames(self):
1415 groups = self.GetGroups()
1417 for group in groups:
1418 names.append(group.GetName())
1421 ## Produces a union of two groups
1422 # A new group is created. All mesh elements that are
1423 # present in the initial groups are added to the new one
1424 # @return an instance of SMESH_Group
1425 # @ingroup l2_grps_operon
1426 def UnionGroups(self, group1, group2, name):
1427 return self.mesh.UnionGroups(group1, group2, name)
1429 ## Prodices an intersection of two groups
1430 # A new group is created. All mesh elements that are common
1431 # for the two initial groups are added to the new one.
1432 # @return an instance of SMESH_Group
1433 # @ingroup l2_grps_operon
1434 def IntersectGroups(self, group1, group2, name):
1435 return self.mesh.IntersectGroups(group1, group2, name)
1437 ## Produces a cut of two groups
1438 # A new group is created. All mesh elements that are present in
1439 # the main group but are not present in the tool group are added to the new one
1440 # @return an instance of SMESH_Group
1441 # @ingroup l2_grps_operon
1442 def CutGroups(self, mainGroup, toolGroup, name):
1443 return self.mesh.CutGroups(mainGroup, toolGroup, name)
1446 # Get some info about mesh:
1447 # ------------------------
1449 ## Returns the log of nodes and elements added or removed
1450 # since the previous clear of the log.
1451 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1452 # @return list of log_block structures:
1457 # @ingroup l1_auxiliary
1458 def GetLog(self, clearAfterGet):
1459 return self.mesh.GetLog(clearAfterGet)
1461 ## Clears the log of nodes and elements added or removed since the previous
1462 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1463 # @ingroup l1_auxiliary
1465 self.mesh.ClearLog()
1467 ## Toggles auto color mode on the object.
1468 # @param theAutoColor the flag which toggles auto color mode.
1469 # @ingroup l1_auxiliary
1470 def SetAutoColor(self, theAutoColor):
1471 self.mesh.SetAutoColor(theAutoColor)
1473 ## Gets flag of object auto color mode.
1474 # @return True or False
1475 # @ingroup l1_auxiliary
1476 def GetAutoColor(self):
1477 return self.mesh.GetAutoColor()
1479 ## Gets the internal ID
1480 # @return integer value, which is the internal Id of the mesh
1481 # @ingroup l1_auxiliary
1483 return self.mesh.GetId()
1486 # @return integer value, which is the study Id of the mesh
1487 # @ingroup l1_auxiliary
1488 def GetStudyId(self):
1489 return self.mesh.GetStudyId()
1491 ## Checks the group names for duplications.
1492 # Consider the maximum group name length stored in MED file.
1493 # @return True or False
1494 # @ingroup l1_auxiliary
1495 def HasDuplicatedGroupNamesMED(self):
1496 return self.mesh.HasDuplicatedGroupNamesMED()
1498 ## Obtains the mesh editor tool
1499 # @return an instance of SMESH_MeshEditor
1500 # @ingroup l1_modifying
1501 def GetMeshEditor(self):
1502 return self.mesh.GetMeshEditor()
1505 # @return an instance of SALOME_MED::MESH
1506 # @ingroup l1_auxiliary
1507 def GetMEDMesh(self):
1508 return self.mesh.GetMEDMesh()
1511 # Get informations about mesh contents:
1512 # ------------------------------------
1514 ## Returns the number of nodes in the mesh
1515 # @return an integer value
1516 # @ingroup l1_meshinfo
1518 return self.mesh.NbNodes()
1520 ## Returns the number of elements in the mesh
1521 # @return an integer value
1522 # @ingroup l1_meshinfo
1523 def NbElements(self):
1524 return self.mesh.NbElements()
1526 ## Returns the number of edges in the mesh
1527 # @return an integer value
1528 # @ingroup l1_meshinfo
1530 return self.mesh.NbEdges()
1532 ## Returns the number of edges with the given order in the mesh
1533 # @param elementOrder the order of elements:
1534 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1535 # @return an integer value
1536 # @ingroup l1_meshinfo
1537 def NbEdgesOfOrder(self, elementOrder):
1538 return self.mesh.NbEdgesOfOrder(elementOrder)
1540 ## Returns the number of faces in the mesh
1541 # @return an integer value
1542 # @ingroup l1_meshinfo
1544 return self.mesh.NbFaces()
1546 ## Returns the number of faces with the given order in the mesh
1547 # @param elementOrder the order of elements:
1548 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1549 # @return an integer value
1550 # @ingroup l1_meshinfo
1551 def NbFacesOfOrder(self, elementOrder):
1552 return self.mesh.NbFacesOfOrder(elementOrder)
1554 ## Returns the number of triangles in the mesh
1555 # @return an integer value
1556 # @ingroup l1_meshinfo
1557 def NbTriangles(self):
1558 return self.mesh.NbTriangles()
1560 ## Returns the number of triangles with the given order in the mesh
1561 # @param elementOrder is the order of elements:
1562 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1563 # @return an integer value
1564 # @ingroup l1_meshinfo
1565 def NbTrianglesOfOrder(self, elementOrder):
1566 return self.mesh.NbTrianglesOfOrder(elementOrder)
1568 ## Returns the number of quadrangles in the mesh
1569 # @return an integer value
1570 # @ingroup l1_meshinfo
1571 def NbQuadrangles(self):
1572 return self.mesh.NbQuadrangles()
1574 ## Returns the number of quadrangles with the given order in the mesh
1575 # @param elementOrder the order of elements:
1576 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1577 # @return an integer value
1578 # @ingroup l1_meshinfo
1579 def NbQuadranglesOfOrder(self, elementOrder):
1580 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1582 ## Returns the number of polygons in the mesh
1583 # @return an integer value
1584 # @ingroup l1_meshinfo
1585 def NbPolygons(self):
1586 return self.mesh.NbPolygons()
1588 ## Returns the number of volumes in the mesh
1589 # @return an integer value
1590 # @ingroup l1_meshinfo
1591 def NbVolumes(self):
1592 return self.mesh.NbVolumes()
1594 ## Returns the number of volumes with the given order in the mesh
1595 # @param elementOrder the order of elements:
1596 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1597 # @return an integer value
1598 # @ingroup l1_meshinfo
1599 def NbVolumesOfOrder(self, elementOrder):
1600 return self.mesh.NbVolumesOfOrder(elementOrder)
1602 ## Returns the number of tetrahedrons in the mesh
1603 # @return an integer value
1604 # @ingroup l1_meshinfo
1606 return self.mesh.NbTetras()
1608 ## Returns the number of tetrahedrons with the given order in the mesh
1609 # @param elementOrder the order of elements:
1610 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1611 # @return an integer value
1612 # @ingroup l1_meshinfo
1613 def NbTetrasOfOrder(self, elementOrder):
1614 return self.mesh.NbTetrasOfOrder(elementOrder)
1616 ## Returns the number of hexahedrons in the mesh
1617 # @return an integer value
1618 # @ingroup l1_meshinfo
1620 return self.mesh.NbHexas()
1622 ## Returns the number of hexahedrons with the given order in the mesh
1623 # @param elementOrder the order of elements:
1624 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1625 # @return an integer value
1626 # @ingroup l1_meshinfo
1627 def NbHexasOfOrder(self, elementOrder):
1628 return self.mesh.NbHexasOfOrder(elementOrder)
1630 ## Returns the number of pyramids in the mesh
1631 # @return an integer value
1632 # @ingroup l1_meshinfo
1633 def NbPyramids(self):
1634 return self.mesh.NbPyramids()
1636 ## Returns the number of pyramids with the given order in the mesh
1637 # @param elementOrder the order of elements:
1638 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1639 # @return an integer value
1640 # @ingroup l1_meshinfo
1641 def NbPyramidsOfOrder(self, elementOrder):
1642 return self.mesh.NbPyramidsOfOrder(elementOrder)
1644 ## Returns the number of prisms in the mesh
1645 # @return an integer value
1646 # @ingroup l1_meshinfo
1648 return self.mesh.NbPrisms()
1650 ## Returns the number of prisms with the given order in the mesh
1651 # @param elementOrder the order of elements:
1652 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1653 # @return an integer value
1654 # @ingroup l1_meshinfo
1655 def NbPrismsOfOrder(self, elementOrder):
1656 return self.mesh.NbPrismsOfOrder(elementOrder)
1658 ## Returns the number of polyhedrons in the mesh
1659 # @return an integer value
1660 # @ingroup l1_meshinfo
1661 def NbPolyhedrons(self):
1662 return self.mesh.NbPolyhedrons()
1664 ## Returns the number of submeshes in the mesh
1665 # @return an integer value
1666 # @ingroup l1_meshinfo
1667 def NbSubMesh(self):
1668 return self.mesh.NbSubMesh()
1670 ## Returns the list of mesh elements IDs
1671 # @return the list of integer values
1672 # @ingroup l1_meshinfo
1673 def GetElementsId(self):
1674 return self.mesh.GetElementsId()
1676 ## Returns the list of IDs of mesh elements with the given type
1677 # @param elementType the required type of elements
1678 # @return list of integer values
1679 # @ingroup l1_meshinfo
1680 def GetElementsByType(self, elementType):
1681 return self.mesh.GetElementsByType(elementType)
1683 ## Returns the list of mesh nodes IDs
1684 # @return the list of integer values
1685 # @ingroup l1_meshinfo
1686 def GetNodesId(self):
1687 return self.mesh.GetNodesId()
1689 # Get the information about mesh elements:
1690 # ------------------------------------
1692 ## Returns the type of mesh element
1693 # @return the value from SMESH::ElementType enumeration
1694 # @ingroup l1_meshinfo
1695 def GetElementType(self, id, iselem):
1696 return self.mesh.GetElementType(id, iselem)
1698 ## Returns the list of submesh elements IDs
1699 # @param Shape a geom object(subshape) IOR
1700 # Shape must be the subshape of a ShapeToMesh()
1701 # @return the list of integer values
1702 # @ingroup l1_meshinfo
1703 def GetSubMeshElementsId(self, Shape):
1704 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1705 ShapeID = Shape.GetSubShapeIndices()[0]
1708 return self.mesh.GetSubMeshElementsId(ShapeID)
1710 ## Returns the list of submesh nodes IDs
1711 # @param Shape a geom object(subshape) IOR
1712 # Shape must be the subshape of a ShapeToMesh()
1713 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1714 # @return the list of integer values
1715 # @ingroup l1_meshinfo
1716 def GetSubMeshNodesId(self, Shape, all):
1717 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1718 ShapeID = Shape.GetSubShapeIndices()[0]
1721 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1723 ## Returns the list of IDs of submesh elements with the given type
1724 # @param Shape a geom object(subshape) IOR
1725 # Shape must be a subshape of a ShapeToMesh()
1726 # @return the list of integer values
1727 # @ingroup l1_meshinfo
1728 def GetSubMeshElementType(self, Shape):
1729 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1730 ShapeID = Shape.GetSubShapeIndices()[0]
1733 return self.mesh.GetSubMeshElementType(ShapeID)
1735 ## Gets the mesh description
1736 # @return string value
1737 # @ingroup l1_meshinfo
1739 return self.mesh.Dump()
1742 # Get the information about nodes and elements of a mesh by its IDs:
1743 # -----------------------------------------------------------
1745 ## Gets XYZ coordinates of a node
1746 # \n If there is no nodes for the given ID - returns an empty list
1747 # @return a list of double precision values
1748 # @ingroup l1_meshinfo
1749 def GetNodeXYZ(self, id):
1750 return self.mesh.GetNodeXYZ(id)
1752 ## Returns list of IDs of inverse elements for the given node
1753 # \n If there is no node for the given ID - returns an empty list
1754 # @return a list of integer values
1755 # @ingroup l1_meshinfo
1756 def GetNodeInverseElements(self, id):
1757 return self.mesh.GetNodeInverseElements(id)
1759 ## @brief Returns the position of a node on the shape
1760 # @return SMESH::NodePosition
1761 # @ingroup l1_meshinfo
1762 def GetNodePosition(self,NodeID):
1763 return self.mesh.GetNodePosition(NodeID)
1765 ## If the given element is a node, returns the ID of shape
1766 # \n If there is no node for the given ID - returns -1
1767 # @return an integer value
1768 # @ingroup l1_meshinfo
1769 def GetShapeID(self, id):
1770 return self.mesh.GetShapeID(id)
1772 ## Returns the ID of the result shape after
1773 # FindShape() from SMESH_MeshEditor for the given element
1774 # \n If there is no element for the given ID - returns -1
1775 # @return an integer value
1776 # @ingroup l1_meshinfo
1777 def GetShapeIDForElem(self,id):
1778 return self.mesh.GetShapeIDForElem(id)
1780 ## Returns the number of nodes for the given element
1781 # \n If there is no element for the given ID - returns -1
1782 # @return an integer value
1783 # @ingroup l1_meshinfo
1784 def GetElemNbNodes(self, id):
1785 return self.mesh.GetElemNbNodes(id)
1787 ## Returns the node ID the given index for the given element
1788 # \n If there is no element for the given ID - returns -1
1789 # \n If there is no node for the given index - returns -2
1790 # @return an integer value
1791 # @ingroup l1_meshinfo
1792 def GetElemNode(self, id, index):
1793 return self.mesh.GetElemNode(id, index)
1795 ## Returns the IDs of nodes of the given element
1796 # @return a list of integer values
1797 # @ingroup l1_meshinfo
1798 def GetElemNodes(self, id):
1799 return self.mesh.GetElemNodes(id)
1801 ## Returns true if the given node is the medium node in the given quadratic element
1802 # @ingroup l1_meshinfo
1803 def IsMediumNode(self, elementID, nodeID):
1804 return self.mesh.IsMediumNode(elementID, nodeID)
1806 ## Returns true if the given node is the medium node in one of quadratic elements
1807 # @ingroup l1_meshinfo
1808 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1809 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1811 ## Returns the number of edges for the given element
1812 # @ingroup l1_meshinfo
1813 def ElemNbEdges(self, id):
1814 return self.mesh.ElemNbEdges(id)
1816 ## Returns the number of faces for the given element
1817 # @ingroup l1_meshinfo
1818 def ElemNbFaces(self, id):
1819 return self.mesh.ElemNbFaces(id)
1821 ## Returns true if the given element is a polygon
1822 # @ingroup l1_meshinfo
1823 def IsPoly(self, id):
1824 return self.mesh.IsPoly(id)
1826 ## Returns true if the given element is quadratic
1827 # @ingroup l1_meshinfo
1828 def IsQuadratic(self, id):
1829 return self.mesh.IsQuadratic(id)
1831 ## Returns XYZ coordinates of the barycenter of the given element
1832 # \n If there is no element for the given ID - returns an empty list
1833 # @return a list of three double values
1834 # @ingroup l1_meshinfo
1835 def BaryCenter(self, id):
1836 return self.mesh.BaryCenter(id)
1839 # Mesh edition (SMESH_MeshEditor functionality):
1840 # ---------------------------------------------
1842 ## Removes the elements from the mesh by ids
1843 # @param IDsOfElements is a list of ids of elements to remove
1844 # @return True or False
1845 # @ingroup l2_modif_del
1846 def RemoveElements(self, IDsOfElements):
1847 return self.editor.RemoveElements(IDsOfElements)
1849 ## Removes nodes from mesh by ids
1850 # @param IDsOfNodes is a list of ids of nodes to remove
1851 # @return True or False
1852 # @ingroup l2_modif_del
1853 def RemoveNodes(self, IDsOfNodes):
1854 return self.editor.RemoveNodes(IDsOfNodes)
1856 ## Add a node to the mesh by coordinates
1857 # @return Id of the new node
1858 # @ingroup l2_modif_add
1859 def AddNode(self, x, y, z):
1860 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
1861 self.mesh.SetParameters(Parameters)
1862 return self.editor.AddNode( x, y, z)
1864 ## Creates a linear or quadratic edge (this is determined
1865 # by the number of given nodes).
1866 # @param IDsOfNodes the list of node IDs for creation of the element.
1867 # The order of nodes in this list should correspond to the description
1868 # of MED. \n This description is located by the following link:
1869 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1870 # @return the Id of the new edge
1871 # @ingroup l2_modif_add
1872 def AddEdge(self, IDsOfNodes):
1873 return self.editor.AddEdge(IDsOfNodes)
1875 ## Creates a linear or quadratic face (this is determined
1876 # by the number of given nodes).
1877 # @param IDsOfNodes the list of node IDs for creation of the element.
1878 # The order of nodes in this list should correspond to the description
1879 # of MED. \n This description is located by the following link:
1880 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1881 # @return the Id of the new face
1882 # @ingroup l2_modif_add
1883 def AddFace(self, IDsOfNodes):
1884 return self.editor.AddFace(IDsOfNodes)
1886 ## Adds a polygonal face to the mesh by the list of node IDs
1887 # @param IdsOfNodes the list of node IDs for creation of the element.
1888 # @return the Id of the new face
1889 # @ingroup l2_modif_add
1890 def AddPolygonalFace(self, IdsOfNodes):
1891 return self.editor.AddPolygonalFace(IdsOfNodes)
1893 ## Creates both simple and quadratic volume (this is determined
1894 # by the number of given nodes).
1895 # @param IDsOfNodes the list of node IDs for creation of the element.
1896 # The order of nodes in this list should correspond to the description
1897 # of MED. \n This description is located by the following link:
1898 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1899 # @return the Id of the new volumic element
1900 # @ingroup l2_modif_add
1901 def AddVolume(self, IDsOfNodes):
1902 return self.editor.AddVolume(IDsOfNodes)
1904 ## Creates a volume of many faces, giving nodes for each face.
1905 # @param IdsOfNodes the list of node IDs for volume creation face by face.
1906 # @param Quantities the list of integer values, Quantities[i]
1907 # gives the quantity of nodes in face number i.
1908 # @return the Id of the new volumic element
1909 # @ingroup l2_modif_add
1910 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1911 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1913 ## Creates a volume of many faces, giving the IDs of the existing faces.
1914 # @param IdsOfFaces the list of face IDs for volume creation.
1916 # Note: The created volume will refer only to the nodes
1917 # of the given faces, not to the faces themselves.
1918 # @return the Id of the new volumic element
1919 # @ingroup l2_modif_add
1920 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1921 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1924 ## @brief Binds a node to a vertex
1925 # @param NodeID a node ID
1926 # @param Vertex a vertex or vertex ID
1927 # @return True if succeed else raises an exception
1928 # @ingroup l2_modif_add
1929 def SetNodeOnVertex(self, NodeID, Vertex):
1930 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
1931 VertexID = Vertex.GetSubShapeIndices()[0]
1935 self.editor.SetNodeOnVertex(NodeID, VertexID)
1936 except SALOME.SALOME_Exception, inst:
1937 raise ValueError, inst.details.text
1941 ## @brief Stores the node position on an edge
1942 # @param NodeID a node ID
1943 # @param Edge an edge or edge ID
1944 # @param paramOnEdge a parameter on the edge where the node is located
1945 # @return True if succeed else raises an exception
1946 # @ingroup l2_modif_add
1947 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
1948 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
1949 EdgeID = Edge.GetSubShapeIndices()[0]
1953 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
1954 except SALOME.SALOME_Exception, inst:
1955 raise ValueError, inst.details.text
1958 ## @brief Stores node position on a face
1959 # @param NodeID a node ID
1960 # @param Face a face or face ID
1961 # @param u U parameter on the face where the node is located
1962 # @param v V parameter on the face where the node is located
1963 # @return True if succeed else raises an exception
1964 # @ingroup l2_modif_add
1965 def SetNodeOnFace(self, NodeID, Face, u, v):
1966 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
1967 FaceID = Face.GetSubShapeIndices()[0]
1971 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
1972 except SALOME.SALOME_Exception, inst:
1973 raise ValueError, inst.details.text
1976 ## @brief Binds a node to a solid
1977 # @param NodeID a node ID
1978 # @param Solid a solid or solid ID
1979 # @return True if succeed else raises an exception
1980 # @ingroup l2_modif_add
1981 def SetNodeInVolume(self, NodeID, Solid):
1982 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
1983 SolidID = Solid.GetSubShapeIndices()[0]
1987 self.editor.SetNodeInVolume(NodeID, SolidID)
1988 except SALOME.SALOME_Exception, inst:
1989 raise ValueError, inst.details.text
1992 ## @brief Bind an element to a shape
1993 # @param ElementID an element ID
1994 # @param Shape a shape or shape ID
1995 # @return True if succeed else raises an exception
1996 # @ingroup l2_modif_add
1997 def SetMeshElementOnShape(self, ElementID, Shape):
1998 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1999 ShapeID = Shape.GetSubShapeIndices()[0]
2003 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2004 except SALOME.SALOME_Exception, inst:
2005 raise ValueError, inst.details.text
2009 ## Moves the node with the given id
2010 # @param NodeID the id of the node
2011 # @param x a new X coordinate
2012 # @param y a new Y coordinate
2013 # @param z a new Z coordinate
2014 # @return True if succeed else False
2015 # @ingroup l2_modif_movenode
2016 def MoveNode(self, NodeID, x, y, z):
2017 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2018 self.mesh.SetParameters(Parameters)
2019 return self.editor.MoveNode(NodeID, x, y, z)
2021 ## Finds the node closest to a point and moves it to a point location
2022 # @param x the X coordinate of a point
2023 # @param y the Y coordinate of a point
2024 # @param z the Z coordinate of a point
2025 # @return the ID of a node
2026 # @ingroup l2_modif_throughp
2027 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2028 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2029 self.mesh.SetParameters(Parameters)
2030 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2032 ## Finds the node closest to a point
2033 # @param x the X coordinate of a point
2034 # @param y the Y coordinate of a point
2035 # @param z the Z coordinate of a point
2036 # @return the ID of a node
2037 # @ingroup l2_modif_throughp
2038 def FindNodeClosestTo(self, x, y, z):
2039 preview = self.mesh.GetMeshEditPreviewer()
2040 return preview.MoveClosestNodeToPoint(x, y, z, -1)
2042 ## Finds the node closest to a point and moves it to a point location
2043 # @param x the X coordinate of a point
2044 # @param y the Y coordinate of a point
2045 # @param z the Z coordinate of a point
2046 # @return the ID of a moved node
2047 # @ingroup l2_modif_throughp
2048 def MeshToPassThroughAPoint(self, x, y, z):
2049 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2051 ## Replaces two neighbour triangles sharing Node1-Node2 link
2052 # with the triangles built on the same 4 nodes but having other common link.
2053 # @param NodeID1 the ID of the first node
2054 # @param NodeID2 the ID of the second node
2055 # @return false if proper faces were not found
2056 # @ingroup l2_modif_invdiag
2057 def InverseDiag(self, NodeID1, NodeID2):
2058 return self.editor.InverseDiag(NodeID1, NodeID2)
2060 ## Replaces two neighbour triangles sharing Node1-Node2 link
2061 # with a quadrangle built on the same 4 nodes.
2062 # @param NodeID1 the ID of the first node
2063 # @param NodeID2 the ID of the second node
2064 # @return false if proper faces were not found
2065 # @ingroup l2_modif_unitetri
2066 def DeleteDiag(self, NodeID1, NodeID2):
2067 return self.editor.DeleteDiag(NodeID1, NodeID2)
2069 ## Reorients elements by ids
2070 # @param IDsOfElements if undefined reorients all mesh elements
2071 # @return True if succeed else False
2072 # @ingroup l2_modif_changori
2073 def Reorient(self, IDsOfElements=None):
2074 if IDsOfElements == None:
2075 IDsOfElements = self.GetElementsId()
2076 return self.editor.Reorient(IDsOfElements)
2078 ## Reorients all elements of the object
2079 # @param theObject mesh, submesh or group
2080 # @return True if succeed else False
2081 # @ingroup l2_modif_changori
2082 def ReorientObject(self, theObject):
2083 if ( isinstance( theObject, Mesh )):
2084 theObject = theObject.GetMesh()
2085 return self.editor.ReorientObject(theObject)
2087 ## Fuses the neighbouring triangles into quadrangles.
2088 # @param IDsOfElements The triangles to be fused,
2089 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2090 # @param MaxAngle is the maximum angle between element normals at which the fusion
2091 # is still performed; theMaxAngle is mesured in radians.
2092 # Also it could be a name of variable which defines angle in degrees.
2093 # @return TRUE in case of success, FALSE otherwise.
2094 # @ingroup l2_modif_unitetri
2095 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2097 if isinstance(MaxAngle,str):
2099 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2101 MaxAngle = DegreesToRadians(MaxAngle)
2102 if IDsOfElements == []:
2103 IDsOfElements = self.GetElementsId()
2104 self.mesh.SetParameters(Parameters)
2106 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2107 Functor = theCriterion
2109 Functor = self.smeshpyD.GetFunctor(theCriterion)
2110 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2112 ## Fuses the neighbouring triangles of the object into quadrangles
2113 # @param theObject is mesh, submesh or group
2114 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2115 # @param MaxAngle a max angle between element normals at which the fusion
2116 # is still performed; theMaxAngle is mesured in radians.
2117 # @return TRUE in case of success, FALSE otherwise.
2118 # @ingroup l2_modif_unitetri
2119 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2120 if ( isinstance( theObject, Mesh )):
2121 theObject = theObject.GetMesh()
2122 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2124 ## Splits quadrangles into triangles.
2125 # @param IDsOfElements the faces to be splitted.
2126 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2127 # @return TRUE in case of success, FALSE otherwise.
2128 # @ingroup l2_modif_cutquadr
2129 def QuadToTri (self, IDsOfElements, theCriterion):
2130 if IDsOfElements == []:
2131 IDsOfElements = self.GetElementsId()
2132 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2134 ## Splits quadrangles into triangles.
2135 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2136 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2137 # @return TRUE in case of success, FALSE otherwise.
2138 # @ingroup l2_modif_cutquadr
2139 def QuadToTriObject (self, theObject, theCriterion):
2140 if ( isinstance( theObject, Mesh )):
2141 theObject = theObject.GetMesh()
2142 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2144 ## Splits quadrangles into triangles.
2145 # @param IDsOfElements the faces to be splitted
2146 # @param Diag13 is used to choose a diagonal for splitting.
2147 # @return TRUE in case of success, FALSE otherwise.
2148 # @ingroup l2_modif_cutquadr
2149 def SplitQuad (self, IDsOfElements, Diag13):
2150 if IDsOfElements == []:
2151 IDsOfElements = self.GetElementsId()
2152 return self.editor.SplitQuad(IDsOfElements, Diag13)
2154 ## Splits quadrangles into triangles.
2155 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2156 # @param Diag13 is used to choose a diagonal for splitting.
2157 # @return TRUE in case of success, FALSE otherwise.
2158 # @ingroup l2_modif_cutquadr
2159 def SplitQuadObject (self, theObject, Diag13):
2160 if ( isinstance( theObject, Mesh )):
2161 theObject = theObject.GetMesh()
2162 return self.editor.SplitQuadObject(theObject, Diag13)
2164 ## Finds a better splitting of the given quadrangle.
2165 # @param IDOfQuad the ID of the quadrangle to be splitted.
2166 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2167 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2168 # diagonal is better, 0 if error occurs.
2169 # @ingroup l2_modif_cutquadr
2170 def BestSplit (self, IDOfQuad, theCriterion):
2171 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2173 ## Splits quadrangle faces near triangular facets of volumes
2175 # @ingroup l1_auxiliary
2176 def SplitQuadsNearTriangularFacets(self):
2177 faces_array = self.GetElementsByType(SMESH.FACE)
2178 for face_id in faces_array:
2179 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2180 quad_nodes = self.mesh.GetElemNodes(face_id)
2181 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2182 isVolumeFound = False
2183 for node1_elem in node1_elems:
2184 if not isVolumeFound:
2185 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2186 nb_nodes = self.GetElemNbNodes(node1_elem)
2187 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2188 volume_elem = node1_elem
2189 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2190 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2191 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2192 isVolumeFound = True
2193 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2194 self.SplitQuad([face_id], False) # diagonal 2-4
2195 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2196 isVolumeFound = True
2197 self.SplitQuad([face_id], True) # diagonal 1-3
2198 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2199 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2200 isVolumeFound = True
2201 self.SplitQuad([face_id], True) # diagonal 1-3
2203 ## @brief Splits hexahedrons into tetrahedrons.
2205 # This operation uses pattern mapping functionality for splitting.
2206 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2207 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2208 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2209 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2210 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2211 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2212 # @return TRUE in case of success, FALSE otherwise.
2213 # @ingroup l1_auxiliary
2214 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2215 # Pattern: 5.---------.6
2220 # (0,0,1) 4.---------.7 * |
2227 # (0,0,0) 0.---------.3
2228 pattern_tetra = "!!! Nb of points: \n 8 \n\
2238 !!! Indices of points of 6 tetras: \n\
2246 pattern = self.smeshpyD.GetPattern()
2247 isDone = pattern.LoadFromFile(pattern_tetra)
2249 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2252 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2253 isDone = pattern.MakeMesh(self.mesh, False, False)
2254 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2256 # split quafrangle faces near triangular facets of volumes
2257 self.SplitQuadsNearTriangularFacets()
2261 ## @brief Split hexahedrons into prisms.
2263 # Uses the pattern mapping functionality for splitting.
2264 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2265 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2266 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2267 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2268 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2269 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2270 # @return TRUE in case of success, FALSE otherwise.
2271 # @ingroup l1_auxiliary
2272 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2273 # Pattern: 5.---------.6
2278 # (0,0,1) 4.---------.7 |
2285 # (0,0,0) 0.---------.3
2286 pattern_prism = "!!! Nb of points: \n 8 \n\
2296 !!! Indices of points of 2 prisms: \n\
2300 pattern = self.smeshpyD.GetPattern()
2301 isDone = pattern.LoadFromFile(pattern_prism)
2303 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2306 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2307 isDone = pattern.MakeMesh(self.mesh, False, False)
2308 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2310 # Splits quafrangle faces near triangular facets of volumes
2311 self.SplitQuadsNearTriangularFacets()
2315 ## Smoothes elements
2316 # @param IDsOfElements the list if ids of elements to smooth
2317 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2318 # Note that nodes built on edges and boundary nodes are always fixed.
2319 # @param MaxNbOfIterations the maximum number of iterations
2320 # @param MaxAspectRatio varies in range [1.0, inf]
2321 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2322 # @return TRUE in case of success, FALSE otherwise.
2323 # @ingroup l2_modif_smooth
2324 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2325 MaxNbOfIterations, MaxAspectRatio, Method):
2326 if IDsOfElements == []:
2327 IDsOfElements = self.GetElementsId()
2328 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2329 self.mesh.SetParameters(Parameters)
2330 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2331 MaxNbOfIterations, MaxAspectRatio, Method)
2333 ## Smoothes elements which belong to the given object
2334 # @param theObject the object to smooth
2335 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2336 # Note that nodes built on edges and boundary nodes are always fixed.
2337 # @param MaxNbOfIterations the maximum number of iterations
2338 # @param MaxAspectRatio varies in range [1.0, inf]
2339 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2340 # @return TRUE in case of success, FALSE otherwise.
2341 # @ingroup l2_modif_smooth
2342 def SmoothObject(self, theObject, IDsOfFixedNodes,
2343 MaxNbOfIterations, MaxAspectRatio, Method):
2344 if ( isinstance( theObject, Mesh )):
2345 theObject = theObject.GetMesh()
2346 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2347 MaxNbOfIterations, MaxAspectRatio, Method)
2349 ## Parametrically smoothes the given elements
2350 # @param IDsOfElements the list if ids of elements to smooth
2351 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2352 # Note that nodes built on edges and boundary nodes are always fixed.
2353 # @param MaxNbOfIterations the maximum number of iterations
2354 # @param MaxAspectRatio varies in range [1.0, inf]
2355 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2356 # @return TRUE in case of success, FALSE otherwise.
2357 # @ingroup l2_modif_smooth
2358 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2359 MaxNbOfIterations, MaxAspectRatio, Method):
2360 if IDsOfElements == []:
2361 IDsOfElements = self.GetElementsId()
2362 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2363 self.mesh.SetParameters(Parameters)
2364 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2365 MaxNbOfIterations, MaxAspectRatio, Method)
2367 ## Parametrically smoothes the elements which belong to the given object
2368 # @param theObject the object to smooth
2369 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2370 # Note that nodes built on edges and boundary nodes are always fixed.
2371 # @param MaxNbOfIterations the maximum number of iterations
2372 # @param MaxAspectRatio varies in range [1.0, inf]
2373 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2374 # @return TRUE in case of success, FALSE otherwise.
2375 # @ingroup l2_modif_smooth
2376 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2377 MaxNbOfIterations, MaxAspectRatio, Method):
2378 if ( isinstance( theObject, Mesh )):
2379 theObject = theObject.GetMesh()
2380 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2381 MaxNbOfIterations, MaxAspectRatio, Method)
2383 ## Converts the mesh to quadratic, deletes old elements, replacing
2384 # them with quadratic with the same id.
2385 # @ingroup l2_modif_tofromqu
2386 def ConvertToQuadratic(self, theForce3d):
2387 self.editor.ConvertToQuadratic(theForce3d)
2389 ## Converts the mesh from quadratic to ordinary,
2390 # deletes old quadratic elements, \n replacing
2391 # them with ordinary mesh elements with the same id.
2392 # @return TRUE in case of success, FALSE otherwise.
2393 # @ingroup l2_modif_tofromqu
2394 def ConvertFromQuadratic(self):
2395 return self.editor.ConvertFromQuadratic()
2397 ## Renumber mesh nodes
2398 # @ingroup l2_modif_renumber
2399 def RenumberNodes(self):
2400 self.editor.RenumberNodes()
2402 ## Renumber mesh elements
2403 # @ingroup l2_modif_renumber
2404 def RenumberElements(self):
2405 self.editor.RenumberElements()
2407 ## Generates new elements by rotation of the elements around the axis
2408 # @param IDsOfElements the list of ids of elements to sweep
2409 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2410 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2411 # @param NbOfSteps the number of steps
2412 # @param Tolerance tolerance
2413 # @param MakeGroups forces the generation of new groups from existing ones
2414 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2415 # of all steps, else - size of each step
2416 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2417 # @ingroup l2_modif_extrurev
2418 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2419 MakeGroups=False, TotalAngle=False):
2421 if isinstance(AngleInRadians,str):
2423 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2425 AngleInRadians = DegreesToRadians(AngleInRadians)
2426 if IDsOfElements == []:
2427 IDsOfElements = self.GetElementsId()
2428 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2429 Axis = self.smeshpyD.GetAxisStruct(Axis)
2430 Axis,AxisParameters = ParseAxisStruct(Axis)
2431 if TotalAngle and NbOfSteps:
2432 AngleInRadians /= NbOfSteps
2433 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2434 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2435 self.mesh.SetParameters(Parameters)
2437 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2438 AngleInRadians, NbOfSteps, Tolerance)
2439 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2442 ## Generates new elements by rotation of the elements of object around the axis
2443 # @param theObject object which elements should be sweeped
2444 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2445 # @param AngleInRadians the angle of Rotation
2446 # @param NbOfSteps number of steps
2447 # @param Tolerance tolerance
2448 # @param MakeGroups forces the generation of new groups from existing ones
2449 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2450 # of all steps, else - size of each step
2451 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2452 # @ingroup l2_modif_extrurev
2453 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2454 MakeGroups=False, TotalAngle=False):
2456 if isinstance(AngleInRadians,str):
2458 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2460 AngleInRadians = DegreesToRadians(AngleInRadians)
2461 if ( isinstance( theObject, Mesh )):
2462 theObject = theObject.GetMesh()
2463 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2464 Axis = self.smeshpyD.GetAxisStruct(Axis)
2465 Axis,AxisParameters = ParseAxisStruct(Axis)
2466 if TotalAngle and NbOfSteps:
2467 AngleInRadians /= NbOfSteps
2468 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2469 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2470 self.mesh.SetParameters(Parameters)
2472 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2473 NbOfSteps, Tolerance)
2474 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2477 ## Generates new elements by rotation of the elements of object around the axis
2478 # @param theObject object which elements should be sweeped
2479 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2480 # @param AngleInRadians the angle of Rotation
2481 # @param NbOfSteps number of steps
2482 # @param Tolerance tolerance
2483 # @param MakeGroups forces the generation of new groups from existing ones
2484 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2485 # of all steps, else - size of each step
2486 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2487 # @ingroup l2_modif_extrurev
2488 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2489 MakeGroups=False, TotalAngle=False):
2491 if isinstance(AngleInRadians,str):
2493 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2495 AngleInRadians = DegreesToRadians(AngleInRadians)
2496 if ( isinstance( theObject, Mesh )):
2497 theObject = theObject.GetMesh()
2498 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2499 Axis = self.smeshpyD.GetAxisStruct(Axis)
2500 Axis,AxisParameters = ParseAxisStruct(Axis)
2501 if TotalAngle and NbOfSteps:
2502 AngleInRadians /= NbOfSteps
2503 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2504 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2505 self.mesh.SetParameters(Parameters)
2507 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2508 NbOfSteps, Tolerance)
2509 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2512 ## Generates new elements by rotation of the elements of object around the axis
2513 # @param theObject object which elements should be sweeped
2514 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2515 # @param AngleInRadians the angle of Rotation
2516 # @param NbOfSteps number of steps
2517 # @param Tolerance tolerance
2518 # @param MakeGroups forces the generation of new groups from existing ones
2519 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2520 # of all steps, else - size of each step
2521 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2522 # @ingroup l2_modif_extrurev
2523 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2524 MakeGroups=False, TotalAngle=False):
2526 if isinstance(AngleInRadians,str):
2528 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2530 AngleInRadians = DegreesToRadians(AngleInRadians)
2531 if ( isinstance( theObject, Mesh )):
2532 theObject = theObject.GetMesh()
2533 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2534 Axis = self.smeshpyD.GetAxisStruct(Axis)
2535 Axis,AxisParameters = ParseAxisStruct(Axis)
2536 if TotalAngle and NbOfSteps:
2537 AngleInRadians /= NbOfSteps
2538 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2539 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2540 self.mesh.SetParameters(Parameters)
2542 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2543 NbOfSteps, Tolerance)
2544 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2547 ## Generates new elements by extrusion of the elements with given ids
2548 # @param IDsOfElements the list of elements ids for extrusion
2549 # @param StepVector vector, defining the direction and value of extrusion
2550 # @param NbOfSteps the number of steps
2551 # @param MakeGroups forces the generation of new groups from existing ones
2552 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2553 # @ingroup l2_modif_extrurev
2554 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2555 if IDsOfElements == []:
2556 IDsOfElements = self.GetElementsId()
2557 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2558 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2559 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2560 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2561 Parameters = StepVectorParameters + var_separator + Parameters
2562 self.mesh.SetParameters(Parameters)
2564 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2565 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2568 ## Generates new elements by extrusion of the elements with given ids
2569 # @param IDsOfElements is ids of elements
2570 # @param StepVector vector, defining the direction and value of extrusion
2571 # @param NbOfSteps the number of steps
2572 # @param ExtrFlags sets flags for extrusion
2573 # @param SewTolerance uses for comparing locations of nodes if flag
2574 # EXTRUSION_FLAG_SEW is set
2575 # @param MakeGroups forces the generation of new groups from existing ones
2576 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2577 # @ingroup l2_modif_extrurev
2578 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2579 ExtrFlags, SewTolerance, MakeGroups=False):
2580 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2581 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2583 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2584 ExtrFlags, SewTolerance)
2585 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2586 ExtrFlags, SewTolerance)
2589 ## Generates new elements by extrusion of the elements which belong to the object
2590 # @param theObject the object which elements should be processed
2591 # @param StepVector vector, defining the direction and value of extrusion
2592 # @param NbOfSteps the number of steps
2593 # @param MakeGroups forces the generation of new groups from existing ones
2594 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2595 # @ingroup l2_modif_extrurev
2596 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2597 if ( isinstance( theObject, Mesh )):
2598 theObject = theObject.GetMesh()
2599 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2600 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2601 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2602 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2603 Parameters = StepVectorParameters + var_separator + Parameters
2604 self.mesh.SetParameters(Parameters)
2606 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2607 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2610 ## Generates new elements by extrusion of the elements which belong to the object
2611 # @param theObject object which elements should be processed
2612 # @param StepVector vector, defining the direction and value of extrusion
2613 # @param NbOfSteps the number of steps
2614 # @param MakeGroups to generate new groups from existing ones
2615 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2616 # @ingroup l2_modif_extrurev
2617 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2618 if ( isinstance( theObject, Mesh )):
2619 theObject = theObject.GetMesh()
2620 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2621 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2622 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2623 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2624 Parameters = StepVectorParameters + var_separator + Parameters
2625 self.mesh.SetParameters(Parameters)
2627 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2628 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2631 ## Generates new elements by extrusion of the elements which belong to the object
2632 # @param theObject object which elements should be processed
2633 # @param StepVector vector, defining the direction and value of extrusion
2634 # @param NbOfSteps the number of steps
2635 # @param MakeGroups forces the generation of new groups from existing ones
2636 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2637 # @ingroup l2_modif_extrurev
2638 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2639 if ( isinstance( theObject, Mesh )):
2640 theObject = theObject.GetMesh()
2641 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2642 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2643 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2644 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2645 Parameters = StepVectorParameters + var_separator + Parameters
2646 self.mesh.SetParameters(Parameters)
2648 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2649 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2652 ## Generates new elements by extrusion of the given elements
2653 # The path of extrusion must be a meshed edge.
2654 # @param IDsOfElements ids of elements
2655 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2656 # @param PathShape shape(edge) defines the sub-mesh for the path
2657 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2658 # @param HasAngles allows the shape to be rotated around the path
2659 # to get the resulting mesh in a helical fashion
2660 # @param Angles list of angles
2661 # @param HasRefPoint allows using the reference point
2662 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2663 # The User can specify any point as the Reference Point.
2664 # @param MakeGroups forces the generation of new groups from existing ones
2665 # @param LinearVariation forces the computation of rotation angles as linear
2666 # variation of the given Angles along path steps
2667 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2668 # only SMESH::Extrusion_Error otherwise
2669 # @ingroup l2_modif_extrurev
2670 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2671 HasAngles, Angles, HasRefPoint, RefPoint,
2672 MakeGroups=False, LinearVariation=False):
2673 Angles,AnglesParameters = ParseAngles(Angles)
2674 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2675 if IDsOfElements == []:
2676 IDsOfElements = self.GetElementsId()
2677 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2678 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2680 if ( isinstance( PathMesh, Mesh )):
2681 PathMesh = PathMesh.GetMesh()
2682 if HasAngles and Angles and LinearVariation:
2683 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2685 Parameters = AnglesParameters + var_separator + RefPointParameters
2686 self.mesh.SetParameters(Parameters)
2688 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2689 PathShape, NodeStart, HasAngles,
2690 Angles, HasRefPoint, RefPoint)
2691 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2692 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2694 ## Generates new elements by extrusion of the elements which belong to the object
2695 # The path of extrusion must be a meshed edge.
2696 # @param theObject the object which elements should be processed
2697 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2698 # @param PathShape shape(edge) defines the sub-mesh for the path
2699 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2700 # @param HasAngles allows the shape to be rotated around the path
2701 # to get the resulting mesh in a helical fashion
2702 # @param Angles list of angles
2703 # @param HasRefPoint allows using the reference point
2704 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2705 # The User can specify any point as the Reference Point.
2706 # @param MakeGroups forces the generation of new groups from existing ones
2707 # @param LinearVariation forces the computation of rotation angles as linear
2708 # variation of the given Angles along path steps
2709 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2710 # only SMESH::Extrusion_Error otherwise
2711 # @ingroup l2_modif_extrurev
2712 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2713 HasAngles, Angles, HasRefPoint, RefPoint,
2714 MakeGroups=False, LinearVariation=False):
2715 Angles,AnglesParameters = ParseAngles(Angles)
2716 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2717 if ( isinstance( theObject, Mesh )):
2718 theObject = theObject.GetMesh()
2719 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2720 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2721 if ( isinstance( PathMesh, Mesh )):
2722 PathMesh = PathMesh.GetMesh()
2723 if HasAngles and Angles and LinearVariation:
2724 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2726 Parameters = AnglesParameters + var_separator + RefPointParameters
2727 self.mesh.SetParameters(Parameters)
2729 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2730 PathShape, NodeStart, HasAngles,
2731 Angles, HasRefPoint, RefPoint)
2732 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2733 NodeStart, HasAngles, Angles, HasRefPoint,
2736 ## Generates new elements by extrusion of the elements which belong to the object
2737 # The path of extrusion must be a meshed edge.
2738 # @param theObject the object which elements should be processed
2739 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2740 # @param PathShape shape(edge) defines the sub-mesh for the path
2741 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2742 # @param HasAngles allows the shape to be rotated around the path
2743 # to get the resulting mesh in a helical fashion
2744 # @param Angles list of angles
2745 # @param HasRefPoint allows using the reference point
2746 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2747 # The User can specify any point as the Reference Point.
2748 # @param MakeGroups forces the generation of new groups from existing ones
2749 # @param LinearVariation forces the computation of rotation angles as linear
2750 # variation of the given Angles along path steps
2751 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2752 # only SMESH::Extrusion_Error otherwise
2753 # @ingroup l2_modif_extrurev
2754 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
2755 HasAngles, Angles, HasRefPoint, RefPoint,
2756 MakeGroups=False, LinearVariation=False):
2757 Angles,AnglesParameters = ParseAngles(Angles)
2758 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2759 if ( isinstance( theObject, Mesh )):
2760 theObject = theObject.GetMesh()
2761 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2762 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2763 if ( isinstance( PathMesh, Mesh )):
2764 PathMesh = PathMesh.GetMesh()
2765 if HasAngles and Angles and LinearVariation:
2766 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2768 Parameters = AnglesParameters + var_separator + RefPointParameters
2769 self.mesh.SetParameters(Parameters)
2771 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
2772 PathShape, NodeStart, HasAngles,
2773 Angles, HasRefPoint, RefPoint)
2774 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
2775 NodeStart, HasAngles, Angles, HasRefPoint,
2778 ## Generates new elements by extrusion of the elements which belong to the object
2779 # The path of extrusion must be a meshed edge.
2780 # @param theObject the object which elements should be processed
2781 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2782 # @param PathShape shape(edge) defines the sub-mesh for the path
2783 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2784 # @param HasAngles allows the shape to be rotated around the path
2785 # to get the resulting mesh in a helical fashion
2786 # @param Angles list of angles
2787 # @param HasRefPoint allows using the reference point
2788 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2789 # The User can specify any point as the Reference Point.
2790 # @param MakeGroups forces the generation of new groups from existing ones
2791 # @param LinearVariation forces the computation of rotation angles as linear
2792 # variation of the given Angles along path steps
2793 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2794 # only SMESH::Extrusion_Error otherwise
2795 # @ingroup l2_modif_extrurev
2796 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
2797 HasAngles, Angles, HasRefPoint, RefPoint,
2798 MakeGroups=False, LinearVariation=False):
2799 Angles,AnglesParameters = ParseAngles(Angles)
2800 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2801 if ( isinstance( theObject, Mesh )):
2802 theObject = theObject.GetMesh()
2803 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2804 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2805 if ( isinstance( PathMesh, Mesh )):
2806 PathMesh = PathMesh.GetMesh()
2807 if HasAngles and Angles and LinearVariation:
2808 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2810 Parameters = AnglesParameters + var_separator + RefPointParameters
2811 self.mesh.SetParameters(Parameters)
2813 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
2814 PathShape, NodeStart, HasAngles,
2815 Angles, HasRefPoint, RefPoint)
2816 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
2817 NodeStart, HasAngles, Angles, HasRefPoint,
2820 ## Creates a symmetrical copy of mesh elements
2821 # @param IDsOfElements list of elements ids
2822 # @param Mirror is AxisStruct or geom object(point, line, plane)
2823 # @param theMirrorType is POINT, AXIS or PLANE
2824 # If the Mirror is a geom object this parameter is unnecessary
2825 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2826 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2827 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2828 # @ingroup l2_modif_trsf
2829 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2830 if IDsOfElements == []:
2831 IDsOfElements = self.GetElementsId()
2832 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2833 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2834 Mirror,Parameters = ParseAxisStruct(Mirror)
2835 self.mesh.SetParameters(Parameters)
2836 if Copy and MakeGroups:
2837 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2838 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2841 ## Creates a new mesh by a symmetrical copy of mesh elements
2842 # @param IDsOfElements the list of elements ids
2843 # @param Mirror is AxisStruct or geom object (point, line, plane)
2844 # @param theMirrorType is POINT, AXIS or PLANE
2845 # If the Mirror is a geom object this parameter is unnecessary
2846 # @param MakeGroups to generate new groups from existing ones
2847 # @param NewMeshName a name of the new mesh to create
2848 # @return instance of Mesh class
2849 # @ingroup l2_modif_trsf
2850 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2851 if IDsOfElements == []:
2852 IDsOfElements = self.GetElementsId()
2853 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2854 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2855 Mirror,Parameters = ParseAxisStruct(Mirror)
2856 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2857 MakeGroups, NewMeshName)
2858 mesh.SetParameters(Parameters)
2859 return Mesh(self.smeshpyD,self.geompyD,mesh)
2861 ## Creates a symmetrical copy of the object
2862 # @param theObject mesh, submesh or group
2863 # @param Mirror AxisStruct or geom object (point, line, plane)
2864 # @param theMirrorType is POINT, AXIS or PLANE
2865 # If the Mirror is a geom object this parameter is unnecessary
2866 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2867 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2868 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2869 # @ingroup l2_modif_trsf
2870 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2871 if ( isinstance( theObject, Mesh )):
2872 theObject = theObject.GetMesh()
2873 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2874 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2875 Mirror,Parameters = ParseAxisStruct(Mirror)
2876 self.mesh.SetParameters(Parameters)
2877 if Copy and MakeGroups:
2878 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2879 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2882 ## Creates a new mesh by a symmetrical copy of the object
2883 # @param theObject mesh, submesh or group
2884 # @param Mirror AxisStruct or geom object (point, line, plane)
2885 # @param theMirrorType POINT, AXIS or PLANE
2886 # If the Mirror is a geom object this parameter is unnecessary
2887 # @param MakeGroups forces the generation of new groups from existing ones
2888 # @param NewMeshName the name of the new mesh to create
2889 # @return instance of Mesh class
2890 # @ingroup l2_modif_trsf
2891 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2892 if ( isinstance( theObject, Mesh )):
2893 theObject = theObject.GetMesh()
2894 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2895 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2896 Mirror,Parameters = ParseAxisStruct(Mirror)
2897 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2898 MakeGroups, NewMeshName)
2899 mesh.SetParameters(Parameters)
2900 return Mesh( self.smeshpyD,self.geompyD,mesh )
2902 ## Translates the elements
2903 # @param IDsOfElements list of elements ids
2904 # @param Vector the direction of translation (DirStruct or vector)
2905 # @param Copy allows copying the translated elements
2906 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2907 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2908 # @ingroup l2_modif_trsf
2909 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2910 if IDsOfElements == []:
2911 IDsOfElements = self.GetElementsId()
2912 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2913 Vector = self.smeshpyD.GetDirStruct(Vector)
2914 Vector,Parameters = ParseDirStruct(Vector)
2915 self.mesh.SetParameters(Parameters)
2916 if Copy and MakeGroups:
2917 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
2918 self.editor.Translate(IDsOfElements, Vector, Copy)
2921 ## Creates a new mesh of translated elements
2922 # @param IDsOfElements list of elements ids
2923 # @param Vector the direction of translation (DirStruct or vector)
2924 # @param MakeGroups forces the generation of new groups from existing ones
2925 # @param NewMeshName the name of the newly created mesh
2926 # @return instance of Mesh class
2927 # @ingroup l2_modif_trsf
2928 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
2929 if IDsOfElements == []:
2930 IDsOfElements = self.GetElementsId()
2931 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2932 Vector = self.smeshpyD.GetDirStruct(Vector)
2933 Vector,Parameters = ParseDirStruct(Vector)
2934 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
2935 mesh.SetParameters(Parameters)
2936 return Mesh ( self.smeshpyD, self.geompyD, mesh )
2938 ## Translates the object
2939 # @param theObject the object to translate (mesh, submesh, or group)
2940 # @param Vector direction of translation (DirStruct or geom vector)
2941 # @param Copy allows copying the translated elements
2942 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2943 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2944 # @ingroup l2_modif_trsf
2945 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
2946 if ( isinstance( theObject, Mesh )):
2947 theObject = theObject.GetMesh()
2948 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2949 Vector = self.smeshpyD.GetDirStruct(Vector)
2950 Vector,Parameters = ParseDirStruct(Vector)
2951 self.mesh.SetParameters(Parameters)
2952 if Copy and MakeGroups:
2953 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
2954 self.editor.TranslateObject(theObject, Vector, Copy)
2957 ## Creates a new mesh from the translated object
2958 # @param theObject the object to translate (mesh, submesh, or group)
2959 # @param Vector the direction of translation (DirStruct or geom vector)
2960 # @param MakeGroups forces the generation of new groups from existing ones
2961 # @param NewMeshName the name of the newly created mesh
2962 # @return instance of Mesh class
2963 # @ingroup l2_modif_trsf
2964 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
2965 if (isinstance(theObject, Mesh)):
2966 theObject = theObject.GetMesh()
2967 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
2968 Vector = self.smeshpyD.GetDirStruct(Vector)
2969 Vector,Parameters = ParseDirStruct(Vector)
2970 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
2971 mesh.SetParameters(Parameters)
2972 return Mesh( self.smeshpyD, self.geompyD, mesh )
2974 ## Rotates the elements
2975 # @param IDsOfElements list of elements ids
2976 # @param Axis the axis of rotation (AxisStruct or geom line)
2977 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
2978 # @param Copy allows copying the rotated elements
2979 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2980 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2981 # @ingroup l2_modif_trsf
2982 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
2984 if isinstance(AngleInRadians,str):
2986 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
2988 AngleInRadians = DegreesToRadians(AngleInRadians)
2989 if IDsOfElements == []:
2990 IDsOfElements = self.GetElementsId()
2991 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2992 Axis = self.smeshpyD.GetAxisStruct(Axis)
2993 Axis,AxisParameters = ParseAxisStruct(Axis)
2994 Parameters = AxisParameters + var_separator + Parameters
2995 self.mesh.SetParameters(Parameters)
2996 if Copy and MakeGroups:
2997 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
2998 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3001 ## Creates a new mesh of rotated elements
3002 # @param IDsOfElements list of element ids
3003 # @param Axis the axis of rotation (AxisStruct or geom line)
3004 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3005 # @param MakeGroups forces the generation of new groups from existing ones
3006 # @param NewMeshName the name of the newly created mesh
3007 # @return instance of Mesh class
3008 # @ingroup l2_modif_trsf
3009 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3011 if isinstance(AngleInRadians,str):
3013 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3015 AngleInRadians = DegreesToRadians(AngleInRadians)
3016 if IDsOfElements == []:
3017 IDsOfElements = self.GetElementsId()
3018 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3019 Axis = self.smeshpyD.GetAxisStruct(Axis)
3020 Axis,AxisParameters = ParseAxisStruct(Axis)
3021 Parameters = AxisParameters + var_separator + Parameters
3022 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3023 MakeGroups, NewMeshName)
3024 mesh.SetParameters(Parameters)
3025 return Mesh( self.smeshpyD, self.geompyD, mesh )
3027 ## Rotates the object
3028 # @param theObject the object to rotate( mesh, submesh, or group)
3029 # @param Axis the axis of rotation (AxisStruct or geom line)
3030 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3031 # @param Copy allows copying the rotated elements
3032 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3033 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3034 # @ingroup l2_modif_trsf
3035 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3037 if isinstance(AngleInRadians,str):
3039 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3041 AngleInRadians = DegreesToRadians(AngleInRadians)
3042 if (isinstance(theObject, Mesh)):
3043 theObject = theObject.GetMesh()
3044 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3045 Axis = self.smeshpyD.GetAxisStruct(Axis)
3046 Axis,AxisParameters = ParseAxisStruct(Axis)
3047 Parameters = AxisParameters + ":" + Parameters
3048 self.mesh.SetParameters(Parameters)
3049 if Copy and MakeGroups:
3050 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3051 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3054 ## Creates a new mesh from the rotated object
3055 # @param theObject the object to rotate (mesh, submesh, or group)
3056 # @param Axis the axis of rotation (AxisStruct or geom line)
3057 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3058 # @param MakeGroups forces the generation of new groups from existing ones
3059 # @param NewMeshName the name of the newly created mesh
3060 # @return instance of Mesh class
3061 # @ingroup l2_modif_trsf
3062 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3064 if isinstance(AngleInRadians,str):
3066 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3068 AngleInRadians = DegreesToRadians(AngleInRadians)
3069 if (isinstance( theObject, Mesh )):
3070 theObject = theObject.GetMesh()
3071 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3072 Axis = self.smeshpyD.GetAxisStruct(Axis)
3073 Axis,AxisParameters = ParseAxisStruct(Axis)
3074 Parameters = AxisParameters + ":" + Parameters
3075 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3076 MakeGroups, NewMeshName)
3077 mesh.SetParameters(Parameters)
3078 return Mesh( self.smeshpyD, self.geompyD, mesh )
3080 ## Finds groups of ajacent nodes within Tolerance.
3081 # @param Tolerance the value of tolerance
3082 # @return the list of groups of nodes
3083 # @ingroup l2_modif_trsf
3084 def FindCoincidentNodes (self, Tolerance):
3085 return self.editor.FindCoincidentNodes(Tolerance)
3087 ## Finds groups of ajacent nodes within Tolerance.
3088 # @param Tolerance the value of tolerance
3089 # @param SubMeshOrGroup SubMesh or Group
3090 # @return the list of groups of nodes
3091 # @ingroup l2_modif_trsf
3092 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3093 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3096 # @param GroupsOfNodes the list of groups of nodes
3097 # @ingroup l2_modif_trsf
3098 def MergeNodes (self, GroupsOfNodes):
3099 self.editor.MergeNodes(GroupsOfNodes)
3101 ## Finds the elements built on the same nodes.
3102 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3103 # @return a list of groups of equal elements
3104 # @ingroup l2_modif_trsf
3105 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3106 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3108 ## Merges elements in each given group.
3109 # @param GroupsOfElementsID groups of elements for merging
3110 # @ingroup l2_modif_trsf
3111 def MergeElements(self, GroupsOfElementsID):
3112 self.editor.MergeElements(GroupsOfElementsID)
3114 ## Leaves one element and removes all other elements built on the same nodes.
3115 # @ingroup l2_modif_trsf
3116 def MergeEqualElements(self):
3117 self.editor.MergeEqualElements()
3119 ## Sews free borders
3120 # @return SMESH::Sew_Error
3121 # @ingroup l2_modif_trsf
3122 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3123 FirstNodeID2, SecondNodeID2, LastNodeID2,
3124 CreatePolygons, CreatePolyedrs):
3125 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3126 FirstNodeID2, SecondNodeID2, LastNodeID2,
3127 CreatePolygons, CreatePolyedrs)
3129 ## Sews conform free borders
3130 # @return SMESH::Sew_Error
3131 # @ingroup l2_modif_trsf
3132 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3133 FirstNodeID2, SecondNodeID2):
3134 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3135 FirstNodeID2, SecondNodeID2)
3137 ## Sews border to side
3138 # @return SMESH::Sew_Error
3139 # @ingroup l2_modif_trsf
3140 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3141 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3142 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3143 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3145 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3146 # merged with the nodes of elements of Side2.
3147 # The number of elements in theSide1 and in theSide2 must be
3148 # equal and they should have similar nodal connectivity.
3149 # The nodes to merge should belong to side borders and
3150 # the first node should be linked to the second.
3151 # @return SMESH::Sew_Error
3152 # @ingroup l2_modif_trsf
3153 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3154 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3155 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3156 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3157 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3158 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3160 ## Sets new nodes for the given element.
3161 # @param ide the element id
3162 # @param newIDs nodes ids
3163 # @return If the number of nodes does not correspond to the type of element - returns false
3164 # @ingroup l2_modif_edit
3165 def ChangeElemNodes(self, ide, newIDs):
3166 return self.editor.ChangeElemNodes(ide, newIDs)
3168 ## If during the last operation of MeshEditor some nodes were
3169 # created, this method returns the list of their IDs, \n
3170 # if new nodes were not created - returns empty list
3171 # @return the list of integer values (can be empty)
3172 # @ingroup l1_auxiliary
3173 def GetLastCreatedNodes(self):
3174 return self.editor.GetLastCreatedNodes()
3176 ## If during the last operation of MeshEditor some elements were
3177 # created this method returns the list of their IDs, \n
3178 # if new elements were not created - returns empty list
3179 # @return the list of integer values (can be empty)
3180 # @ingroup l1_auxiliary
3181 def GetLastCreatedElems(self):
3182 return self.editor.GetLastCreatedElems()
3184 ## The mother class to define algorithm, it is not recommended to use it directly.
3187 # @ingroup l2_algorithms
3188 class Mesh_Algorithm:
3189 # @class Mesh_Algorithm
3190 # @brief Class Mesh_Algorithm
3192 #def __init__(self,smesh):
3200 ## Finds a hypothesis in the study by its type name and parameters.
3201 # Finds only the hypotheses created in smeshpyD engine.
3202 # @return SMESH.SMESH_Hypothesis
3203 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3204 study = smeshpyD.GetCurrentStudy()
3205 #to do: find component by smeshpyD object, not by its data type
3206 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3207 if scomp is not None:
3208 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3209 # Check if the root label of the hypotheses exists
3210 if res and hypRoot is not None:
3211 iter = study.NewChildIterator(hypRoot)
3212 # Check all published hypotheses
3214 hypo_so_i = iter.Value()
3215 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3216 if attr is not None:
3217 anIOR = attr.Value()
3218 hypo_o_i = salome.orb.string_to_object(anIOR)
3219 if hypo_o_i is not None:
3220 # Check if this is a hypothesis
3221 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3222 if hypo_i is not None:
3223 # Check if the hypothesis belongs to current engine
3224 if smeshpyD.GetObjectId(hypo_i) > 0:
3225 # Check if this is the required hypothesis
3226 if hypo_i.GetName() == hypname:
3228 if CompareMethod(hypo_i, args):
3242 ## Finds the algorithm in the study by its type name.
3243 # Finds only the algorithms, which have been created in smeshpyD engine.
3244 # @return SMESH.SMESH_Algo
3245 def FindAlgorithm (self, algoname, smeshpyD):
3246 study = smeshpyD.GetCurrentStudy()
3247 #to do: find component by smeshpyD object, not by its data type
3248 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3249 if scomp is not None:
3250 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3251 # Check if the root label of the algorithms exists
3252 if res and hypRoot is not None:
3253 iter = study.NewChildIterator(hypRoot)
3254 # Check all published algorithms
3256 algo_so_i = iter.Value()
3257 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3258 if attr is not None:
3259 anIOR = attr.Value()
3260 algo_o_i = salome.orb.string_to_object(anIOR)
3261 if algo_o_i is not None:
3262 # Check if this is an algorithm
3263 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3264 if algo_i is not None:
3265 # Checks if the algorithm belongs to the current engine
3266 if smeshpyD.GetObjectId(algo_i) > 0:
3267 # Check if this is the required algorithm
3268 if algo_i.GetName() == algoname:
3281 ## If the algorithm is global, returns 0; \n
3282 # else returns the submesh associated to this algorithm.
3283 def GetSubMesh(self):
3286 ## Returns the wrapped mesher.
3287 def GetAlgorithm(self):
3290 ## Gets the list of hypothesis that can be used with this algorithm
3291 def GetCompatibleHypothesis(self):
3294 mylist = self.algo.GetCompatibleHypothesis()
3297 ## Gets the name of the algorithm
3301 ## Sets the name to the algorithm
3302 def SetName(self, name):
3303 SetName(self.algo, name)
3305 ## Gets the id of the algorithm
3307 return self.algo.GetId()
3310 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3312 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3313 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3315 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3317 self.Assign(algo, mesh, geom)
3321 def Assign(self, algo, mesh, geom):
3323 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3330 name = GetName(geom)
3332 name = mesh.geompyD.SubShapeName(geom, piece)
3333 mesh.geompyD.addToStudyInFather(piece, geom, name)
3334 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3337 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3338 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3340 def CompareHyp (self, hyp, args):
3341 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3344 def CompareEqualHyp (self, hyp, args):
3348 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3349 UseExisting=0, CompareMethod=""):
3352 if CompareMethod == "": CompareMethod = self.CompareHyp
3353 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3356 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3362 a = a + s + str(args[i])
3366 SetName(hypo, hyp + a)
3368 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3369 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3373 # Public class: Mesh_Segment
3374 # --------------------------
3376 ## Class to define a segment 1D algorithm for discretization
3379 # @ingroup l3_algos_basic
3380 class Mesh_Segment(Mesh_Algorithm):
3382 ## Private constructor.
3383 def __init__(self, mesh, geom=0):
3384 Mesh_Algorithm.__init__(self)
3385 self.Create(mesh, geom, "Regular_1D")
3387 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3388 # @param l for the length of segments that cut an edge
3389 # @param UseExisting if ==true - searches for an existing hypothesis created with
3390 # the same parameters, else (default) - creates a new one
3391 # @param p precision, used for calculation of the number of segments.
3392 # The precision should be a positive, meaningful value within the range [0,1].
3393 # In general, the number of segments is calculated with the formula:
3394 # nb = ceil((edge_length / l) - p)
3395 # Function ceil rounds its argument to the higher integer.
3396 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3397 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3398 # p=1 means rounding of (edge_length / l) to the lower integer.
3399 # Default value is 1e-07.
3400 # @return an instance of StdMeshers_LocalLength hypothesis
3401 # @ingroup l3_hypos_1dhyps
3402 def LocalLength(self, l, UseExisting=0, p=1e-07):
3403 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3404 CompareMethod=self.CompareLocalLength)
3410 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3411 def CompareLocalLength(self, hyp, args):
3412 if IsEqual(hyp.GetLength(), args[0]):
3413 return IsEqual(hyp.GetPrecision(), args[1])
3416 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3417 # @param n for the number of segments that cut an edge
3418 # @param s for the scale factor (optional)
3419 # @param UseExisting if ==true - searches for an existing hypothesis created with
3420 # the same parameters, else (default) - create a new one
3421 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3422 # @ingroup l3_hypos_1dhyps
3423 def NumberOfSegments(self, n, s=[], UseExisting=0):
3425 hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
3426 CompareMethod=self.CompareNumberOfSegments)
3428 hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
3429 CompareMethod=self.CompareNumberOfSegments)
3430 hyp.SetDistrType( 1 )
3431 hyp.SetScaleFactor(s)
3432 hyp.SetNumberOfSegments(n)
3436 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3437 def CompareNumberOfSegments(self, hyp, args):
3438 if hyp.GetNumberOfSegments() == args[0]:
3442 if hyp.GetDistrType() == 1:
3443 if IsEqual(hyp.GetScaleFactor(), args[1]):
3447 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3448 # @param start defines the length of the first segment
3449 # @param end defines the length of the last segment
3450 # @param UseExisting if ==true - searches for an existing hypothesis created with
3451 # the same parameters, else (default) - creates a new one
3452 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3453 # @ingroup l3_hypos_1dhyps
3454 def Arithmetic1D(self, start, end, UseExisting=0):
3455 hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
3456 CompareMethod=self.CompareArithmetic1D)
3457 hyp.SetLength(start, 1)
3458 hyp.SetLength(end , 0)
3462 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3463 def CompareArithmetic1D(self, hyp, args):
3464 if IsEqual(hyp.GetLength(1), args[0]):
3465 if IsEqual(hyp.GetLength(0), args[1]):
3469 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3470 # @param start defines the length of the first segment
3471 # @param end defines the length of the last segment
3472 # @param UseExisting if ==true - searches for an existing hypothesis created with
3473 # the same parameters, else (default) - creates a new one
3474 # @return an instance of StdMeshers_StartEndLength hypothesis
3475 # @ingroup l3_hypos_1dhyps
3476 def StartEndLength(self, start, end, UseExisting=0):
3477 hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
3478 CompareMethod=self.CompareStartEndLength)
3479 hyp.SetLength(start, 1)
3480 hyp.SetLength(end , 0)
3483 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3484 def CompareStartEndLength(self, hyp, args):
3485 if IsEqual(hyp.GetLength(1), args[0]):
3486 if IsEqual(hyp.GetLength(0), args[1]):
3490 ## Defines "Deflection1D" hypothesis
3491 # @param d for the deflection
3492 # @param UseExisting if ==true - searches for an existing hypothesis created with
3493 # the same parameters, else (default) - create a new one
3494 # @ingroup l3_hypos_1dhyps
3495 def Deflection1D(self, d, UseExisting=0):
3496 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3497 CompareMethod=self.CompareDeflection1D)
3498 hyp.SetDeflection(d)
3501 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3502 def CompareDeflection1D(self, hyp, args):
3503 return IsEqual(hyp.GetDeflection(), args[0])
3505 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3506 # the opposite side in case of quadrangular faces
3507 # @ingroup l3_hypos_additi
3508 def Propagation(self):
3509 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3511 ## Defines "AutomaticLength" hypothesis
3512 # @param fineness for the fineness [0-1]
3513 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3514 # same parameters, else (default) - create a new one
3515 # @ingroup l3_hypos_1dhyps
3516 def AutomaticLength(self, fineness=0, UseExisting=0):
3517 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3518 CompareMethod=self.CompareAutomaticLength)
3519 hyp.SetFineness( fineness )
3522 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3523 def CompareAutomaticLength(self, hyp, args):
3524 return IsEqual(hyp.GetFineness(), args[0])
3526 ## Defines "SegmentLengthAroundVertex" hypothesis
3527 # @param length for the segment length
3528 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3529 # Any other integer value means that the hypothesis will be set on the
3530 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3531 # @param UseExisting if ==true - searches for an existing hypothesis created with
3532 # the same parameters, else (default) - creates a new one
3533 # @ingroup l3_algos_segmarv
3534 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3536 store_geom = self.geom
3537 if type(vertex) is types.IntType:
3538 if vertex == 0 or vertex == 1:
3539 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3547 if self.geom is None:
3548 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3549 name = GetName(self.geom)
3551 piece = self.mesh.geom
3552 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3553 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3554 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3556 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3558 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3559 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3561 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3562 CompareMethod=self.CompareLengthNearVertex)
3563 self.geom = store_geom
3564 hyp.SetLength( length )
3567 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3568 # @ingroup l3_algos_segmarv
3569 def CompareLengthNearVertex(self, hyp, args):
3570 return IsEqual(hyp.GetLength(), args[0])
3572 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3573 # If the 2D mesher sees that all boundary edges are quadratic,
3574 # it generates quadratic faces, else it generates linear faces using
3575 # medium nodes as if they are vertices.
3576 # The 3D mesher generates quadratic volumes only if all boundary faces
3577 # are quadratic, else it fails.
3579 # @ingroup l3_hypos_additi
3580 def QuadraticMesh(self):
3581 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3584 # Public class: Mesh_CompositeSegment
3585 # --------------------------
3587 ## Defines a segment 1D algorithm for discretization
3589 # @ingroup l3_algos_basic
3590 class Mesh_CompositeSegment(Mesh_Segment):
3592 ## Private constructor.
3593 def __init__(self, mesh, geom=0):
3594 self.Create(mesh, geom, "CompositeSegment_1D")
3597 # Public class: Mesh_Segment_Python
3598 # ---------------------------------
3600 ## Defines a segment 1D algorithm for discretization with python function
3602 # @ingroup l3_algos_basic
3603 class Mesh_Segment_Python(Mesh_Segment):
3605 ## Private constructor.
3606 def __init__(self, mesh, geom=0):
3607 import Python1dPlugin
3608 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3610 ## Defines "PythonSplit1D" hypothesis
3611 # @param n for the number of segments that cut an edge
3612 # @param func for the python function that calculates the length of all segments
3613 # @param UseExisting if ==true - searches for the existing hypothesis created with
3614 # the same parameters, else (default) - creates a new one
3615 # @ingroup l3_hypos_1dhyps
3616 def PythonSplit1D(self, n, func, UseExisting=0):
3617 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3618 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3619 hyp.SetNumberOfSegments(n)
3620 hyp.SetPythonLog10RatioFunction(func)
3623 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3624 def ComparePythonSplit1D(self, hyp, args):
3625 #if hyp.GetNumberOfSegments() == args[0]:
3626 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3630 # Public class: Mesh_Triangle
3631 # ---------------------------
3633 ## Defines a triangle 2D algorithm
3635 # @ingroup l3_algos_basic
3636 class Mesh_Triangle(Mesh_Algorithm):
3645 ## Private constructor.
3646 def __init__(self, mesh, algoType, geom=0):
3647 Mesh_Algorithm.__init__(self)
3649 self.algoType = algoType
3650 if algoType == MEFISTO:
3651 self.Create(mesh, geom, "MEFISTO_2D")
3653 elif algoType == BLSURF:
3655 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3656 #self.SetPhysicalMesh() - PAL19680
3657 elif algoType == NETGEN:
3659 print "Warning: NETGENPlugin module unavailable"
3661 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3663 elif algoType == NETGEN_2D:
3665 print "Warning: NETGENPlugin module unavailable"
3667 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3670 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3671 # @param area for the maximum area of each triangle
3672 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3673 # same parameters, else (default) - creates a new one
3675 # Only for algoType == MEFISTO || NETGEN_2D
3676 # @ingroup l3_hypos_2dhyps
3677 def MaxElementArea(self, area, UseExisting=0):
3678 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3679 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3680 CompareMethod=self.CompareMaxElementArea)
3681 elif self.algoType == NETGEN:
3682 hyp = self.Parameters(SIMPLE)
3683 hyp.SetMaxElementArea(area)
3686 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3687 def CompareMaxElementArea(self, hyp, args):
3688 return IsEqual(hyp.GetMaxElementArea(), args[0])
3690 ## Defines "LengthFromEdges" hypothesis to build triangles
3691 # based on the length of the edges taken from the wire
3693 # Only for algoType == MEFISTO || NETGEN_2D
3694 # @ingroup l3_hypos_2dhyps
3695 def LengthFromEdges(self):
3696 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3697 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3699 elif self.algoType == NETGEN:
3700 hyp = self.Parameters(SIMPLE)
3701 hyp.LengthFromEdges()
3704 ## Sets a way to define size of mesh elements to generate.
3705 # @param thePhysicalMesh is: DefaultSize or Custom.
3706 # @ingroup l3_hypos_blsurf
3707 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3708 # Parameter of BLSURF algo
3709 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3711 ## Sets size of mesh elements to generate.
3712 # @ingroup l3_hypos_blsurf
3713 def SetPhySize(self, theVal):
3714 # Parameter of BLSURF algo
3715 self.Parameters().SetPhySize(theVal)
3717 ## Sets lower boundary of mesh element size (PhySize).
3718 # @ingroup l3_hypos_blsurf
3719 def SetPhyMin(self, theVal=-1):
3720 # Parameter of BLSURF algo
3721 self.Parameters().SetPhyMin(theVal)
3723 ## Sets upper boundary of mesh element size (PhySize).
3724 # @ingroup l3_hypos_blsurf
3725 def SetPhyMax(self, theVal=-1):
3726 # Parameter of BLSURF algo
3727 self.Parameters().SetPhyMax(theVal)
3729 ## Sets a way to define maximum angular deflection of mesh from CAD model.
3730 # @param theGeometricMesh is: DefaultGeom or Custom
3731 # @ingroup l3_hypos_blsurf
3732 def SetGeometricMesh(self, theGeometricMesh=0):
3733 # Parameter of BLSURF algo
3734 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3735 self.params.SetGeometricMesh(theGeometricMesh)
3737 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3738 # @ingroup l3_hypos_blsurf
3739 def SetAngleMeshS(self, theVal=_angleMeshS):
3740 # Parameter of BLSURF algo
3741 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3742 self.params.SetAngleMeshS(theVal)
3744 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3745 # @ingroup l3_hypos_blsurf
3746 def SetAngleMeshC(self, theVal=_angleMeshS):
3747 # Parameter of BLSURF algo
3748 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3749 self.params.SetAngleMeshC(theVal)
3751 ## Sets lower boundary of mesh element size computed to respect angular deflection.
3752 # @ingroup l3_hypos_blsurf
3753 def SetGeoMin(self, theVal=-1):
3754 # Parameter of BLSURF algo
3755 self.Parameters().SetGeoMin(theVal)
3757 ## Sets upper boundary of mesh element size computed to respect angular deflection.
3758 # @ingroup l3_hypos_blsurf
3759 def SetGeoMax(self, theVal=-1):
3760 # Parameter of BLSURF algo
3761 self.Parameters().SetGeoMax(theVal)
3763 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3764 # @ingroup l3_hypos_blsurf
3765 def SetGradation(self, theVal=_gradation):
3766 # Parameter of BLSURF algo
3767 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3768 self.params.SetGradation(theVal)
3770 ## Sets topology usage way.
3771 # @param way defines how mesh conformity is assured <ul>
3772 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
3773 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
3774 # @ingroup l3_hypos_blsurf
3775 def SetTopology(self, way):
3776 # Parameter of BLSURF algo
3777 self.Parameters().SetTopology(way)
3779 ## To respect geometrical edges or not.
3780 # @ingroup l3_hypos_blsurf
3781 def SetDecimesh(self, toIgnoreEdges=False):
3782 # Parameter of BLSURF algo
3783 self.Parameters().SetDecimesh(toIgnoreEdges)
3785 ## Sets verbosity level in the range 0 to 100.
3786 # @ingroup l3_hypos_blsurf
3787 def SetVerbosity(self, level):
3788 # Parameter of BLSURF algo
3789 self.Parameters().SetVerbosity(level)
3791 ## Sets advanced option value.
3792 # @ingroup l3_hypos_blsurf
3793 def SetOptionValue(self, optionName, level):
3794 # Parameter of BLSURF algo
3795 self.Parameters().SetOptionValue(optionName,level)
3797 ## Sets QuadAllowed flag.
3798 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
3799 # @ingroup l3_hypos_netgen l3_hypos_blsurf
3800 def SetQuadAllowed(self, toAllow=True):
3801 if self.algoType == NETGEN_2D:
3802 if toAllow: # add QuadranglePreference
3803 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3804 else: # remove QuadranglePreference
3805 for hyp in self.mesh.GetHypothesisList( self.geom ):
3806 if hyp.GetName() == "QuadranglePreference":
3807 self.mesh.RemoveHypothesis( self.geom, hyp )
3812 if self.Parameters():
3813 self.params.SetQuadAllowed(toAllow)
3816 ## Defines hypothesis having several parameters
3818 # @ingroup l3_hypos_netgen
3819 def Parameters(self, which=SOLE):
3822 if self.algoType == NETGEN:
3824 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
3825 "libNETGENEngine.so", UseExisting=0)
3827 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
3828 "libNETGENEngine.so", UseExisting=0)
3830 elif self.algoType == MEFISTO:
3831 print "Mefisto algo support no multi-parameter hypothesis"
3833 elif self.algoType == NETGEN_2D:
3834 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
3835 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3837 elif self.algoType == BLSURF:
3838 self.params = self.Hypothesis("BLSURF_Parameters", [],
3839 "libBLSURFEngine.so", UseExisting=0)
3842 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
3847 # Only for algoType == NETGEN
3848 # @ingroup l3_hypos_netgen
3849 def SetMaxSize(self, theSize):
3850 if self.Parameters():
3851 self.params.SetMaxSize(theSize)
3853 ## Sets SecondOrder flag
3855 # Only for algoType == NETGEN
3856 # @ingroup l3_hypos_netgen
3857 def SetSecondOrder(self, theVal):
3858 if self.Parameters():
3859 self.params.SetSecondOrder(theVal)
3861 ## Sets Optimize flag
3863 # Only for algoType == NETGEN
3864 # @ingroup l3_hypos_netgen
3865 def SetOptimize(self, theVal):
3866 if self.Parameters():
3867 self.params.SetOptimize(theVal)
3870 # @param theFineness is:
3871 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3873 # Only for algoType == NETGEN
3874 # @ingroup l3_hypos_netgen
3875 def SetFineness(self, theFineness):
3876 if self.Parameters():
3877 self.params.SetFineness(theFineness)
3881 # Only for algoType == NETGEN
3882 # @ingroup l3_hypos_netgen
3883 def SetGrowthRate(self, theRate):
3884 if self.Parameters():
3885 self.params.SetGrowthRate(theRate)
3887 ## Sets NbSegPerEdge
3889 # Only for algoType == NETGEN
3890 # @ingroup l3_hypos_netgen
3891 def SetNbSegPerEdge(self, theVal):
3892 if self.Parameters():
3893 self.params.SetNbSegPerEdge(theVal)
3895 ## Sets NbSegPerRadius
3897 # Only for algoType == NETGEN
3898 # @ingroup l3_hypos_netgen
3899 def SetNbSegPerRadius(self, theVal):
3900 if self.Parameters():
3901 self.params.SetNbSegPerRadius(theVal)
3903 ## Sets number of segments overriding value set by SetLocalLength()
3905 # Only for algoType == NETGEN
3906 # @ingroup l3_hypos_netgen
3907 def SetNumberOfSegments(self, theVal):
3908 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3910 ## Sets number of segments overriding value set by SetNumberOfSegments()
3912 # Only for algoType == NETGEN
3913 # @ingroup l3_hypos_netgen
3914 def SetLocalLength(self, theVal):
3915 self.Parameters(SIMPLE).SetLocalLength(theVal)
3920 # Public class: Mesh_Quadrangle
3921 # -----------------------------
3923 ## Defines a quadrangle 2D algorithm
3925 # @ingroup l3_algos_basic
3926 class Mesh_Quadrangle(Mesh_Algorithm):
3928 ## Private constructor.
3929 def __init__(self, mesh, geom=0):
3930 Mesh_Algorithm.__init__(self)
3931 self.Create(mesh, geom, "Quadrangle_2D")
3933 ## Defines "QuadranglePreference" hypothesis, forcing construction
3934 # of quadrangles if the number of nodes on the opposite edges is not the same
3935 # while the total number of nodes on edges is even
3937 # @ingroup l3_hypos_additi
3938 def QuadranglePreference(self):
3939 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
3940 CompareMethod=self.CompareEqualHyp)
3943 ## Defines "TrianglePreference" hypothesis, forcing construction
3944 # of triangles in the refinement area if the number of nodes
3945 # on the opposite edges is not the same
3947 # @ingroup l3_hypos_additi
3948 def TrianglePreference(self):
3949 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
3950 CompareMethod=self.CompareEqualHyp)
3953 # Public class: Mesh_Tetrahedron
3954 # ------------------------------
3956 ## Defines a tetrahedron 3D algorithm
3958 # @ingroup l3_algos_basic
3959 class Mesh_Tetrahedron(Mesh_Algorithm):
3964 ## Private constructor.
3965 def __init__(self, mesh, algoType, geom=0):
3966 Mesh_Algorithm.__init__(self)
3968 if algoType == NETGEN:
3969 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
3972 elif algoType == FULL_NETGEN:
3974 print "Warning: NETGENPlugin module has not been imported."
3975 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3978 elif algoType == GHS3D:
3980 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
3983 self.algoType = algoType
3985 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
3986 # @param vol for the maximum volume of each tetrahedron
3987 # @param UseExisting if ==true - searches for the existing hypothesis created with
3988 # the same parameters, else (default) - creates a new one
3989 # @ingroup l3_hypos_maxvol
3990 def MaxElementVolume(self, vol, UseExisting=0):
3991 if self.algoType == NETGEN:
3992 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
3993 CompareMethod=self.CompareMaxElementVolume)
3994 hyp.SetMaxElementVolume(vol)
3996 elif self.algoType == FULL_NETGEN:
3997 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4000 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4001 def CompareMaxElementVolume(self, hyp, args):
4002 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4004 ## Defines hypothesis having several parameters
4006 # @ingroup l3_hypos_netgen
4007 def Parameters(self, which=SOLE):
4010 if self.algoType == FULL_NETGEN:
4012 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4013 "libNETGENEngine.so", UseExisting=0)
4015 self.params = self.Hypothesis("NETGEN_Parameters", [],
4016 "libNETGENEngine.so", UseExisting=0)
4018 if self.algoType == GHS3D:
4019 self.params = self.Hypothesis("GHS3D_Parameters", [],
4020 "libGHS3DEngine.so", UseExisting=0)
4023 print "Algo supports no multi-parameter hypothesis"
4027 # Parameter of FULL_NETGEN
4028 # @ingroup l3_hypos_netgen
4029 def SetMaxSize(self, theSize):
4030 self.Parameters().SetMaxSize(theSize)
4032 ## Sets SecondOrder flag
4033 # Parameter of FULL_NETGEN
4034 # @ingroup l3_hypos_netgen
4035 def SetSecondOrder(self, theVal):
4036 self.Parameters().SetSecondOrder(theVal)
4038 ## Sets Optimize flag
4039 # Parameter of FULL_NETGEN
4040 # @ingroup l3_hypos_netgen
4041 def SetOptimize(self, theVal):
4042 self.Parameters().SetOptimize(theVal)
4045 # @param theFineness is:
4046 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4047 # Parameter of FULL_NETGEN
4048 # @ingroup l3_hypos_netgen
4049 def SetFineness(self, theFineness):
4050 self.Parameters().SetFineness(theFineness)
4053 # Parameter of FULL_NETGEN
4054 # @ingroup l3_hypos_netgen
4055 def SetGrowthRate(self, theRate):
4056 self.Parameters().SetGrowthRate(theRate)
4058 ## Sets NbSegPerEdge
4059 # Parameter of FULL_NETGEN
4060 # @ingroup l3_hypos_netgen
4061 def SetNbSegPerEdge(self, theVal):
4062 self.Parameters().SetNbSegPerEdge(theVal)
4064 ## Sets NbSegPerRadius
4065 # Parameter of FULL_NETGEN
4066 # @ingroup l3_hypos_netgen
4067 def SetNbSegPerRadius(self, theVal):
4068 self.Parameters().SetNbSegPerRadius(theVal)
4070 ## Sets number of segments overriding value set by SetLocalLength()
4071 # Only for algoType == NETGEN_FULL
4072 # @ingroup l3_hypos_netgen
4073 def SetNumberOfSegments(self, theVal):
4074 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4076 ## Sets number of segments overriding value set by SetNumberOfSegments()
4077 # Only for algoType == NETGEN_FULL
4078 # @ingroup l3_hypos_netgen
4079 def SetLocalLength(self, theVal):
4080 self.Parameters(SIMPLE).SetLocalLength(theVal)
4082 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4083 # Overrides value set by LengthFromEdges()
4084 # Only for algoType == NETGEN_FULL
4085 # @ingroup l3_hypos_netgen
4086 def MaxElementArea(self, area):
4087 self.Parameters(SIMPLE).SetMaxElementArea(area)
4089 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4090 # Overrides value set by MaxElementArea()
4091 # Only for algoType == NETGEN_FULL
4092 # @ingroup l3_hypos_netgen
4093 def LengthFromEdges(self):
4094 self.Parameters(SIMPLE).LengthFromEdges()
4096 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4097 # Overrides value set by MaxElementVolume()
4098 # Only for algoType == NETGEN_FULL
4099 # @ingroup l3_hypos_netgen
4100 def LengthFromFaces(self):
4101 self.Parameters(SIMPLE).LengthFromFaces()
4103 ## To mesh "holes" in a solid or not. Default is to mesh.
4104 # @ingroup l3_hypos_ghs3dh
4105 def SetToMeshHoles(self, toMesh):
4106 # Parameter of GHS3D
4107 self.Parameters().SetToMeshHoles(toMesh)
4109 ## Set Optimization level:
4110 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
4111 # Default is Medium_Optimization
4112 # @ingroup l3_hypos_ghs3dh
4113 def SetOptimizationLevel(self, level):
4114 # Parameter of GHS3D
4115 self.Parameters().SetOptimizationLevel(level)
4117 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4118 # @ingroup l3_hypos_ghs3dh
4119 def SetMaximumMemory(self, MB):
4120 # Advanced parameter of GHS3D
4121 self.Parameters().SetMaximumMemory(MB)
4123 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4124 # automatic memory adjustment mode.
4125 # @ingroup l3_hypos_ghs3dh
4126 def SetInitialMemory(self, MB):
4127 # Advanced parameter of GHS3D
4128 self.Parameters().SetInitialMemory(MB)
4130 ## Path to working directory.
4131 # @ingroup l3_hypos_ghs3dh
4132 def SetWorkingDirectory(self, path):
4133 # Advanced parameter of GHS3D
4134 self.Parameters().SetWorkingDirectory(path)
4136 ## To keep working files or remove them. Log file remains in case of errors anyway.
4137 # @ingroup l3_hypos_ghs3dh
4138 def SetKeepFiles(self, toKeep):
4139 # Advanced parameter of GHS3D
4140 self.Parameters().SetKeepFiles(toKeep)
4142 ## To set verbose level [0-10]. <ul>
4143 #<li> 0 - no standard output,
4144 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4145 # indicates when the final mesh is being saved. In addition the software
4146 # gives indication regarding the CPU time.
4147 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4148 # histogram of the skin mesh, quality statistics histogram together with
4149 # the characteristics of the final mesh.</ul>
4150 # @ingroup l3_hypos_ghs3dh
4151 def SetVerboseLevel(self, level):
4152 # Advanced parameter of GHS3D
4153 self.Parameters().SetVerboseLevel(level)
4155 ## To create new nodes.
4156 # @ingroup l3_hypos_ghs3dh
4157 def SetToCreateNewNodes(self, toCreate):
4158 # Advanced parameter of GHS3D
4159 self.Parameters().SetToCreateNewNodes(toCreate)
4161 ## To use boundary recovery version which tries to create mesh on a very poor
4162 # quality surface mesh.
4163 # @ingroup l3_hypos_ghs3dh
4164 def SetToUseBoundaryRecoveryVersion(self, toUse):
4165 # Advanced parameter of GHS3D
4166 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4168 ## Sets command line option as text.
4169 # @ingroup l3_hypos_ghs3dh
4170 def SetTextOption(self, option):
4171 # Advanced parameter of GHS3D
4172 self.Parameters().SetTextOption(option)
4174 # Public class: Mesh_Hexahedron
4175 # ------------------------------
4177 ## Defines a hexahedron 3D algorithm
4179 # @ingroup l3_algos_basic
4180 class Mesh_Hexahedron(Mesh_Algorithm):
4185 ## Private constructor.
4186 def __init__(self, mesh, algoType=Hexa, geom=0):
4187 Mesh_Algorithm.__init__(self)
4189 self.algoType = algoType
4191 if algoType == Hexa:
4192 self.Create(mesh, geom, "Hexa_3D")
4195 elif algoType == Hexotic:
4196 import HexoticPlugin
4197 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4200 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4201 # @ingroup l3_hypos_hexotic
4202 def MinMaxQuad(self, min=3, max=8, quad=True):
4203 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4205 self.params.SetHexesMinLevel(min)
4206 self.params.SetHexesMaxLevel(max)
4207 self.params.SetHexoticQuadrangles(quad)
4210 # Deprecated, only for compatibility!
4211 # Public class: Mesh_Netgen
4212 # ------------------------------
4214 ## Defines a NETGEN-based 2D or 3D algorithm
4215 # that needs no discrete boundary (i.e. independent)
4217 # This class is deprecated, only for compatibility!
4220 # @ingroup l3_algos_basic
4221 class Mesh_Netgen(Mesh_Algorithm):
4225 ## Private constructor.
4226 def __init__(self, mesh, is3D, geom=0):
4227 Mesh_Algorithm.__init__(self)
4230 print "Warning: NETGENPlugin module has not been imported."
4234 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4238 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4241 ## Defines the hypothesis containing parameters of the algorithm
4242 def Parameters(self):
4244 hyp = self.Hypothesis("NETGEN_Parameters", [],
4245 "libNETGENEngine.so", UseExisting=0)
4247 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4248 "libNETGENEngine.so", UseExisting=0)
4251 # Public class: Mesh_Projection1D
4252 # ------------------------------
4254 ## Defines a projection 1D algorithm
4255 # @ingroup l3_algos_proj
4257 class Mesh_Projection1D(Mesh_Algorithm):
4259 ## Private constructor.
4260 def __init__(self, mesh, geom=0):
4261 Mesh_Algorithm.__init__(self)
4262 self.Create(mesh, geom, "Projection_1D")
4264 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4265 # a mesh pattern is taken, and, optionally, the association of vertices
4266 # between the source edge and a target edge (to which a hypothesis is assigned)
4267 # @param edge from which nodes distribution is taken
4268 # @param mesh from which nodes distribution is taken (optional)
4269 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4270 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4271 # to associate with \a srcV (optional)
4272 # @param UseExisting if ==true - searches for the existing hypothesis created with
4273 # the same parameters, else (default) - creates a new one
4274 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4275 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4277 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4278 hyp.SetSourceEdge( edge )
4279 if not mesh is None and isinstance(mesh, Mesh):
4280 mesh = mesh.GetMesh()
4281 hyp.SetSourceMesh( mesh )
4282 hyp.SetVertexAssociation( srcV, tgtV )
4285 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4286 #def CompareSourceEdge(self, hyp, args):
4287 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4291 # Public class: Mesh_Projection2D
4292 # ------------------------------
4294 ## Defines a projection 2D algorithm
4295 # @ingroup l3_algos_proj
4297 class Mesh_Projection2D(Mesh_Algorithm):
4299 ## Private constructor.
4300 def __init__(self, mesh, geom=0):
4301 Mesh_Algorithm.__init__(self)
4302 self.Create(mesh, geom, "Projection_2D")
4304 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4305 # a mesh pattern is taken, and, optionally, the association of vertices
4306 # between the source face and the target face (to which a hypothesis is assigned)
4307 # @param face from which the mesh pattern is taken
4308 # @param mesh from which the mesh pattern is taken (optional)
4309 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4310 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4311 # to associate with \a srcV1 (optional)
4312 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4313 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4314 # to associate with \a srcV2 (optional)
4315 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4316 # the same parameters, else (default) - forces the creation a new one
4318 # Note: all association vertices must belong to one edge of a face
4319 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4320 srcV2=None, tgtV2=None, UseExisting=0):
4321 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4323 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4324 hyp.SetSourceFace( face )
4325 if not mesh is None and isinstance(mesh, Mesh):
4326 mesh = mesh.GetMesh()
4327 hyp.SetSourceMesh( mesh )
4328 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4331 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4332 #def CompareSourceFace(self, hyp, args):
4333 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4336 # Public class: Mesh_Projection3D
4337 # ------------------------------
4339 ## Defines a projection 3D algorithm
4340 # @ingroup l3_algos_proj
4342 class Mesh_Projection3D(Mesh_Algorithm):
4344 ## Private constructor.
4345 def __init__(self, mesh, geom=0):
4346 Mesh_Algorithm.__init__(self)
4347 self.Create(mesh, geom, "Projection_3D")
4349 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4350 # the mesh pattern is taken, and, optionally, the association of vertices
4351 # between the source and the target solid (to which a hipothesis is assigned)
4352 # @param solid from where the mesh pattern is taken
4353 # @param mesh from where the mesh pattern is taken (optional)
4354 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4355 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4356 # to associate with \a srcV1 (optional)
4357 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4358 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4359 # to associate with \a srcV2 (optional)
4360 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4361 # the same parameters, else (default) - creates a new one
4363 # Note: association vertices must belong to one edge of a solid
4364 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4365 srcV2=0, tgtV2=0, UseExisting=0):
4366 hyp = self.Hypothesis("ProjectionSource3D",
4367 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4369 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4370 hyp.SetSource3DShape( solid )
4371 if not mesh is None and isinstance(mesh, Mesh):
4372 mesh = mesh.GetMesh()
4373 hyp.SetSourceMesh( mesh )
4374 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4377 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4378 #def CompareSourceShape3D(self, hyp, args):
4379 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4383 # Public class: Mesh_Prism
4384 # ------------------------
4386 ## Defines a 3D extrusion algorithm
4387 # @ingroup l3_algos_3dextr
4389 class Mesh_Prism3D(Mesh_Algorithm):
4391 ## Private constructor.
4392 def __init__(self, mesh, geom=0):
4393 Mesh_Algorithm.__init__(self)
4394 self.Create(mesh, geom, "Prism_3D")
4396 # Public class: Mesh_RadialPrism
4397 # -------------------------------
4399 ## Defines a Radial Prism 3D algorithm
4400 # @ingroup l3_algos_radialp
4402 class Mesh_RadialPrism3D(Mesh_Algorithm):
4404 ## Private constructor.
4405 def __init__(self, mesh, geom=0):
4406 Mesh_Algorithm.__init__(self)
4407 self.Create(mesh, geom, "RadialPrism_3D")
4409 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4410 self.nbLayers = None
4412 ## Return 3D hypothesis holding the 1D one
4413 def Get3DHypothesis(self):
4414 return self.distribHyp
4416 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4417 # hypothesis. Returns the created hypothesis
4418 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4419 #print "OwnHypothesis",hypType
4420 if not self.nbLayers is None:
4421 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4422 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4423 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4424 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4425 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4426 self.distribHyp.SetLayerDistribution( hyp )
4429 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4430 # prisms to build between the inner and outer shells
4431 # @param n number of layers
4432 # @param UseExisting if ==true - searches for the existing hypothesis created with
4433 # the same parameters, else (default) - creates a new one
4434 def NumberOfLayers(self, n, UseExisting=0):
4435 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4436 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4437 CompareMethod=self.CompareNumberOfLayers)
4438 self.nbLayers.SetNumberOfLayers( n )
4439 return self.nbLayers
4441 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4442 def CompareNumberOfLayers(self, hyp, args):
4443 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4445 ## Defines "LocalLength" hypothesis, specifying the segment length
4446 # to build between the inner and the outer shells
4447 # @param l the length of segments
4448 # @param p the precision of rounding
4449 def LocalLength(self, l, p=1e-07):
4450 hyp = self.OwnHypothesis("LocalLength", [l,p])
4455 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4456 # prisms to build between the inner and the outer shells.
4457 # @param n the number of layers
4458 # @param s the scale factor (optional)
4459 def NumberOfSegments(self, n, s=[]):
4461 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4463 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4464 hyp.SetDistrType( 1 )
4465 hyp.SetScaleFactor(s)
4466 hyp.SetNumberOfSegments(n)
4469 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4470 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4471 # @param start the length of the first segment
4472 # @param end the length of the last segment
4473 def Arithmetic1D(self, start, end ):
4474 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4475 hyp.SetLength(start, 1)
4476 hyp.SetLength(end , 0)
4479 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4480 # to build between the inner and the outer shells as geometric length increasing
4481 # @param start for the length of the first segment
4482 # @param end for the length of the last segment
4483 def StartEndLength(self, start, end):
4484 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4485 hyp.SetLength(start, 1)
4486 hyp.SetLength(end , 0)
4489 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4490 # to build between the inner and outer shells
4491 # @param fineness defines the quality of the mesh within the range [0-1]
4492 def AutomaticLength(self, fineness=0):
4493 hyp = self.OwnHypothesis("AutomaticLength")
4494 hyp.SetFineness( fineness )
4497 # Private class: Mesh_UseExisting
4498 # -------------------------------
4499 class Mesh_UseExisting(Mesh_Algorithm):
4501 def __init__(self, dim, mesh, geom=0):
4503 self.Create(mesh, geom, "UseExisting_1D")
4505 self.Create(mesh, geom, "UseExisting_2D")
4508 import salome_notebook
4509 notebook = salome_notebook.notebook
4511 ##Return values of the notebook variables
4512 def ParseParameters(last, nbParams,nbParam, value):
4516 listSize = len(last)
4517 for n in range(0,nbParams):
4519 if counter < listSize:
4520 strResult = strResult + last[counter]
4522 strResult = strResult + ""
4524 if isinstance(value, str):
4525 if notebook.isVariable(value):
4526 result = notebook.get(value)
4527 strResult=strResult+value
4529 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
4531 strResult=strResult+str(value)
4533 if nbParams - 1 != counter:
4534 strResult=strResult+var_separator #":"
4536 return result, strResult
4538 #Wrapper class for StdMeshers_LocalLength hypothesis
4539 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
4541 ## Set Length parameter value
4542 # @param length numerical value or name of variable from notebook
4543 def SetLength(self, length):
4544 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
4545 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4546 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
4548 ## Set Precision parameter value
4549 # @param precision numerical value or name of variable from notebook
4550 def SetPrecision(self, precision):
4551 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
4552 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4553 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
4555 #Registering the new proxy for LocalLength
4556 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
4559 #Wrapper class for StdMeshers_LayerDistribution hypothesis
4560 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
4562 def SetLayerDistribution(self, hypo):
4563 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
4564 hypo.ClearParameters();
4565 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
4567 #Registering the new proxy for LayerDistribution
4568 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
4570 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
4571 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
4573 ## Set Length parameter value
4574 # @param length numerical value or name of variable from notebook
4575 def SetLength(self, length):
4576 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
4577 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
4578 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
4580 #Registering the new proxy for SegmentLengthAroundVertex
4581 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
4584 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
4585 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
4587 ## Set Length parameter value
4588 # @param length numerical value or name of variable from notebook
4589 # @param isStart true is length is Start Length, otherwise false
4590 def SetLength(self, length, isStart):
4594 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
4595 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
4596 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
4598 #Registering the new proxy for Arithmetic1D
4599 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
4601 #Wrapper class for StdMeshers_Deflection1D hypothesis
4602 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
4604 ## Set Deflection parameter value
4605 # @param deflection numerical value or name of variable from notebook
4606 def SetDeflection(self, deflection):
4607 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
4608 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
4609 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
4611 #Registering the new proxy for Deflection1D
4612 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
4614 #Wrapper class for StdMeshers_StartEndLength hypothesis
4615 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
4617 ## Set Length parameter value
4618 # @param length numerical value or name of variable from notebook
4619 # @param isStart true is length is Start Length, otherwise false
4620 def SetLength(self, length, isStart):
4624 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
4625 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
4626 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
4628 #Registering the new proxy for StartEndLength
4629 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
4631 #Wrapper class for StdMeshers_MaxElementArea hypothesis
4632 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
4634 ## Set Max Element Area parameter value
4635 # @param area numerical value or name of variable from notebook
4636 def SetMaxElementArea(self, area):
4637 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
4638 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
4639 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
4641 #Registering the new proxy for MaxElementArea
4642 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
4645 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
4646 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
4648 ## Set Max Element Volume parameter value
4649 # @param area numerical value or name of variable from notebook
4650 def SetMaxElementVolume(self, volume):
4651 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
4652 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
4653 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
4655 #Registering the new proxy for MaxElementVolume
4656 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
4659 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
4660 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
4662 ## Set Number Of Layers parameter value
4663 # @param nbLayers numerical value or name of variable from notebook
4664 def SetNumberOfLayers(self, nbLayers):
4665 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
4666 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
4667 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
4669 #Registering the new proxy for NumberOfLayers
4670 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
4672 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
4673 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
4675 ## Set Number Of Segments parameter value
4676 # @param nbSeg numerical value or name of variable from notebook
4677 def SetNumberOfSegments(self, nbSeg):
4678 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
4679 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
4680 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4681 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
4683 ## Set Scale Factor parameter value
4684 # @param factor numerical value or name of variable from notebook
4685 def SetScaleFactor(self, factor):
4686 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
4687 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4688 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
4690 #Registering the new proxy for NumberOfSegments
4691 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
4694 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
4695 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
4697 ## Set Max Size parameter value
4698 # @param maxsize numerical value or name of variable from notebook
4699 def SetMaxSize(self, maxsize):
4700 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4701 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
4702 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4703 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
4705 ## Set Growth Rate parameter value
4706 # @param value numerical value or name of variable from notebook
4707 def SetGrowthRate(self, value):
4708 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4709 value, parameters = ParseParameters(lastParameters,4,2,value)
4710 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4711 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
4713 ## Set Number of Segments per Edge parameter value
4714 # @param value numerical value or name of variable from notebook
4715 def SetNbSegPerEdge(self, value):
4716 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4717 value, parameters = ParseParameters(lastParameters,4,3,value)
4718 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4719 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
4721 ## Set Number of Segments per Radius parameter value
4722 # @param value numerical value or name of variable from notebook
4723 def SetNbSegPerRadius(self, value):
4724 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4725 value, parameters = ParseParameters(lastParameters,4,4,value)
4726 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4727 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
4729 #Registering the new proxy for NETGENPlugin_Hypothesis
4730 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
4733 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
4734 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
4737 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
4738 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
4740 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
4741 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
4743 ## Set Number of Segments parameter value
4744 # @param nbSeg numerical value or name of variable from notebook
4745 def SetNumberOfSegments(self, nbSeg):
4746 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4747 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
4748 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4749 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
4751 ## Set Local Length parameter value
4752 # @param length numerical value or name of variable from notebook
4753 def SetLocalLength(self, length):
4754 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4755 length, parameters = ParseParameters(lastParameters,2,1,length)
4756 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4757 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
4759 ## Set Max Element Area parameter value
4760 # @param area numerical value or name of variable from notebook
4761 def SetMaxElementArea(self, area):
4762 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4763 area, parameters = ParseParameters(lastParameters,2,2,area)
4764 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4765 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
4767 def LengthFromEdges(self):
4768 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4770 value, parameters = ParseParameters(lastParameters,2,2,value)
4771 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4772 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
4774 #Registering the new proxy for NETGEN_SimpleParameters_2D
4775 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
4778 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
4779 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
4780 ## Set Max Element Volume parameter value
4781 # @param volume numerical value or name of variable from notebook
4782 def SetMaxElementVolume(self, volume):
4783 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
4784 volume, parameters = ParseParameters(lastParameters,3,3,volume)
4785 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
4786 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
4788 def LengthFromFaces(self):
4789 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
4791 value, parameters = ParseParameters(lastParameters,3,3,value)
4792 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
4793 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
4795 #Registering the new proxy for NETGEN_SimpleParameters_3D
4796 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
4798 class Pattern(SMESH._objref_SMESH_Pattern):
4800 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
4802 if isinstance(theNodeIndexOnKeyPoint1,str):
4804 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
4806 theNodeIndexOnKeyPoint1 -= 1
4807 theMesh.SetParameters(Parameters)
4808 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
4810 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
4813 if isinstance(theNode000Index,str):
4815 if isinstance(theNode001Index,str):
4817 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
4819 theNode000Index -= 1
4821 theNode001Index -= 1
4822 theMesh.SetParameters(Parameters)
4823 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
4825 #Registering the new proxy for Pattern
4826 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)