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
164 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):
298 if isinstance(Point, PointStructStr):
299 Parameters = str(Point.xStr) + ":" + str(Point.yStr) + ":" + 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):
306 if isinstance(Dir, DirStructStr):
307 pntStr = Dir.pointStruct
308 if isinstance(pntStr, PointStructStr6):
309 Parameters = str(pntStr.x1Str) + ":" + str(pntStr.x2Str) + ":"
310 Parameters += str(pntStr.y1Str) + ":" + str(pntStr.y2Str) + ":"
311 Parameters += str(pntStr.z1Str) + ":" + str(pntStr.z2Str)
312 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
314 Parameters = str(pntStr.xStr) + ":" + str(pntStr.yStr) + ":" + 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*variable_separator
322 if isinstance(Axis, AxisStructStr):
323 Parameters = str(Axis.xStr) + variable_separator + str(Axis.yStr) + variable_separator + str(Axis.zStr) + variable_separator
324 Parameters += str(Axis.dxStr) + variable_separator + str(Axis.dyStr) + variable_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 + ":"
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 + ":" + AngleParameters + ":" + 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):
2455 if ( isinstance( theObject, Mesh )):
2456 theObject = theObject.GetMesh()
2457 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2458 Axis = self.smeshpyD.GetAxisStruct(Axis)
2459 if TotalAngle and NbOfSteps:
2460 AngleInRadians /= NbOfSteps
2462 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2463 NbOfSteps, Tolerance)
2464 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2467 ## Generates new elements by extrusion of the elements with given ids
2468 # @param IDsOfElements the list of elements ids for extrusion
2469 # @param StepVector vector, defining the direction and value of extrusion
2470 # @param NbOfSteps the number of steps
2471 # @param MakeGroups forces the generation of new groups from existing ones
2472 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2473 # @ingroup l2_modif_extrurev
2474 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2475 if IDsOfElements == []:
2476 IDsOfElements = self.GetElementsId()
2477 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2478 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2479 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2480 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2481 Parameters = StepVectorParameters + ":" + Parameters
2482 self.mesh.SetParameters(Parameters)
2484 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2485 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2488 ## Generates new elements by extrusion of the elements with given ids
2489 # @param IDsOfElements is ids of elements
2490 # @param StepVector vector, defining the direction and value of extrusion
2491 # @param NbOfSteps the number of steps
2492 # @param ExtrFlags sets flags for extrusion
2493 # @param SewTolerance uses for comparing locations of nodes if flag
2494 # EXTRUSION_FLAG_SEW is set
2495 # @param MakeGroups forces the generation of new groups from existing ones
2496 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2497 # @ingroup l2_modif_extrurev
2498 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2499 ExtrFlags, SewTolerance, MakeGroups=False):
2500 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2501 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2503 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2504 ExtrFlags, SewTolerance)
2505 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2506 ExtrFlags, SewTolerance)
2509 ## Generates new elements by extrusion of the elements which belong to the object
2510 # @param theObject the object which elements should be processed
2511 # @param StepVector vector, defining the direction and value of extrusion
2512 # @param NbOfSteps the number of steps
2513 # @param MakeGroups forces the generation of new groups from existing ones
2514 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2515 # @ingroup l2_modif_extrurev
2516 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2517 if ( isinstance( theObject, Mesh )):
2518 theObject = theObject.GetMesh()
2519 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2520 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2522 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2523 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2526 ## Generates new elements by extrusion of the elements which belong to the object
2527 # @param theObject object which elements should be processed
2528 # @param StepVector vector, defining the direction and value of extrusion
2529 # @param NbOfSteps the number of steps
2530 # @param MakeGroups to generate new groups from existing ones
2531 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2532 # @ingroup l2_modif_extrurev
2533 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2534 if ( isinstance( theObject, Mesh )):
2535 theObject = theObject.GetMesh()
2536 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2537 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2539 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2540 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2543 ## Generates new elements by extrusion of the elements which belong to the object
2544 # @param theObject object which elements should be processed
2545 # @param StepVector vector, defining the direction and value of extrusion
2546 # @param NbOfSteps the number of steps
2547 # @param MakeGroups forces the generation of new groups from existing ones
2548 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2549 # @ingroup l2_modif_extrurev
2550 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2551 if ( isinstance( theObject, Mesh )):
2552 theObject = theObject.GetMesh()
2553 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2554 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2556 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2557 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2560 ## Generates new elements by extrusion of the given elements
2561 # The path of extrusion must be a meshed edge.
2562 # @param IDsOfElements ids of elements
2563 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2564 # @param PathShape shape(edge) defines the sub-mesh for the path
2565 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2566 # @param HasAngles allows the shape to be rotated around the path
2567 # to get the resulting mesh in a helical fashion
2568 # @param Angles list of angles
2569 # @param HasRefPoint allows using the reference point
2570 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2571 # The User can specify any point as the Reference Point.
2572 # @param MakeGroups forces the generation of new groups from existing ones
2573 # @param LinearVariation forces the computation of rotation angles as linear
2574 # variation of the given Angles along path steps
2575 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2576 # only SMESH::Extrusion_Error otherwise
2577 # @ingroup l2_modif_extrurev
2578 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2579 HasAngles, Angles, HasRefPoint, RefPoint,
2580 MakeGroups=False, LinearVariation=False):
2581 Angles,AnglesParameters = ParseAngles(Angles)
2582 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2583 if IDsOfElements == []:
2584 IDsOfElements = self.GetElementsId()
2585 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2586 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2588 if ( isinstance( PathMesh, Mesh )):
2589 PathMesh = PathMesh.GetMesh()
2590 if HasAngles and Angles and LinearVariation:
2591 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2593 Parameters = AnglesParameters + ":" + RefPointParameters
2594 self.mesh.SetParameters(Parameters)
2596 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2597 PathShape, NodeStart, HasAngles,
2598 Angles, HasRefPoint, RefPoint)
2599 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2600 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2602 ## Generates new elements by extrusion of the elements which belong to the object
2603 # The path of extrusion must be a meshed edge.
2604 # @param theObject the object which elements should be processed
2605 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2606 # @param PathShape shape(edge) defines the sub-mesh for the path
2607 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2608 # @param HasAngles allows the shape to be rotated around the path
2609 # to get the resulting mesh in a helical fashion
2610 # @param Angles list of angles
2611 # @param HasRefPoint allows using the reference point
2612 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2613 # The User can specify any point as the Reference Point.
2614 # @param MakeGroups forces the generation of new groups from existing ones
2615 # @param LinearVariation forces the computation of rotation angles as linear
2616 # variation of the given Angles along path steps
2617 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2618 # only SMESH::Extrusion_Error otherwise
2619 # @ingroup l2_modif_extrurev
2620 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2621 HasAngles, Angles, HasRefPoint, RefPoint,
2622 MakeGroups=False, LinearVariation=False):
2623 if ( isinstance( theObject, Mesh )):
2624 theObject = theObject.GetMesh()
2625 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2626 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2627 if ( isinstance( PathMesh, Mesh )):
2628 PathMesh = PathMesh.GetMesh()
2629 if HasAngles and Angles and LinearVariation:
2630 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2633 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2634 PathShape, NodeStart, HasAngles,
2635 Angles, HasRefPoint, RefPoint)
2636 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2637 NodeStart, HasAngles, Angles, HasRefPoint,
2640 ## Creates a symmetrical copy of mesh elements
2641 # @param IDsOfElements list of elements ids
2642 # @param Mirror is AxisStruct or geom object(point, line, plane)
2643 # @param theMirrorType is POINT, AXIS or PLANE
2644 # If the Mirror is a geom object this parameter is unnecessary
2645 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2646 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2647 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2648 # @ingroup l2_modif_trsf
2649 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2650 if IDsOfElements == []:
2651 IDsOfElements = self.GetElementsId()
2652 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2653 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2654 Mirror,Parameters = ParseAxisStruct(Mirror)
2655 self.mesh.SetParameters(Parameters)
2656 if Copy and MakeGroups:
2657 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2658 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2661 ## Creates a new mesh by a symmetrical copy of mesh elements
2662 # @param IDsOfElements the list of elements ids
2663 # @param Mirror is AxisStruct or geom object (point, line, plane)
2664 # @param theMirrorType is POINT, AXIS or PLANE
2665 # If the Mirror is a geom object this parameter is unnecessary
2666 # @param MakeGroups to generate new groups from existing ones
2667 # @param NewMeshName a name of the new mesh to create
2668 # @return instance of Mesh class
2669 # @ingroup l2_modif_trsf
2670 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2671 if IDsOfElements == []:
2672 IDsOfElements = self.GetElementsId()
2673 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2674 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2675 Mirror,Parameters = ParseAxisStruct(Mirror)
2676 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2677 MakeGroups, NewMeshName)
2678 mesh.SetParameters(Parameters)
2679 return Mesh(self.smeshpyD,self.geompyD,mesh)
2681 ## Creates a symmetrical copy of the object
2682 # @param theObject mesh, submesh or group
2683 # @param Mirror AxisStruct or geom object (point, line, plane)
2684 # @param theMirrorType is POINT, AXIS or PLANE
2685 # If the Mirror is a geom object this parameter is unnecessary
2686 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2687 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2688 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2689 # @ingroup l2_modif_trsf
2690 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2691 if ( isinstance( theObject, Mesh )):
2692 theObject = theObject.GetMesh()
2693 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2694 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2695 Mirror,Parameters = ParseAxisStruct(Mirror)
2696 self.mesh.SetParameters(Parameters)
2697 if Copy and MakeGroups:
2698 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2699 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2702 ## Creates a new mesh by a symmetrical copy of the object
2703 # @param theObject mesh, submesh or group
2704 # @param Mirror AxisStruct or geom object (point, line, plane)
2705 # @param theMirrorType POINT, AXIS or PLANE
2706 # If the Mirror is a geom object this parameter is unnecessary
2707 # @param MakeGroups forces the generation of new groups from existing ones
2708 # @param NewMeshName the name of the new mesh to create
2709 # @return instance of Mesh class
2710 # @ingroup l2_modif_trsf
2711 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2712 if ( isinstance( theObject, Mesh )):
2713 theObject = theObject.GetMesh()
2714 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2715 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2716 Mirror,Parameters = ParseAxisStruct(Mirror)
2717 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2718 MakeGroups, NewMeshName)
2719 mesh.SetParameters(Parameters)
2720 return Mesh( self.smeshpyD,self.geompyD,mesh )
2722 ## Translates the elements
2723 # @param IDsOfElements list of elements ids
2724 # @param Vector the direction of translation (DirStruct or vector)
2725 # @param Copy allows copying the translated elements
2726 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2727 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2728 # @ingroup l2_modif_trsf
2729 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2730 if IDsOfElements == []:
2731 IDsOfElements = self.GetElementsId()
2732 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2733 Vector = self.smeshpyD.GetDirStruct(Vector)
2734 Vector,Parameters = ParseDirStruct(Vector)
2735 self.mesh.SetParameters(Parameters)
2736 if Copy and MakeGroups:
2737 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
2738 self.editor.Translate(IDsOfElements, Vector, Copy)
2741 ## Creates a new mesh of translated elements
2742 # @param IDsOfElements list of elements ids
2743 # @param Vector the direction of translation (DirStruct or vector)
2744 # @param MakeGroups forces the generation of new groups from existing ones
2745 # @param NewMeshName the name of the newly created mesh
2746 # @return instance of Mesh class
2747 # @ingroup l2_modif_trsf
2748 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
2749 if IDsOfElements == []:
2750 IDsOfElements = self.GetElementsId()
2751 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2752 Vector = self.smeshpyD.GetDirStruct(Vector)
2753 Vector,Parameters = ParseDirStruct(Vector)
2754 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
2755 mesh.SetParameters(Parameters)
2756 return Mesh ( self.smeshpyD, self.geompyD, mesh )
2758 ## Translates the object
2759 # @param theObject the object to translate (mesh, submesh, or group)
2760 # @param Vector direction of translation (DirStruct or geom vector)
2761 # @param Copy allows copying the translated elements
2762 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2763 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2764 # @ingroup l2_modif_trsf
2765 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
2766 if ( isinstance( theObject, Mesh )):
2767 theObject = theObject.GetMesh()
2768 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2769 Vector = self.smeshpyD.GetDirStruct(Vector)
2770 if Copy and MakeGroups:
2771 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
2772 self.editor.TranslateObject(theObject, Vector, Copy)
2775 ## Creates a new mesh from the translated object
2776 # @param theObject the object to translate (mesh, submesh, or group)
2777 # @param Vector the direction of translation (DirStruct or geom vector)
2778 # @param MakeGroups forces the generation of new groups from existing ones
2779 # @param NewMeshName the name of the newly created mesh
2780 # @return instance of Mesh class
2781 # @ingroup l2_modif_trsf
2782 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
2783 if (isinstance(theObject, Mesh)):
2784 theObject = theObject.GetMesh()
2785 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
2786 Vector = self.smeshpyD.GetDirStruct(Vector)
2787 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
2788 return Mesh( self.smeshpyD, self.geompyD, mesh )
2790 ## Rotates the elements
2791 # @param IDsOfElements list of elements ids
2792 # @param Axis the axis of rotation (AxisStruct or geom line)
2793 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
2794 # @param Copy allows copying the rotated elements
2795 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2796 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2797 # @ingroup l2_modif_trsf
2798 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
2800 if isinstance(AngleInRadians,str):
2802 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
2804 AngleInRadians = DegreesToRadians(AngleInRadians)
2805 if IDsOfElements == []:
2806 IDsOfElements = self.GetElementsId()
2807 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2808 Axis = self.smeshpyD.GetAxisStruct(Axis)
2809 Axis,AxisParameters = ParseAxisStruct(Axis)
2810 Parameters = AxisParameters + ":" + Parameters
2811 self.mesh.SetParameters(Parameters)
2812 if Copy and MakeGroups:
2813 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
2814 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2817 ## Creates a new mesh of rotated elements
2818 # @param IDsOfElements list of element ids
2819 # @param Axis the axis of rotation (AxisStruct or geom line)
2820 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
2821 # @param MakeGroups forces the generation of new groups from existing ones
2822 # @param NewMeshName the name of the newly created mesh
2823 # @return instance of Mesh class
2824 # @ingroup l2_modif_trsf
2825 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
2827 if isinstance(AngleInRadians,str):
2829 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
2831 AngleInRadians = DegreesToRadians(AngleInRadians)
2832 if IDsOfElements == []:
2833 IDsOfElements = self.GetElementsId()
2834 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2835 Axis = self.smeshpyD.GetAxisStruct(Axis)
2836 Axis,AxisParameters = ParseAxisStruct(Axis)
2837 Parameters = AxisParameters + ":" + Parameters
2838 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
2839 MakeGroups, NewMeshName)
2840 mesh.SetParameters(Parameters)
2841 return Mesh( self.smeshpyD, self.geompyD, mesh )
2843 ## Rotates the object
2844 # @param theObject the object to rotate( mesh, submesh, or group)
2845 # @param Axis the axis of rotation (AxisStruct or geom line)
2846 # @param AngleInRadians the angle of rotation (in radians)
2847 # @param Copy allows copying the rotated elements
2848 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2849 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2850 # @ingroup l2_modif_trsf
2851 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
2852 if (isinstance(theObject, Mesh)):
2853 theObject = theObject.GetMesh()
2854 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2855 Axis = self.smeshpyD.GetAxisStruct(Axis)
2856 if Copy and MakeGroups:
2857 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
2858 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2861 ## Creates a new mesh from the rotated object
2862 # @param theObject the object to rotate (mesh, submesh, or group)
2863 # @param Axis the axis of rotation (AxisStruct or geom line)
2864 # @param AngleInRadians the angle of rotation (in radians)
2865 # @param MakeGroups forces the generation of new groups from existing ones
2866 # @param NewMeshName the name of the newly created mesh
2867 # @return instance of Mesh class
2868 # @ingroup l2_modif_trsf
2869 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
2870 if (isinstance( theObject, Mesh )):
2871 theObject = theObject.GetMesh()
2872 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2873 Axis = self.smeshpyD.GetAxisStruct(Axis)
2874 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
2875 MakeGroups, NewMeshName)
2876 return Mesh( self.smeshpyD, self.geompyD, mesh )
2878 ## Finds groups of ajacent nodes within Tolerance.
2879 # @param Tolerance the value of tolerance
2880 # @return the list of groups of nodes
2881 # @ingroup l2_modif_trsf
2882 def FindCoincidentNodes (self, Tolerance):
2883 return self.editor.FindCoincidentNodes(Tolerance)
2885 ## Finds groups of ajacent nodes within Tolerance.
2886 # @param Tolerance the value of tolerance
2887 # @param SubMeshOrGroup SubMesh or Group
2888 # @return the list of groups of nodes
2889 # @ingroup l2_modif_trsf
2890 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
2891 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
2894 # @param GroupsOfNodes the list of groups of nodes
2895 # @ingroup l2_modif_trsf
2896 def MergeNodes (self, GroupsOfNodes):
2897 self.editor.MergeNodes(GroupsOfNodes)
2899 ## Finds the elements built on the same nodes.
2900 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
2901 # @return a list of groups of equal elements
2902 # @ingroup l2_modif_trsf
2903 def FindEqualElements (self, MeshOrSubMeshOrGroup):
2904 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
2906 ## Merges elements in each given group.
2907 # @param GroupsOfElementsID groups of elements for merging
2908 # @ingroup l2_modif_trsf
2909 def MergeElements(self, GroupsOfElementsID):
2910 self.editor.MergeElements(GroupsOfElementsID)
2912 ## Leaves one element and removes all other elements built on the same nodes.
2913 # @ingroup l2_modif_trsf
2914 def MergeEqualElements(self):
2915 self.editor.MergeEqualElements()
2917 ## Sews free borders
2918 # @return SMESH::Sew_Error
2919 # @ingroup l2_modif_trsf
2920 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2921 FirstNodeID2, SecondNodeID2, LastNodeID2,
2922 CreatePolygons, CreatePolyedrs):
2923 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2924 FirstNodeID2, SecondNodeID2, LastNodeID2,
2925 CreatePolygons, CreatePolyedrs)
2927 ## Sews conform free borders
2928 # @return SMESH::Sew_Error
2929 # @ingroup l2_modif_trsf
2930 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2931 FirstNodeID2, SecondNodeID2):
2932 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2933 FirstNodeID2, SecondNodeID2)
2935 ## Sews border to side
2936 # @return SMESH::Sew_Error
2937 # @ingroup l2_modif_trsf
2938 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2939 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
2940 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2941 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
2943 ## Sews two sides of a mesh. The nodes belonging to Side1 are
2944 # merged with the nodes of elements of Side2.
2945 # The number of elements in theSide1 and in theSide2 must be
2946 # equal and they should have similar nodal connectivity.
2947 # The nodes to merge should belong to side borders and
2948 # the first node should be linked to the second.
2949 # @return SMESH::Sew_Error
2950 # @ingroup l2_modif_trsf
2951 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
2952 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2953 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
2954 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
2955 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2956 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
2958 ## Sets new nodes for the given element.
2959 # @param ide the element id
2960 # @param newIDs nodes ids
2961 # @return If the number of nodes does not correspond to the type of element - returns false
2962 # @ingroup l2_modif_edit
2963 def ChangeElemNodes(self, ide, newIDs):
2964 return self.editor.ChangeElemNodes(ide, newIDs)
2966 ## If during the last operation of MeshEditor some nodes were
2967 # created, this method returns the list of their IDs, \n
2968 # if new nodes were not created - returns empty list
2969 # @return the list of integer values (can be empty)
2970 # @ingroup l1_auxiliary
2971 def GetLastCreatedNodes(self):
2972 return self.editor.GetLastCreatedNodes()
2974 ## If during the last operation of MeshEditor some elements were
2975 # created this method returns the list of their IDs, \n
2976 # if new elements were not created - returns empty list
2977 # @return the list of integer values (can be empty)
2978 # @ingroup l1_auxiliary
2979 def GetLastCreatedElems(self):
2980 return self.editor.GetLastCreatedElems()
2982 ## The mother class to define algorithm, it is not recommended to use it directly.
2985 # @ingroup l2_algorithms
2986 class Mesh_Algorithm:
2987 # @class Mesh_Algorithm
2988 # @brief Class Mesh_Algorithm
2990 #def __init__(self,smesh):
2998 ## Finds a hypothesis in the study by its type name and parameters.
2999 # Finds only the hypotheses created in smeshpyD engine.
3000 # @return SMESH.SMESH_Hypothesis
3001 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3002 study = smeshpyD.GetCurrentStudy()
3003 #to do: find component by smeshpyD object, not by its data type
3004 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3005 if scomp is not None:
3006 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3007 # Check if the root label of the hypotheses exists
3008 if res and hypRoot is not None:
3009 iter = study.NewChildIterator(hypRoot)
3010 # Check all published hypotheses
3012 hypo_so_i = iter.Value()
3013 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3014 if attr is not None:
3015 anIOR = attr.Value()
3016 hypo_o_i = salome.orb.string_to_object(anIOR)
3017 if hypo_o_i is not None:
3018 # Check if this is a hypothesis
3019 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3020 if hypo_i is not None:
3021 # Check if the hypothesis belongs to current engine
3022 if smeshpyD.GetObjectId(hypo_i) > 0:
3023 # Check if this is the required hypothesis
3024 if hypo_i.GetName() == hypname:
3026 if CompareMethod(hypo_i, args):
3040 ## Finds the algorithm in the study by its type name.
3041 # Finds only the algorithms, which have been created in smeshpyD engine.
3042 # @return SMESH.SMESH_Algo
3043 def FindAlgorithm (self, algoname, smeshpyD):
3044 study = smeshpyD.GetCurrentStudy()
3045 #to do: find component by smeshpyD object, not by its data type
3046 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3047 if scomp is not None:
3048 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3049 # Check if the root label of the algorithms exists
3050 if res and hypRoot is not None:
3051 iter = study.NewChildIterator(hypRoot)
3052 # Check all published algorithms
3054 algo_so_i = iter.Value()
3055 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3056 if attr is not None:
3057 anIOR = attr.Value()
3058 algo_o_i = salome.orb.string_to_object(anIOR)
3059 if algo_o_i is not None:
3060 # Check if this is an algorithm
3061 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3062 if algo_i is not None:
3063 # Checks if the algorithm belongs to the current engine
3064 if smeshpyD.GetObjectId(algo_i) > 0:
3065 # Check if this is the required algorithm
3066 if algo_i.GetName() == algoname:
3079 ## If the algorithm is global, returns 0; \n
3080 # else returns the submesh associated to this algorithm.
3081 def GetSubMesh(self):
3084 ## Returns the wrapped mesher.
3085 def GetAlgorithm(self):
3088 ## Gets the list of hypothesis that can be used with this algorithm
3089 def GetCompatibleHypothesis(self):
3092 mylist = self.algo.GetCompatibleHypothesis()
3095 ## Gets the name of the algorithm
3099 ## Sets the name to the algorithm
3100 def SetName(self, name):
3101 SetName(self.algo, name)
3103 ## Gets the id of the algorithm
3105 return self.algo.GetId()
3108 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3110 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3111 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3113 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3115 self.Assign(algo, mesh, geom)
3119 def Assign(self, algo, mesh, geom):
3121 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3128 name = GetName(geom)
3130 name = mesh.geompyD.SubShapeName(geom, piece)
3131 mesh.geompyD.addToStudyInFather(piece, geom, name)
3132 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3135 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3136 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3138 def CompareHyp (self, hyp, args):
3139 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3142 def CompareEqualHyp (self, hyp, args):
3146 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3147 UseExisting=0, CompareMethod=""):
3150 if CompareMethod == "": CompareMethod = self.CompareHyp
3151 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3154 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3160 a = a + s + str(args[i])
3164 SetName(hypo, hyp + a)
3166 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3167 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3171 # Public class: Mesh_Segment
3172 # --------------------------
3174 ## Class to define a segment 1D algorithm for discretization
3177 # @ingroup l3_algos_basic
3178 class Mesh_Segment(Mesh_Algorithm):
3180 ## Private constructor.
3181 def __init__(self, mesh, geom=0):
3182 Mesh_Algorithm.__init__(self)
3183 self.Create(mesh, geom, "Regular_1D")
3185 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3186 # @param l for the length of segments that cut an edge
3187 # @param UseExisting if ==true - searches for an existing hypothesis created with
3188 # the same parameters, else (default) - creates a new one
3189 # @param p precision, used for calculation of the number of segments.
3190 # The precision should be a positive, meaningful value within the range [0,1].
3191 # In general, the number of segments is calculated with the formula:
3192 # nb = ceil((edge_length / l) - p)
3193 # Function ceil rounds its argument to the higher integer.
3194 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3195 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3196 # p=1 means rounding of (edge_length / l) to the lower integer.
3197 # Default value is 1e-07.
3198 # @return an instance of StdMeshers_LocalLength hypothesis
3199 # @ingroup l3_hypos_1dhyps
3200 def LocalLength(self, l, UseExisting=0, p=1e-07):
3201 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3202 CompareMethod=self.CompareLocalLength)
3208 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3209 def CompareLocalLength(self, hyp, args):
3210 if IsEqual(hyp.GetLength(), args[0]):
3211 return IsEqual(hyp.GetPrecision(), args[1])
3214 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3215 # @param n for the number of segments that cut an edge
3216 # @param s for the scale factor (optional)
3217 # @param UseExisting if ==true - searches for an existing hypothesis created with
3218 # the same parameters, else (default) - create a new one
3219 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3220 # @ingroup l3_hypos_1dhyps
3221 def NumberOfSegments(self, n, s=[], UseExisting=0):
3223 hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
3224 CompareMethod=self.CompareNumberOfSegments)
3226 hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
3227 CompareMethod=self.CompareNumberOfSegments)
3228 hyp.SetDistrType( 1 )
3229 hyp.SetScaleFactor(s)
3230 hyp.SetNumberOfSegments(n)
3234 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3235 def CompareNumberOfSegments(self, hyp, args):
3236 if hyp.GetNumberOfSegments() == args[0]:
3240 if hyp.GetDistrType() == 1:
3241 if IsEqual(hyp.GetScaleFactor(), args[1]):
3245 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3246 # @param start defines the length of the first segment
3247 # @param end defines the length of the last segment
3248 # @param UseExisting if ==true - searches for an existing hypothesis created with
3249 # the same parameters, else (default) - creates a new one
3250 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3251 # @ingroup l3_hypos_1dhyps
3252 def Arithmetic1D(self, start, end, UseExisting=0):
3253 hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
3254 CompareMethod=self.CompareArithmetic1D)
3255 hyp.SetLength(start, 1)
3256 hyp.SetLength(end , 0)
3260 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3261 def CompareArithmetic1D(self, hyp, args):
3262 if IsEqual(hyp.GetLength(1), args[0]):
3263 if IsEqual(hyp.GetLength(0), args[1]):
3267 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3268 # @param start defines the length of the first segment
3269 # @param end defines the length of the last segment
3270 # @param UseExisting if ==true - searches for an existing hypothesis created with
3271 # the same parameters, else (default) - creates a new one
3272 # @return an instance of StdMeshers_StartEndLength hypothesis
3273 # @ingroup l3_hypos_1dhyps
3274 def StartEndLength(self, start, end, UseExisting=0):
3275 hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
3276 CompareMethod=self.CompareStartEndLength)
3277 hyp.SetLength(start, 1)
3278 hyp.SetLength(end , 0)
3281 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3282 def CompareStartEndLength(self, hyp, args):
3283 if IsEqual(hyp.GetLength(1), args[0]):
3284 if IsEqual(hyp.GetLength(0), args[1]):
3288 ## Defines "Deflection1D" hypothesis
3289 # @param d for the deflection
3290 # @param UseExisting if ==true - searches for an existing hypothesis created with
3291 # the same parameters, else (default) - create a new one
3292 # @ingroup l3_hypos_1dhyps
3293 def Deflection1D(self, d, UseExisting=0):
3294 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3295 CompareMethod=self.CompareDeflection1D)
3296 hyp.SetDeflection(d)
3299 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3300 def CompareDeflection1D(self, hyp, args):
3301 return IsEqual(hyp.GetDeflection(), args[0])
3303 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3304 # the opposite side in case of quadrangular faces
3305 # @ingroup l3_hypos_additi
3306 def Propagation(self):
3307 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3309 ## Defines "AutomaticLength" hypothesis
3310 # @param fineness for the fineness [0-1]
3311 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3312 # same parameters, else (default) - create a new one
3313 # @ingroup l3_hypos_1dhyps
3314 def AutomaticLength(self, fineness=0, UseExisting=0):
3315 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3316 CompareMethod=self.CompareAutomaticLength)
3317 hyp.SetFineness( fineness )
3320 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3321 def CompareAutomaticLength(self, hyp, args):
3322 return IsEqual(hyp.GetFineness(), args[0])
3324 ## Defines "SegmentLengthAroundVertex" hypothesis
3325 # @param length for the segment length
3326 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3327 # Any other integer value means that the hypothesis will be set on the
3328 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3329 # @param UseExisting if ==true - searches for an existing hypothesis created with
3330 # the same parameters, else (default) - creates a new one
3331 # @ingroup l3_algos_segmarv
3332 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3334 store_geom = self.geom
3335 if type(vertex) is types.IntType:
3336 if vertex == 0 or vertex == 1:
3337 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3345 if self.geom is None:
3346 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3347 name = GetName(self.geom)
3349 piece = self.mesh.geom
3350 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3351 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3352 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3354 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3356 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3357 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3359 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3360 CompareMethod=self.CompareLengthNearVertex)
3361 self.geom = store_geom
3362 hyp.SetLength( length )
3365 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3366 # @ingroup l3_algos_segmarv
3367 def CompareLengthNearVertex(self, hyp, args):
3368 return IsEqual(hyp.GetLength(), args[0])
3370 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3371 # If the 2D mesher sees that all boundary edges are quadratic,
3372 # it generates quadratic faces, else it generates linear faces using
3373 # medium nodes as if they are vertices.
3374 # The 3D mesher generates quadratic volumes only if all boundary faces
3375 # are quadratic, else it fails.
3377 # @ingroup l3_hypos_additi
3378 def QuadraticMesh(self):
3379 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3382 # Public class: Mesh_CompositeSegment
3383 # --------------------------
3385 ## Defines a segment 1D algorithm for discretization
3387 # @ingroup l3_algos_basic
3388 class Mesh_CompositeSegment(Mesh_Segment):
3390 ## Private constructor.
3391 def __init__(self, mesh, geom=0):
3392 self.Create(mesh, geom, "CompositeSegment_1D")
3395 # Public class: Mesh_Segment_Python
3396 # ---------------------------------
3398 ## Defines a segment 1D algorithm for discretization with python function
3400 # @ingroup l3_algos_basic
3401 class Mesh_Segment_Python(Mesh_Segment):
3403 ## Private constructor.
3404 def __init__(self, mesh, geom=0):
3405 import Python1dPlugin
3406 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3408 ## Defines "PythonSplit1D" hypothesis
3409 # @param n for the number of segments that cut an edge
3410 # @param func for the python function that calculates the length of all segments
3411 # @param UseExisting if ==true - searches for the existing hypothesis created with
3412 # the same parameters, else (default) - creates a new one
3413 # @ingroup l3_hypos_1dhyps
3414 def PythonSplit1D(self, n, func, UseExisting=0):
3415 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3416 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3417 hyp.SetNumberOfSegments(n)
3418 hyp.SetPythonLog10RatioFunction(func)
3421 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3422 def ComparePythonSplit1D(self, hyp, args):
3423 #if hyp.GetNumberOfSegments() == args[0]:
3424 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3428 # Public class: Mesh_Triangle
3429 # ---------------------------
3431 ## Defines a triangle 2D algorithm
3433 # @ingroup l3_algos_basic
3434 class Mesh_Triangle(Mesh_Algorithm):
3443 ## Private constructor.
3444 def __init__(self, mesh, algoType, geom=0):
3445 Mesh_Algorithm.__init__(self)
3447 self.algoType = algoType
3448 if algoType == MEFISTO:
3449 self.Create(mesh, geom, "MEFISTO_2D")
3451 elif algoType == BLSURF:
3453 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3454 #self.SetPhysicalMesh() - PAL19680
3455 elif algoType == NETGEN:
3457 print "Warning: NETGENPlugin module unavailable"
3459 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3461 elif algoType == NETGEN_2D:
3463 print "Warning: NETGENPlugin module unavailable"
3465 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3468 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3469 # @param area for the maximum area of each triangle
3470 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3471 # same parameters, else (default) - creates a new one
3473 # Only for algoType == MEFISTO || NETGEN_2D
3474 # @ingroup l3_hypos_2dhyps
3475 def MaxElementArea(self, area, UseExisting=0):
3476 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3477 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3478 CompareMethod=self.CompareMaxElementArea)
3479 elif self.algoType == NETGEN:
3480 hyp = self.Parameters(SIMPLE)
3481 hyp.SetMaxElementArea(area)
3484 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3485 def CompareMaxElementArea(self, hyp, args):
3486 return IsEqual(hyp.GetMaxElementArea(), args[0])
3488 ## Defines "LengthFromEdges" hypothesis to build triangles
3489 # based on the length of the edges taken from the wire
3491 # Only for algoType == MEFISTO || NETGEN_2D
3492 # @ingroup l3_hypos_2dhyps
3493 def LengthFromEdges(self):
3494 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3495 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3497 elif self.algoType == NETGEN:
3498 hyp = self.Parameters(SIMPLE)
3499 hyp.LengthFromEdges()
3502 ## Sets a way to define size of mesh elements to generate.
3503 # @param thePhysicalMesh is: DefaultSize or Custom.
3504 # @ingroup l3_hypos_blsurf
3505 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3506 # Parameter of BLSURF algo
3507 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3509 ## Sets size of mesh elements to generate.
3510 # @ingroup l3_hypos_blsurf
3511 def SetPhySize(self, theVal):
3512 # Parameter of BLSURF algo
3513 self.Parameters().SetPhySize(theVal)
3515 ## Sets lower boundary of mesh element size (PhySize).
3516 # @ingroup l3_hypos_blsurf
3517 def SetPhyMin(self, theVal=-1):
3518 # Parameter of BLSURF algo
3519 self.Parameters().SetPhyMin(theVal)
3521 ## Sets upper boundary of mesh element size (PhySize).
3522 # @ingroup l3_hypos_blsurf
3523 def SetPhyMax(self, theVal=-1):
3524 # Parameter of BLSURF algo
3525 self.Parameters().SetPhyMax(theVal)
3527 ## Sets a way to define maximum angular deflection of mesh from CAD model.
3528 # @param theGeometricMesh is: DefaultGeom or Custom
3529 # @ingroup l3_hypos_blsurf
3530 def SetGeometricMesh(self, theGeometricMesh=0):
3531 # Parameter of BLSURF algo
3532 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3533 self.params.SetGeometricMesh(theGeometricMesh)
3535 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3536 # @ingroup l3_hypos_blsurf
3537 def SetAngleMeshS(self, theVal=_angleMeshS):
3538 # Parameter of BLSURF algo
3539 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3540 self.params.SetAngleMeshS(theVal)
3542 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3543 # @ingroup l3_hypos_blsurf
3544 def SetAngleMeshC(self, theVal=_angleMeshS):
3545 # Parameter of BLSURF algo
3546 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3547 self.params.SetAngleMeshC(theVal)
3549 ## Sets lower boundary of mesh element size computed to respect angular deflection.
3550 # @ingroup l3_hypos_blsurf
3551 def SetGeoMin(self, theVal=-1):
3552 # Parameter of BLSURF algo
3553 self.Parameters().SetGeoMin(theVal)
3555 ## Sets upper boundary of mesh element size computed to respect angular deflection.
3556 # @ingroup l3_hypos_blsurf
3557 def SetGeoMax(self, theVal=-1):
3558 # Parameter of BLSURF algo
3559 self.Parameters().SetGeoMax(theVal)
3561 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3562 # @ingroup l3_hypos_blsurf
3563 def SetGradation(self, theVal=_gradation):
3564 # Parameter of BLSURF algo
3565 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3566 self.params.SetGradation(theVal)
3568 ## Sets topology usage way.
3569 # @param way defines how mesh conformity is assured <ul>
3570 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
3571 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
3572 # @ingroup l3_hypos_blsurf
3573 def SetTopology(self, way):
3574 # Parameter of BLSURF algo
3575 self.Parameters().SetTopology(way)
3577 ## To respect geometrical edges or not.
3578 # @ingroup l3_hypos_blsurf
3579 def SetDecimesh(self, toIgnoreEdges=False):
3580 # Parameter of BLSURF algo
3581 self.Parameters().SetDecimesh(toIgnoreEdges)
3583 ## Sets verbosity level in the range 0 to 100.
3584 # @ingroup l3_hypos_blsurf
3585 def SetVerbosity(self, level):
3586 # Parameter of BLSURF algo
3587 self.Parameters().SetVerbosity(level)
3589 ## Sets advanced option value.
3590 # @ingroup l3_hypos_blsurf
3591 def SetOptionValue(self, optionName, level):
3592 # Parameter of BLSURF algo
3593 self.Parameters().SetOptionValue(optionName,level)
3595 ## Sets QuadAllowed flag.
3596 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
3597 # @ingroup l3_hypos_netgen l3_hypos_blsurf
3598 def SetQuadAllowed(self, toAllow=True):
3599 if self.algoType == NETGEN_2D:
3600 if toAllow: # add QuadranglePreference
3601 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3602 else: # remove QuadranglePreference
3603 for hyp in self.mesh.GetHypothesisList( self.geom ):
3604 if hyp.GetName() == "QuadranglePreference":
3605 self.mesh.RemoveHypothesis( self.geom, hyp )
3610 if self.Parameters():
3611 self.params.SetQuadAllowed(toAllow)
3614 ## Defines hypothesis having several parameters
3616 # @ingroup l3_hypos_netgen
3617 def Parameters(self, which=SOLE):
3620 if self.algoType == NETGEN:
3622 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
3623 "libNETGENEngine.so", UseExisting=0)
3625 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
3626 "libNETGENEngine.so", UseExisting=0)
3628 elif self.algoType == MEFISTO:
3629 print "Mefisto algo support no multi-parameter hypothesis"
3631 elif self.algoType == NETGEN_2D:
3632 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
3633 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3635 elif self.algoType == BLSURF:
3636 self.params = self.Hypothesis("BLSURF_Parameters", [],
3637 "libBLSURFEngine.so", UseExisting=0)
3640 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
3645 # Only for algoType == NETGEN
3646 # @ingroup l3_hypos_netgen
3647 def SetMaxSize(self, theSize):
3648 if self.Parameters():
3649 self.params.SetMaxSize(theSize)
3651 ## Sets SecondOrder flag
3653 # Only for algoType == NETGEN
3654 # @ingroup l3_hypos_netgen
3655 def SetSecondOrder(self, theVal):
3656 if self.Parameters():
3657 self.params.SetSecondOrder(theVal)
3659 ## Sets Optimize flag
3661 # Only for algoType == NETGEN
3662 # @ingroup l3_hypos_netgen
3663 def SetOptimize(self, theVal):
3664 if self.Parameters():
3665 self.params.SetOptimize(theVal)
3668 # @param theFineness is:
3669 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3671 # Only for algoType == NETGEN
3672 # @ingroup l3_hypos_netgen
3673 def SetFineness(self, theFineness):
3674 if self.Parameters():
3675 self.params.SetFineness(theFineness)
3679 # Only for algoType == NETGEN
3680 # @ingroup l3_hypos_netgen
3681 def SetGrowthRate(self, theRate):
3682 if self.Parameters():
3683 self.params.SetGrowthRate(theRate)
3685 ## Sets NbSegPerEdge
3687 # Only for algoType == NETGEN
3688 # @ingroup l3_hypos_netgen
3689 def SetNbSegPerEdge(self, theVal):
3690 if self.Parameters():
3691 self.params.SetNbSegPerEdge(theVal)
3693 ## Sets NbSegPerRadius
3695 # Only for algoType == NETGEN
3696 # @ingroup l3_hypos_netgen
3697 def SetNbSegPerRadius(self, theVal):
3698 if self.Parameters():
3699 self.params.SetNbSegPerRadius(theVal)
3701 ## Sets number of segments overriding value set by SetLocalLength()
3703 # Only for algoType == NETGEN
3704 # @ingroup l3_hypos_netgen
3705 def SetNumberOfSegments(self, theVal):
3706 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3708 ## Sets number of segments overriding value set by SetNumberOfSegments()
3710 # Only for algoType == NETGEN
3711 # @ingroup l3_hypos_netgen
3712 def SetLocalLength(self, theVal):
3713 self.Parameters(SIMPLE).SetLocalLength(theVal)
3718 # Public class: Mesh_Quadrangle
3719 # -----------------------------
3721 ## Defines a quadrangle 2D algorithm
3723 # @ingroup l3_algos_basic
3724 class Mesh_Quadrangle(Mesh_Algorithm):
3726 ## Private constructor.
3727 def __init__(self, mesh, geom=0):
3728 Mesh_Algorithm.__init__(self)
3729 self.Create(mesh, geom, "Quadrangle_2D")
3731 ## Defines "QuadranglePreference" hypothesis, forcing construction
3732 # of quadrangles if the number of nodes on the opposite edges is not the same
3733 # while the total number of nodes on edges is even
3735 # @ingroup l3_hypos_additi
3736 def QuadranglePreference(self):
3737 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
3738 CompareMethod=self.CompareEqualHyp)
3741 ## Defines "TrianglePreference" hypothesis, forcing construction
3742 # of triangles in the refinement area if the number of nodes
3743 # on the opposite edges is not the same
3745 # @ingroup l3_hypos_additi
3746 def TrianglePreference(self):
3747 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
3748 CompareMethod=self.CompareEqualHyp)
3751 # Public class: Mesh_Tetrahedron
3752 # ------------------------------
3754 ## Defines a tetrahedron 3D algorithm
3756 # @ingroup l3_algos_basic
3757 class Mesh_Tetrahedron(Mesh_Algorithm):
3762 ## Private constructor.
3763 def __init__(self, mesh, algoType, geom=0):
3764 Mesh_Algorithm.__init__(self)
3766 if algoType == NETGEN:
3767 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
3770 elif algoType == FULL_NETGEN:
3772 print "Warning: NETGENPlugin module has not been imported."
3773 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3776 elif algoType == GHS3D:
3778 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
3781 self.algoType = algoType
3783 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
3784 # @param vol for the maximum volume of each tetrahedron
3785 # @param UseExisting if ==true - searches for the existing hypothesis created with
3786 # the same parameters, else (default) - creates a new one
3787 # @ingroup l3_hypos_maxvol
3788 def MaxElementVolume(self, vol, UseExisting=0):
3789 if self.algoType == NETGEN:
3790 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
3791 CompareMethod=self.CompareMaxElementVolume)
3792 hyp.SetMaxElementVolume(vol)
3794 elif self.algoType == FULL_NETGEN:
3795 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
3798 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
3799 def CompareMaxElementVolume(self, hyp, args):
3800 return IsEqual(hyp.GetMaxElementVolume(), args[0])
3802 ## Defines hypothesis having several parameters
3804 # @ingroup l3_hypos_netgen
3805 def Parameters(self, which=SOLE):
3808 if self.algoType == FULL_NETGEN:
3810 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
3811 "libNETGENEngine.so", UseExisting=0)
3813 self.params = self.Hypothesis("NETGEN_Parameters", [],
3814 "libNETGENEngine.so", UseExisting=0)
3816 if self.algoType == GHS3D:
3817 self.params = self.Hypothesis("GHS3D_Parameters", [],
3818 "libGHS3DEngine.so", UseExisting=0)
3821 print "Algo supports no multi-parameter hypothesis"
3825 # Parameter of FULL_NETGEN
3826 # @ingroup l3_hypos_netgen
3827 def SetMaxSize(self, theSize):
3828 self.Parameters().SetMaxSize(theSize)
3830 ## Sets SecondOrder flag
3831 # Parameter of FULL_NETGEN
3832 # @ingroup l3_hypos_netgen
3833 def SetSecondOrder(self, theVal):
3834 self.Parameters().SetSecondOrder(theVal)
3836 ## Sets Optimize flag
3837 # Parameter of FULL_NETGEN
3838 # @ingroup l3_hypos_netgen
3839 def SetOptimize(self, theVal):
3840 self.Parameters().SetOptimize(theVal)
3843 # @param theFineness is:
3844 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3845 # Parameter of FULL_NETGEN
3846 # @ingroup l3_hypos_netgen
3847 def SetFineness(self, theFineness):
3848 self.Parameters().SetFineness(theFineness)
3851 # Parameter of FULL_NETGEN
3852 # @ingroup l3_hypos_netgen
3853 def SetGrowthRate(self, theRate):
3854 self.Parameters().SetGrowthRate(theRate)
3856 ## Sets NbSegPerEdge
3857 # Parameter of FULL_NETGEN
3858 # @ingroup l3_hypos_netgen
3859 def SetNbSegPerEdge(self, theVal):
3860 self.Parameters().SetNbSegPerEdge(theVal)
3862 ## Sets NbSegPerRadius
3863 # Parameter of FULL_NETGEN
3864 # @ingroup l3_hypos_netgen
3865 def SetNbSegPerRadius(self, theVal):
3866 self.Parameters().SetNbSegPerRadius(theVal)
3868 ## Sets number of segments overriding value set by SetLocalLength()
3869 # Only for algoType == NETGEN_FULL
3870 # @ingroup l3_hypos_netgen
3871 def SetNumberOfSegments(self, theVal):
3872 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3874 ## Sets number of segments overriding value set by SetNumberOfSegments()
3875 # Only for algoType == NETGEN_FULL
3876 # @ingroup l3_hypos_netgen
3877 def SetLocalLength(self, theVal):
3878 self.Parameters(SIMPLE).SetLocalLength(theVal)
3880 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
3881 # Overrides value set by LengthFromEdges()
3882 # Only for algoType == NETGEN_FULL
3883 # @ingroup l3_hypos_netgen
3884 def MaxElementArea(self, area):
3885 self.Parameters(SIMPLE).SetMaxElementArea(area)
3887 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
3888 # Overrides value set by MaxElementArea()
3889 # Only for algoType == NETGEN_FULL
3890 # @ingroup l3_hypos_netgen
3891 def LengthFromEdges(self):
3892 self.Parameters(SIMPLE).LengthFromEdges()
3894 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
3895 # Overrides value set by MaxElementVolume()
3896 # Only for algoType == NETGEN_FULL
3897 # @ingroup l3_hypos_netgen
3898 def LengthFromFaces(self):
3899 self.Parameters(SIMPLE).LengthFromFaces()
3901 ## To mesh "holes" in a solid or not. Default is to mesh.
3902 # @ingroup l3_hypos_ghs3dh
3903 def SetToMeshHoles(self, toMesh):
3904 # Parameter of GHS3D
3905 self.Parameters().SetToMeshHoles(toMesh)
3907 ## Set Optimization level:
3908 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
3909 # Default is Medium_Optimization
3910 # @ingroup l3_hypos_ghs3dh
3911 def SetOptimizationLevel(self, level):
3912 # Parameter of GHS3D
3913 self.Parameters().SetOptimizationLevel(level)
3915 ## Maximal size of memory to be used by the algorithm (in Megabytes).
3916 # @ingroup l3_hypos_ghs3dh
3917 def SetMaximumMemory(self, MB):
3918 # Advanced parameter of GHS3D
3919 self.Parameters().SetMaximumMemory(MB)
3921 ## Initial size of memory to be used by the algorithm (in Megabytes) in
3922 # automatic memory adjustment mode.
3923 # @ingroup l3_hypos_ghs3dh
3924 def SetInitialMemory(self, MB):
3925 # Advanced parameter of GHS3D
3926 self.Parameters().SetInitialMemory(MB)
3928 ## Path to working directory.
3929 # @ingroup l3_hypos_ghs3dh
3930 def SetWorkingDirectory(self, path):
3931 # Advanced parameter of GHS3D
3932 self.Parameters().SetWorkingDirectory(path)
3934 ## To keep working files or remove them. Log file remains in case of errors anyway.
3935 # @ingroup l3_hypos_ghs3dh
3936 def SetKeepFiles(self, toKeep):
3937 # Advanced parameter of GHS3D
3938 self.Parameters().SetKeepFiles(toKeep)
3940 ## To set verbose level [0-10]. <ul>
3941 #<li> 0 - no standard output,
3942 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
3943 # indicates when the final mesh is being saved. In addition the software
3944 # gives indication regarding the CPU time.
3945 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
3946 # histogram of the skin mesh, quality statistics histogram together with
3947 # the characteristics of the final mesh.</ul>
3948 # @ingroup l3_hypos_ghs3dh
3949 def SetVerboseLevel(self, level):
3950 # Advanced parameter of GHS3D
3951 self.Parameters().SetVerboseLevel(level)
3953 ## To create new nodes.
3954 # @ingroup l3_hypos_ghs3dh
3955 def SetToCreateNewNodes(self, toCreate):
3956 # Advanced parameter of GHS3D
3957 self.Parameters().SetToCreateNewNodes(toCreate)
3959 ## To use boundary recovery version which tries to create mesh on a very poor
3960 # quality surface mesh.
3961 # @ingroup l3_hypos_ghs3dh
3962 def SetToUseBoundaryRecoveryVersion(self, toUse):
3963 # Advanced parameter of GHS3D
3964 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
3966 ## Sets command line option as text.
3967 # @ingroup l3_hypos_ghs3dh
3968 def SetTextOption(self, option):
3969 # Advanced parameter of GHS3D
3970 self.Parameters().SetTextOption(option)
3972 # Public class: Mesh_Hexahedron
3973 # ------------------------------
3975 ## Defines a hexahedron 3D algorithm
3977 # @ingroup l3_algos_basic
3978 class Mesh_Hexahedron(Mesh_Algorithm):
3983 ## Private constructor.
3984 def __init__(self, mesh, algoType=Hexa, geom=0):
3985 Mesh_Algorithm.__init__(self)
3987 self.algoType = algoType
3989 if algoType == Hexa:
3990 self.Create(mesh, geom, "Hexa_3D")
3993 elif algoType == Hexotic:
3994 import HexoticPlugin
3995 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
3998 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
3999 # @ingroup l3_hypos_hexotic
4000 def MinMaxQuad(self, min=3, max=8, quad=True):
4001 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4003 self.params.SetHexesMinLevel(min)
4004 self.params.SetHexesMaxLevel(max)
4005 self.params.SetHexoticQuadrangles(quad)
4008 # Deprecated, only for compatibility!
4009 # Public class: Mesh_Netgen
4010 # ------------------------------
4012 ## Defines a NETGEN-based 2D or 3D algorithm
4013 # that needs no discrete boundary (i.e. independent)
4015 # This class is deprecated, only for compatibility!
4018 # @ingroup l3_algos_basic
4019 class Mesh_Netgen(Mesh_Algorithm):
4023 ## Private constructor.
4024 def __init__(self, mesh, is3D, geom=0):
4025 Mesh_Algorithm.__init__(self)
4028 print "Warning: NETGENPlugin module has not been imported."
4032 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4036 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4039 ## Defines the hypothesis containing parameters of the algorithm
4040 def Parameters(self):
4042 hyp = self.Hypothesis("NETGEN_Parameters", [],
4043 "libNETGENEngine.so", UseExisting=0)
4045 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4046 "libNETGENEngine.so", UseExisting=0)
4049 # Public class: Mesh_Projection1D
4050 # ------------------------------
4052 ## Defines a projection 1D algorithm
4053 # @ingroup l3_algos_proj
4055 class Mesh_Projection1D(Mesh_Algorithm):
4057 ## Private constructor.
4058 def __init__(self, mesh, geom=0):
4059 Mesh_Algorithm.__init__(self)
4060 self.Create(mesh, geom, "Projection_1D")
4062 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4063 # a mesh pattern is taken, and, optionally, the association of vertices
4064 # between the source edge and a target edge (to which a hypothesis is assigned)
4065 # @param edge from which nodes distribution is taken
4066 # @param mesh from which nodes distribution is taken (optional)
4067 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4068 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4069 # to associate with \a srcV (optional)
4070 # @param UseExisting if ==true - searches for the existing hypothesis created with
4071 # the same parameters, else (default) - creates a new one
4072 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4073 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4075 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4076 hyp.SetSourceEdge( edge )
4077 if not mesh is None and isinstance(mesh, Mesh):
4078 mesh = mesh.GetMesh()
4079 hyp.SetSourceMesh( mesh )
4080 hyp.SetVertexAssociation( srcV, tgtV )
4083 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4084 #def CompareSourceEdge(self, hyp, args):
4085 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4089 # Public class: Mesh_Projection2D
4090 # ------------------------------
4092 ## Defines a projection 2D algorithm
4093 # @ingroup l3_algos_proj
4095 class Mesh_Projection2D(Mesh_Algorithm):
4097 ## Private constructor.
4098 def __init__(self, mesh, geom=0):
4099 Mesh_Algorithm.__init__(self)
4100 self.Create(mesh, geom, "Projection_2D")
4102 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4103 # a mesh pattern is taken, and, optionally, the association of vertices
4104 # between the source face and the target face (to which a hypothesis is assigned)
4105 # @param face from which the mesh pattern is taken
4106 # @param mesh from which the mesh pattern is taken (optional)
4107 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4108 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4109 # to associate with \a srcV1 (optional)
4110 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4111 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4112 # to associate with \a srcV2 (optional)
4113 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4114 # the same parameters, else (default) - forces the creation a new one
4116 # Note: all association vertices must belong to one edge of a face
4117 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4118 srcV2=None, tgtV2=None, UseExisting=0):
4119 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4121 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4122 hyp.SetSourceFace( face )
4123 if not mesh is None and isinstance(mesh, Mesh):
4124 mesh = mesh.GetMesh()
4125 hyp.SetSourceMesh( mesh )
4126 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4129 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4130 #def CompareSourceFace(self, hyp, args):
4131 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4134 # Public class: Mesh_Projection3D
4135 # ------------------------------
4137 ## Defines a projection 3D algorithm
4138 # @ingroup l3_algos_proj
4140 class Mesh_Projection3D(Mesh_Algorithm):
4142 ## Private constructor.
4143 def __init__(self, mesh, geom=0):
4144 Mesh_Algorithm.__init__(self)
4145 self.Create(mesh, geom, "Projection_3D")
4147 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4148 # the mesh pattern is taken, and, optionally, the association of vertices
4149 # between the source and the target solid (to which a hipothesis is assigned)
4150 # @param solid from where the mesh pattern is taken
4151 # @param mesh from where the mesh pattern is taken (optional)
4152 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4153 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4154 # to associate with \a srcV1 (optional)
4155 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4156 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4157 # to associate with \a srcV2 (optional)
4158 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4159 # the same parameters, else (default) - creates a new one
4161 # Note: association vertices must belong to one edge of a solid
4162 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4163 srcV2=0, tgtV2=0, UseExisting=0):
4164 hyp = self.Hypothesis("ProjectionSource3D",
4165 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4167 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4168 hyp.SetSource3DShape( solid )
4169 if not mesh is None and isinstance(mesh, Mesh):
4170 mesh = mesh.GetMesh()
4171 hyp.SetSourceMesh( mesh )
4172 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4175 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4176 #def CompareSourceShape3D(self, hyp, args):
4177 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4181 # Public class: Mesh_Prism
4182 # ------------------------
4184 ## Defines a 3D extrusion algorithm
4185 # @ingroup l3_algos_3dextr
4187 class Mesh_Prism3D(Mesh_Algorithm):
4189 ## Private constructor.
4190 def __init__(self, mesh, geom=0):
4191 Mesh_Algorithm.__init__(self)
4192 self.Create(mesh, geom, "Prism_3D")
4194 # Public class: Mesh_RadialPrism
4195 # -------------------------------
4197 ## Defines a Radial Prism 3D algorithm
4198 # @ingroup l3_algos_radialp
4200 class Mesh_RadialPrism3D(Mesh_Algorithm):
4202 ## Private constructor.
4203 def __init__(self, mesh, geom=0):
4204 Mesh_Algorithm.__init__(self)
4205 self.Create(mesh, geom, "RadialPrism_3D")
4207 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4208 self.nbLayers = None
4210 ## Return 3D hypothesis holding the 1D one
4211 def Get3DHypothesis(self):
4212 return self.distribHyp
4214 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4215 # hypothesis. Returns the created hypothesis
4216 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4217 #print "OwnHypothesis",hypType
4218 if not self.nbLayers is None:
4219 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4220 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4221 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4222 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4223 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4224 self.distribHyp.SetLayerDistribution( hyp )
4227 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4228 # prisms to build between the inner and outer shells
4229 # @param n number of layers
4230 # @param UseExisting if ==true - searches for the existing hypothesis created with
4231 # the same parameters, else (default) - creates a new one
4232 def NumberOfLayers(self, n, UseExisting=0):
4233 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4234 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4235 CompareMethod=self.CompareNumberOfLayers)
4236 self.nbLayers.SetNumberOfLayers( n )
4237 return self.nbLayers
4239 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4240 def CompareNumberOfLayers(self, hyp, args):
4241 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4243 ## Defines "LocalLength" hypothesis, specifying the segment length
4244 # to build between the inner and the outer shells
4245 # @param l the length of segments
4246 # @param p the precision of rounding
4247 def LocalLength(self, l, p=1e-07):
4248 hyp = self.OwnHypothesis("LocalLength", [l,p])
4253 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4254 # prisms to build between the inner and the outer shells.
4255 # @param n the number of layers
4256 # @param s the scale factor (optional)
4257 def NumberOfSegments(self, n, s=[]):
4259 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4261 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4262 hyp.SetDistrType( 1 )
4263 hyp.SetScaleFactor(s)
4264 hyp.SetNumberOfSegments(n)
4267 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4268 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4269 # @param start the length of the first segment
4270 # @param end the length of the last segment
4271 def Arithmetic1D(self, start, end ):
4272 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4273 hyp.SetLength(start, 1)
4274 hyp.SetLength(end , 0)
4277 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4278 # to build between the inner and the outer shells as geometric length increasing
4279 # @param start for the length of the first segment
4280 # @param end for the length of the last segment
4281 def StartEndLength(self, start, end):
4282 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4283 hyp.SetLength(start, 1)
4284 hyp.SetLength(end , 0)
4287 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4288 # to build between the inner and outer shells
4289 # @param fineness defines the quality of the mesh within the range [0-1]
4290 def AutomaticLength(self, fineness=0):
4291 hyp = self.OwnHypothesis("AutomaticLength")
4292 hyp.SetFineness( fineness )
4295 # Private class: Mesh_UseExisting
4296 # -------------------------------
4297 class Mesh_UseExisting(Mesh_Algorithm):
4299 def __init__(self, dim, mesh, geom=0):
4301 self.Create(mesh, geom, "UseExisting_1D")
4303 self.Create(mesh, geom, "UseExisting_2D")
4306 import salome_notebook
4307 notebook = salome_notebook.notebook
4309 ##Return values of the notebook variables
4310 def ParseParameters(last, nbParams,nbParam, value):
4314 listSize = len(last)
4315 for n in range(0,nbParams):
4317 if counter < listSize:
4318 strResult = strResult + last[counter]
4320 strResult = strResult + ""
4322 if isinstance(value, str):
4323 if notebook.isVariable(value):
4324 result = notebook.get(value)
4325 strResult=strResult+value
4327 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
4329 strResult=strResult+str(value)
4331 if nbParams - 1 != counter:
4332 strResult=strResult+variable_separator #":"
4334 return result, strResult
4336 #Wrapper class for StdMeshers_LocalLength hypothesis
4337 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
4339 ## Set Length parameter value
4340 # @param length numerical value or name of variable from notebook
4341 def SetLength(self, length):
4342 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
4343 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4344 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
4346 ## Set Precision parameter value
4347 # @param precision numerical value or name of variable from notebook
4348 def SetPrecision(self, precision):
4349 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
4350 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4351 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
4353 #Registering the new proxy for LocalLength
4354 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
4357 #Wrapper class for StdMeshers_LayerDistribution hypothesis
4358 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
4360 def SetLayerDistribution(self, hypo):
4361 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
4362 hypo.ClearParameters();
4363 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
4365 #Registering the new proxy for LayerDistribution
4366 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
4368 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
4369 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
4371 ## Set Length parameter value
4372 # @param length numerical value or name of variable from notebook
4373 def SetLength(self, length):
4374 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
4375 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
4376 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
4378 #Registering the new proxy for SegmentLengthAroundVertex
4379 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
4382 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
4383 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
4385 ## Set Length parameter value
4386 # @param length numerical value or name of variable from notebook
4387 # @param isStart true is length is Start Length, otherwise false
4388 def SetLength(self, length, isStart):
4392 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
4393 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
4394 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
4396 #Registering the new proxy for Arithmetic1D
4397 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
4399 #Wrapper class for StdMeshers_Deflection1D hypothesis
4400 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
4402 ## Set Deflection parameter value
4403 # @param deflection numerical value or name of variable from notebook
4404 def SetDeflection(self, deflection):
4405 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
4406 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
4407 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
4409 #Registering the new proxy for Deflection1D
4410 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
4412 #Wrapper class for StdMeshers_StartEndLength hypothesis
4413 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
4415 ## Set Length parameter value
4416 # @param length numerical value or name of variable from notebook
4417 # @param isStart true is length is Start Length, otherwise false
4418 def SetLength(self, length, isStart):
4422 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
4423 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
4424 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
4426 #Registering the new proxy for StartEndLength
4427 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
4429 #Wrapper class for StdMeshers_MaxElementArea hypothesis
4430 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
4432 ## Set Max Element Area parameter value
4433 # @param area numerical value or name of variable from notebook
4434 def SetMaxElementArea(self, area):
4435 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
4436 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
4437 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
4439 #Registering the new proxy for MaxElementArea
4440 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
4443 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
4444 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
4446 ## Set Max Element Volume parameter value
4447 # @param area numerical value or name of variable from notebook
4448 def SetMaxElementVolume(self, volume):
4449 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
4450 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
4451 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
4453 #Registering the new proxy for MaxElementVolume
4454 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
4457 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
4458 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
4460 ## Set Number Of Layers parameter value
4461 # @param nbLayers numerical value or name of variable from notebook
4462 def SetNumberOfLayers(self, nbLayers):
4463 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
4464 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
4465 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
4467 #Registering the new proxy for NumberOfLayers
4468 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
4470 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
4471 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
4473 ## Set Number Of Segments parameter value
4474 # @param nbSeg numerical value or name of variable from notebook
4475 def SetNumberOfSegments(self, nbSeg):
4476 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
4477 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
4478 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4479 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
4481 ## Set Scale Factor parameter value
4482 # @param factor numerical value or name of variable from notebook
4483 def SetScaleFactor(self, factor):
4484 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
4485 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4486 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
4488 #Registering the new proxy for NumberOfSegments
4489 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
4492 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
4493 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
4495 ## Set Max Size parameter value
4496 # @param maxsize numerical value or name of variable from notebook
4497 def SetMaxSize(self, maxsize):
4498 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4499 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
4500 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4501 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
4503 ## Set Growth Rate parameter value
4504 # @param value numerical value or name of variable from notebook
4505 def SetGrowthRate(self, value):
4506 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4507 value, parameters = ParseParameters(lastParameters,4,2,value)
4508 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4509 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
4511 ## Set Number of Segments per Edge parameter value
4512 # @param value numerical value or name of variable from notebook
4513 def SetNbSegPerEdge(self, value):
4514 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4515 value, parameters = ParseParameters(lastParameters,4,3,value)
4516 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4517 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
4519 ## Set Number of Segments per Radius parameter value
4520 # @param value numerical value or name of variable from notebook
4521 def SetNbSegPerRadius(self, value):
4522 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4523 value, parameters = ParseParameters(lastParameters,4,4,value)
4524 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4525 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
4527 #Registering the new proxy for NETGENPlugin_Hypothesis
4528 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
4531 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
4532 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
4535 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
4536 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
4538 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
4539 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
4541 ## Set Number of Segments parameter value
4542 # @param nbSeg numerical value or name of variable from notebook
4543 def SetNumberOfSegments(self, nbSeg):
4544 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4545 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
4546 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4547 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
4549 ## Set Local Length parameter value
4550 # @param length numerical value or name of variable from notebook
4551 def SetLocalLength(self, length):
4552 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4553 length, parameters = ParseParameters(lastParameters,2,1,length)
4554 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4555 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
4557 ## Set Max Element Area parameter value
4558 # @param area numerical value or name of variable from notebook
4559 def SetMaxElementArea(self, area):
4560 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4561 area, parameters = ParseParameters(lastParameters,2,2,area)
4562 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4563 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
4565 def LengthFromEdges(self):
4566 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4568 value, parameters = ParseParameters(lastParameters,2,2,value)
4569 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4570 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
4572 #Registering the new proxy for NETGEN_SimpleParameters_2D
4573 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
4576 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
4577 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
4578 ## Set Max Element Volume parameter value
4579 # @param volume numerical value or name of variable from notebook
4580 def SetMaxElementVolume(self, volume):
4581 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
4582 volume, parameters = ParseParameters(lastParameters,3,3,volume)
4583 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
4584 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
4586 def LengthFromFaces(self):
4587 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
4589 value, parameters = ParseParameters(lastParameters,3,3,value)
4590 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
4591 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
4593 #Registering the new proxy for NETGEN_SimpleParameters_3D
4594 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
4596 class Pattern(SMESH._objref_SMESH_Pattern):
4598 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
4600 if isinstance(theNodeIndexOnKeyPoint1,str):
4602 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
4604 theNodeIndexOnKeyPoint1 -= 1
4605 theMesh.SetParameters(Parameters)
4606 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
4608 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
4611 if isinstance(theNode000Index,str):
4613 if isinstance(theNode001Index,str):
4615 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
4617 theNode000Index -= 1
4619 theNode001Index -= 1
4620 theMesh.SetParameters(Parameters)
4621 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
4623 #Registering the new proxy for Pattern
4624 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)