1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 # Author : Francis KLOSS, OCC
31 ## @defgroup l1_auxiliary Auxiliary methods and structures
32 ## @defgroup l1_creating Creating meshes
34 ## @defgroup l2_impexp Importing and exporting meshes
35 ## @defgroup l2_construct Constructing meshes
36 ## @defgroup l2_algorithms Defining Algorithms
38 ## @defgroup l3_algos_basic Basic meshing algorithms
39 ## @defgroup l3_algos_proj Projection Algorithms
40 ## @defgroup l3_algos_radialp Radial Prism
41 ## @defgroup l3_algos_segmarv Segments around Vertex
42 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
45 ## @defgroup l2_hypotheses Defining hypotheses
47 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
48 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
49 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
50 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
51 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
52 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
53 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
54 ## @defgroup l3_hypos_additi Additional Hypotheses
57 ## @defgroup l2_submeshes Constructing submeshes
58 ## @defgroup l2_compounds Building Compounds
59 ## @defgroup l2_editing Editing Meshes
62 ## @defgroup l1_meshinfo Mesh Information
63 ## @defgroup l1_controls Quality controls and Filtering
64 ## @defgroup l1_grouping Grouping elements
66 ## @defgroup l2_grps_create Creating groups
67 ## @defgroup l2_grps_edit Editing groups
68 ## @defgroup l2_grps_operon Using operations on groups
69 ## @defgroup l2_grps_delete Deleting Groups
72 ## @defgroup l1_modifying Modifying meshes
74 ## @defgroup l2_modif_add Adding nodes and elements
75 ## @defgroup l2_modif_del Removing nodes and elements
76 ## @defgroup l2_modif_edit Modifying nodes and elements
77 ## @defgroup l2_modif_renumber Renumbering nodes and elements
78 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
79 ## @defgroup l2_modif_movenode Moving nodes
80 ## @defgroup l2_modif_throughp Mesh through point
81 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
82 ## @defgroup l2_modif_unitetri Uniting triangles
83 ## @defgroup l2_modif_changori Changing orientation of elements
84 ## @defgroup l2_modif_cutquadr Cutting quadrangles
85 ## @defgroup l2_modif_smooth Smoothing
86 ## @defgroup l2_modif_extrurev Extrusion and Revolution
87 ## @defgroup l2_modif_patterns Pattern mapping
88 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
95 import SMESH # This is necessary for back compatibility
102 # import NETGENPlugin module if possible
110 ## @addtogroup l1_auxiliary
113 # Types of algorithms
126 NETGEN_1D2D3D = FULL_NETGEN
127 NETGEN_FULL = FULL_NETGEN
133 # MirrorType enumeration
134 POINT = SMESH_MeshEditor.POINT
135 AXIS = SMESH_MeshEditor.AXIS
136 PLANE = SMESH_MeshEditor.PLANE
138 # Smooth_Method enumeration
139 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
140 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
142 # Fineness enumeration (for NETGEN)
150 # Optimization level of GHS3D
151 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
153 # Topology treatment way of BLSURF
154 FromCAD, PreProcess, PreProcessPlus = 0,1,2
156 # Element size flag of BLSURF
157 DefaultSize, DefaultGeom, Custom = 0,0,1
159 PrecisionConfusion = 1e-07
161 ## Converts an angle from degrees to radians
162 def DegreesToRadians(AngleInDegrees):
164 return AngleInDegrees * pi / 180.0
166 # Salome notebook variable separator
169 # Parametrized substitute for PointStruct
170 class PointStructStr:
179 def __init__(self, xStr, yStr, zStr):
183 if isinstance(xStr, str) and notebook.isVariable(xStr):
184 self.x = notebook.get(xStr)
187 if isinstance(yStr, str) and notebook.isVariable(yStr):
188 self.y = notebook.get(yStr)
191 if isinstance(zStr, str) and notebook.isVariable(zStr):
192 self.z = notebook.get(zStr)
196 # Parametrized substitute for PointStruct (with 6 parameters)
197 class PointStructStr6:
212 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
219 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
220 self.x1 = notebook.get(x1Str)
223 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
224 self.x2 = notebook.get(x2Str)
227 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
228 self.y1 = notebook.get(y1Str)
231 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
232 self.y2 = notebook.get(y2Str)
235 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
236 self.z1 = notebook.get(z1Str)
239 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
240 self.z2 = notebook.get(z2Str)
244 # Parametrized substitute for AxisStruct
260 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
267 if isinstance(xStr, str) and notebook.isVariable(xStr):
268 self.x = notebook.get(xStr)
271 if isinstance(yStr, str) and notebook.isVariable(yStr):
272 self.y = notebook.get(yStr)
275 if isinstance(zStr, str) and notebook.isVariable(zStr):
276 self.z = notebook.get(zStr)
279 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
280 self.dx = notebook.get(dxStr)
283 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
284 self.dy = notebook.get(dyStr)
287 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
288 self.dz = notebook.get(dzStr)
292 # Parametrized substitute for DirStruct
295 def __init__(self, pointStruct):
296 self.pointStruct = pointStruct
298 # Returns list of variable values from salome notebook
299 def ParsePointStruct(Point):
300 Parameters = 2*var_separator
301 if isinstance(Point, PointStructStr):
302 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
303 Point = PointStruct(Point.x, Point.y, Point.z)
304 return Point, Parameters
306 # Returns list of variable values from salome notebook
307 def ParseDirStruct(Dir):
308 Parameters = 2*var_separator
309 if isinstance(Dir, DirStructStr):
310 pntStr = Dir.pointStruct
311 if isinstance(pntStr, PointStructStr6):
312 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
313 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
314 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
315 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
317 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
318 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
319 Dir = DirStruct(Point)
320 return Dir, Parameters
322 # Returns list of variable values from salome notebook
323 def ParseAxisStruct(Axis):
324 Parameters = 5*var_separator
325 if isinstance(Axis, AxisStructStr):
326 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
327 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
328 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
329 return Axis, Parameters
331 ## Return list of variable values from salome notebook
332 def ParseAngles(list):
335 for parameter in list:
336 if isinstance(parameter,str) and notebook.isVariable(parameter):
337 Result.append(DegreesToRadians(notebook.get(parameter)))
340 Result.append(parameter)
343 Parameters = Parameters + str(parameter)
344 Parameters = Parameters + var_separator
346 Parameters = Parameters[:len(Parameters)-1]
347 return Result, Parameters
349 def IsEqual(val1, val2, tol=PrecisionConfusion):
350 if abs(val1 - val2) < tol:
358 ior = salome.orb.object_to_string(obj)
359 sobj = salome.myStudy.FindObjectIOR(ior)
363 attr = sobj.FindAttribute("AttributeName")[1]
366 ## Prints error message if a hypothesis was not assigned.
367 def TreatHypoStatus(status, hypName, geomName, isAlgo):
369 hypType = "algorithm"
371 hypType = "hypothesis"
373 if status == HYP_UNKNOWN_FATAL :
374 reason = "for unknown reason"
375 elif status == HYP_INCOMPATIBLE :
376 reason = "this hypothesis mismatches the algorithm"
377 elif status == HYP_NOTCONFORM :
378 reason = "a non-conform mesh would be built"
379 elif status == HYP_ALREADY_EXIST :
380 reason = hypType + " of the same dimension is already assigned to this shape"
381 elif status == HYP_BAD_DIM :
382 reason = hypType + " mismatches the shape"
383 elif status == HYP_CONCURENT :
384 reason = "there are concurrent hypotheses on sub-shapes"
385 elif status == HYP_BAD_SUBSHAPE :
386 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
387 elif status == HYP_BAD_GEOMETRY:
388 reason = "geometry mismatches the expectation of the algorithm"
389 elif status == HYP_HIDDEN_ALGO:
390 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
391 elif status == HYP_HIDING_ALGO:
392 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
393 elif status == HYP_NEED_SHAPE:
394 reason = "Algorithm can't work without shape"
397 hypName = '"' + hypName + '"'
398 geomName= '"' + geomName+ '"'
399 if status < HYP_UNKNOWN_FATAL:
400 print hypName, "was assigned to", geomName,"but", reason
402 print hypName, "was not assigned to",geomName,":", reason
405 # end of l1_auxiliary
408 # All methods of this class are accessible directly from the smesh.py package.
409 class smeshDC(SMESH._objref_SMESH_Gen):
411 ## Sets the current study and Geometry component
412 # @ingroup l1_auxiliary
413 def init_smesh(self,theStudy,geompyD):
414 self.SetCurrentStudy(theStudy,geompyD)
416 ## Creates an empty Mesh. This mesh can have an underlying geometry.
417 # @param obj the Geometrical object on which the mesh is built. If not defined,
418 # the mesh will have no underlying geometry.
419 # @param name the name for the new mesh.
420 # @return an instance of Mesh class.
421 # @ingroup l2_construct
422 def Mesh(self, obj=0, name=0):
423 return Mesh(self,self.geompyD,obj,name)
425 ## Returns a long value from enumeration
426 # Should be used for SMESH.FunctorType enumeration
427 # @ingroup l1_controls
428 def EnumToLong(self,theItem):
431 ## Gets PointStruct from vertex
432 # @param theVertex a GEOM object(vertex)
433 # @return SMESH.PointStruct
434 # @ingroup l1_auxiliary
435 def GetPointStruct(self,theVertex):
436 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
437 return PointStruct(x,y,z)
439 ## Gets DirStruct from vector
440 # @param theVector a GEOM object(vector)
441 # @return SMESH.DirStruct
442 # @ingroup l1_auxiliary
443 def GetDirStruct(self,theVector):
444 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
445 if(len(vertices) != 2):
446 print "Error: vector object is incorrect."
448 p1 = self.geompyD.PointCoordinates(vertices[0])
449 p2 = self.geompyD.PointCoordinates(vertices[1])
450 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
451 dirst = DirStruct(pnt)
454 ## Makes DirStruct from a triplet
455 # @param x,y,z vector components
456 # @return SMESH.DirStruct
457 # @ingroup l1_auxiliary
458 def MakeDirStruct(self,x,y,z):
459 pnt = PointStruct(x,y,z)
460 return DirStruct(pnt)
462 ## Get AxisStruct from object
463 # @param theObj a GEOM object (line or plane)
464 # @return SMESH.AxisStruct
465 # @ingroup l1_auxiliary
466 def GetAxisStruct(self,theObj):
467 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
469 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
470 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
471 vertex1 = self.geompyD.PointCoordinates(vertex1)
472 vertex2 = self.geompyD.PointCoordinates(vertex2)
473 vertex3 = self.geompyD.PointCoordinates(vertex3)
474 vertex4 = self.geompyD.PointCoordinates(vertex4)
475 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
476 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
477 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] ]
478 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
480 elif len(edges) == 1:
481 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
482 p1 = self.geompyD.PointCoordinates( vertex1 )
483 p2 = self.geompyD.PointCoordinates( vertex2 )
484 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
488 # From SMESH_Gen interface:
489 # ------------------------
491 ## Sets the given name to the object
492 # @param obj the object to rename
493 # @param name a new object name
494 # @ingroup l1_auxiliary
495 def SetName(self, obj, name):
496 if isinstance( obj, Mesh ):
498 elif isinstance( obj, Mesh_Algorithm ):
499 obj = obj.GetAlgorithm()
500 ior = salome.orb.object_to_string(obj)
501 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
503 ## Sets the current mode
504 # @ingroup l1_auxiliary
505 def SetEmbeddedMode( self,theMode ):
506 #self.SetEmbeddedMode(theMode)
507 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
509 ## Gets the current mode
510 # @ingroup l1_auxiliary
511 def IsEmbeddedMode(self):
512 #return self.IsEmbeddedMode()
513 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
515 ## Sets the current study
516 # @ingroup l1_auxiliary
517 def SetCurrentStudy( self, theStudy, geompyD = None ):
518 #self.SetCurrentStudy(theStudy)
521 geompyD = geompy.geom
524 self.SetGeomEngine(geompyD)
525 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
527 ## Gets the current study
528 # @ingroup l1_auxiliary
529 def GetCurrentStudy(self):
530 #return self.GetCurrentStudy()
531 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
533 ## Creates a Mesh object importing data from the given UNV file
534 # @return an instance of Mesh class
536 def CreateMeshesFromUNV( self,theFileName ):
537 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
538 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
541 ## Creates a Mesh object(s) importing data from the given MED file
542 # @return a list of Mesh class instances
544 def CreateMeshesFromMED( self,theFileName ):
545 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
547 for iMesh in range(len(aSmeshMeshes)) :
548 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
549 aMeshes.append(aMesh)
550 return aMeshes, aStatus
552 ## Creates a Mesh object importing data from the given STL file
553 # @return an instance of Mesh class
555 def CreateMeshesFromSTL( self, theFileName ):
556 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
557 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
560 ## From SMESH_Gen interface
561 # @return the list of integer values
562 # @ingroup l1_auxiliary
563 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
564 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
566 ## From SMESH_Gen interface. Creates a pattern
567 # @return an instance of SMESH_Pattern
569 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
570 # @ingroup l2_modif_patterns
571 def GetPattern(self):
572 return SMESH._objref_SMESH_Gen.GetPattern(self)
574 ## Sets number of segments per diagonal of boundary box of geometry by which
575 # default segment length of appropriate 1D hypotheses is defined.
576 # Default value is 10
577 # @ingroup l1_auxiliary
578 def SetBoundaryBoxSegmentation(self, nbSegments):
579 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
581 ## Concatenate the given meshes into one mesh.
582 # @return an instance of Mesh class
583 # @param meshes the meshes to combine into one mesh
584 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
585 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
586 # @param mergeTolerance tolerance for merging nodes
587 # @param allGroups forces creation of groups of all elements
588 def Concatenate( self, meshes, uniteIdenticalGroups,
589 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
590 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
592 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
593 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
595 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
596 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
597 aSmeshMesh.SetParameters(Parameters)
598 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
601 # Filtering. Auxiliary functions:
602 # ------------------------------
604 ## Creates an empty criterion
605 # @return SMESH.Filter.Criterion
606 # @ingroup l1_controls
607 def GetEmptyCriterion(self):
608 Type = self.EnumToLong(FT_Undefined)
609 Compare = self.EnumToLong(FT_Undefined)
613 UnaryOp = self.EnumToLong(FT_Undefined)
614 BinaryOp = self.EnumToLong(FT_Undefined)
617 Precision = -1 ##@1e-07
618 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
619 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
621 ## Creates a criterion by the given parameters
622 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
623 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
624 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
625 # @param Treshold the threshold value (range of ids as string, shape, numeric)
626 # @param UnaryOp FT_LogicalNOT or FT_Undefined
627 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
628 # FT_Undefined (must be for the last criterion of all criteria)
629 # @return SMESH.Filter.Criterion
630 # @ingroup l1_controls
631 def GetCriterion(self,elementType,
633 Compare = FT_EqualTo,
635 UnaryOp=FT_Undefined,
636 BinaryOp=FT_Undefined):
637 aCriterion = self.GetEmptyCriterion()
638 aCriterion.TypeOfElement = elementType
639 aCriterion.Type = self.EnumToLong(CritType)
643 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
644 aCriterion.Compare = self.EnumToLong(Compare)
645 elif Compare == "=" or Compare == "==":
646 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
648 aCriterion.Compare = self.EnumToLong(FT_LessThan)
650 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
652 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
655 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
656 FT_BelongToCylinder, FT_LyingOnGeom]:
657 # Checks the treshold
658 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
659 aCriterion.ThresholdStr = GetName(aTreshold)
660 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
662 print "Error: The treshold should be a shape."
664 elif CritType == FT_RangeOfIds:
665 # Checks the treshold
666 if isinstance(aTreshold, str):
667 aCriterion.ThresholdStr = aTreshold
669 print "Error: The treshold should be a string."
671 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
672 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
673 # At this point the treshold is unnecessary
674 if aTreshold == FT_LogicalNOT:
675 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
676 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
677 aCriterion.BinaryOp = aTreshold
681 aTreshold = float(aTreshold)
682 aCriterion.Threshold = aTreshold
684 print "Error: The treshold should be a number."
687 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
688 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
690 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
691 aCriterion.BinaryOp = self.EnumToLong(Treshold)
693 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
694 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
696 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
697 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
701 ## Creates a filter with the given parameters
702 # @param elementType the type of elements in the group
703 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
704 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
705 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
706 # @param UnaryOp FT_LogicalNOT or FT_Undefined
707 # @return SMESH_Filter
708 # @ingroup l1_controls
709 def GetFilter(self,elementType,
710 CritType=FT_Undefined,
713 UnaryOp=FT_Undefined):
714 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
715 aFilterMgr = self.CreateFilterManager()
716 aFilter = aFilterMgr.CreateFilter()
718 aCriteria.append(aCriterion)
719 aFilter.SetCriteria(aCriteria)
722 ## Creates a numerical functor by its type
723 # @param theCriterion FT_...; functor type
724 # @return SMESH_NumericalFunctor
725 # @ingroup l1_controls
726 def GetFunctor(self,theCriterion):
727 aFilterMgr = self.CreateFilterManager()
728 if theCriterion == FT_AspectRatio:
729 return aFilterMgr.CreateAspectRatio()
730 elif theCriterion == FT_AspectRatio3D:
731 return aFilterMgr.CreateAspectRatio3D()
732 elif theCriterion == FT_Warping:
733 return aFilterMgr.CreateWarping()
734 elif theCriterion == FT_MinimumAngle:
735 return aFilterMgr.CreateMinimumAngle()
736 elif theCriterion == FT_Taper:
737 return aFilterMgr.CreateTaper()
738 elif theCriterion == FT_Skew:
739 return aFilterMgr.CreateSkew()
740 elif theCriterion == FT_Area:
741 return aFilterMgr.CreateArea()
742 elif theCriterion == FT_Volume3D:
743 return aFilterMgr.CreateVolume3D()
744 elif theCriterion == FT_MultiConnection:
745 return aFilterMgr.CreateMultiConnection()
746 elif theCriterion == FT_MultiConnection2D:
747 return aFilterMgr.CreateMultiConnection2D()
748 elif theCriterion == FT_Length:
749 return aFilterMgr.CreateLength()
750 elif theCriterion == FT_Length2D:
751 return aFilterMgr.CreateLength2D()
753 print "Error: given parameter is not numerucal functor type."
755 ## Creates hypothesis
758 # @return created hypothesis instance
759 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
760 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
763 #Registering the new proxy for SMESH_Gen
764 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
770 ## This class allows defining and managing a mesh.
771 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
772 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
773 # new nodes and elements and by changing the existing entities), to get information
774 # about a mesh and to export a mesh into different formats.
783 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
784 # sets the GUI name of this mesh to \a name.
785 # @param smeshpyD an instance of smeshDC class
786 # @param geompyD an instance of geompyDC class
787 # @param obj Shape to be meshed or SMESH_Mesh object
788 # @param name Study name of the mesh
789 # @ingroup l2_construct
790 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
791 self.smeshpyD=smeshpyD
796 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
798 self.mesh = self.smeshpyD.CreateMesh(self.geom)
799 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
802 self.mesh = self.smeshpyD.CreateEmptyMesh()
804 self.smeshpyD.SetName(self.mesh, name)
806 self.smeshpyD.SetName(self.mesh, GetName(obj))
809 self.geom = self.mesh.GetShapeToMesh()
811 self.editor = self.mesh.GetMeshEditor()
813 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
814 # @param theMesh a SMESH_Mesh object
815 # @ingroup l2_construct
816 def SetMesh(self, theMesh):
818 self.geom = self.mesh.GetShapeToMesh()
820 ## Returns the mesh, that is an instance of SMESH_Mesh interface
821 # @return a SMESH_Mesh object
822 # @ingroup l2_construct
826 ## Gets the name of the mesh
827 # @return the name of the mesh as a string
828 # @ingroup l2_construct
830 name = GetName(self.GetMesh())
833 ## Sets a name to the mesh
834 # @param name a new name of the mesh
835 # @ingroup l2_construct
836 def SetName(self, name):
837 self.smeshpyD.SetName(self.GetMesh(), name)
839 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
840 # The subMesh object gives access to the IDs of nodes and elements.
841 # @param theSubObject a geometrical object (shape)
842 # @param theName a name for the submesh
843 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
844 # @ingroup l2_submeshes
845 def GetSubMesh(self, theSubObject, theName):
846 submesh = self.mesh.GetSubMesh(theSubObject, theName)
849 ## Returns the shape associated to the mesh
850 # @return a GEOM_Object
851 # @ingroup l2_construct
855 ## Associates the given shape to the mesh (entails the recreation of the mesh)
856 # @param geom the shape to be meshed (GEOM_Object)
857 # @ingroup l2_construct
858 def SetShape(self, geom):
859 self.mesh = self.smeshpyD.CreateMesh(geom)
861 ## Returns true if the hypotheses are defined well
862 # @param theSubObject a subshape of a mesh shape
863 # @return True or False
864 # @ingroup l2_construct
865 def IsReadyToCompute(self, theSubObject):
866 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
868 ## Returns errors of hypotheses definition.
869 # The list of errors is empty if everything is OK.
870 # @param theSubObject a subshape of a mesh shape
871 # @return a list of errors
872 # @ingroup l2_construct
873 def GetAlgoState(self, theSubObject):
874 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
876 ## Returns a geometrical object on which the given element was built.
877 # The returned geometrical object, if not nil, is either found in the
878 # study or published by this method with the given name
879 # @param theElementID the id of the mesh element
880 # @param theGeomName the user-defined name of the geometrical object
881 # @return GEOM::GEOM_Object instance
882 # @ingroup l2_construct
883 def GetGeometryByMeshElement(self, theElementID, theGeomName):
884 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
886 ## Returns the mesh dimension depending on the dimension of the underlying shape
887 # @return mesh dimension as an integer value [0,3]
888 # @ingroup l1_auxiliary
889 def MeshDimension(self):
890 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
891 if len( shells ) > 0 :
893 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
895 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
901 ## Creates a segment discretization 1D algorithm.
902 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
903 # \n If the optional \a geom parameter is not set, this algorithm is global.
904 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
905 # @param algo the type of the required algorithm. Possible values are:
907 # - smesh.PYTHON for discretization via a python function,
908 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
909 # @param geom If defined is the subshape to be meshed
910 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
911 # @ingroup l3_algos_basic
912 def Segment(self, algo=REGULAR, geom=0):
913 ## if Segment(geom) is called by mistake
914 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
915 algo, geom = geom, algo
916 if not algo: algo = REGULAR
919 return Mesh_Segment(self, geom)
921 return Mesh_Segment_Python(self, geom)
922 elif algo == COMPOSITE:
923 return Mesh_CompositeSegment(self, geom)
925 return Mesh_Segment(self, geom)
927 ## Enables creation of nodes and segments usable by 2D algoritms.
928 # The added nodes and segments must be bound to edges and vertices by
929 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
930 # If the optional \a geom parameter is not set, this algorithm is global.
931 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
932 # @param geom the subshape to be manually meshed
933 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
934 # @ingroup l3_algos_basic
935 def UseExistingSegments(self, geom=0):
936 algo = Mesh_UseExisting(1,self,geom)
937 return algo.GetAlgorithm()
939 ## Enables creation of nodes and faces usable by 3D algoritms.
940 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
941 # and SetMeshElementOnShape()
942 # If the optional \a geom parameter is not set, this algorithm is global.
943 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
944 # @param geom the subshape to be manually meshed
945 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
946 # @ingroup l3_algos_basic
947 def UseExistingFaces(self, geom=0):
948 algo = Mesh_UseExisting(2,self,geom)
949 return algo.GetAlgorithm()
951 ## Creates a triangle 2D algorithm for faces.
952 # If the optional \a geom parameter is not set, this algorithm is global.
953 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
954 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
955 # @param geom If defined, the subshape to be meshed (GEOM_Object)
956 # @return an instance of Mesh_Triangle algorithm
957 # @ingroup l3_algos_basic
958 def Triangle(self, algo=MEFISTO, geom=0):
959 ## if Triangle(geom) is called by mistake
960 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
964 return Mesh_Triangle(self, algo, geom)
966 ## Creates a quadrangle 2D algorithm for faces.
967 # If the optional \a geom parameter is not set, this algorithm is global.
968 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
969 # @param geom If defined, the subshape to be meshed (GEOM_Object)
970 # @return an instance of Mesh_Quadrangle algorithm
971 # @ingroup l3_algos_basic
972 def Quadrangle(self, geom=0):
973 return Mesh_Quadrangle(self, geom)
975 ## Creates a tetrahedron 3D algorithm for solids.
976 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
977 # If the optional \a geom parameter is not set, this algorithm is global.
978 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
979 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
980 # @param geom If defined, the subshape to be meshed (GEOM_Object)
981 # @return an instance of Mesh_Tetrahedron algorithm
982 # @ingroup l3_algos_basic
983 def Tetrahedron(self, algo=NETGEN, geom=0):
984 ## if Tetrahedron(geom) is called by mistake
985 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
986 algo, geom = geom, algo
987 if not algo: algo = NETGEN
989 return Mesh_Tetrahedron(self, algo, geom)
991 ## Creates a hexahedron 3D algorithm for solids.
992 # If the optional \a geom parameter is not set, this algorithm is global.
993 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
994 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
995 # @param geom If defined, the subshape to be meshed (GEOM_Object)
996 # @return an instance of Mesh_Hexahedron algorithm
997 # @ingroup l3_algos_basic
998 def Hexahedron(self, algo=Hexa, geom=0):
999 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1000 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1001 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1002 elif geom == 0: algo, geom = Hexa, algo
1003 return Mesh_Hexahedron(self, algo, geom)
1005 ## Deprecated, used only for compatibility!
1006 # @return an instance of Mesh_Netgen algorithm
1007 # @ingroup l3_algos_basic
1008 def Netgen(self, is3D, geom=0):
1009 return Mesh_Netgen(self, is3D, geom)
1011 ## Creates a projection 1D algorithm for edges.
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_Projection1D algorithm
1016 # @ingroup l3_algos_proj
1017 def Projection1D(self, geom=0):
1018 return Mesh_Projection1D(self, geom)
1020 ## Creates a projection 2D algorithm for faces.
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_Projection2D algorithm
1025 # @ingroup l3_algos_proj
1026 def Projection2D(self, geom=0):
1027 return Mesh_Projection2D(self, geom)
1029 ## Creates a projection 3D algorithm for solids.
1030 # If the optional \a geom parameter is not set, this algorithm is global.
1031 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1032 # @param geom If defined, the subshape to be meshed
1033 # @return an instance of Mesh_Projection3D algorithm
1034 # @ingroup l3_algos_proj
1035 def Projection3D(self, geom=0):
1036 return Mesh_Projection3D(self, geom)
1038 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1039 # If the optional \a geom parameter is not set, this algorithm is global.
1040 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1041 # @param geom If defined, the subshape to be meshed
1042 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1043 # @ingroup l3_algos_radialp l3_algos_3dextr
1044 def Prism(self, geom=0):
1048 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1049 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1050 if nbSolids == 0 or nbSolids == nbShells:
1051 return Mesh_Prism3D(self, geom)
1052 return Mesh_RadialPrism3D(self, geom)
1054 ## Evaluates size of prospective mesh on a shape
1055 # @return True or False
1056 def Evaluate(self, geom=0):
1057 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1059 geom = self.mesh.GetShapeToMesh()
1062 return self.smeshpyD.Evaluate(self.mesh, geom)
1065 ## Computes the mesh and returns the status of the computation
1066 # @return True or False
1067 # @ingroup l2_construct
1068 def Compute(self, geom=0):
1069 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1071 geom = self.mesh.GetShapeToMesh()
1076 ok = self.smeshpyD.Compute(self.mesh, geom)
1077 except SALOME.SALOME_Exception, ex:
1078 print "Mesh computation failed, exception caught:"
1079 print " ", ex.details.text
1082 print "Mesh computation failed, exception caught:"
1083 traceback.print_exc()
1085 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1088 if err.isGlobalAlgo:
1096 reason = '%s %sD algorithm is missing' % (glob, dim)
1097 elif err.state == HYP_MISSING:
1098 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1099 % (glob, dim, name, dim))
1100 elif err.state == HYP_NOTCONFORM:
1101 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1102 elif err.state == HYP_BAD_PARAMETER:
1103 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1104 % ( glob, dim, name ))
1105 elif err.state == HYP_BAD_GEOMETRY:
1106 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1107 'geometry' % ( glob, dim, name ))
1109 reason = "For unknown reason."+\
1110 " Revise Mesh.Compute() implementation in smeshDC.py!"
1112 if allReasons != "":
1115 allReasons += reason
1117 if allReasons != "":
1118 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1122 print '"' + GetName(self.mesh) + '"',"has not been computed."
1125 if salome.sg.hasDesktop():
1126 smeshgui = salome.ImportComponentGUI("SMESH")
1127 smeshgui.Init(self.mesh.GetStudyId())
1128 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1129 salome.sg.updateObjBrowser(1)
1133 ## Removes all nodes and elements
1134 # @ingroup l2_construct
1137 if salome.sg.hasDesktop():
1138 smeshgui = salome.ImportComponentGUI("SMESH")
1139 smeshgui.Init(self.mesh.GetStudyId())
1140 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1141 salome.sg.updateObjBrowser(1)
1143 ## Removes all nodes and elements of indicated shape
1144 # @ingroup l2_construct
1145 def ClearSubMesh(self, geomId):
1146 self.mesh.ClearSubMesh(geomId)
1147 if salome.sg.hasDesktop():
1148 smeshgui = salome.ImportComponentGUI("SMESH")
1149 smeshgui.Init(self.mesh.GetStudyId())
1150 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1151 salome.sg.updateObjBrowser(1)
1153 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1154 # @param fineness [0,-1] defines mesh fineness
1155 # @return True or False
1156 # @ingroup l3_algos_basic
1157 def AutomaticTetrahedralization(self, fineness=0):
1158 dim = self.MeshDimension()
1160 self.RemoveGlobalHypotheses()
1161 self.Segment().AutomaticLength(fineness)
1163 self.Triangle().LengthFromEdges()
1166 self.Tetrahedron(NETGEN)
1168 return self.Compute()
1170 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1171 # @param fineness [0,-1] defines mesh fineness
1172 # @return True or False
1173 # @ingroup l3_algos_basic
1174 def AutomaticHexahedralization(self, fineness=0):
1175 dim = self.MeshDimension()
1176 # assign the hypotheses
1177 self.RemoveGlobalHypotheses()
1178 self.Segment().AutomaticLength(fineness)
1185 return self.Compute()
1187 ## Assigns a hypothesis
1188 # @param hyp a hypothesis to assign
1189 # @param geom a subhape of mesh geometry
1190 # @return SMESH.Hypothesis_Status
1191 # @ingroup l2_hypotheses
1192 def AddHypothesis(self, hyp, geom=0):
1193 if isinstance( hyp, Mesh_Algorithm ):
1194 hyp = hyp.GetAlgorithm()
1199 geom = self.mesh.GetShapeToMesh()
1201 status = self.mesh.AddHypothesis(geom, hyp)
1202 isAlgo = hyp._narrow( SMESH_Algo )
1203 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1206 ## Unassigns a hypothesis
1207 # @param hyp a hypothesis to unassign
1208 # @param geom a subshape of mesh geometry
1209 # @return SMESH.Hypothesis_Status
1210 # @ingroup l2_hypotheses
1211 def RemoveHypothesis(self, hyp, geom=0):
1212 if isinstance( hyp, Mesh_Algorithm ):
1213 hyp = hyp.GetAlgorithm()
1218 status = self.mesh.RemoveHypothesis(geom, hyp)
1221 ## Gets the list of hypotheses added on a geometry
1222 # @param geom a subshape of mesh geometry
1223 # @return the sequence of SMESH_Hypothesis
1224 # @ingroup l2_hypotheses
1225 def GetHypothesisList(self, geom):
1226 return self.mesh.GetHypothesisList( geom )
1228 ## Removes all global hypotheses
1229 # @ingroup l2_hypotheses
1230 def RemoveGlobalHypotheses(self):
1231 current_hyps = self.mesh.GetHypothesisList( self.geom )
1232 for hyp in current_hyps:
1233 self.mesh.RemoveHypothesis( self.geom, hyp )
1237 ## Creates a mesh group based on the geometric object \a grp
1238 # and gives a \a name, \n if this parameter is not defined
1239 # the name is the same as the geometric group name \n
1240 # Note: Works like GroupOnGeom().
1241 # @param grp a geometric group, a vertex, an edge, a face or a solid
1242 # @param name the name of the mesh group
1243 # @return SMESH_GroupOnGeom
1244 # @ingroup l2_grps_create
1245 def Group(self, grp, name=""):
1246 return self.GroupOnGeom(grp, name)
1248 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1249 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1250 # @param f the file name
1251 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1252 # @ingroup l2_impexp
1253 def ExportToMED(self, f, version, opt=0):
1254 self.mesh.ExportToMED(f, opt, version)
1256 ## Exports the mesh in a file in MED format
1257 # @param f is the file name
1258 # @param auto_groups boolean parameter for creating/not creating
1259 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1260 # the typical use is auto_groups=false.
1261 # @param version MED format version(MED_V2_1 or MED_V2_2)
1262 # @ingroup l2_impexp
1263 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1264 self.mesh.ExportToMED(f, auto_groups, version)
1266 ## Exports the mesh in a file in DAT format
1267 # @param f the file name
1268 # @ingroup l2_impexp
1269 def ExportDAT(self, f):
1270 self.mesh.ExportDAT(f)
1272 ## Exports the mesh in a file in UNV format
1273 # @param f the file name
1274 # @ingroup l2_impexp
1275 def ExportUNV(self, f):
1276 self.mesh.ExportUNV(f)
1278 ## Export the mesh in a file in STL format
1279 # @param f the file name
1280 # @param ascii defines the file encoding
1281 # @ingroup l2_impexp
1282 def ExportSTL(self, f, ascii=1):
1283 self.mesh.ExportSTL(f, ascii)
1286 # Operations with groups:
1287 # ----------------------
1289 ## Creates an empty mesh group
1290 # @param elementType the type of elements in the group
1291 # @param name the name of the mesh group
1292 # @return SMESH_Group
1293 # @ingroup l2_grps_create
1294 def CreateEmptyGroup(self, elementType, name):
1295 return self.mesh.CreateGroup(elementType, name)
1297 ## Creates a mesh group based on the geometrical object \a grp
1298 # and gives a \a name, \n if this parameter is not defined
1299 # the name is the same as the geometrical group name
1300 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1301 # @param name the name of the mesh group
1302 # @param typ the type of elements in the group. If not set, it is
1303 # automatically detected by the type of the geometry
1304 # @return SMESH_GroupOnGeom
1305 # @ingroup l2_grps_create
1306 def GroupOnGeom(self, grp, name="", typ=None):
1308 name = grp.GetName()
1311 tgeo = str(grp.GetShapeType())
1312 if tgeo == "VERTEX":
1314 elif tgeo == "EDGE":
1316 elif tgeo == "FACE":
1318 elif tgeo == "SOLID":
1320 elif tgeo == "SHELL":
1322 elif tgeo == "COMPOUND":
1323 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1324 print "Mesh.Group: empty geometric group", GetName( grp )
1326 tgeo = self.geompyD.GetType(grp)
1327 if tgeo == geompyDC.ShapeType["VERTEX"]:
1329 elif tgeo == geompyDC.ShapeType["EDGE"]:
1331 elif tgeo == geompyDC.ShapeType["FACE"]:
1333 elif tgeo == geompyDC.ShapeType["SOLID"]:
1337 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1340 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1342 ## Creates a mesh group by the given ids of elements
1343 # @param groupName the name of the mesh group
1344 # @param elementType the type of elements in the group
1345 # @param elemIDs the list of ids
1346 # @return SMESH_Group
1347 # @ingroup l2_grps_create
1348 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1349 group = self.mesh.CreateGroup(elementType, groupName)
1353 ## Creates a mesh group by the given conditions
1354 # @param groupName the name of the mesh group
1355 # @param elementType the type of elements in the group
1356 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1357 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1358 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1359 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1360 # @return SMESH_Group
1361 # @ingroup l2_grps_create
1365 CritType=FT_Undefined,
1368 UnaryOp=FT_Undefined):
1369 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1370 group = self.MakeGroupByCriterion(groupName, aCriterion)
1373 ## Creates a mesh group by the given criterion
1374 # @param groupName the name of the mesh group
1375 # @param Criterion the instance of Criterion class
1376 # @return SMESH_Group
1377 # @ingroup l2_grps_create
1378 def MakeGroupByCriterion(self, groupName, Criterion):
1379 aFilterMgr = self.smeshpyD.CreateFilterManager()
1380 aFilter = aFilterMgr.CreateFilter()
1382 aCriteria.append(Criterion)
1383 aFilter.SetCriteria(aCriteria)
1384 group = self.MakeGroupByFilter(groupName, aFilter)
1387 ## Creates a mesh group by the given criteria (list of criteria)
1388 # @param groupName the name of the mesh group
1389 # @param theCriteria the list of criteria
1390 # @return SMESH_Group
1391 # @ingroup l2_grps_create
1392 def MakeGroupByCriteria(self, groupName, theCriteria):
1393 aFilterMgr = self.smeshpyD.CreateFilterManager()
1394 aFilter = aFilterMgr.CreateFilter()
1395 aFilter.SetCriteria(theCriteria)
1396 group = self.MakeGroupByFilter(groupName, aFilter)
1399 ## Creates a mesh group by the given filter
1400 # @param groupName the name of the mesh group
1401 # @param theFilter the instance of Filter class
1402 # @return SMESH_Group
1403 # @ingroup l2_grps_create
1404 def MakeGroupByFilter(self, groupName, theFilter):
1405 anIds = theFilter.GetElementsId(self.mesh)
1406 anElemType = theFilter.GetElementType()
1407 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1410 ## Passes mesh elements through the given filter and return IDs of fitting elements
1411 # @param theFilter SMESH_Filter
1412 # @return a list of ids
1413 # @ingroup l1_controls
1414 def GetIdsFromFilter(self, theFilter):
1415 return theFilter.GetElementsId(self.mesh)
1417 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1418 # Returns a list of special structures (borders).
1419 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1420 # @ingroup l1_controls
1421 def GetFreeBorders(self):
1422 aFilterMgr = self.smeshpyD.CreateFilterManager()
1423 aPredicate = aFilterMgr.CreateFreeEdges()
1424 aPredicate.SetMesh(self.mesh)
1425 aBorders = aPredicate.GetBorders()
1429 # @ingroup l2_grps_delete
1430 def RemoveGroup(self, group):
1431 self.mesh.RemoveGroup(group)
1433 ## Removes a group with its contents
1434 # @ingroup l2_grps_delete
1435 def RemoveGroupWithContents(self, group):
1436 self.mesh.RemoveGroupWithContents(group)
1438 ## Gets the list of groups existing in the mesh
1439 # @return a sequence of SMESH_GroupBase
1440 # @ingroup l2_grps_create
1441 def GetGroups(self):
1442 return self.mesh.GetGroups()
1444 ## Gets the number of groups existing in the mesh
1445 # @return the quantity of groups as an integer value
1446 # @ingroup l2_grps_create
1448 return self.mesh.NbGroups()
1450 ## Gets the list of names of groups existing in the mesh
1451 # @return list of strings
1452 # @ingroup l2_grps_create
1453 def GetGroupNames(self):
1454 groups = self.GetGroups()
1456 for group in groups:
1457 names.append(group.GetName())
1460 ## Produces a union of two groups
1461 # A new group is created. All mesh elements that are
1462 # present in the initial groups are added to the new one
1463 # @return an instance of SMESH_Group
1464 # @ingroup l2_grps_operon
1465 def UnionGroups(self, group1, group2, name):
1466 return self.mesh.UnionGroups(group1, group2, name)
1468 ## Produces a union list of groups
1469 # New group is created. All mesh elements that are present in
1470 # initial groups are added to the new one
1471 # @return an instance of SMESH_Group
1472 # @ingroup l2_grps_operon
1473 def UnionListOfGroups(self, groups, name):
1474 return self.mesh.UnionListOfGroups(groups, name)
1476 ## Prodices an intersection of two groups
1477 # A new group is created. All mesh elements that are common
1478 # for the two initial groups are added to the new one.
1479 # @return an instance of SMESH_Group
1480 # @ingroup l2_grps_operon
1481 def IntersectGroups(self, group1, group2, name):
1482 return self.mesh.IntersectGroups(group1, group2, name)
1484 ## Produces an intersection of groups
1485 # New group is created. All mesh elements that are present in all
1486 # initial groups simultaneously are added to the new one
1487 # @return an instance of SMESH_Group
1488 # @ingroup l2_grps_operon
1489 def IntersectListOfGroups(self, groups, name):
1490 return self.mesh.IntersectListOfGroups(groups, name)
1492 ## Produces a cut of two groups
1493 # A new group is created. All mesh elements that are present in
1494 # the main group but are not present in the tool group are added to the new one
1495 # @return an instance of SMESH_Group
1496 # @ingroup l2_grps_operon
1497 def CutGroups(self, main_group, tool_group, name):
1498 return self.mesh.CutGroups(main_group, tool_group, name)
1500 ## Produces a cut of groups
1501 # A new group is created. All mesh elements that are present in main groups
1502 # but do not present in tool groups are added to the new one
1503 # @return an instance of SMESH_Group
1504 # @ingroup l2_grps_operon
1505 def CutListOfGroups(self, main_groups, tool_groups, name):
1506 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1508 ## Produces a group of elements with specified element type using list of existing groups
1509 # A new group is created. System
1510 # 1) extract all nodes on which groups elements are built
1511 # 2) combine all elements of specified dimension laying on these nodes
1512 # @return an instance of SMESH_Group
1513 # @ingroup l2_grps_operon
1514 def CreateDimGroup(self, groups, elem_type, name):
1515 return self.mesh.CreateDimGroup(groups, elem_type, name)
1518 ## Convert group on geom into standalone group
1519 # @ingroup l2_grps_delete
1520 def ConvertToStandalone(self, group):
1521 return self.mesh.ConvertToStandalone(group)
1523 # Get some info about mesh:
1524 # ------------------------
1526 ## Returns the log of nodes and elements added or removed
1527 # since the previous clear of the log.
1528 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1529 # @return list of log_block structures:
1534 # @ingroup l1_auxiliary
1535 def GetLog(self, clearAfterGet):
1536 return self.mesh.GetLog(clearAfterGet)
1538 ## Clears the log of nodes and elements added or removed since the previous
1539 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1540 # @ingroup l1_auxiliary
1542 self.mesh.ClearLog()
1544 ## Toggles auto color mode on the object.
1545 # @param theAutoColor the flag which toggles auto color mode.
1546 # @ingroup l1_auxiliary
1547 def SetAutoColor(self, theAutoColor):
1548 self.mesh.SetAutoColor(theAutoColor)
1550 ## Gets flag of object auto color mode.
1551 # @return True or False
1552 # @ingroup l1_auxiliary
1553 def GetAutoColor(self):
1554 return self.mesh.GetAutoColor()
1556 ## Gets the internal ID
1557 # @return integer value, which is the internal Id of the mesh
1558 # @ingroup l1_auxiliary
1560 return self.mesh.GetId()
1563 # @return integer value, which is the study Id of the mesh
1564 # @ingroup l1_auxiliary
1565 def GetStudyId(self):
1566 return self.mesh.GetStudyId()
1568 ## Checks the group names for duplications.
1569 # Consider the maximum group name length stored in MED file.
1570 # @return True or False
1571 # @ingroup l1_auxiliary
1572 def HasDuplicatedGroupNamesMED(self):
1573 return self.mesh.HasDuplicatedGroupNamesMED()
1575 ## Obtains the mesh editor tool
1576 # @return an instance of SMESH_MeshEditor
1577 # @ingroup l1_modifying
1578 def GetMeshEditor(self):
1579 return self.mesh.GetMeshEditor()
1582 # @return an instance of SALOME_MED::MESH
1583 # @ingroup l1_auxiliary
1584 def GetMEDMesh(self):
1585 return self.mesh.GetMEDMesh()
1588 # Get informations about mesh contents:
1589 # ------------------------------------
1591 ## Gets the mesh stattistic
1592 # @return dictionary type element - count of elements
1593 # @ingroup l1_meshinfo
1594 def GetMeshInfo(self, obj = None):
1595 if not obj: obj = self.mesh
1597 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
1598 values = obj.GetMeshInfo()
1599 for i in range(SMESH.Entity_Last._v):
1600 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
1604 ## Returns the number of nodes in the mesh
1605 # @return an integer value
1606 # @ingroup l1_meshinfo
1608 return self.mesh.NbNodes()
1610 ## Returns the number of elements in the mesh
1611 # @return an integer value
1612 # @ingroup l1_meshinfo
1613 def NbElements(self):
1614 return self.mesh.NbElements()
1616 ## Returns the number of 0d elements in the mesh
1617 # @return an integer value
1618 # @ingroup l1_meshinfo
1619 def Nb0DElements(self):
1620 return self.mesh.Nb0DElements()
1622 ## Returns the number of edges in the mesh
1623 # @return an integer value
1624 # @ingroup l1_meshinfo
1626 return self.mesh.NbEdges()
1628 ## Returns the number of edges with the given order in the mesh
1629 # @param elementOrder the order of elements:
1630 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1631 # @return an integer value
1632 # @ingroup l1_meshinfo
1633 def NbEdgesOfOrder(self, elementOrder):
1634 return self.mesh.NbEdgesOfOrder(elementOrder)
1636 ## Returns the number of faces in the mesh
1637 # @return an integer value
1638 # @ingroup l1_meshinfo
1640 return self.mesh.NbFaces()
1642 ## Returns the number of faces with the given order in the mesh
1643 # @param elementOrder the order of elements:
1644 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1645 # @return an integer value
1646 # @ingroup l1_meshinfo
1647 def NbFacesOfOrder(self, elementOrder):
1648 return self.mesh.NbFacesOfOrder(elementOrder)
1650 ## Returns the number of triangles in the mesh
1651 # @return an integer value
1652 # @ingroup l1_meshinfo
1653 def NbTriangles(self):
1654 return self.mesh.NbTriangles()
1656 ## Returns the number of triangles with the given order in the mesh
1657 # @param elementOrder is the order of elements:
1658 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1659 # @return an integer value
1660 # @ingroup l1_meshinfo
1661 def NbTrianglesOfOrder(self, elementOrder):
1662 return self.mesh.NbTrianglesOfOrder(elementOrder)
1664 ## Returns the number of quadrangles in the mesh
1665 # @return an integer value
1666 # @ingroup l1_meshinfo
1667 def NbQuadrangles(self):
1668 return self.mesh.NbQuadrangles()
1670 ## Returns the number of quadrangles with the given order in the mesh
1671 # @param elementOrder the order of elements:
1672 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1673 # @return an integer value
1674 # @ingroup l1_meshinfo
1675 def NbQuadranglesOfOrder(self, elementOrder):
1676 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1678 ## Returns the number of polygons in the mesh
1679 # @return an integer value
1680 # @ingroup l1_meshinfo
1681 def NbPolygons(self):
1682 return self.mesh.NbPolygons()
1684 ## Returns the number of volumes in the mesh
1685 # @return an integer value
1686 # @ingroup l1_meshinfo
1687 def NbVolumes(self):
1688 return self.mesh.NbVolumes()
1690 ## Returns the number of volumes with the given order in the mesh
1691 # @param elementOrder the order of elements:
1692 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1693 # @return an integer value
1694 # @ingroup l1_meshinfo
1695 def NbVolumesOfOrder(self, elementOrder):
1696 return self.mesh.NbVolumesOfOrder(elementOrder)
1698 ## Returns the number of tetrahedrons in the mesh
1699 # @return an integer value
1700 # @ingroup l1_meshinfo
1702 return self.mesh.NbTetras()
1704 ## Returns the number of tetrahedrons with the given order in the mesh
1705 # @param elementOrder the order of elements:
1706 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1707 # @return an integer value
1708 # @ingroup l1_meshinfo
1709 def NbTetrasOfOrder(self, elementOrder):
1710 return self.mesh.NbTetrasOfOrder(elementOrder)
1712 ## Returns the number of hexahedrons in the mesh
1713 # @return an integer value
1714 # @ingroup l1_meshinfo
1716 return self.mesh.NbHexas()
1718 ## Returns the number of hexahedrons with the given order in the mesh
1719 # @param elementOrder the order of elements:
1720 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1721 # @return an integer value
1722 # @ingroup l1_meshinfo
1723 def NbHexasOfOrder(self, elementOrder):
1724 return self.mesh.NbHexasOfOrder(elementOrder)
1726 ## Returns the number of pyramids in the mesh
1727 # @return an integer value
1728 # @ingroup l1_meshinfo
1729 def NbPyramids(self):
1730 return self.mesh.NbPyramids()
1732 ## Returns the number of pyramids with the given order in the mesh
1733 # @param elementOrder the order of elements:
1734 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1735 # @return an integer value
1736 # @ingroup l1_meshinfo
1737 def NbPyramidsOfOrder(self, elementOrder):
1738 return self.mesh.NbPyramidsOfOrder(elementOrder)
1740 ## Returns the number of prisms in the mesh
1741 # @return an integer value
1742 # @ingroup l1_meshinfo
1744 return self.mesh.NbPrisms()
1746 ## Returns the number of prisms with the given order in the mesh
1747 # @param elementOrder the order of elements:
1748 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1749 # @return an integer value
1750 # @ingroup l1_meshinfo
1751 def NbPrismsOfOrder(self, elementOrder):
1752 return self.mesh.NbPrismsOfOrder(elementOrder)
1754 ## Returns the number of polyhedrons in the mesh
1755 # @return an integer value
1756 # @ingroup l1_meshinfo
1757 def NbPolyhedrons(self):
1758 return self.mesh.NbPolyhedrons()
1760 ## Returns the number of submeshes in the mesh
1761 # @return an integer value
1762 # @ingroup l1_meshinfo
1763 def NbSubMesh(self):
1764 return self.mesh.NbSubMesh()
1766 ## Returns the list of mesh elements IDs
1767 # @return the list of integer values
1768 # @ingroup l1_meshinfo
1769 def GetElementsId(self):
1770 return self.mesh.GetElementsId()
1772 ## Returns the list of IDs of mesh elements with the given type
1773 # @param elementType the required type of elements
1774 # @return list of integer values
1775 # @ingroup l1_meshinfo
1776 def GetElementsByType(self, elementType):
1777 return self.mesh.GetElementsByType(elementType)
1779 ## Returns the list of mesh nodes IDs
1780 # @return the list of integer values
1781 # @ingroup l1_meshinfo
1782 def GetNodesId(self):
1783 return self.mesh.GetNodesId()
1785 # Get the information about mesh elements:
1786 # ------------------------------------
1788 ## Returns the type of mesh element
1789 # @return the value from SMESH::ElementType enumeration
1790 # @ingroup l1_meshinfo
1791 def GetElementType(self, id, iselem):
1792 return self.mesh.GetElementType(id, iselem)
1794 ## Returns the list of submesh elements IDs
1795 # @param Shape a geom object(subshape) IOR
1796 # Shape must be the subshape of a ShapeToMesh()
1797 # @return the list of integer values
1798 # @ingroup l1_meshinfo
1799 def GetSubMeshElementsId(self, Shape):
1800 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1801 ShapeID = Shape.GetSubShapeIndices()[0]
1804 return self.mesh.GetSubMeshElementsId(ShapeID)
1806 ## Returns the list of submesh nodes IDs
1807 # @param Shape a geom object(subshape) IOR
1808 # Shape must be the subshape of a ShapeToMesh()
1809 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1810 # @return the list of integer values
1811 # @ingroup l1_meshinfo
1812 def GetSubMeshNodesId(self, Shape, all):
1813 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1814 ShapeID = Shape.GetSubShapeIndices()[0]
1817 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1819 ## Returns type of elements on given shape
1820 # @param Shape a geom object(subshape) IOR
1821 # Shape must be a subshape of a ShapeToMesh()
1822 # @return element type
1823 # @ingroup l1_meshinfo
1824 def GetSubMeshElementType(self, Shape):
1825 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1826 ShapeID = Shape.GetSubShapeIndices()[0]
1829 return self.mesh.GetSubMeshElementType(ShapeID)
1831 ## Gets the mesh description
1832 # @return string value
1833 # @ingroup l1_meshinfo
1835 return self.mesh.Dump()
1838 # Get the information about nodes and elements of a mesh by its IDs:
1839 # -----------------------------------------------------------
1841 ## Gets XYZ coordinates of a node
1842 # \n If there is no nodes for the given ID - returns an empty list
1843 # @return a list of double precision values
1844 # @ingroup l1_meshinfo
1845 def GetNodeXYZ(self, id):
1846 return self.mesh.GetNodeXYZ(id)
1848 ## Returns list of IDs of inverse elements for the given node
1849 # \n If there is no node for the given ID - returns an empty list
1850 # @return a list of integer values
1851 # @ingroup l1_meshinfo
1852 def GetNodeInverseElements(self, id):
1853 return self.mesh.GetNodeInverseElements(id)
1855 ## @brief Returns the position of a node on the shape
1856 # @return SMESH::NodePosition
1857 # @ingroup l1_meshinfo
1858 def GetNodePosition(self,NodeID):
1859 return self.mesh.GetNodePosition(NodeID)
1861 ## If the given element is a node, returns the ID of shape
1862 # \n If there is no node for the given ID - returns -1
1863 # @return an integer value
1864 # @ingroup l1_meshinfo
1865 def GetShapeID(self, id):
1866 return self.mesh.GetShapeID(id)
1868 ## Returns the ID of the result shape after
1869 # FindShape() from SMESH_MeshEditor for the given element
1870 # \n If there is no element for the given ID - returns -1
1871 # @return an integer value
1872 # @ingroup l1_meshinfo
1873 def GetShapeIDForElem(self,id):
1874 return self.mesh.GetShapeIDForElem(id)
1876 ## Returns the number of nodes for the given element
1877 # \n If there is no element for the given ID - returns -1
1878 # @return an integer value
1879 # @ingroup l1_meshinfo
1880 def GetElemNbNodes(self, id):
1881 return self.mesh.GetElemNbNodes(id)
1883 ## Returns the node ID the given index for the given element
1884 # \n If there is no element for the given ID - returns -1
1885 # \n If there is no node for the given index - returns -2
1886 # @return an integer value
1887 # @ingroup l1_meshinfo
1888 def GetElemNode(self, id, index):
1889 return self.mesh.GetElemNode(id, index)
1891 ## Returns the IDs of nodes of the given element
1892 # @return a list of integer values
1893 # @ingroup l1_meshinfo
1894 def GetElemNodes(self, id):
1895 return self.mesh.GetElemNodes(id)
1897 ## Returns true if the given node is the medium node in the given quadratic element
1898 # @ingroup l1_meshinfo
1899 def IsMediumNode(self, elementID, nodeID):
1900 return self.mesh.IsMediumNode(elementID, nodeID)
1902 ## Returns true if the given node is the medium node in one of quadratic elements
1903 # @ingroup l1_meshinfo
1904 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1905 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1907 ## Returns the number of edges for the given element
1908 # @ingroup l1_meshinfo
1909 def ElemNbEdges(self, id):
1910 return self.mesh.ElemNbEdges(id)
1912 ## Returns the number of faces for the given element
1913 # @ingroup l1_meshinfo
1914 def ElemNbFaces(self, id):
1915 return self.mesh.ElemNbFaces(id)
1917 ## Returns true if the given element is a polygon
1918 # @ingroup l1_meshinfo
1919 def IsPoly(self, id):
1920 return self.mesh.IsPoly(id)
1922 ## Returns true if the given element is quadratic
1923 # @ingroup l1_meshinfo
1924 def IsQuadratic(self, id):
1925 return self.mesh.IsQuadratic(id)
1927 ## Returns XYZ coordinates of the barycenter of the given element
1928 # \n If there is no element for the given ID - returns an empty list
1929 # @return a list of three double values
1930 # @ingroup l1_meshinfo
1931 def BaryCenter(self, id):
1932 return self.mesh.BaryCenter(id)
1935 # Mesh edition (SMESH_MeshEditor functionality):
1936 # ---------------------------------------------
1938 ## Removes the elements from the mesh by ids
1939 # @param IDsOfElements is a list of ids of elements to remove
1940 # @return True or False
1941 # @ingroup l2_modif_del
1942 def RemoveElements(self, IDsOfElements):
1943 return self.editor.RemoveElements(IDsOfElements)
1945 ## Removes nodes from mesh by ids
1946 # @param IDsOfNodes is a list of ids of nodes to remove
1947 # @return True or False
1948 # @ingroup l2_modif_del
1949 def RemoveNodes(self, IDsOfNodes):
1950 return self.editor.RemoveNodes(IDsOfNodes)
1952 ## Add a node to the mesh by coordinates
1953 # @return Id of the new node
1954 # @ingroup l2_modif_add
1955 def AddNode(self, x, y, z):
1956 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
1957 self.mesh.SetParameters(Parameters)
1958 return self.editor.AddNode( x, y, z)
1960 ## Creates a 0D element on a node with given number.
1961 # @param IDOfNode the ID of node for creation of the element.
1962 # @return the Id of the new 0D element
1963 # @ingroup l2_modif_add
1964 def Add0DElement(self, IDOfNode):
1965 return self.editor.Add0DElement(IDOfNode)
1967 ## Creates a linear or quadratic edge (this is determined
1968 # by the number of given nodes).
1969 # @param IDsOfNodes the list of node IDs for creation of the element.
1970 # The order of nodes in this list should correspond to the description
1971 # of MED. \n This description is located by the following link:
1972 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1973 # @return the Id of the new edge
1974 # @ingroup l2_modif_add
1975 def AddEdge(self, IDsOfNodes):
1976 return self.editor.AddEdge(IDsOfNodes)
1978 ## Creates a linear or quadratic face (this is determined
1979 # by the number of given nodes).
1980 # @param IDsOfNodes the list of node IDs for creation of the element.
1981 # The order of nodes in this list should correspond to the description
1982 # of MED. \n This description is located by the following link:
1983 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1984 # @return the Id of the new face
1985 # @ingroup l2_modif_add
1986 def AddFace(self, IDsOfNodes):
1987 return self.editor.AddFace(IDsOfNodes)
1989 ## Adds a polygonal face to the mesh by the list of node IDs
1990 # @param IdsOfNodes the list of node IDs for creation of the element.
1991 # @return the Id of the new face
1992 # @ingroup l2_modif_add
1993 def AddPolygonalFace(self, IdsOfNodes):
1994 return self.editor.AddPolygonalFace(IdsOfNodes)
1996 ## Creates both simple and quadratic volume (this is determined
1997 # by the number of given nodes).
1998 # @param IDsOfNodes the list of node IDs for creation of the element.
1999 # The order of nodes in this list should correspond to the description
2000 # of MED. \n This description is located by the following link:
2001 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2002 # @return the Id of the new volumic element
2003 # @ingroup l2_modif_add
2004 def AddVolume(self, IDsOfNodes):
2005 return self.editor.AddVolume(IDsOfNodes)
2007 ## Creates a volume of many faces, giving nodes for each face.
2008 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2009 # @param Quantities the list of integer values, Quantities[i]
2010 # gives the quantity of nodes in face number i.
2011 # @return the Id of the new volumic element
2012 # @ingroup l2_modif_add
2013 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2014 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2016 ## Creates a volume of many faces, giving the IDs of the existing faces.
2017 # @param IdsOfFaces the list of face IDs for volume creation.
2019 # Note: The created volume will refer only to the nodes
2020 # of the given faces, not to the faces themselves.
2021 # @return the Id of the new volumic element
2022 # @ingroup l2_modif_add
2023 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2024 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2027 ## @brief Binds a node to a vertex
2028 # @param NodeID a node ID
2029 # @param Vertex a vertex or vertex ID
2030 # @return True if succeed else raises an exception
2031 # @ingroup l2_modif_add
2032 def SetNodeOnVertex(self, NodeID, Vertex):
2033 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2034 VertexID = Vertex.GetSubShapeIndices()[0]
2038 self.editor.SetNodeOnVertex(NodeID, VertexID)
2039 except SALOME.SALOME_Exception, inst:
2040 raise ValueError, inst.details.text
2044 ## @brief Stores the node position on an edge
2045 # @param NodeID a node ID
2046 # @param Edge an edge or edge ID
2047 # @param paramOnEdge a parameter on the edge where the node is located
2048 # @return True if succeed else raises an exception
2049 # @ingroup l2_modif_add
2050 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2051 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2052 EdgeID = Edge.GetSubShapeIndices()[0]
2056 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2057 except SALOME.SALOME_Exception, inst:
2058 raise ValueError, inst.details.text
2061 ## @brief Stores node position on a face
2062 # @param NodeID a node ID
2063 # @param Face a face or face ID
2064 # @param u U parameter on the face where the node is located
2065 # @param v V parameter on the face where the node is located
2066 # @return True if succeed else raises an exception
2067 # @ingroup l2_modif_add
2068 def SetNodeOnFace(self, NodeID, Face, u, v):
2069 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2070 FaceID = Face.GetSubShapeIndices()[0]
2074 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2075 except SALOME.SALOME_Exception, inst:
2076 raise ValueError, inst.details.text
2079 ## @brief Binds a node to a solid
2080 # @param NodeID a node ID
2081 # @param Solid a solid or solid ID
2082 # @return True if succeed else raises an exception
2083 # @ingroup l2_modif_add
2084 def SetNodeInVolume(self, NodeID, Solid):
2085 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2086 SolidID = Solid.GetSubShapeIndices()[0]
2090 self.editor.SetNodeInVolume(NodeID, SolidID)
2091 except SALOME.SALOME_Exception, inst:
2092 raise ValueError, inst.details.text
2095 ## @brief Bind an element to a shape
2096 # @param ElementID an element ID
2097 # @param Shape a shape or shape ID
2098 # @return True if succeed else raises an exception
2099 # @ingroup l2_modif_add
2100 def SetMeshElementOnShape(self, ElementID, Shape):
2101 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2102 ShapeID = Shape.GetSubShapeIndices()[0]
2106 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2107 except SALOME.SALOME_Exception, inst:
2108 raise ValueError, inst.details.text
2112 ## Moves the node with the given id
2113 # @param NodeID the id of the node
2114 # @param x a new X coordinate
2115 # @param y a new Y coordinate
2116 # @param z a new Z coordinate
2117 # @return True if succeed else False
2118 # @ingroup l2_modif_movenode
2119 def MoveNode(self, NodeID, x, y, z):
2120 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2121 self.mesh.SetParameters(Parameters)
2122 return self.editor.MoveNode(NodeID, x, y, z)
2124 ## Finds the node closest to a point and moves it to a point location
2125 # @param x the X coordinate of a point
2126 # @param y the Y coordinate of a point
2127 # @param z the Z coordinate of a point
2128 # @return the ID of a node
2129 # @ingroup l2_modif_throughp
2130 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2131 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2132 self.mesh.SetParameters(Parameters)
2133 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2135 ## Finds the node closest to a point
2136 # @param x the X coordinate of a point
2137 # @param y the Y coordinate of a point
2138 # @param z the Z coordinate of a point
2139 # @return the ID of a node
2140 # @ingroup l2_modif_throughp
2141 def FindNodeClosestTo(self, x, y, z):
2142 preview = self.mesh.GetMeshEditPreviewer()
2143 return preview.MoveClosestNodeToPoint(x, y, z, -1)
2145 ## Finds the node closest to a point and moves it to a point location
2146 # @param x the X coordinate of a point
2147 # @param y the Y coordinate of a point
2148 # @param z the Z coordinate of a point
2149 # @return the ID of a moved node
2150 # @ingroup l2_modif_throughp
2151 def MeshToPassThroughAPoint(self, x, y, z):
2152 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2154 ## Replaces two neighbour triangles sharing Node1-Node2 link
2155 # with the triangles built on the same 4 nodes but having other common link.
2156 # @param NodeID1 the ID of the first node
2157 # @param NodeID2 the ID of the second node
2158 # @return false if proper faces were not found
2159 # @ingroup l2_modif_invdiag
2160 def InverseDiag(self, NodeID1, NodeID2):
2161 return self.editor.InverseDiag(NodeID1, NodeID2)
2163 ## Replaces two neighbour triangles sharing Node1-Node2 link
2164 # with a quadrangle built on the same 4 nodes.
2165 # @param NodeID1 the ID of the first node
2166 # @param NodeID2 the ID of the second node
2167 # @return false if proper faces were not found
2168 # @ingroup l2_modif_unitetri
2169 def DeleteDiag(self, NodeID1, NodeID2):
2170 return self.editor.DeleteDiag(NodeID1, NodeID2)
2172 ## Reorients elements by ids
2173 # @param IDsOfElements if undefined reorients all mesh elements
2174 # @return True if succeed else False
2175 # @ingroup l2_modif_changori
2176 def Reorient(self, IDsOfElements=None):
2177 if IDsOfElements == None:
2178 IDsOfElements = self.GetElementsId()
2179 return self.editor.Reorient(IDsOfElements)
2181 ## Reorients all elements of the object
2182 # @param theObject mesh, submesh or group
2183 # @return True if succeed else False
2184 # @ingroup l2_modif_changori
2185 def ReorientObject(self, theObject):
2186 if ( isinstance( theObject, Mesh )):
2187 theObject = theObject.GetMesh()
2188 return self.editor.ReorientObject(theObject)
2190 ## Fuses the neighbouring triangles into quadrangles.
2191 # @param IDsOfElements The triangles to be fused,
2192 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2193 # @param MaxAngle is the maximum angle between element normals at which the fusion
2194 # is still performed; theMaxAngle is mesured in radians.
2195 # Also it could be a name of variable which defines angle in degrees.
2196 # @return TRUE in case of success, FALSE otherwise.
2197 # @ingroup l2_modif_unitetri
2198 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2200 if isinstance(MaxAngle,str):
2202 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2204 MaxAngle = DegreesToRadians(MaxAngle)
2205 if IDsOfElements == []:
2206 IDsOfElements = self.GetElementsId()
2207 self.mesh.SetParameters(Parameters)
2209 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2210 Functor = theCriterion
2212 Functor = self.smeshpyD.GetFunctor(theCriterion)
2213 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2215 ## Fuses the neighbouring triangles of the object into quadrangles
2216 # @param theObject is mesh, submesh or group
2217 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2218 # @param MaxAngle a max angle between element normals at which the fusion
2219 # is still performed; theMaxAngle is mesured in radians.
2220 # @return TRUE in case of success, FALSE otherwise.
2221 # @ingroup l2_modif_unitetri
2222 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2223 if ( isinstance( theObject, Mesh )):
2224 theObject = theObject.GetMesh()
2225 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2227 ## Splits quadrangles into triangles.
2228 # @param IDsOfElements the faces to be splitted.
2229 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2230 # @return TRUE in case of success, FALSE otherwise.
2231 # @ingroup l2_modif_cutquadr
2232 def QuadToTri (self, IDsOfElements, theCriterion):
2233 if IDsOfElements == []:
2234 IDsOfElements = self.GetElementsId()
2235 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2237 ## Splits quadrangles into triangles.
2238 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2239 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2240 # @return TRUE in case of success, FALSE otherwise.
2241 # @ingroup l2_modif_cutquadr
2242 def QuadToTriObject (self, theObject, theCriterion):
2243 if ( isinstance( theObject, Mesh )):
2244 theObject = theObject.GetMesh()
2245 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2247 ## Splits quadrangles into triangles.
2248 # @param IDsOfElements the faces to be splitted
2249 # @param Diag13 is used to choose a diagonal for splitting.
2250 # @return TRUE in case of success, FALSE otherwise.
2251 # @ingroup l2_modif_cutquadr
2252 def SplitQuad (self, IDsOfElements, Diag13):
2253 if IDsOfElements == []:
2254 IDsOfElements = self.GetElementsId()
2255 return self.editor.SplitQuad(IDsOfElements, Diag13)
2257 ## Splits quadrangles into triangles.
2258 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2259 # @param Diag13 is used to choose a diagonal for splitting.
2260 # @return TRUE in case of success, FALSE otherwise.
2261 # @ingroup l2_modif_cutquadr
2262 def SplitQuadObject (self, theObject, Diag13):
2263 if ( isinstance( theObject, Mesh )):
2264 theObject = theObject.GetMesh()
2265 return self.editor.SplitQuadObject(theObject, Diag13)
2267 ## Finds a better splitting of the given quadrangle.
2268 # @param IDOfQuad the ID of the quadrangle to be splitted.
2269 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2270 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2271 # diagonal is better, 0 if error occurs.
2272 # @ingroup l2_modif_cutquadr
2273 def BestSplit (self, IDOfQuad, theCriterion):
2274 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2276 ## Splits quadrangle faces near triangular facets of volumes
2278 # @ingroup l1_auxiliary
2279 def SplitQuadsNearTriangularFacets(self):
2280 faces_array = self.GetElementsByType(SMESH.FACE)
2281 for face_id in faces_array:
2282 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2283 quad_nodes = self.mesh.GetElemNodes(face_id)
2284 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2285 isVolumeFound = False
2286 for node1_elem in node1_elems:
2287 if not isVolumeFound:
2288 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2289 nb_nodes = self.GetElemNbNodes(node1_elem)
2290 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2291 volume_elem = node1_elem
2292 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2293 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2294 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2295 isVolumeFound = True
2296 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2297 self.SplitQuad([face_id], False) # diagonal 2-4
2298 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2299 isVolumeFound = True
2300 self.SplitQuad([face_id], True) # diagonal 1-3
2301 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2302 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2303 isVolumeFound = True
2304 self.SplitQuad([face_id], True) # diagonal 1-3
2306 ## @brief Splits hexahedrons into tetrahedrons.
2308 # This operation uses pattern mapping functionality for splitting.
2309 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2310 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2311 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2312 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2313 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2314 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2315 # @return TRUE in case of success, FALSE otherwise.
2316 # @ingroup l1_auxiliary
2317 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2318 # Pattern: 5.---------.6
2323 # (0,0,1) 4.---------.7 * |
2330 # (0,0,0) 0.---------.3
2331 pattern_tetra = "!!! Nb of points: \n 8 \n\
2341 !!! Indices of points of 6 tetras: \n\
2349 pattern = self.smeshpyD.GetPattern()
2350 isDone = pattern.LoadFromFile(pattern_tetra)
2352 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2355 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2356 isDone = pattern.MakeMesh(self.mesh, False, False)
2357 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2359 # split quafrangle faces near triangular facets of volumes
2360 self.SplitQuadsNearTriangularFacets()
2364 ## @brief Split hexahedrons into prisms.
2366 # Uses the pattern mapping functionality for splitting.
2367 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2368 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2369 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2370 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2371 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2372 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2373 # @return TRUE in case of success, FALSE otherwise.
2374 # @ingroup l1_auxiliary
2375 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2376 # Pattern: 5.---------.6
2381 # (0,0,1) 4.---------.7 |
2388 # (0,0,0) 0.---------.3
2389 pattern_prism = "!!! Nb of points: \n 8 \n\
2399 !!! Indices of points of 2 prisms: \n\
2403 pattern = self.smeshpyD.GetPattern()
2404 isDone = pattern.LoadFromFile(pattern_prism)
2406 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2409 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2410 isDone = pattern.MakeMesh(self.mesh, False, False)
2411 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2413 # Splits quafrangle faces near triangular facets of volumes
2414 self.SplitQuadsNearTriangularFacets()
2418 ## Smoothes elements
2419 # @param IDsOfElements the list if ids of elements to smooth
2420 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2421 # Note that nodes built on edges and boundary nodes are always fixed.
2422 # @param MaxNbOfIterations the maximum number of iterations
2423 # @param MaxAspectRatio varies in range [1.0, inf]
2424 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2425 # @return TRUE in case of success, FALSE otherwise.
2426 # @ingroup l2_modif_smooth
2427 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2428 MaxNbOfIterations, MaxAspectRatio, Method):
2429 if IDsOfElements == []:
2430 IDsOfElements = self.GetElementsId()
2431 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2432 self.mesh.SetParameters(Parameters)
2433 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2434 MaxNbOfIterations, MaxAspectRatio, Method)
2436 ## Smoothes elements which belong to the given object
2437 # @param theObject the object to smooth
2438 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2439 # Note that nodes built on edges and boundary nodes are always fixed.
2440 # @param MaxNbOfIterations the maximum number of iterations
2441 # @param MaxAspectRatio varies in range [1.0, inf]
2442 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2443 # @return TRUE in case of success, FALSE otherwise.
2444 # @ingroup l2_modif_smooth
2445 def SmoothObject(self, theObject, IDsOfFixedNodes,
2446 MaxNbOfIterations, MaxAspectRatio, Method):
2447 if ( isinstance( theObject, Mesh )):
2448 theObject = theObject.GetMesh()
2449 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2450 MaxNbOfIterations, MaxAspectRatio, Method)
2452 ## Parametrically smoothes the given elements
2453 # @param IDsOfElements the list if ids of elements to smooth
2454 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2455 # Note that nodes built on edges and boundary nodes are always fixed.
2456 # @param MaxNbOfIterations the maximum number of iterations
2457 # @param MaxAspectRatio varies in range [1.0, inf]
2458 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2459 # @return TRUE in case of success, FALSE otherwise.
2460 # @ingroup l2_modif_smooth
2461 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2462 MaxNbOfIterations, MaxAspectRatio, Method):
2463 if IDsOfElements == []:
2464 IDsOfElements = self.GetElementsId()
2465 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2466 self.mesh.SetParameters(Parameters)
2467 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2468 MaxNbOfIterations, MaxAspectRatio, Method)
2470 ## Parametrically smoothes the elements which belong to the given object
2471 # @param theObject the object to smooth
2472 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2473 # Note that nodes built on edges and boundary nodes are always fixed.
2474 # @param MaxNbOfIterations the maximum number of iterations
2475 # @param MaxAspectRatio varies in range [1.0, inf]
2476 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2477 # @return TRUE in case of success, FALSE otherwise.
2478 # @ingroup l2_modif_smooth
2479 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2480 MaxNbOfIterations, MaxAspectRatio, Method):
2481 if ( isinstance( theObject, Mesh )):
2482 theObject = theObject.GetMesh()
2483 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2484 MaxNbOfIterations, MaxAspectRatio, Method)
2486 ## Converts the mesh to quadratic, deletes old elements, replacing
2487 # them with quadratic with the same id.
2488 # @ingroup l2_modif_tofromqu
2489 def ConvertToQuadratic(self, theForce3d):
2490 self.editor.ConvertToQuadratic(theForce3d)
2492 ## Converts the mesh from quadratic to ordinary,
2493 # deletes old quadratic elements, \n replacing
2494 # them with ordinary mesh elements with the same id.
2495 # @return TRUE in case of success, FALSE otherwise.
2496 # @ingroup l2_modif_tofromqu
2497 def ConvertFromQuadratic(self):
2498 return self.editor.ConvertFromQuadratic()
2500 ## Renumber mesh nodes
2501 # @ingroup l2_modif_renumber
2502 def RenumberNodes(self):
2503 self.editor.RenumberNodes()
2505 ## Renumber mesh elements
2506 # @ingroup l2_modif_renumber
2507 def RenumberElements(self):
2508 self.editor.RenumberElements()
2510 ## Generates new elements by rotation of the elements around the axis
2511 # @param IDsOfElements the list of ids of elements to sweep
2512 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2513 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2514 # @param NbOfSteps the number of steps
2515 # @param Tolerance tolerance
2516 # @param MakeGroups forces the generation of new groups from existing ones
2517 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2518 # of all steps, else - size of each step
2519 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2520 # @ingroup l2_modif_extrurev
2521 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2522 MakeGroups=False, TotalAngle=False):
2524 if isinstance(AngleInRadians,str):
2526 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2528 AngleInRadians = DegreesToRadians(AngleInRadians)
2529 if IDsOfElements == []:
2530 IDsOfElements = self.GetElementsId()
2531 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2532 Axis = self.smeshpyD.GetAxisStruct(Axis)
2533 Axis,AxisParameters = ParseAxisStruct(Axis)
2534 if TotalAngle and NbOfSteps:
2535 AngleInRadians /= NbOfSteps
2536 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2537 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2538 self.mesh.SetParameters(Parameters)
2540 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2541 AngleInRadians, NbOfSteps, Tolerance)
2542 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2545 ## Generates new elements by rotation of the elements of object around the axis
2546 # @param theObject object which elements should be sweeped
2547 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2548 # @param AngleInRadians the angle of Rotation
2549 # @param NbOfSteps number of steps
2550 # @param Tolerance tolerance
2551 # @param MakeGroups forces the generation of new groups from existing ones
2552 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2553 # of all steps, else - size of each step
2554 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2555 # @ingroup l2_modif_extrurev
2556 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2557 MakeGroups=False, TotalAngle=False):
2559 if isinstance(AngleInRadians,str):
2561 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2563 AngleInRadians = DegreesToRadians(AngleInRadians)
2564 if ( isinstance( theObject, Mesh )):
2565 theObject = theObject.GetMesh()
2566 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2567 Axis = self.smeshpyD.GetAxisStruct(Axis)
2568 Axis,AxisParameters = ParseAxisStruct(Axis)
2569 if TotalAngle and NbOfSteps:
2570 AngleInRadians /= NbOfSteps
2571 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2572 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2573 self.mesh.SetParameters(Parameters)
2575 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2576 NbOfSteps, Tolerance)
2577 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2580 ## Generates new elements by rotation of the elements of object around the axis
2581 # @param theObject object which elements should be sweeped
2582 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2583 # @param AngleInRadians the angle of Rotation
2584 # @param NbOfSteps number of steps
2585 # @param Tolerance tolerance
2586 # @param MakeGroups forces the generation of new groups from existing ones
2587 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2588 # of all steps, else - size of each step
2589 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2590 # @ingroup l2_modif_extrurev
2591 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2592 MakeGroups=False, TotalAngle=False):
2594 if isinstance(AngleInRadians,str):
2596 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2598 AngleInRadians = DegreesToRadians(AngleInRadians)
2599 if ( isinstance( theObject, Mesh )):
2600 theObject = theObject.GetMesh()
2601 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2602 Axis = self.smeshpyD.GetAxisStruct(Axis)
2603 Axis,AxisParameters = ParseAxisStruct(Axis)
2604 if TotalAngle and NbOfSteps:
2605 AngleInRadians /= NbOfSteps
2606 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2607 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2608 self.mesh.SetParameters(Parameters)
2610 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2611 NbOfSteps, Tolerance)
2612 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2615 ## Generates new elements by rotation of the elements of object around the axis
2616 # @param theObject object which elements should be sweeped
2617 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2618 # @param AngleInRadians the angle of Rotation
2619 # @param NbOfSteps number of steps
2620 # @param Tolerance tolerance
2621 # @param MakeGroups forces the generation of new groups from existing ones
2622 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2623 # of all steps, else - size of each step
2624 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2625 # @ingroup l2_modif_extrurev
2626 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2627 MakeGroups=False, TotalAngle=False):
2629 if isinstance(AngleInRadians,str):
2631 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2633 AngleInRadians = DegreesToRadians(AngleInRadians)
2634 if ( isinstance( theObject, Mesh )):
2635 theObject = theObject.GetMesh()
2636 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2637 Axis = self.smeshpyD.GetAxisStruct(Axis)
2638 Axis,AxisParameters = ParseAxisStruct(Axis)
2639 if TotalAngle and NbOfSteps:
2640 AngleInRadians /= NbOfSteps
2641 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2642 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2643 self.mesh.SetParameters(Parameters)
2645 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2646 NbOfSteps, Tolerance)
2647 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2650 ## Generates new elements by extrusion of the elements with given ids
2651 # @param IDsOfElements the list of elements ids for extrusion
2652 # @param StepVector vector, defining the direction and value of extrusion
2653 # @param NbOfSteps the number of steps
2654 # @param MakeGroups forces the generation of new groups from existing ones
2655 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2656 # @ingroup l2_modif_extrurev
2657 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2658 if IDsOfElements == []:
2659 IDsOfElements = self.GetElementsId()
2660 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2661 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2662 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2663 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2664 Parameters = StepVectorParameters + var_separator + Parameters
2665 self.mesh.SetParameters(Parameters)
2667 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2668 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2671 ## Generates new elements by extrusion of the elements with given ids
2672 # @param IDsOfElements is ids of elements
2673 # @param StepVector vector, defining the direction and value of extrusion
2674 # @param NbOfSteps the number of steps
2675 # @param ExtrFlags sets flags for extrusion
2676 # @param SewTolerance uses for comparing locations of nodes if flag
2677 # EXTRUSION_FLAG_SEW is set
2678 # @param MakeGroups forces the generation of new groups from existing ones
2679 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2680 # @ingroup l2_modif_extrurev
2681 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2682 ExtrFlags, SewTolerance, MakeGroups=False):
2683 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2684 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2686 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2687 ExtrFlags, SewTolerance)
2688 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2689 ExtrFlags, SewTolerance)
2692 ## Generates new elements by extrusion of the elements which belong to the object
2693 # @param theObject the object which elements should be processed
2694 # @param StepVector vector, defining the direction and value of extrusion
2695 # @param NbOfSteps the number of steps
2696 # @param MakeGroups forces the generation of new groups from existing ones
2697 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2698 # @ingroup l2_modif_extrurev
2699 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2700 if ( isinstance( theObject, Mesh )):
2701 theObject = theObject.GetMesh()
2702 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2703 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2704 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2705 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2706 Parameters = StepVectorParameters + var_separator + Parameters
2707 self.mesh.SetParameters(Parameters)
2709 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2710 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2713 ## Generates new elements by extrusion of the elements which belong to the object
2714 # @param theObject object which elements should be processed
2715 # @param StepVector vector, defining the direction and value of extrusion
2716 # @param NbOfSteps the number of steps
2717 # @param MakeGroups to generate new groups from existing ones
2718 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2719 # @ingroup l2_modif_extrurev
2720 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2721 if ( isinstance( theObject, Mesh )):
2722 theObject = theObject.GetMesh()
2723 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2724 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2725 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2726 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2727 Parameters = StepVectorParameters + var_separator + Parameters
2728 self.mesh.SetParameters(Parameters)
2730 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2731 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2734 ## Generates new elements by extrusion of the elements which belong to the object
2735 # @param theObject object which elements should be processed
2736 # @param StepVector vector, defining the direction and value of extrusion
2737 # @param NbOfSteps the number of steps
2738 # @param MakeGroups forces the generation of new groups from existing ones
2739 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2740 # @ingroup l2_modif_extrurev
2741 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2742 if ( isinstance( theObject, Mesh )):
2743 theObject = theObject.GetMesh()
2744 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2745 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2746 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2747 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2748 Parameters = StepVectorParameters + var_separator + Parameters
2749 self.mesh.SetParameters(Parameters)
2751 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2752 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2757 ## Generates new elements by extrusion of the given elements
2758 # The path of extrusion must be a meshed edge.
2759 # @param Base mesh or list of ids of elements for extrusion
2760 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2761 # @param NodeStart the start node from Path. Defines the direction of extrusion
2762 # @param HasAngles allows the shape to be rotated around the path
2763 # to get the resulting mesh in a helical fashion
2764 # @param Angles list of angles in radians
2765 # @param LinearVariation forces the computation of rotation angles as linear
2766 # variation of the given Angles along path steps
2767 # @param HasRefPoint allows using the reference point
2768 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2769 # The User can specify any point as the Reference Point.
2770 # @param MakeGroups forces the generation of new groups from existing ones
2771 # @param ElemType type of elements for extrusion (if param Base is a mesh)
2772 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2773 # only SMESH::Extrusion_Error otherwise
2774 # @ingroup l2_modif_extrurev
2775 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2776 HasAngles, Angles, LinearVariation,
2777 HasRefPoint, RefPoint, MakeGroups, ElemType):
2778 Angles,AnglesParameters = ParseAngles(Angles)
2779 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2780 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2781 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2783 Parameters = AnglesParameters + var_separator + RefPointParameters
2784 self.mesh.SetParameters(Parameters)
2786 if isinstance(Base,list):
2788 if Base == []: IDsOfElements = self.GetElementsId()
2789 else: IDsOfElements = Base
2790 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2791 HasAngles, Angles, LinearVariation,
2792 HasRefPoint, RefPoint, MakeGroups, ElemType)
2794 if isinstance(Base,Mesh):
2795 return self.editor.ExtrusionAlongPathObjX(Base.GetMesh(), Path, NodeStart,
2796 HasAngles, Angles, LinearVariation,
2797 HasRefPoint, RefPoint, MakeGroups, ElemType)
2799 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2802 ## Generates new elements by extrusion of the given elements
2803 # The path of extrusion must be a meshed edge.
2804 # @param IDsOfElements ids of elements
2805 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2806 # @param PathShape shape(edge) defines the sub-mesh for the path
2807 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2808 # @param HasAngles allows the shape to be rotated around the path
2809 # to get the resulting mesh in a helical fashion
2810 # @param Angles list of angles in radians
2811 # @param HasRefPoint allows using the reference point
2812 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2813 # The User can specify any point as the Reference Point.
2814 # @param MakeGroups forces the generation of new groups from existing ones
2815 # @param LinearVariation forces the computation of rotation angles as linear
2816 # variation of the given Angles along path steps
2817 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2818 # only SMESH::Extrusion_Error otherwise
2819 # @ingroup l2_modif_extrurev
2820 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2821 HasAngles, Angles, HasRefPoint, RefPoint,
2822 MakeGroups=False, LinearVariation=False):
2823 Angles,AnglesParameters = ParseAngles(Angles)
2824 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2825 if IDsOfElements == []:
2826 IDsOfElements = self.GetElementsId()
2827 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2828 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2830 if ( isinstance( PathMesh, Mesh )):
2831 PathMesh = PathMesh.GetMesh()
2832 if HasAngles and Angles and LinearVariation:
2833 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2835 Parameters = AnglesParameters + var_separator + RefPointParameters
2836 self.mesh.SetParameters(Parameters)
2838 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2839 PathShape, NodeStart, HasAngles,
2840 Angles, HasRefPoint, RefPoint)
2841 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2842 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2844 ## Generates new elements by extrusion of the elements which belong to the object
2845 # The path of extrusion must be a meshed edge.
2846 # @param theObject the object which elements should be processed
2847 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2848 # @param PathShape shape(edge) defines the sub-mesh for the path
2849 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2850 # @param HasAngles allows the shape to be rotated around the path
2851 # to get the resulting mesh in a helical fashion
2852 # @param Angles list of angles
2853 # @param HasRefPoint allows using the reference point
2854 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2855 # The User can specify any point as the Reference Point.
2856 # @param MakeGroups forces the generation of new groups from existing ones
2857 # @param LinearVariation forces the computation of rotation angles as linear
2858 # variation of the given Angles along path steps
2859 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2860 # only SMESH::Extrusion_Error otherwise
2861 # @ingroup l2_modif_extrurev
2862 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2863 HasAngles, Angles, HasRefPoint, RefPoint,
2864 MakeGroups=False, LinearVariation=False):
2865 Angles,AnglesParameters = ParseAngles(Angles)
2866 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2867 if ( isinstance( theObject, Mesh )):
2868 theObject = theObject.GetMesh()
2869 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2870 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2871 if ( isinstance( PathMesh, Mesh )):
2872 PathMesh = PathMesh.GetMesh()
2873 if HasAngles and Angles and LinearVariation:
2874 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2876 Parameters = AnglesParameters + var_separator + RefPointParameters
2877 self.mesh.SetParameters(Parameters)
2879 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2880 PathShape, NodeStart, HasAngles,
2881 Angles, HasRefPoint, RefPoint)
2882 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2883 NodeStart, HasAngles, Angles, HasRefPoint,
2886 ## Generates new elements by extrusion of the elements which belong to the object
2887 # The path of extrusion must be a meshed edge.
2888 # @param theObject the object which elements should be processed
2889 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2890 # @param PathShape shape(edge) defines the sub-mesh for the path
2891 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2892 # @param HasAngles allows the shape to be rotated around the path
2893 # to get the resulting mesh in a helical fashion
2894 # @param Angles list of angles
2895 # @param HasRefPoint allows using the reference point
2896 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2897 # The User can specify any point as the Reference Point.
2898 # @param MakeGroups forces the generation of new groups from existing ones
2899 # @param LinearVariation forces the computation of rotation angles as linear
2900 # variation of the given Angles along path steps
2901 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2902 # only SMESH::Extrusion_Error otherwise
2903 # @ingroup l2_modif_extrurev
2904 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
2905 HasAngles, Angles, HasRefPoint, RefPoint,
2906 MakeGroups=False, LinearVariation=False):
2907 Angles,AnglesParameters = ParseAngles(Angles)
2908 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2909 if ( isinstance( theObject, Mesh )):
2910 theObject = theObject.GetMesh()
2911 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2912 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2913 if ( isinstance( PathMesh, Mesh )):
2914 PathMesh = PathMesh.GetMesh()
2915 if HasAngles and Angles and LinearVariation:
2916 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2918 Parameters = AnglesParameters + var_separator + RefPointParameters
2919 self.mesh.SetParameters(Parameters)
2921 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
2922 PathShape, NodeStart, HasAngles,
2923 Angles, HasRefPoint, RefPoint)
2924 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
2925 NodeStart, HasAngles, Angles, HasRefPoint,
2928 ## Generates new elements by extrusion of the elements which belong to the object
2929 # The path of extrusion must be a meshed edge.
2930 # @param theObject the object which elements should be processed
2931 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2932 # @param PathShape shape(edge) defines the sub-mesh for the path
2933 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2934 # @param HasAngles allows the shape to be rotated around the path
2935 # to get the resulting mesh in a helical fashion
2936 # @param Angles list of angles
2937 # @param HasRefPoint allows using the reference point
2938 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2939 # The User can specify any point as the Reference Point.
2940 # @param MakeGroups forces the generation of new groups from existing ones
2941 # @param LinearVariation forces the computation of rotation angles as linear
2942 # variation of the given Angles along path steps
2943 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2944 # only SMESH::Extrusion_Error otherwise
2945 # @ingroup l2_modif_extrurev
2946 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
2947 HasAngles, Angles, HasRefPoint, RefPoint,
2948 MakeGroups=False, LinearVariation=False):
2949 Angles,AnglesParameters = ParseAngles(Angles)
2950 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2951 if ( isinstance( theObject, Mesh )):
2952 theObject = theObject.GetMesh()
2953 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2954 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2955 if ( isinstance( PathMesh, Mesh )):
2956 PathMesh = PathMesh.GetMesh()
2957 if HasAngles and Angles and LinearVariation:
2958 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2960 Parameters = AnglesParameters + var_separator + RefPointParameters
2961 self.mesh.SetParameters(Parameters)
2963 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
2964 PathShape, NodeStart, HasAngles,
2965 Angles, HasRefPoint, RefPoint)
2966 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
2967 NodeStart, HasAngles, Angles, HasRefPoint,
2970 ## Creates a symmetrical copy of mesh elements
2971 # @param IDsOfElements list of elements ids
2972 # @param Mirror is AxisStruct or geom object(point, line, plane)
2973 # @param theMirrorType is POINT, AXIS or PLANE
2974 # If the Mirror is a geom object this parameter is unnecessary
2975 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2976 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2977 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2978 # @ingroup l2_modif_trsf
2979 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2980 if IDsOfElements == []:
2981 IDsOfElements = self.GetElementsId()
2982 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2983 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2984 Mirror,Parameters = ParseAxisStruct(Mirror)
2985 self.mesh.SetParameters(Parameters)
2986 if Copy and MakeGroups:
2987 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2988 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2991 ## Creates a new mesh by a symmetrical copy of mesh elements
2992 # @param IDsOfElements the list of elements ids
2993 # @param Mirror is AxisStruct or geom object (point, line, plane)
2994 # @param theMirrorType is POINT, AXIS or PLANE
2995 # If the Mirror is a geom object this parameter is unnecessary
2996 # @param MakeGroups to generate new groups from existing ones
2997 # @param NewMeshName a name of the new mesh to create
2998 # @return instance of Mesh class
2999 # @ingroup l2_modif_trsf
3000 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3001 if IDsOfElements == []:
3002 IDsOfElements = self.GetElementsId()
3003 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3004 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3005 Mirror,Parameters = ParseAxisStruct(Mirror)
3006 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3007 MakeGroups, NewMeshName)
3008 mesh.SetParameters(Parameters)
3009 return Mesh(self.smeshpyD,self.geompyD,mesh)
3011 ## Creates a symmetrical copy of the object
3012 # @param theObject mesh, submesh or group
3013 # @param Mirror AxisStruct or geom object (point, line, plane)
3014 # @param theMirrorType is POINT, AXIS or PLANE
3015 # If the Mirror is a geom object this parameter is unnecessary
3016 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3017 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3018 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3019 # @ingroup l2_modif_trsf
3020 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3021 if ( isinstance( theObject, Mesh )):
3022 theObject = theObject.GetMesh()
3023 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3024 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3025 Mirror,Parameters = ParseAxisStruct(Mirror)
3026 self.mesh.SetParameters(Parameters)
3027 if Copy and MakeGroups:
3028 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3029 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3032 ## Creates a new mesh by a symmetrical copy of the object
3033 # @param theObject mesh, submesh or group
3034 # @param Mirror AxisStruct or geom object (point, line, plane)
3035 # @param theMirrorType POINT, AXIS or PLANE
3036 # If the Mirror is a geom object this parameter is unnecessary
3037 # @param MakeGroups forces the generation of new groups from existing ones
3038 # @param NewMeshName the name of the new mesh to create
3039 # @return instance of Mesh class
3040 # @ingroup l2_modif_trsf
3041 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3042 if ( isinstance( theObject, Mesh )):
3043 theObject = theObject.GetMesh()
3044 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3045 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3046 Mirror,Parameters = ParseAxisStruct(Mirror)
3047 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3048 MakeGroups, NewMeshName)
3049 mesh.SetParameters(Parameters)
3050 return Mesh( self.smeshpyD,self.geompyD,mesh )
3052 ## Translates the elements
3053 # @param IDsOfElements list of elements ids
3054 # @param Vector the direction of translation (DirStruct or vector)
3055 # @param Copy allows copying the translated elements
3056 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3057 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3058 # @ingroup l2_modif_trsf
3059 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3060 if IDsOfElements == []:
3061 IDsOfElements = self.GetElementsId()
3062 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3063 Vector = self.smeshpyD.GetDirStruct(Vector)
3064 Vector,Parameters = ParseDirStruct(Vector)
3065 self.mesh.SetParameters(Parameters)
3066 if Copy and MakeGroups:
3067 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3068 self.editor.Translate(IDsOfElements, Vector, Copy)
3071 ## Creates a new mesh of translated elements
3072 # @param IDsOfElements list of elements ids
3073 # @param Vector the direction of translation (DirStruct or vector)
3074 # @param MakeGroups forces the generation of new groups from existing ones
3075 # @param NewMeshName the name of the newly created mesh
3076 # @return instance of Mesh class
3077 # @ingroup l2_modif_trsf
3078 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3079 if IDsOfElements == []:
3080 IDsOfElements = self.GetElementsId()
3081 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3082 Vector = self.smeshpyD.GetDirStruct(Vector)
3083 Vector,Parameters = ParseDirStruct(Vector)
3084 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3085 mesh.SetParameters(Parameters)
3086 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3088 ## Translates the object
3089 # @param theObject the object to translate (mesh, submesh, or group)
3090 # @param Vector direction of translation (DirStruct or geom vector)
3091 # @param Copy allows copying the translated elements
3092 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3093 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3094 # @ingroup l2_modif_trsf
3095 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3096 if ( isinstance( theObject, Mesh )):
3097 theObject = theObject.GetMesh()
3098 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3099 Vector = self.smeshpyD.GetDirStruct(Vector)
3100 Vector,Parameters = ParseDirStruct(Vector)
3101 self.mesh.SetParameters(Parameters)
3102 if Copy and MakeGroups:
3103 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3104 self.editor.TranslateObject(theObject, Vector, Copy)
3107 ## Creates a new mesh from the translated object
3108 # @param theObject the object to translate (mesh, submesh, or group)
3109 # @param Vector the direction of translation (DirStruct or geom vector)
3110 # @param MakeGroups forces the generation of new groups from existing ones
3111 # @param NewMeshName the name of the newly created mesh
3112 # @return instance of Mesh class
3113 # @ingroup l2_modif_trsf
3114 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3115 if (isinstance(theObject, Mesh)):
3116 theObject = theObject.GetMesh()
3117 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3118 Vector = self.smeshpyD.GetDirStruct(Vector)
3119 Vector,Parameters = ParseDirStruct(Vector)
3120 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3121 mesh.SetParameters(Parameters)
3122 return Mesh( self.smeshpyD, self.geompyD, mesh )
3124 ## Rotates the elements
3125 # @param IDsOfElements list of elements ids
3126 # @param Axis the axis of rotation (AxisStruct or geom line)
3127 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3128 # @param Copy allows copying the rotated elements
3129 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3130 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3131 # @ingroup l2_modif_trsf
3132 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3134 if isinstance(AngleInRadians,str):
3136 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3138 AngleInRadians = DegreesToRadians(AngleInRadians)
3139 if IDsOfElements == []:
3140 IDsOfElements = self.GetElementsId()
3141 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3142 Axis = self.smeshpyD.GetAxisStruct(Axis)
3143 Axis,AxisParameters = ParseAxisStruct(Axis)
3144 Parameters = AxisParameters + var_separator + Parameters
3145 self.mesh.SetParameters(Parameters)
3146 if Copy and MakeGroups:
3147 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3148 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3151 ## Creates a new mesh of rotated elements
3152 # @param IDsOfElements list of element ids
3153 # @param Axis the axis of rotation (AxisStruct or geom line)
3154 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3155 # @param MakeGroups forces the generation of new groups from existing ones
3156 # @param NewMeshName the name of the newly created mesh
3157 # @return instance of Mesh class
3158 # @ingroup l2_modif_trsf
3159 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3161 if isinstance(AngleInRadians,str):
3163 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3165 AngleInRadians = DegreesToRadians(AngleInRadians)
3166 if IDsOfElements == []:
3167 IDsOfElements = self.GetElementsId()
3168 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3169 Axis = self.smeshpyD.GetAxisStruct(Axis)
3170 Axis,AxisParameters = ParseAxisStruct(Axis)
3171 Parameters = AxisParameters + var_separator + Parameters
3172 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3173 MakeGroups, NewMeshName)
3174 mesh.SetParameters(Parameters)
3175 return Mesh( self.smeshpyD, self.geompyD, mesh )
3177 ## Rotates the object
3178 # @param theObject the object to rotate( mesh, submesh, or group)
3179 # @param Axis the axis of rotation (AxisStruct or geom line)
3180 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3181 # @param Copy allows copying the rotated elements
3182 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3183 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3184 # @ingroup l2_modif_trsf
3185 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3187 if isinstance(AngleInRadians,str):
3189 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3191 AngleInRadians = DegreesToRadians(AngleInRadians)
3192 if (isinstance(theObject, Mesh)):
3193 theObject = theObject.GetMesh()
3194 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3195 Axis = self.smeshpyD.GetAxisStruct(Axis)
3196 Axis,AxisParameters = ParseAxisStruct(Axis)
3197 Parameters = AxisParameters + ":" + Parameters
3198 self.mesh.SetParameters(Parameters)
3199 if Copy and MakeGroups:
3200 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3201 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3204 ## Creates a new mesh from the rotated object
3205 # @param theObject the object to rotate (mesh, submesh, or group)
3206 # @param Axis the axis of rotation (AxisStruct or geom line)
3207 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3208 # @param MakeGroups forces the generation of new groups from existing ones
3209 # @param NewMeshName the name of the newly created mesh
3210 # @return instance of Mesh class
3211 # @ingroup l2_modif_trsf
3212 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3214 if isinstance(AngleInRadians,str):
3216 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3218 AngleInRadians = DegreesToRadians(AngleInRadians)
3219 if (isinstance( theObject, Mesh )):
3220 theObject = theObject.GetMesh()
3221 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3222 Axis = self.smeshpyD.GetAxisStruct(Axis)
3223 Axis,AxisParameters = ParseAxisStruct(Axis)
3224 Parameters = AxisParameters + ":" + Parameters
3225 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3226 MakeGroups, NewMeshName)
3227 mesh.SetParameters(Parameters)
3228 return Mesh( self.smeshpyD, self.geompyD, mesh )
3230 ## Finds groups of ajacent nodes within Tolerance.
3231 # @param Tolerance the value of tolerance
3232 # @return the list of groups of nodes
3233 # @ingroup l2_modif_trsf
3234 def FindCoincidentNodes (self, Tolerance):
3235 return self.editor.FindCoincidentNodes(Tolerance)
3237 ## Finds groups of ajacent nodes within Tolerance.
3238 # @param Tolerance the value of tolerance
3239 # @param SubMeshOrGroup SubMesh or Group
3240 # @return the list of groups of nodes
3241 # @ingroup l2_modif_trsf
3242 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3243 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3246 # @param GroupsOfNodes the list of groups of nodes
3247 # @ingroup l2_modif_trsf
3248 def MergeNodes (self, GroupsOfNodes):
3249 self.editor.MergeNodes(GroupsOfNodes)
3251 ## Finds the elements built on the same nodes.
3252 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3253 # @return a list of groups of equal elements
3254 # @ingroup l2_modif_trsf
3255 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3256 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3258 ## Merges elements in each given group.
3259 # @param GroupsOfElementsID groups of elements for merging
3260 # @ingroup l2_modif_trsf
3261 def MergeElements(self, GroupsOfElementsID):
3262 self.editor.MergeElements(GroupsOfElementsID)
3264 ## Leaves one element and removes all other elements built on the same nodes.
3265 # @ingroup l2_modif_trsf
3266 def MergeEqualElements(self):
3267 self.editor.MergeEqualElements()
3269 ## Sews free borders
3270 # @return SMESH::Sew_Error
3271 # @ingroup l2_modif_trsf
3272 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3273 FirstNodeID2, SecondNodeID2, LastNodeID2,
3274 CreatePolygons, CreatePolyedrs):
3275 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3276 FirstNodeID2, SecondNodeID2, LastNodeID2,
3277 CreatePolygons, CreatePolyedrs)
3279 ## Sews conform free borders
3280 # @return SMESH::Sew_Error
3281 # @ingroup l2_modif_trsf
3282 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3283 FirstNodeID2, SecondNodeID2):
3284 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3285 FirstNodeID2, SecondNodeID2)
3287 ## Sews border to side
3288 # @return SMESH::Sew_Error
3289 # @ingroup l2_modif_trsf
3290 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3291 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3292 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3293 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3295 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3296 # merged with the nodes of elements of Side2.
3297 # The number of elements in theSide1 and in theSide2 must be
3298 # equal and they should have similar nodal connectivity.
3299 # The nodes to merge should belong to side borders and
3300 # the first node should be linked to the second.
3301 # @return SMESH::Sew_Error
3302 # @ingroup l2_modif_trsf
3303 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3304 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3305 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3306 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3307 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3308 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3310 ## Sets new nodes for the given element.
3311 # @param ide the element id
3312 # @param newIDs nodes ids
3313 # @return If the number of nodes does not correspond to the type of element - returns false
3314 # @ingroup l2_modif_edit
3315 def ChangeElemNodes(self, ide, newIDs):
3316 return self.editor.ChangeElemNodes(ide, newIDs)
3318 ## If during the last operation of MeshEditor some nodes were
3319 # created, this method returns the list of their IDs, \n
3320 # if new nodes were not created - returns empty list
3321 # @return the list of integer values (can be empty)
3322 # @ingroup l1_auxiliary
3323 def GetLastCreatedNodes(self):
3324 return self.editor.GetLastCreatedNodes()
3326 ## If during the last operation of MeshEditor some elements were
3327 # created this method returns the list of their IDs, \n
3328 # if new elements were not created - returns empty list
3329 # @return the list of integer values (can be empty)
3330 # @ingroup l1_auxiliary
3331 def GetLastCreatedElems(self):
3332 return self.editor.GetLastCreatedElems()
3334 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3335 # @param theElems - the list of elements (edges or faces) to be replicated
3336 # The nodes for duplication could be found from these elements
3337 # @param theNodesNot - list of nodes to NOT replicate
3338 # @param theAffectedElems - the list of elements (cells and edges) to which the
3339 # replicated nodes should be associated to.
3340 # @return TRUE if operation has been completed successfully, FALSE otherwise
3341 # @ingroup l2_modif_edit
3342 def DoubleNodes(self, theElems, theNodesNot, theAffectedElems):
3343 return self.editor.DoubleNodes(theElems, theNodesNot, theAffectedElems)
3345 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3346 # @param theElems - the list of elements (edges or faces) to be replicated
3347 # The nodes for duplication could be found from these elements
3348 # @param theNodesNot - list of nodes to NOT replicate
3349 # @param theShape - shape to detect affected elements (element which geometric center
3350 # located on or inside shape).
3351 # The replicated nodes should be associated to affected elements.
3352 # @return TRUE if operation has been completed successfully, FALSE otherwise
3353 # @ingroup l2_modif_edit
3354 def DoubleNodesInRegion(self, theElems, theNodesNot, theShape):
3355 return self.editor.DoubleNodesInRegion(theElems, theNodesNot, theShape)
3357 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3358 # This method provided for convenience works as DoubleNodes() described above.
3359 # @param theElems - group of of elements (edges or faces) to be replicated
3360 # @param theNodesNot - group of nodes not to replicated
3361 # @param theAffectedElems - group of elements to which the replicated nodes
3362 # should be associated to.
3363 # @ingroup l2_modif_edit
3364 def DoubleNodeGroup(self, theElems, theNodesNot, theAffectedElems):
3365 return self.editor.DoubleNodeGroup(theElems, theNodesNot, theAffectedElems)
3367 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3368 # This method provided for convenience works as DoubleNodes() described above.
3369 # @param theElems - group of of elements (edges or faces) to be replicated
3370 # @param theNodesNot - group of nodes not to replicated
3371 # @param theShape - shape to detect affected elements (element which geometric center
3372 # located on or inside shape).
3373 # The replicated nodes should be associated to affected elements.
3374 # @ingroup l2_modif_edit
3375 def DoubleNodeGroupInRegion(self, theElems, theNodesNot, theShape):
3376 return self.editor.DoubleNodeGroup(theElems, theNodesNot, theShape)
3378 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3379 # This method provided for convenience works as DoubleNodes() described above.
3380 # @param theElems - list of groups of elements (edges or faces) to be replicated
3381 # @param theNodesNot - list of groups of nodes not to replicated
3382 # @param theAffectedElems - group of elements to which the replicated nodes
3383 # should be associated to.
3384 # @return TRUE if operation has been completed successfully, FALSE otherwise
3385 # @ingroup l2_modif_edit
3386 def DoubleNodeGroups(self, theElems, theNodesNot, theAffectedElems):
3387 return self.editor.DoubleNodeGroups(theElems, theNodesNot, theAffectedElems)
3389 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3390 # This method provided for convenience works as DoubleNodes() described above.
3391 # @param theElems - list of groups of elements (edges or faces) to be replicated
3392 # @param theNodesNot - list of groups of nodes not to replicated
3393 # @param theShape - shape to detect affected elements (element which geometric center
3394 # located on or inside shape).
3395 # The replicated nodes should be associated to affected elements.
3396 # @return TRUE if operation has been completed successfully, FALSE otherwise
3397 # @ingroup l2_modif_edit
3398 def DoubleNodeGroupsInRegion(self, theElems, theNodesNot, theShape):
3399 return self.editor.DoubleNodeGroupsInRegion(theElems, theNodesNot, theShape)
3401 ## The mother class to define algorithm, it is not recommended to use it directly.
3404 # @ingroup l2_algorithms
3405 class Mesh_Algorithm:
3406 # @class Mesh_Algorithm
3407 # @brief Class Mesh_Algorithm
3409 #def __init__(self,smesh):
3417 ## Finds a hypothesis in the study by its type name and parameters.
3418 # Finds only the hypotheses created in smeshpyD engine.
3419 # @return SMESH.SMESH_Hypothesis
3420 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3421 study = smeshpyD.GetCurrentStudy()
3422 #to do: find component by smeshpyD object, not by its data type
3423 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3424 if scomp is not None:
3425 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3426 # Check if the root label of the hypotheses exists
3427 if res and hypRoot is not None:
3428 iter = study.NewChildIterator(hypRoot)
3429 # Check all published hypotheses
3431 hypo_so_i = iter.Value()
3432 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3433 if attr is not None:
3434 anIOR = attr.Value()
3435 hypo_o_i = salome.orb.string_to_object(anIOR)
3436 if hypo_o_i is not None:
3437 # Check if this is a hypothesis
3438 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3439 if hypo_i is not None:
3440 # Check if the hypothesis belongs to current engine
3441 if smeshpyD.GetObjectId(hypo_i) > 0:
3442 # Check if this is the required hypothesis
3443 if hypo_i.GetName() == hypname:
3445 if CompareMethod(hypo_i, args):
3459 ## Finds the algorithm in the study by its type name.
3460 # Finds only the algorithms, which have been created in smeshpyD engine.
3461 # @return SMESH.SMESH_Algo
3462 def FindAlgorithm (self, algoname, smeshpyD):
3463 study = smeshpyD.GetCurrentStudy()
3464 #to do: find component by smeshpyD object, not by its data type
3465 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3466 if scomp is not None:
3467 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3468 # Check if the root label of the algorithms exists
3469 if res and hypRoot is not None:
3470 iter = study.NewChildIterator(hypRoot)
3471 # Check all published algorithms
3473 algo_so_i = iter.Value()
3474 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3475 if attr is not None:
3476 anIOR = attr.Value()
3477 algo_o_i = salome.orb.string_to_object(anIOR)
3478 if algo_o_i is not None:
3479 # Check if this is an algorithm
3480 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3481 if algo_i is not None:
3482 # Checks if the algorithm belongs to the current engine
3483 if smeshpyD.GetObjectId(algo_i) > 0:
3484 # Check if this is the required algorithm
3485 if algo_i.GetName() == algoname:
3498 ## If the algorithm is global, returns 0; \n
3499 # else returns the submesh associated to this algorithm.
3500 def GetSubMesh(self):
3503 ## Returns the wrapped mesher.
3504 def GetAlgorithm(self):
3507 ## Gets the list of hypothesis that can be used with this algorithm
3508 def GetCompatibleHypothesis(self):
3511 mylist = self.algo.GetCompatibleHypothesis()
3514 ## Gets the name of the algorithm
3518 ## Sets the name to the algorithm
3519 def SetName(self, name):
3520 self.mesh.smeshpyD.SetName(self.algo, name)
3522 ## Gets the id of the algorithm
3524 return self.algo.GetId()
3527 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3529 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3530 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3532 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3534 self.Assign(algo, mesh, geom)
3538 def Assign(self, algo, mesh, geom):
3540 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3547 name = GetName(geom)
3549 name = mesh.geompyD.SubShapeName(geom, piece)
3550 mesh.geompyD.addToStudyInFather(piece, geom, name)
3551 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3554 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3555 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3557 def CompareHyp (self, hyp, args):
3558 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3561 def CompareEqualHyp (self, hyp, args):
3565 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3566 UseExisting=0, CompareMethod=""):
3569 if CompareMethod == "": CompareMethod = self.CompareHyp
3570 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3573 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3579 a = a + s + str(args[i])
3583 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3585 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3586 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3589 ## Returns entry of the shape to mesh in the study
3590 def MainShapeEntry(self):
3592 if not self.mesh or not self.mesh.GetMesh(): return entry
3593 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3594 study = self.mesh.smeshpyD.GetCurrentStudy()
3595 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3596 sobj = study.FindObjectIOR(ior)
3597 if sobj: entry = sobj.GetID()
3598 if not entry: return ""
3601 # Public class: Mesh_Segment
3602 # --------------------------
3604 ## Class to define a segment 1D algorithm for discretization
3607 # @ingroup l3_algos_basic
3608 class Mesh_Segment(Mesh_Algorithm):
3610 ## Private constructor.
3611 def __init__(self, mesh, geom=0):
3612 Mesh_Algorithm.__init__(self)
3613 self.Create(mesh, geom, "Regular_1D")
3615 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3616 # @param l for the length of segments that cut an edge
3617 # @param UseExisting if ==true - searches for an existing hypothesis created with
3618 # the same parameters, else (default) - creates a new one
3619 # @param p precision, used for calculation of the number of segments.
3620 # The precision should be a positive, meaningful value within the range [0,1].
3621 # In general, the number of segments is calculated with the formula:
3622 # nb = ceil((edge_length / l) - p)
3623 # Function ceil rounds its argument to the higher integer.
3624 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3625 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3626 # p=1 means rounding of (edge_length / l) to the lower integer.
3627 # Default value is 1e-07.
3628 # @return an instance of StdMeshers_LocalLength hypothesis
3629 # @ingroup l3_hypos_1dhyps
3630 def LocalLength(self, l, UseExisting=0, p=1e-07):
3631 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3632 CompareMethod=self.CompareLocalLength)
3638 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3639 def CompareLocalLength(self, hyp, args):
3640 if IsEqual(hyp.GetLength(), args[0]):
3641 return IsEqual(hyp.GetPrecision(), args[1])
3644 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3645 # @param length is optional maximal allowed length of segment, if it is omitted
3646 # the preestimated length is used that depends on geometry size
3647 # @param UseExisting if ==true - searches for an existing hypothesis created with
3648 # the same parameters, else (default) - create a new one
3649 # @return an instance of StdMeshers_MaxLength hypothesis
3650 # @ingroup l3_hypos_1dhyps
3651 def MaxSize(self, length=0.0, UseExisting=0):
3652 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3655 hyp.SetLength(length)
3657 # set preestimated length
3658 gen = self.mesh.smeshpyD
3659 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3660 self.mesh.GetMesh(), self.mesh.GetShape(),
3662 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3664 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3667 hyp.SetUsePreestimatedLength( length == 0.0 )
3670 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3671 # @param n for the number of segments that cut an edge
3672 # @param s for the scale factor (optional)
3673 # @param reversedEdges is a list of edges to mesh using reversed orientation
3674 # @param UseExisting if ==true - searches for an existing hypothesis created with
3675 # the same parameters, else (default) - create a new one
3676 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3677 # @ingroup l3_hypos_1dhyps
3678 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3679 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3680 reversedEdges, UseExisting = [], reversedEdges
3681 entry = self.MainShapeEntry()
3683 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3684 UseExisting=UseExisting,
3685 CompareMethod=self.CompareNumberOfSegments)
3687 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3688 UseExisting=UseExisting,
3689 CompareMethod=self.CompareNumberOfSegments)
3690 hyp.SetDistrType( 1 )
3691 hyp.SetScaleFactor(s)
3692 hyp.SetNumberOfSegments(n)
3693 hyp.SetReversedEdges( reversedEdges )
3694 hyp.SetObjectEntry( entry )
3698 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3699 def CompareNumberOfSegments(self, hyp, args):
3700 if hyp.GetNumberOfSegments() == args[0]:
3702 if hyp.GetReversedEdges() == args[1]:
3703 if not args[1] or hyp.GetObjectEntry() == args[2]:
3706 if hyp.GetReversedEdges() == args[2]:
3707 if not args[2] or hyp.GetObjectEntry() == args[3]:
3708 if hyp.GetDistrType() == 1:
3709 if IsEqual(hyp.GetScaleFactor(), args[1]):
3713 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3714 # @param start defines the length of the first segment
3715 # @param end defines the length of the last segment
3716 # @param reversedEdges is a list of edges to mesh using reversed orientation
3717 # @param UseExisting if ==true - searches for an existing hypothesis created with
3718 # the same parameters, else (default) - creates a new one
3719 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3720 # @ingroup l3_hypos_1dhyps
3721 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3722 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3723 reversedEdges, UseExisting = [], reversedEdges
3724 entry = self.MainShapeEntry()
3725 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
3726 UseExisting=UseExisting,
3727 CompareMethod=self.CompareArithmetic1D)
3728 hyp.SetStartLength(start)
3729 hyp.SetEndLength(end)
3730 hyp.SetReversedEdges( reversedEdges )
3731 hyp.SetObjectEntry( entry )
3735 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3736 def CompareArithmetic1D(self, hyp, args):
3737 if IsEqual(hyp.GetLength(1), args[0]):
3738 if IsEqual(hyp.GetLength(0), args[1]):
3739 if hyp.GetReversedEdges() == args[2]:
3740 if not args[2] or hyp.GetObjectEntry() == args[3]:
3745 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
3746 # on curve from 0 to 1 (additionally it is neecessary to check
3747 # orientation of edges and create list of reversed edges if it is
3748 # needed) and sets numbers of segments between given points (default
3749 # values are equals 1
3750 # @param points defines the list of parameters on curve
3751 # @param nbSegs defines the list of numbers of segments
3752 # @param reversedEdges is a list of edges to mesh using reversed orientation
3753 # @param UseExisting if ==true - searches for an existing hypothesis created with
3754 # the same parameters, else (default) - creates a new one
3755 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3756 # @ingroup l3_hypos_1dhyps
3757 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
3758 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3759 reversedEdges, UseExisting = [], reversedEdges
3760 entry = self.MainShapeEntry()
3761 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
3762 UseExisting=UseExisting,
3763 CompareMethod=self.CompareArithmetic1D)
3764 hyp.SetPoints(points)
3765 hyp.SetNbSegments(nbSegs)
3766 hyp.SetReversedEdges(reversedEdges)
3767 hyp.SetObjectEntry(entry)
3771 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
3772 ## as the given arguments
3773 def CompareFixedPoints1D(self, hyp, args):
3774 if hyp.GetPoints() == args[0]:
3775 if hyp.GetNbSegments() == args[1]:
3776 if hyp.GetReversedEdges() == args[2]:
3777 if not args[2] or hyp.GetObjectEntry() == args[3]:
3783 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3784 # @param start defines the length of the first segment
3785 # @param end defines the length of the last segment
3786 # @param reversedEdges is a list of edges to mesh using reversed orientation
3787 # @param UseExisting if ==true - searches for an existing hypothesis created with
3788 # the same parameters, else (default) - creates a new one
3789 # @return an instance of StdMeshers_StartEndLength hypothesis
3790 # @ingroup l3_hypos_1dhyps
3791 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3792 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3793 reversedEdges, UseExisting = [], reversedEdges
3794 entry = self.MainShapeEntry()
3795 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3796 UseExisting=UseExisting,
3797 CompareMethod=self.CompareStartEndLength)
3798 hyp.SetStartLength(start)
3799 hyp.SetEndLength(end)
3800 hyp.SetReversedEdges( reversedEdges )
3801 hyp.SetObjectEntry( entry )
3804 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3805 def CompareStartEndLength(self, hyp, args):
3806 if IsEqual(hyp.GetLength(1), args[0]):
3807 if IsEqual(hyp.GetLength(0), args[1]):
3808 if hyp.GetReversedEdges() == args[2]:
3809 if not args[2] or hyp.GetObjectEntry() == args[3]:
3813 ## Defines "Deflection1D" hypothesis
3814 # @param d for the deflection
3815 # @param UseExisting if ==true - searches for an existing hypothesis created with
3816 # the same parameters, else (default) - create a new one
3817 # @ingroup l3_hypos_1dhyps
3818 def Deflection1D(self, d, UseExisting=0):
3819 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3820 CompareMethod=self.CompareDeflection1D)
3821 hyp.SetDeflection(d)
3824 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3825 def CompareDeflection1D(self, hyp, args):
3826 return IsEqual(hyp.GetDeflection(), args[0])
3828 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3829 # the opposite side in case of quadrangular faces
3830 # @ingroup l3_hypos_additi
3831 def Propagation(self):
3832 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3834 ## Defines "AutomaticLength" hypothesis
3835 # @param fineness for the fineness [0-1]
3836 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3837 # same parameters, else (default) - create a new one
3838 # @ingroup l3_hypos_1dhyps
3839 def AutomaticLength(self, fineness=0, UseExisting=0):
3840 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3841 CompareMethod=self.CompareAutomaticLength)
3842 hyp.SetFineness( fineness )
3845 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3846 def CompareAutomaticLength(self, hyp, args):
3847 return IsEqual(hyp.GetFineness(), args[0])
3849 ## Defines "SegmentLengthAroundVertex" hypothesis
3850 # @param length for the segment length
3851 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3852 # Any other integer value means that the hypothesis will be set on the
3853 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3854 # @param UseExisting if ==true - searches for an existing hypothesis created with
3855 # the same parameters, else (default) - creates a new one
3856 # @ingroup l3_algos_segmarv
3857 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3859 store_geom = self.geom
3860 if type(vertex) is types.IntType:
3861 if vertex == 0 or vertex == 1:
3862 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3870 if self.geom is None:
3871 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3872 name = GetName(self.geom)
3874 piece = self.mesh.geom
3875 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3876 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3877 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3879 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3881 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3882 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3884 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3885 CompareMethod=self.CompareLengthNearVertex)
3886 self.geom = store_geom
3887 hyp.SetLength( length )
3890 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3891 # @ingroup l3_algos_segmarv
3892 def CompareLengthNearVertex(self, hyp, args):
3893 return IsEqual(hyp.GetLength(), args[0])
3895 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3896 # If the 2D mesher sees that all boundary edges are quadratic,
3897 # it generates quadratic faces, else it generates linear faces using
3898 # medium nodes as if they are vertices.
3899 # The 3D mesher generates quadratic volumes only if all boundary faces
3900 # are quadratic, else it fails.
3902 # @ingroup l3_hypos_additi
3903 def QuadraticMesh(self):
3904 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3907 # Public class: Mesh_CompositeSegment
3908 # --------------------------
3910 ## Defines a segment 1D algorithm for discretization
3912 # @ingroup l3_algos_basic
3913 class Mesh_CompositeSegment(Mesh_Segment):
3915 ## Private constructor.
3916 def __init__(self, mesh, geom=0):
3917 self.Create(mesh, geom, "CompositeSegment_1D")
3920 # Public class: Mesh_Segment_Python
3921 # ---------------------------------
3923 ## Defines a segment 1D algorithm for discretization with python function
3925 # @ingroup l3_algos_basic
3926 class Mesh_Segment_Python(Mesh_Segment):
3928 ## Private constructor.
3929 def __init__(self, mesh, geom=0):
3930 import Python1dPlugin
3931 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3933 ## Defines "PythonSplit1D" hypothesis
3934 # @param n for the number of segments that cut an edge
3935 # @param func for the python function that calculates the length of all segments
3936 # @param UseExisting if ==true - searches for the existing hypothesis created with
3937 # the same parameters, else (default) - creates a new one
3938 # @ingroup l3_hypos_1dhyps
3939 def PythonSplit1D(self, n, func, UseExisting=0):
3940 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3941 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3942 hyp.SetNumberOfSegments(n)
3943 hyp.SetPythonLog10RatioFunction(func)
3946 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3947 def ComparePythonSplit1D(self, hyp, args):
3948 #if hyp.GetNumberOfSegments() == args[0]:
3949 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3953 # Public class: Mesh_Triangle
3954 # ---------------------------
3956 ## Defines a triangle 2D algorithm
3958 # @ingroup l3_algos_basic
3959 class Mesh_Triangle(Mesh_Algorithm):
3968 ## Private constructor.
3969 def __init__(self, mesh, algoType, geom=0):
3970 Mesh_Algorithm.__init__(self)
3972 self.algoType = algoType
3973 if algoType == MEFISTO:
3974 self.Create(mesh, geom, "MEFISTO_2D")
3976 elif algoType == BLSURF:
3978 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3979 #self.SetPhysicalMesh() - PAL19680
3980 elif algoType == NETGEN:
3982 print "Warning: NETGENPlugin module unavailable"
3984 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3986 elif algoType == NETGEN_2D:
3988 print "Warning: NETGENPlugin module unavailable"
3990 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3993 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3994 # @param area for the maximum area of each triangle
3995 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3996 # same parameters, else (default) - creates a new one
3998 # Only for algoType == MEFISTO || NETGEN_2D
3999 # @ingroup l3_hypos_2dhyps
4000 def MaxElementArea(self, area, UseExisting=0):
4001 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4002 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4003 CompareMethod=self.CompareMaxElementArea)
4004 elif self.algoType == NETGEN:
4005 hyp = self.Parameters(SIMPLE)
4006 hyp.SetMaxElementArea(area)
4009 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4010 def CompareMaxElementArea(self, hyp, args):
4011 return IsEqual(hyp.GetMaxElementArea(), args[0])
4013 ## Defines "LengthFromEdges" hypothesis to build triangles
4014 # based on the length of the edges taken from the wire
4016 # Only for algoType == MEFISTO || NETGEN_2D
4017 # @ingroup l3_hypos_2dhyps
4018 def LengthFromEdges(self):
4019 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4020 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4022 elif self.algoType == NETGEN:
4023 hyp = self.Parameters(SIMPLE)
4024 hyp.LengthFromEdges()
4027 ## Sets a way to define size of mesh elements to generate.
4028 # @param thePhysicalMesh is: DefaultSize or Custom.
4029 # @ingroup l3_hypos_blsurf
4030 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4031 # Parameter of BLSURF algo
4032 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4034 ## Sets size of mesh elements to generate.
4035 # @ingroup l3_hypos_blsurf
4036 def SetPhySize(self, theVal):
4037 # Parameter of BLSURF algo
4038 self.Parameters().SetPhySize(theVal)
4040 ## Sets lower boundary of mesh element size (PhySize).
4041 # @ingroup l3_hypos_blsurf
4042 def SetPhyMin(self, theVal=-1):
4043 # Parameter of BLSURF algo
4044 self.Parameters().SetPhyMin(theVal)
4046 ## Sets upper boundary of mesh element size (PhySize).
4047 # @ingroup l3_hypos_blsurf
4048 def SetPhyMax(self, theVal=-1):
4049 # Parameter of BLSURF algo
4050 self.Parameters().SetPhyMax(theVal)
4052 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4053 # @param theGeometricMesh is: DefaultGeom or Custom
4054 # @ingroup l3_hypos_blsurf
4055 def SetGeometricMesh(self, theGeometricMesh=0):
4056 # Parameter of BLSURF algo
4057 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4058 self.params.SetGeometricMesh(theGeometricMesh)
4060 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4061 # @ingroup l3_hypos_blsurf
4062 def SetAngleMeshS(self, theVal=_angleMeshS):
4063 # Parameter of BLSURF algo
4064 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4065 self.params.SetAngleMeshS(theVal)
4067 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4068 # @ingroup l3_hypos_blsurf
4069 def SetAngleMeshC(self, theVal=_angleMeshS):
4070 # Parameter of BLSURF algo
4071 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4072 self.params.SetAngleMeshC(theVal)
4074 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4075 # @ingroup l3_hypos_blsurf
4076 def SetGeoMin(self, theVal=-1):
4077 # Parameter of BLSURF algo
4078 self.Parameters().SetGeoMin(theVal)
4080 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4081 # @ingroup l3_hypos_blsurf
4082 def SetGeoMax(self, theVal=-1):
4083 # Parameter of BLSURF algo
4084 self.Parameters().SetGeoMax(theVal)
4086 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4087 # @ingroup l3_hypos_blsurf
4088 def SetGradation(self, theVal=_gradation):
4089 # Parameter of BLSURF algo
4090 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4091 self.params.SetGradation(theVal)
4093 ## Sets topology usage way.
4094 # @param way defines how mesh conformity is assured <ul>
4095 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4096 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4097 # @ingroup l3_hypos_blsurf
4098 def SetTopology(self, way):
4099 # Parameter of BLSURF algo
4100 self.Parameters().SetTopology(way)
4102 ## To respect geometrical edges or not.
4103 # @ingroup l3_hypos_blsurf
4104 def SetDecimesh(self, toIgnoreEdges=False):
4105 # Parameter of BLSURF algo
4106 self.Parameters().SetDecimesh(toIgnoreEdges)
4108 ## Sets verbosity level in the range 0 to 100.
4109 # @ingroup l3_hypos_blsurf
4110 def SetVerbosity(self, level):
4111 # Parameter of BLSURF algo
4112 self.Parameters().SetVerbosity(level)
4114 ## Sets advanced option value.
4115 # @ingroup l3_hypos_blsurf
4116 def SetOptionValue(self, optionName, level):
4117 # Parameter of BLSURF algo
4118 self.Parameters().SetOptionValue(optionName,level)
4120 ## Sets QuadAllowed flag.
4121 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4122 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4123 def SetQuadAllowed(self, toAllow=True):
4124 if self.algoType == NETGEN_2D:
4125 if toAllow: # add QuadranglePreference
4126 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4127 else: # remove QuadranglePreference
4128 for hyp in self.mesh.GetHypothesisList( self.geom ):
4129 if hyp.GetName() == "QuadranglePreference":
4130 self.mesh.RemoveHypothesis( self.geom, hyp )
4135 if self.Parameters():
4136 self.params.SetQuadAllowed(toAllow)
4139 ## Defines hypothesis having several parameters
4141 # @ingroup l3_hypos_netgen
4142 def Parameters(self, which=SOLE):
4145 if self.algoType == NETGEN:
4147 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4148 "libNETGENEngine.so", UseExisting=0)
4150 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4151 "libNETGENEngine.so", UseExisting=0)
4153 elif self.algoType == MEFISTO:
4154 print "Mefisto algo support no multi-parameter hypothesis"
4156 elif self.algoType == NETGEN_2D:
4157 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4158 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4160 elif self.algoType == BLSURF:
4161 self.params = self.Hypothesis("BLSURF_Parameters", [],
4162 "libBLSURFEngine.so", UseExisting=0)
4165 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4170 # Only for algoType == NETGEN
4171 # @ingroup l3_hypos_netgen
4172 def SetMaxSize(self, theSize):
4173 if self.Parameters():
4174 self.params.SetMaxSize(theSize)
4176 ## Sets SecondOrder flag
4178 # Only for algoType == NETGEN
4179 # @ingroup l3_hypos_netgen
4180 def SetSecondOrder(self, theVal):
4181 if self.Parameters():
4182 self.params.SetSecondOrder(theVal)
4184 ## Sets Optimize flag
4186 # Only for algoType == NETGEN
4187 # @ingroup l3_hypos_netgen
4188 def SetOptimize(self, theVal):
4189 if self.Parameters():
4190 self.params.SetOptimize(theVal)
4193 # @param theFineness is:
4194 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4196 # Only for algoType == NETGEN
4197 # @ingroup l3_hypos_netgen
4198 def SetFineness(self, theFineness):
4199 if self.Parameters():
4200 self.params.SetFineness(theFineness)
4204 # Only for algoType == NETGEN
4205 # @ingroup l3_hypos_netgen
4206 def SetGrowthRate(self, theRate):
4207 if self.Parameters():
4208 self.params.SetGrowthRate(theRate)
4210 ## Sets NbSegPerEdge
4212 # Only for algoType == NETGEN
4213 # @ingroup l3_hypos_netgen
4214 def SetNbSegPerEdge(self, theVal):
4215 if self.Parameters():
4216 self.params.SetNbSegPerEdge(theVal)
4218 ## Sets NbSegPerRadius
4220 # Only for algoType == NETGEN
4221 # @ingroup l3_hypos_netgen
4222 def SetNbSegPerRadius(self, theVal):
4223 if self.Parameters():
4224 self.params.SetNbSegPerRadius(theVal)
4226 ## Sets number of segments overriding value set by SetLocalLength()
4228 # Only for algoType == NETGEN
4229 # @ingroup l3_hypos_netgen
4230 def SetNumberOfSegments(self, theVal):
4231 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4233 ## Sets number of segments overriding value set by SetNumberOfSegments()
4235 # Only for algoType == NETGEN
4236 # @ingroup l3_hypos_netgen
4237 def SetLocalLength(self, theVal):
4238 self.Parameters(SIMPLE).SetLocalLength(theVal)
4243 # Public class: Mesh_Quadrangle
4244 # -----------------------------
4246 ## Defines a quadrangle 2D algorithm
4248 # @ingroup l3_algos_basic
4249 class Mesh_Quadrangle(Mesh_Algorithm):
4251 ## Private constructor.
4252 def __init__(self, mesh, geom=0):
4253 Mesh_Algorithm.__init__(self)
4254 self.Create(mesh, geom, "Quadrangle_2D")
4256 ## Defines "QuadranglePreference" hypothesis, forcing construction
4257 # of quadrangles if the number of nodes on the opposite edges is not the same
4258 # while the total number of nodes on edges is even
4260 # @ingroup l3_hypos_additi
4261 def QuadranglePreference(self):
4262 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4263 CompareMethod=self.CompareEqualHyp)
4266 ## Defines "TrianglePreference" hypothesis, forcing construction
4267 # of triangles in the refinement area if the number of nodes
4268 # on the opposite edges is not the same
4270 # @ingroup l3_hypos_additi
4271 def TrianglePreference(self):
4272 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4273 CompareMethod=self.CompareEqualHyp)
4276 # Public class: Mesh_Tetrahedron
4277 # ------------------------------
4279 ## Defines a tetrahedron 3D algorithm
4281 # @ingroup l3_algos_basic
4282 class Mesh_Tetrahedron(Mesh_Algorithm):
4287 ## Private constructor.
4288 def __init__(self, mesh, algoType, geom=0):
4289 Mesh_Algorithm.__init__(self)
4291 if algoType == NETGEN:
4292 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4295 elif algoType == FULL_NETGEN:
4297 print "Warning: NETGENPlugin module has not been imported."
4298 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4301 elif algoType == GHS3D:
4303 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4306 elif algoType == GHS3DPRL:
4307 import GHS3DPRLPlugin
4308 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4311 self.algoType = algoType
4313 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4314 # @param vol for the maximum volume of each tetrahedron
4315 # @param UseExisting if ==true - searches for the existing hypothesis created with
4316 # the same parameters, else (default) - creates a new one
4317 # @ingroup l3_hypos_maxvol
4318 def MaxElementVolume(self, vol, UseExisting=0):
4319 if self.algoType == NETGEN:
4320 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4321 CompareMethod=self.CompareMaxElementVolume)
4322 hyp.SetMaxElementVolume(vol)
4324 elif self.algoType == FULL_NETGEN:
4325 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4328 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4329 def CompareMaxElementVolume(self, hyp, args):
4330 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4332 ## Defines hypothesis having several parameters
4334 # @ingroup l3_hypos_netgen
4335 def Parameters(self, which=SOLE):
4339 if self.algoType == FULL_NETGEN:
4341 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4342 "libNETGENEngine.so", UseExisting=0)
4344 self.params = self.Hypothesis("NETGEN_Parameters", [],
4345 "libNETGENEngine.so", UseExisting=0)
4348 if self.algoType == GHS3D:
4349 self.params = self.Hypothesis("GHS3D_Parameters", [],
4350 "libGHS3DEngine.so", UseExisting=0)
4353 if self.algoType == GHS3DPRL:
4354 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4355 "libGHS3DPRLEngine.so", UseExisting=0)
4358 print "Algo supports no multi-parameter hypothesis"
4362 # Parameter of FULL_NETGEN
4363 # @ingroup l3_hypos_netgen
4364 def SetMaxSize(self, theSize):
4365 self.Parameters().SetMaxSize(theSize)
4367 ## Sets SecondOrder flag
4368 # Parameter of FULL_NETGEN
4369 # @ingroup l3_hypos_netgen
4370 def SetSecondOrder(self, theVal):
4371 self.Parameters().SetSecondOrder(theVal)
4373 ## Sets Optimize flag
4374 # Parameter of FULL_NETGEN
4375 # @ingroup l3_hypos_netgen
4376 def SetOptimize(self, theVal):
4377 self.Parameters().SetOptimize(theVal)
4380 # @param theFineness is:
4381 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4382 # Parameter of FULL_NETGEN
4383 # @ingroup l3_hypos_netgen
4384 def SetFineness(self, theFineness):
4385 self.Parameters().SetFineness(theFineness)
4388 # Parameter of FULL_NETGEN
4389 # @ingroup l3_hypos_netgen
4390 def SetGrowthRate(self, theRate):
4391 self.Parameters().SetGrowthRate(theRate)
4393 ## Sets NbSegPerEdge
4394 # Parameter of FULL_NETGEN
4395 # @ingroup l3_hypos_netgen
4396 def SetNbSegPerEdge(self, theVal):
4397 self.Parameters().SetNbSegPerEdge(theVal)
4399 ## Sets NbSegPerRadius
4400 # Parameter of FULL_NETGEN
4401 # @ingroup l3_hypos_netgen
4402 def SetNbSegPerRadius(self, theVal):
4403 self.Parameters().SetNbSegPerRadius(theVal)
4405 ## Sets number of segments overriding value set by SetLocalLength()
4406 # Only for algoType == NETGEN_FULL
4407 # @ingroup l3_hypos_netgen
4408 def SetNumberOfSegments(self, theVal):
4409 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4411 ## Sets number of segments overriding value set by SetNumberOfSegments()
4412 # Only for algoType == NETGEN_FULL
4413 # @ingroup l3_hypos_netgen
4414 def SetLocalLength(self, theVal):
4415 self.Parameters(SIMPLE).SetLocalLength(theVal)
4417 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4418 # Overrides value set by LengthFromEdges()
4419 # Only for algoType == NETGEN_FULL
4420 # @ingroup l3_hypos_netgen
4421 def MaxElementArea(self, area):
4422 self.Parameters(SIMPLE).SetMaxElementArea(area)
4424 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4425 # Overrides value set by MaxElementArea()
4426 # Only for algoType == NETGEN_FULL
4427 # @ingroup l3_hypos_netgen
4428 def LengthFromEdges(self):
4429 self.Parameters(SIMPLE).LengthFromEdges()
4431 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4432 # Overrides value set by MaxElementVolume()
4433 # Only for algoType == NETGEN_FULL
4434 # @ingroup l3_hypos_netgen
4435 def LengthFromFaces(self):
4436 self.Parameters(SIMPLE).LengthFromFaces()
4438 ## To mesh "holes" in a solid or not. Default is to mesh.
4439 # @ingroup l3_hypos_ghs3dh
4440 def SetToMeshHoles(self, toMesh):
4441 # Parameter of GHS3D
4442 self.Parameters().SetToMeshHoles(toMesh)
4444 ## Set Optimization level:
4445 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
4446 # Default is Medium_Optimization
4447 # @ingroup l3_hypos_ghs3dh
4448 def SetOptimizationLevel(self, level):
4449 # Parameter of GHS3D
4450 self.Parameters().SetOptimizationLevel(level)
4452 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4453 # @ingroup l3_hypos_ghs3dh
4454 def SetMaximumMemory(self, MB):
4455 # Advanced parameter of GHS3D
4456 self.Parameters().SetMaximumMemory(MB)
4458 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4459 # automatic memory adjustment mode.
4460 # @ingroup l3_hypos_ghs3dh
4461 def SetInitialMemory(self, MB):
4462 # Advanced parameter of GHS3D
4463 self.Parameters().SetInitialMemory(MB)
4465 ## Path to working directory.
4466 # @ingroup l3_hypos_ghs3dh
4467 def SetWorkingDirectory(self, path):
4468 # Advanced parameter of GHS3D
4469 self.Parameters().SetWorkingDirectory(path)
4471 ## To keep working files or remove them. Log file remains in case of errors anyway.
4472 # @ingroup l3_hypos_ghs3dh
4473 def SetKeepFiles(self, toKeep):
4474 # Advanced parameter of GHS3D and GHS3DPRL
4475 self.Parameters().SetKeepFiles(toKeep)
4477 ## To set verbose level [0-10]. <ul>
4478 #<li> 0 - no standard output,
4479 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4480 # indicates when the final mesh is being saved. In addition the software
4481 # gives indication regarding the CPU time.
4482 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4483 # histogram of the skin mesh, quality statistics histogram together with
4484 # the characteristics of the final mesh.</ul>
4485 # @ingroup l3_hypos_ghs3dh
4486 def SetVerboseLevel(self, level):
4487 # Advanced parameter of GHS3D
4488 self.Parameters().SetVerboseLevel(level)
4490 ## To create new nodes.
4491 # @ingroup l3_hypos_ghs3dh
4492 def SetToCreateNewNodes(self, toCreate):
4493 # Advanced parameter of GHS3D
4494 self.Parameters().SetToCreateNewNodes(toCreate)
4496 ## To use boundary recovery version which tries to create mesh on a very poor
4497 # quality surface mesh.
4498 # @ingroup l3_hypos_ghs3dh
4499 def SetToUseBoundaryRecoveryVersion(self, toUse):
4500 # Advanced parameter of GHS3D
4501 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4503 ## Sets command line option as text.
4504 # @ingroup l3_hypos_ghs3dh
4505 def SetTextOption(self, option):
4506 # Advanced parameter of GHS3D
4507 self.Parameters().SetTextOption(option)
4509 ## Sets MED files name and path.
4510 def SetMEDName(self, value):
4511 self.Parameters().SetMEDName(value)
4513 ## Sets the number of partition of the initial mesh
4514 def SetNbPart(self, value):
4515 self.Parameters().SetNbPart(value)
4517 ## When big mesh, start tepal in background
4518 def SetBackground(self, value):
4519 self.Parameters().SetBackground(value)
4521 # Public class: Mesh_Hexahedron
4522 # ------------------------------
4524 ## Defines a hexahedron 3D algorithm
4526 # @ingroup l3_algos_basic
4527 class Mesh_Hexahedron(Mesh_Algorithm):
4532 ## Private constructor.
4533 def __init__(self, mesh, algoType=Hexa, geom=0):
4534 Mesh_Algorithm.__init__(self)
4536 self.algoType = algoType
4538 if algoType == Hexa:
4539 self.Create(mesh, geom, "Hexa_3D")
4542 elif algoType == Hexotic:
4543 import HexoticPlugin
4544 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4547 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4548 # @ingroup l3_hypos_hexotic
4549 def MinMaxQuad(self, min=3, max=8, quad=True):
4550 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4552 self.params.SetHexesMinLevel(min)
4553 self.params.SetHexesMaxLevel(max)
4554 self.params.SetHexoticQuadrangles(quad)
4557 # Deprecated, only for compatibility!
4558 # Public class: Mesh_Netgen
4559 # ------------------------------
4561 ## Defines a NETGEN-based 2D or 3D algorithm
4562 # that needs no discrete boundary (i.e. independent)
4564 # This class is deprecated, only for compatibility!
4567 # @ingroup l3_algos_basic
4568 class Mesh_Netgen(Mesh_Algorithm):
4572 ## Private constructor.
4573 def __init__(self, mesh, is3D, geom=0):
4574 Mesh_Algorithm.__init__(self)
4577 print "Warning: NETGENPlugin module has not been imported."
4581 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4585 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4588 ## Defines the hypothesis containing parameters of the algorithm
4589 def Parameters(self):
4591 hyp = self.Hypothesis("NETGEN_Parameters", [],
4592 "libNETGENEngine.so", UseExisting=0)
4594 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4595 "libNETGENEngine.so", UseExisting=0)
4598 # Public class: Mesh_Projection1D
4599 # ------------------------------
4601 ## Defines a projection 1D algorithm
4602 # @ingroup l3_algos_proj
4604 class Mesh_Projection1D(Mesh_Algorithm):
4606 ## Private constructor.
4607 def __init__(self, mesh, geom=0):
4608 Mesh_Algorithm.__init__(self)
4609 self.Create(mesh, geom, "Projection_1D")
4611 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4612 # a mesh pattern is taken, and, optionally, the association of vertices
4613 # between the source edge and a target edge (to which a hypothesis is assigned)
4614 # @param edge from which nodes distribution is taken
4615 # @param mesh from which nodes distribution is taken (optional)
4616 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4617 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4618 # to associate with \a srcV (optional)
4619 # @param UseExisting if ==true - searches for the existing hypothesis created with
4620 # the same parameters, else (default) - creates a new one
4621 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4622 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4624 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4625 hyp.SetSourceEdge( edge )
4626 if not mesh is None and isinstance(mesh, Mesh):
4627 mesh = mesh.GetMesh()
4628 hyp.SetSourceMesh( mesh )
4629 hyp.SetVertexAssociation( srcV, tgtV )
4632 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4633 #def CompareSourceEdge(self, hyp, args):
4634 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4638 # Public class: Mesh_Projection2D
4639 # ------------------------------
4641 ## Defines a projection 2D algorithm
4642 # @ingroup l3_algos_proj
4644 class Mesh_Projection2D(Mesh_Algorithm):
4646 ## Private constructor.
4647 def __init__(self, mesh, geom=0):
4648 Mesh_Algorithm.__init__(self)
4649 self.Create(mesh, geom, "Projection_2D")
4651 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4652 # a mesh pattern is taken, and, optionally, the association of vertices
4653 # between the source face and the target face (to which a hypothesis is assigned)
4654 # @param face from which the mesh pattern is taken
4655 # @param mesh from which the mesh pattern is taken (optional)
4656 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4657 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4658 # to associate with \a srcV1 (optional)
4659 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4660 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4661 # to associate with \a srcV2 (optional)
4662 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4663 # the same parameters, else (default) - forces the creation a new one
4665 # Note: all association vertices must belong to one edge of a face
4666 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4667 srcV2=None, tgtV2=None, UseExisting=0):
4668 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4670 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4671 hyp.SetSourceFace( face )
4672 if not mesh is None and isinstance(mesh, Mesh):
4673 mesh = mesh.GetMesh()
4674 hyp.SetSourceMesh( mesh )
4675 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4678 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4679 #def CompareSourceFace(self, hyp, args):
4680 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4683 # Public class: Mesh_Projection3D
4684 # ------------------------------
4686 ## Defines a projection 3D algorithm
4687 # @ingroup l3_algos_proj
4689 class Mesh_Projection3D(Mesh_Algorithm):
4691 ## Private constructor.
4692 def __init__(self, mesh, geom=0):
4693 Mesh_Algorithm.__init__(self)
4694 self.Create(mesh, geom, "Projection_3D")
4696 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4697 # the mesh pattern is taken, and, optionally, the association of vertices
4698 # between the source and the target solid (to which a hipothesis is assigned)
4699 # @param solid from where the mesh pattern is taken
4700 # @param mesh from where the mesh pattern is taken (optional)
4701 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4702 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4703 # to associate with \a srcV1 (optional)
4704 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4705 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4706 # to associate with \a srcV2 (optional)
4707 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4708 # the same parameters, else (default) - creates a new one
4710 # Note: association vertices must belong to one edge of a solid
4711 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4712 srcV2=0, tgtV2=0, UseExisting=0):
4713 hyp = self.Hypothesis("ProjectionSource3D",
4714 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4716 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4717 hyp.SetSource3DShape( solid )
4718 if not mesh is None and isinstance(mesh, Mesh):
4719 mesh = mesh.GetMesh()
4720 hyp.SetSourceMesh( mesh )
4721 if srcV1 and srcV2 and tgtV1 and tgtV2:
4722 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4723 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4726 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4727 #def CompareSourceShape3D(self, hyp, args):
4728 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4732 # Public class: Mesh_Prism
4733 # ------------------------
4735 ## Defines a 3D extrusion algorithm
4736 # @ingroup l3_algos_3dextr
4738 class Mesh_Prism3D(Mesh_Algorithm):
4740 ## Private constructor.
4741 def __init__(self, mesh, geom=0):
4742 Mesh_Algorithm.__init__(self)
4743 self.Create(mesh, geom, "Prism_3D")
4745 # Public class: Mesh_RadialPrism
4746 # -------------------------------
4748 ## Defines a Radial Prism 3D algorithm
4749 # @ingroup l3_algos_radialp
4751 class Mesh_RadialPrism3D(Mesh_Algorithm):
4753 ## Private constructor.
4754 def __init__(self, mesh, geom=0):
4755 Mesh_Algorithm.__init__(self)
4756 self.Create(mesh, geom, "RadialPrism_3D")
4758 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4759 self.nbLayers = None
4761 ## Return 3D hypothesis holding the 1D one
4762 def Get3DHypothesis(self):
4763 return self.distribHyp
4765 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4766 # hypothesis. Returns the created hypothesis
4767 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4768 #print "OwnHypothesis",hypType
4769 if not self.nbLayers is None:
4770 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4771 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4772 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4773 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4774 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4775 self.distribHyp.SetLayerDistribution( hyp )
4778 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4779 # prisms to build between the inner and outer shells
4780 # @param n number of layers
4781 # @param UseExisting if ==true - searches for the existing hypothesis created with
4782 # the same parameters, else (default) - creates a new one
4783 def NumberOfLayers(self, n, UseExisting=0):
4784 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4785 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4786 CompareMethod=self.CompareNumberOfLayers)
4787 self.nbLayers.SetNumberOfLayers( n )
4788 return self.nbLayers
4790 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4791 def CompareNumberOfLayers(self, hyp, args):
4792 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4794 ## Defines "LocalLength" hypothesis, specifying the segment length
4795 # to build between the inner and the outer shells
4796 # @param l the length of segments
4797 # @param p the precision of rounding
4798 def LocalLength(self, l, p=1e-07):
4799 hyp = self.OwnHypothesis("LocalLength", [l,p])
4804 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4805 # prisms to build between the inner and the outer shells.
4806 # @param n the number of layers
4807 # @param s the scale factor (optional)
4808 def NumberOfSegments(self, n, s=[]):
4810 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4812 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4813 hyp.SetDistrType( 1 )
4814 hyp.SetScaleFactor(s)
4815 hyp.SetNumberOfSegments(n)
4818 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4819 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4820 # @param start the length of the first segment
4821 # @param end the length of the last segment
4822 def Arithmetic1D(self, start, end ):
4823 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4824 hyp.SetLength(start, 1)
4825 hyp.SetLength(end , 0)
4828 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4829 # to build between the inner and the outer shells as geometric length increasing
4830 # @param start for the length of the first segment
4831 # @param end for the length of the last segment
4832 def StartEndLength(self, start, end):
4833 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4834 hyp.SetLength(start, 1)
4835 hyp.SetLength(end , 0)
4838 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4839 # to build between the inner and outer shells
4840 # @param fineness defines the quality of the mesh within the range [0-1]
4841 def AutomaticLength(self, fineness=0):
4842 hyp = self.OwnHypothesis("AutomaticLength")
4843 hyp.SetFineness( fineness )
4846 # Public class: Mesh_RadialQuadrangle1D2D
4847 # -------------------------------
4849 ## Defines a Radial Quadrangle 1D2D algorithm
4850 # @ingroup l2_algos_radialq
4852 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
4854 ## Private constructor.
4855 def __init__(self, mesh, geom=0):
4856 Mesh_Algorithm.__init__(self)
4857 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
4859 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
4860 self.nbLayers = None
4862 ## Return 2D hypothesis holding the 1D one
4863 def Get2DHypothesis(self):
4864 return self.distribHyp
4866 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4867 # hypothesis. Returns the created hypothesis
4868 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4869 #print "OwnHypothesis",hypType
4870 if not self.nbLayers is None:
4871 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4872 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4873 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4874 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4875 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4876 self.distribHyp.SetLayerDistribution( hyp )
4879 ## Defines "NumberOfLayers2D" hypothesis, specifying the number of layers
4880 # @param n number of layers
4881 # @param UseExisting if ==true - searches for the existing hypothesis created with
4882 # the same parameters, else (default) - creates a new one
4883 def NumberOfLayers2D(self, n, UseExisting=0):
4884 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4885 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
4886 CompareMethod=self.CompareNumberOfLayers)
4887 self.nbLayers.SetNumberOfLayers( n )
4888 return self.nbLayers
4890 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4891 def CompareNumberOfLayers(self, hyp, args):
4892 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4894 ## Defines "LocalLength" hypothesis, specifying the segment length
4895 # @param l the length of segments
4896 # @param p the precision of rounding
4897 def LocalLength(self, l, p=1e-07):
4898 hyp = self.OwnHypothesis("LocalLength", [l,p])
4903 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
4904 # @param n the number of layers
4905 # @param s the scale factor (optional)
4906 def NumberOfSegments(self, n, s=[]):
4908 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4910 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4911 hyp.SetDistrType( 1 )
4912 hyp.SetScaleFactor(s)
4913 hyp.SetNumberOfSegments(n)
4916 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4917 # with a length that changes in arithmetic progression
4918 # @param start the length of the first segment
4919 # @param end the length of the last segment
4920 def Arithmetic1D(self, start, end ):
4921 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4922 hyp.SetLength(start, 1)
4923 hyp.SetLength(end , 0)
4926 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4927 # as geometric length increasing
4928 # @param start for the length of the first segment
4929 # @param end for the length of the last segment
4930 def StartEndLength(self, start, end):
4931 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4932 hyp.SetLength(start, 1)
4933 hyp.SetLength(end , 0)
4936 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4937 # @param fineness defines the quality of the mesh within the range [0-1]
4938 def AutomaticLength(self, fineness=0):
4939 hyp = self.OwnHypothesis("AutomaticLength")
4940 hyp.SetFineness( fineness )
4944 # Private class: Mesh_UseExisting
4945 # -------------------------------
4946 class Mesh_UseExisting(Mesh_Algorithm):
4948 def __init__(self, dim, mesh, geom=0):
4950 self.Create(mesh, geom, "UseExisting_1D")
4952 self.Create(mesh, geom, "UseExisting_2D")
4955 import salome_notebook
4956 notebook = salome_notebook.notebook
4958 ##Return values of the notebook variables
4959 def ParseParameters(last, nbParams,nbParam, value):
4963 listSize = len(last)
4964 for n in range(0,nbParams):
4966 if counter < listSize:
4967 strResult = strResult + last[counter]
4969 strResult = strResult + ""
4971 if isinstance(value, str):
4972 if notebook.isVariable(value):
4973 result = notebook.get(value)
4974 strResult=strResult+value
4976 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
4978 strResult=strResult+str(value)
4980 if nbParams - 1 != counter:
4981 strResult=strResult+var_separator #":"
4983 return result, strResult
4985 #Wrapper class for StdMeshers_LocalLength hypothesis
4986 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
4988 ## Set Length parameter value
4989 # @param length numerical value or name of variable from notebook
4990 def SetLength(self, length):
4991 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
4992 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4993 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
4995 ## Set Precision parameter value
4996 # @param precision numerical value or name of variable from notebook
4997 def SetPrecision(self, precision):
4998 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
4999 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5000 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5002 #Registering the new proxy for LocalLength
5003 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5006 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5007 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5009 def SetLayerDistribution(self, hypo):
5010 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5011 hypo.ClearParameters();
5012 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5014 #Registering the new proxy for LayerDistribution
5015 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5017 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5018 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5020 ## Set Length parameter value
5021 # @param length numerical value or name of variable from notebook
5022 def SetLength(self, length):
5023 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5024 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5025 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5027 #Registering the new proxy for SegmentLengthAroundVertex
5028 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5031 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5032 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5034 ## Set Length parameter value
5035 # @param length numerical value or name of variable from notebook
5036 # @param isStart true is length is Start Length, otherwise false
5037 def SetLength(self, length, isStart):
5041 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5042 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5043 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5045 #Registering the new proxy for Arithmetic1D
5046 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5048 #Wrapper class for StdMeshers_Deflection1D hypothesis
5049 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5051 ## Set Deflection parameter value
5052 # @param deflection numerical value or name of variable from notebook
5053 def SetDeflection(self, deflection):
5054 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5055 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5056 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5058 #Registering the new proxy for Deflection1D
5059 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5061 #Wrapper class for StdMeshers_StartEndLength hypothesis
5062 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5064 ## Set Length parameter value
5065 # @param length numerical value or name of variable from notebook
5066 # @param isStart true is length is Start Length, otherwise false
5067 def SetLength(self, length, isStart):
5071 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5072 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5073 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5075 #Registering the new proxy for StartEndLength
5076 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5078 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5079 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5081 ## Set Max Element Area parameter value
5082 # @param area numerical value or name of variable from notebook
5083 def SetMaxElementArea(self, area):
5084 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5085 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5086 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5088 #Registering the new proxy for MaxElementArea
5089 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5092 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5093 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5095 ## Set Max Element Volume parameter value
5096 # @param area numerical value or name of variable from notebook
5097 def SetMaxElementVolume(self, volume):
5098 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5099 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5100 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5102 #Registering the new proxy for MaxElementVolume
5103 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5106 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5107 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5109 ## Set Number Of Layers parameter value
5110 # @param nbLayers numerical value or name of variable from notebook
5111 def SetNumberOfLayers(self, nbLayers):
5112 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5113 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5114 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5116 #Registering the new proxy for NumberOfLayers
5117 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5119 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5120 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5122 ## Set Number Of Segments parameter value
5123 # @param nbSeg numerical value or name of variable from notebook
5124 def SetNumberOfSegments(self, nbSeg):
5125 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5126 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5127 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5128 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5130 ## Set Scale Factor parameter value
5131 # @param factor numerical value or name of variable from notebook
5132 def SetScaleFactor(self, factor):
5133 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5134 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5135 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5137 #Registering the new proxy for NumberOfSegments
5138 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5141 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5142 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5144 ## Set Max Size parameter value
5145 # @param maxsize numerical value or name of variable from notebook
5146 def SetMaxSize(self, maxsize):
5147 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5148 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5149 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5150 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5152 ## Set Growth Rate parameter value
5153 # @param value numerical value or name of variable from notebook
5154 def SetGrowthRate(self, value):
5155 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5156 value, parameters = ParseParameters(lastParameters,4,2,value)
5157 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5158 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5160 ## Set Number of Segments per Edge parameter value
5161 # @param value numerical value or name of variable from notebook
5162 def SetNbSegPerEdge(self, value):
5163 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5164 value, parameters = ParseParameters(lastParameters,4,3,value)
5165 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5166 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5168 ## Set Number of Segments per Radius parameter value
5169 # @param value numerical value or name of variable from notebook
5170 def SetNbSegPerRadius(self, value):
5171 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5172 value, parameters = ParseParameters(lastParameters,4,4,value)
5173 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5174 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5176 #Registering the new proxy for NETGENPlugin_Hypothesis
5177 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5180 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5181 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5184 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5185 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5187 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5188 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5190 ## Set Number of Segments parameter value
5191 # @param nbSeg numerical value or name of variable from notebook
5192 def SetNumberOfSegments(self, nbSeg):
5193 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5194 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5195 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5196 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5198 ## Set Local Length parameter value
5199 # @param length numerical value or name of variable from notebook
5200 def SetLocalLength(self, length):
5201 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5202 length, parameters = ParseParameters(lastParameters,2,1,length)
5203 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5204 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5206 ## Set Max Element Area parameter value
5207 # @param area numerical value or name of variable from notebook
5208 def SetMaxElementArea(self, area):
5209 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5210 area, parameters = ParseParameters(lastParameters,2,2,area)
5211 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5212 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5214 def LengthFromEdges(self):
5215 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5217 value, parameters = ParseParameters(lastParameters,2,2,value)
5218 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5219 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5221 #Registering the new proxy for NETGEN_SimpleParameters_2D
5222 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5225 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5226 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5227 ## Set Max Element Volume parameter value
5228 # @param volume numerical value or name of variable from notebook
5229 def SetMaxElementVolume(self, volume):
5230 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5231 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5232 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5233 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5235 def LengthFromFaces(self):
5236 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5238 value, parameters = ParseParameters(lastParameters,3,3,value)
5239 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5240 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5242 #Registering the new proxy for NETGEN_SimpleParameters_3D
5243 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5245 class Pattern(SMESH._objref_SMESH_Pattern):
5247 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5249 if isinstance(theNodeIndexOnKeyPoint1,str):
5251 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5253 theNodeIndexOnKeyPoint1 -= 1
5254 theMesh.SetParameters(Parameters)
5255 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5257 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5260 if isinstance(theNode000Index,str):
5262 if isinstance(theNode001Index,str):
5264 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5266 theNode000Index -= 1
5268 theNode001Index -= 1
5269 theMesh.SetParameters(Parameters)
5270 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5272 #Registering the new proxy for Pattern
5273 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)