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 ## Returns the number of nodes in the mesh
1592 # @return an integer value
1593 # @ingroup l1_meshinfo
1595 return self.mesh.NbNodes()
1597 ## Returns the number of elements in the mesh
1598 # @return an integer value
1599 # @ingroup l1_meshinfo
1600 def NbElements(self):
1601 return self.mesh.NbElements()
1603 ## Returns the number of 0d elements in the mesh
1604 # @return an integer value
1605 # @ingroup l1_meshinfo
1606 def Nb0DElements(self):
1607 return self.mesh.Nb0DElements()
1609 ## Returns the number of edges in the mesh
1610 # @return an integer value
1611 # @ingroup l1_meshinfo
1613 return self.mesh.NbEdges()
1615 ## Returns the number of edges with the given order in the mesh
1616 # @param elementOrder the order of elements:
1617 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1618 # @return an integer value
1619 # @ingroup l1_meshinfo
1620 def NbEdgesOfOrder(self, elementOrder):
1621 return self.mesh.NbEdgesOfOrder(elementOrder)
1623 ## Returns the number of faces in the mesh
1624 # @return an integer value
1625 # @ingroup l1_meshinfo
1627 return self.mesh.NbFaces()
1629 ## Returns the number of faces with the given order in the mesh
1630 # @param elementOrder the order of elements:
1631 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1632 # @return an integer value
1633 # @ingroup l1_meshinfo
1634 def NbFacesOfOrder(self, elementOrder):
1635 return self.mesh.NbFacesOfOrder(elementOrder)
1637 ## Returns the number of triangles in the mesh
1638 # @return an integer value
1639 # @ingroup l1_meshinfo
1640 def NbTriangles(self):
1641 return self.mesh.NbTriangles()
1643 ## Returns the number of triangles with the given order in the mesh
1644 # @param elementOrder is the order of elements:
1645 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1646 # @return an integer value
1647 # @ingroup l1_meshinfo
1648 def NbTrianglesOfOrder(self, elementOrder):
1649 return self.mesh.NbTrianglesOfOrder(elementOrder)
1651 ## Returns the number of quadrangles in the mesh
1652 # @return an integer value
1653 # @ingroup l1_meshinfo
1654 def NbQuadrangles(self):
1655 return self.mesh.NbQuadrangles()
1657 ## Returns the number of quadrangles with the given order in the mesh
1658 # @param elementOrder the order of elements:
1659 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1660 # @return an integer value
1661 # @ingroup l1_meshinfo
1662 def NbQuadranglesOfOrder(self, elementOrder):
1663 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1665 ## Returns the number of polygons in the mesh
1666 # @return an integer value
1667 # @ingroup l1_meshinfo
1668 def NbPolygons(self):
1669 return self.mesh.NbPolygons()
1671 ## Returns the number of volumes in the mesh
1672 # @return an integer value
1673 # @ingroup l1_meshinfo
1674 def NbVolumes(self):
1675 return self.mesh.NbVolumes()
1677 ## Returns the number of volumes with the given order in the mesh
1678 # @param elementOrder the order of elements:
1679 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1680 # @return an integer value
1681 # @ingroup l1_meshinfo
1682 def NbVolumesOfOrder(self, elementOrder):
1683 return self.mesh.NbVolumesOfOrder(elementOrder)
1685 ## Returns the number of tetrahedrons in the mesh
1686 # @return an integer value
1687 # @ingroup l1_meshinfo
1689 return self.mesh.NbTetras()
1691 ## Returns the number of tetrahedrons with the given order in the mesh
1692 # @param elementOrder the order of elements:
1693 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1694 # @return an integer value
1695 # @ingroup l1_meshinfo
1696 def NbTetrasOfOrder(self, elementOrder):
1697 return self.mesh.NbTetrasOfOrder(elementOrder)
1699 ## Returns the number of hexahedrons in the mesh
1700 # @return an integer value
1701 # @ingroup l1_meshinfo
1703 return self.mesh.NbHexas()
1705 ## Returns the number of hexahedrons with the given order in the mesh
1706 # @param elementOrder the order of elements:
1707 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1708 # @return an integer value
1709 # @ingroup l1_meshinfo
1710 def NbHexasOfOrder(self, elementOrder):
1711 return self.mesh.NbHexasOfOrder(elementOrder)
1713 ## Returns the number of pyramids in the mesh
1714 # @return an integer value
1715 # @ingroup l1_meshinfo
1716 def NbPyramids(self):
1717 return self.mesh.NbPyramids()
1719 ## Returns the number of pyramids with the given order in the mesh
1720 # @param elementOrder the order of elements:
1721 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1722 # @return an integer value
1723 # @ingroup l1_meshinfo
1724 def NbPyramidsOfOrder(self, elementOrder):
1725 return self.mesh.NbPyramidsOfOrder(elementOrder)
1727 ## Returns the number of prisms in the mesh
1728 # @return an integer value
1729 # @ingroup l1_meshinfo
1731 return self.mesh.NbPrisms()
1733 ## Returns the number of prisms with the given order in the mesh
1734 # @param elementOrder the order of elements:
1735 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1736 # @return an integer value
1737 # @ingroup l1_meshinfo
1738 def NbPrismsOfOrder(self, elementOrder):
1739 return self.mesh.NbPrismsOfOrder(elementOrder)
1741 ## Returns the number of polyhedrons in the mesh
1742 # @return an integer value
1743 # @ingroup l1_meshinfo
1744 def NbPolyhedrons(self):
1745 return self.mesh.NbPolyhedrons()
1747 ## Returns the number of submeshes in the mesh
1748 # @return an integer value
1749 # @ingroup l1_meshinfo
1750 def NbSubMesh(self):
1751 return self.mesh.NbSubMesh()
1753 ## Returns the list of mesh elements IDs
1754 # @return the list of integer values
1755 # @ingroup l1_meshinfo
1756 def GetElementsId(self):
1757 return self.mesh.GetElementsId()
1759 ## Returns the list of IDs of mesh elements with the given type
1760 # @param elementType the required type of elements
1761 # @return list of integer values
1762 # @ingroup l1_meshinfo
1763 def GetElementsByType(self, elementType):
1764 return self.mesh.GetElementsByType(elementType)
1766 ## Returns the list of mesh nodes IDs
1767 # @return the list of integer values
1768 # @ingroup l1_meshinfo
1769 def GetNodesId(self):
1770 return self.mesh.GetNodesId()
1772 # Get the information about mesh elements:
1773 # ------------------------------------
1775 ## Returns the type of mesh element
1776 # @return the value from SMESH::ElementType enumeration
1777 # @ingroup l1_meshinfo
1778 def GetElementType(self, id, iselem):
1779 return self.mesh.GetElementType(id, iselem)
1781 ## Returns the list of submesh elements IDs
1782 # @param Shape a geom object(subshape) IOR
1783 # Shape must be the subshape of a ShapeToMesh()
1784 # @return the list of integer values
1785 # @ingroup l1_meshinfo
1786 def GetSubMeshElementsId(self, Shape):
1787 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1788 ShapeID = Shape.GetSubShapeIndices()[0]
1791 return self.mesh.GetSubMeshElementsId(ShapeID)
1793 ## Returns the list of submesh nodes IDs
1794 # @param Shape a geom object(subshape) IOR
1795 # Shape must be the subshape of a ShapeToMesh()
1796 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1797 # @return the list of integer values
1798 # @ingroup l1_meshinfo
1799 def GetSubMeshNodesId(self, Shape, all):
1800 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1801 ShapeID = Shape.GetSubShapeIndices()[0]
1804 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1806 ## Returns type of elements on given shape
1807 # @param Shape a geom object(subshape) IOR
1808 # Shape must be a subshape of a ShapeToMesh()
1809 # @return element type
1810 # @ingroup l1_meshinfo
1811 def GetSubMeshElementType(self, Shape):
1812 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1813 ShapeID = Shape.GetSubShapeIndices()[0]
1816 return self.mesh.GetSubMeshElementType(ShapeID)
1818 ## Gets the mesh description
1819 # @return string value
1820 # @ingroup l1_meshinfo
1822 return self.mesh.Dump()
1825 # Get the information about nodes and elements of a mesh by its IDs:
1826 # -----------------------------------------------------------
1828 ## Gets XYZ coordinates of a node
1829 # \n If there is no nodes for the given ID - returns an empty list
1830 # @return a list of double precision values
1831 # @ingroup l1_meshinfo
1832 def GetNodeXYZ(self, id):
1833 return self.mesh.GetNodeXYZ(id)
1835 ## Returns list of IDs of inverse elements for the given node
1836 # \n If there is no node for the given ID - returns an empty list
1837 # @return a list of integer values
1838 # @ingroup l1_meshinfo
1839 def GetNodeInverseElements(self, id):
1840 return self.mesh.GetNodeInverseElements(id)
1842 ## @brief Returns the position of a node on the shape
1843 # @return SMESH::NodePosition
1844 # @ingroup l1_meshinfo
1845 def GetNodePosition(self,NodeID):
1846 return self.mesh.GetNodePosition(NodeID)
1848 ## If the given element is a node, returns the ID of shape
1849 # \n If there is no node for the given ID - returns -1
1850 # @return an integer value
1851 # @ingroup l1_meshinfo
1852 def GetShapeID(self, id):
1853 return self.mesh.GetShapeID(id)
1855 ## Returns the ID of the result shape after
1856 # FindShape() from SMESH_MeshEditor for the given element
1857 # \n If there is no element for the given ID - returns -1
1858 # @return an integer value
1859 # @ingroup l1_meshinfo
1860 def GetShapeIDForElem(self,id):
1861 return self.mesh.GetShapeIDForElem(id)
1863 ## Returns the number of nodes for the given element
1864 # \n If there is no element for the given ID - returns -1
1865 # @return an integer value
1866 # @ingroup l1_meshinfo
1867 def GetElemNbNodes(self, id):
1868 return self.mesh.GetElemNbNodes(id)
1870 ## Returns the node ID the given index for the given element
1871 # \n If there is no element for the given ID - returns -1
1872 # \n If there is no node for the given index - returns -2
1873 # @return an integer value
1874 # @ingroup l1_meshinfo
1875 def GetElemNode(self, id, index):
1876 return self.mesh.GetElemNode(id, index)
1878 ## Returns the IDs of nodes of the given element
1879 # @return a list of integer values
1880 # @ingroup l1_meshinfo
1881 def GetElemNodes(self, id):
1882 return self.mesh.GetElemNodes(id)
1884 ## Returns true if the given node is the medium node in the given quadratic element
1885 # @ingroup l1_meshinfo
1886 def IsMediumNode(self, elementID, nodeID):
1887 return self.mesh.IsMediumNode(elementID, nodeID)
1889 ## Returns true if the given node is the medium node in one of quadratic elements
1890 # @ingroup l1_meshinfo
1891 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1892 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1894 ## Returns the number of edges for the given element
1895 # @ingroup l1_meshinfo
1896 def ElemNbEdges(self, id):
1897 return self.mesh.ElemNbEdges(id)
1899 ## Returns the number of faces for the given element
1900 # @ingroup l1_meshinfo
1901 def ElemNbFaces(self, id):
1902 return self.mesh.ElemNbFaces(id)
1904 ## Returns true if the given element is a polygon
1905 # @ingroup l1_meshinfo
1906 def IsPoly(self, id):
1907 return self.mesh.IsPoly(id)
1909 ## Returns true if the given element is quadratic
1910 # @ingroup l1_meshinfo
1911 def IsQuadratic(self, id):
1912 return self.mesh.IsQuadratic(id)
1914 ## Returns XYZ coordinates of the barycenter of the given element
1915 # \n If there is no element for the given ID - returns an empty list
1916 # @return a list of three double values
1917 # @ingroup l1_meshinfo
1918 def BaryCenter(self, id):
1919 return self.mesh.BaryCenter(id)
1922 # Mesh edition (SMESH_MeshEditor functionality):
1923 # ---------------------------------------------
1925 ## Removes the elements from the mesh by ids
1926 # @param IDsOfElements is a list of ids of elements to remove
1927 # @return True or False
1928 # @ingroup l2_modif_del
1929 def RemoveElements(self, IDsOfElements):
1930 return self.editor.RemoveElements(IDsOfElements)
1932 ## Removes nodes from mesh by ids
1933 # @param IDsOfNodes is a list of ids of nodes to remove
1934 # @return True or False
1935 # @ingroup l2_modif_del
1936 def RemoveNodes(self, IDsOfNodes):
1937 return self.editor.RemoveNodes(IDsOfNodes)
1939 ## Add a node to the mesh by coordinates
1940 # @return Id of the new node
1941 # @ingroup l2_modif_add
1942 def AddNode(self, x, y, z):
1943 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
1944 self.mesh.SetParameters(Parameters)
1945 return self.editor.AddNode( x, y, z)
1947 ## Creates a 0D element on a node with given number.
1948 # @param IDOfNode the ID of node for creation of the element.
1949 # @return the Id of the new 0D element
1950 # @ingroup l2_modif_add
1951 def Add0DElement(self, IDOfNode):
1952 return self.editor.Add0DElement(IDOfNode)
1954 ## Creates a linear or quadratic edge (this is determined
1955 # by the number of given nodes).
1956 # @param IDsOfNodes the list of node IDs for creation of the element.
1957 # The order of nodes in this list should correspond to the description
1958 # of MED. \n This description is located by the following link:
1959 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1960 # @return the Id of the new edge
1961 # @ingroup l2_modif_add
1962 def AddEdge(self, IDsOfNodes):
1963 return self.editor.AddEdge(IDsOfNodes)
1965 ## Creates a linear or quadratic face (this is determined
1966 # by the number of given nodes).
1967 # @param IDsOfNodes the list of node IDs for creation of the element.
1968 # The order of nodes in this list should correspond to the description
1969 # of MED. \n This description is located by the following link:
1970 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1971 # @return the Id of the new face
1972 # @ingroup l2_modif_add
1973 def AddFace(self, IDsOfNodes):
1974 return self.editor.AddFace(IDsOfNodes)
1976 ## Adds a polygonal face to the mesh by the list of node IDs
1977 # @param IdsOfNodes the list of node IDs for creation of the element.
1978 # @return the Id of the new face
1979 # @ingroup l2_modif_add
1980 def AddPolygonalFace(self, IdsOfNodes):
1981 return self.editor.AddPolygonalFace(IdsOfNodes)
1983 ## Creates both simple and quadratic volume (this is determined
1984 # by the number of given nodes).
1985 # @param IDsOfNodes the list of node IDs for creation of the element.
1986 # The order of nodes in this list should correspond to the description
1987 # of MED. \n This description is located by the following link:
1988 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1989 # @return the Id of the new volumic element
1990 # @ingroup l2_modif_add
1991 def AddVolume(self, IDsOfNodes):
1992 return self.editor.AddVolume(IDsOfNodes)
1994 ## Creates a volume of many faces, giving nodes for each face.
1995 # @param IdsOfNodes the list of node IDs for volume creation face by face.
1996 # @param Quantities the list of integer values, Quantities[i]
1997 # gives the quantity of nodes in face number i.
1998 # @return the Id of the new volumic element
1999 # @ingroup l2_modif_add
2000 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2001 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2003 ## Creates a volume of many faces, giving the IDs of the existing faces.
2004 # @param IdsOfFaces the list of face IDs for volume creation.
2006 # Note: The created volume will refer only to the nodes
2007 # of the given faces, not to the faces themselves.
2008 # @return the Id of the new volumic element
2009 # @ingroup l2_modif_add
2010 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2011 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2014 ## @brief Binds a node to a vertex
2015 # @param NodeID a node ID
2016 # @param Vertex a vertex or vertex ID
2017 # @return True if succeed else raises an exception
2018 # @ingroup l2_modif_add
2019 def SetNodeOnVertex(self, NodeID, Vertex):
2020 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2021 VertexID = Vertex.GetSubShapeIndices()[0]
2025 self.editor.SetNodeOnVertex(NodeID, VertexID)
2026 except SALOME.SALOME_Exception, inst:
2027 raise ValueError, inst.details.text
2031 ## @brief Stores the node position on an edge
2032 # @param NodeID a node ID
2033 # @param Edge an edge or edge ID
2034 # @param paramOnEdge a parameter on the edge where the node is located
2035 # @return True if succeed else raises an exception
2036 # @ingroup l2_modif_add
2037 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2038 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2039 EdgeID = Edge.GetSubShapeIndices()[0]
2043 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2044 except SALOME.SALOME_Exception, inst:
2045 raise ValueError, inst.details.text
2048 ## @brief Stores node position on a face
2049 # @param NodeID a node ID
2050 # @param Face a face or face ID
2051 # @param u U parameter on the face where the node is located
2052 # @param v V parameter on the face where the node is located
2053 # @return True if succeed else raises an exception
2054 # @ingroup l2_modif_add
2055 def SetNodeOnFace(self, NodeID, Face, u, v):
2056 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2057 FaceID = Face.GetSubShapeIndices()[0]
2061 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2062 except SALOME.SALOME_Exception, inst:
2063 raise ValueError, inst.details.text
2066 ## @brief Binds a node to a solid
2067 # @param NodeID a node ID
2068 # @param Solid a solid or solid ID
2069 # @return True if succeed else raises an exception
2070 # @ingroup l2_modif_add
2071 def SetNodeInVolume(self, NodeID, Solid):
2072 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2073 SolidID = Solid.GetSubShapeIndices()[0]
2077 self.editor.SetNodeInVolume(NodeID, SolidID)
2078 except SALOME.SALOME_Exception, inst:
2079 raise ValueError, inst.details.text
2082 ## @brief Bind an element to a shape
2083 # @param ElementID an element ID
2084 # @param Shape a shape or shape ID
2085 # @return True if succeed else raises an exception
2086 # @ingroup l2_modif_add
2087 def SetMeshElementOnShape(self, ElementID, Shape):
2088 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2089 ShapeID = Shape.GetSubShapeIndices()[0]
2093 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2094 except SALOME.SALOME_Exception, inst:
2095 raise ValueError, inst.details.text
2099 ## Moves the node with the given id
2100 # @param NodeID the id of the node
2101 # @param x a new X coordinate
2102 # @param y a new Y coordinate
2103 # @param z a new Z coordinate
2104 # @return True if succeed else False
2105 # @ingroup l2_modif_movenode
2106 def MoveNode(self, NodeID, x, y, z):
2107 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2108 self.mesh.SetParameters(Parameters)
2109 return self.editor.MoveNode(NodeID, x, y, z)
2111 ## Finds the node closest to a point and moves it to a point location
2112 # @param x the X coordinate of a point
2113 # @param y the Y coordinate of a point
2114 # @param z the Z coordinate of a point
2115 # @return the ID of a node
2116 # @ingroup l2_modif_throughp
2117 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2118 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2119 self.mesh.SetParameters(Parameters)
2120 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2122 ## Finds the node closest to a point
2123 # @param x the X coordinate of a point
2124 # @param y the Y coordinate of a point
2125 # @param z the Z coordinate of a point
2126 # @return the ID of a node
2127 # @ingroup l2_modif_throughp
2128 def FindNodeClosestTo(self, x, y, z):
2129 preview = self.mesh.GetMeshEditPreviewer()
2130 return preview.MoveClosestNodeToPoint(x, y, z, -1)
2132 ## Finds the node closest to a point and moves it to a point location
2133 # @param x the X coordinate of a point
2134 # @param y the Y coordinate of a point
2135 # @param z the Z coordinate of a point
2136 # @return the ID of a moved node
2137 # @ingroup l2_modif_throughp
2138 def MeshToPassThroughAPoint(self, x, y, z):
2139 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2141 ## Replaces two neighbour triangles sharing Node1-Node2 link
2142 # with the triangles built on the same 4 nodes but having other common link.
2143 # @param NodeID1 the ID of the first node
2144 # @param NodeID2 the ID of the second node
2145 # @return false if proper faces were not found
2146 # @ingroup l2_modif_invdiag
2147 def InverseDiag(self, NodeID1, NodeID2):
2148 return self.editor.InverseDiag(NodeID1, NodeID2)
2150 ## Replaces two neighbour triangles sharing Node1-Node2 link
2151 # with a quadrangle built on the same 4 nodes.
2152 # @param NodeID1 the ID of the first node
2153 # @param NodeID2 the ID of the second node
2154 # @return false if proper faces were not found
2155 # @ingroup l2_modif_unitetri
2156 def DeleteDiag(self, NodeID1, NodeID2):
2157 return self.editor.DeleteDiag(NodeID1, NodeID2)
2159 ## Reorients elements by ids
2160 # @param IDsOfElements if undefined reorients all mesh elements
2161 # @return True if succeed else False
2162 # @ingroup l2_modif_changori
2163 def Reorient(self, IDsOfElements=None):
2164 if IDsOfElements == None:
2165 IDsOfElements = self.GetElementsId()
2166 return self.editor.Reorient(IDsOfElements)
2168 ## Reorients all elements of the object
2169 # @param theObject mesh, submesh or group
2170 # @return True if succeed else False
2171 # @ingroup l2_modif_changori
2172 def ReorientObject(self, theObject):
2173 if ( isinstance( theObject, Mesh )):
2174 theObject = theObject.GetMesh()
2175 return self.editor.ReorientObject(theObject)
2177 ## Fuses the neighbouring triangles into quadrangles.
2178 # @param IDsOfElements The triangles to be fused,
2179 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2180 # @param MaxAngle is the maximum angle between element normals at which the fusion
2181 # is still performed; theMaxAngle is mesured in radians.
2182 # Also it could be a name of variable which defines angle in degrees.
2183 # @return TRUE in case of success, FALSE otherwise.
2184 # @ingroup l2_modif_unitetri
2185 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2187 if isinstance(MaxAngle,str):
2189 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2191 MaxAngle = DegreesToRadians(MaxAngle)
2192 if IDsOfElements == []:
2193 IDsOfElements = self.GetElementsId()
2194 self.mesh.SetParameters(Parameters)
2196 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2197 Functor = theCriterion
2199 Functor = self.smeshpyD.GetFunctor(theCriterion)
2200 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2202 ## Fuses the neighbouring triangles of the object into quadrangles
2203 # @param theObject is mesh, submesh or group
2204 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2205 # @param MaxAngle a max angle between element normals at which the fusion
2206 # is still performed; theMaxAngle is mesured in radians.
2207 # @return TRUE in case of success, FALSE otherwise.
2208 # @ingroup l2_modif_unitetri
2209 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2210 if ( isinstance( theObject, Mesh )):
2211 theObject = theObject.GetMesh()
2212 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2214 ## Splits quadrangles into triangles.
2215 # @param IDsOfElements the faces to be splitted.
2216 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2217 # @return TRUE in case of success, FALSE otherwise.
2218 # @ingroup l2_modif_cutquadr
2219 def QuadToTri (self, IDsOfElements, theCriterion):
2220 if IDsOfElements == []:
2221 IDsOfElements = self.GetElementsId()
2222 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2224 ## Splits quadrangles into triangles.
2225 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2226 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2227 # @return TRUE in case of success, FALSE otherwise.
2228 # @ingroup l2_modif_cutquadr
2229 def QuadToTriObject (self, theObject, theCriterion):
2230 if ( isinstance( theObject, Mesh )):
2231 theObject = theObject.GetMesh()
2232 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2234 ## Splits quadrangles into triangles.
2235 # @param IDsOfElements the faces to be splitted
2236 # @param Diag13 is used to choose a diagonal for splitting.
2237 # @return TRUE in case of success, FALSE otherwise.
2238 # @ingroup l2_modif_cutquadr
2239 def SplitQuad (self, IDsOfElements, Diag13):
2240 if IDsOfElements == []:
2241 IDsOfElements = self.GetElementsId()
2242 return self.editor.SplitQuad(IDsOfElements, Diag13)
2244 ## Splits quadrangles into triangles.
2245 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2246 # @param Diag13 is used to choose a diagonal for splitting.
2247 # @return TRUE in case of success, FALSE otherwise.
2248 # @ingroup l2_modif_cutquadr
2249 def SplitQuadObject (self, theObject, Diag13):
2250 if ( isinstance( theObject, Mesh )):
2251 theObject = theObject.GetMesh()
2252 return self.editor.SplitQuadObject(theObject, Diag13)
2254 ## Finds a better splitting of the given quadrangle.
2255 # @param IDOfQuad the ID of the quadrangle to be splitted.
2256 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2257 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2258 # diagonal is better, 0 if error occurs.
2259 # @ingroup l2_modif_cutquadr
2260 def BestSplit (self, IDOfQuad, theCriterion):
2261 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2263 ## Splits quadrangle faces near triangular facets of volumes
2265 # @ingroup l1_auxiliary
2266 def SplitQuadsNearTriangularFacets(self):
2267 faces_array = self.GetElementsByType(SMESH.FACE)
2268 for face_id in faces_array:
2269 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2270 quad_nodes = self.mesh.GetElemNodes(face_id)
2271 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2272 isVolumeFound = False
2273 for node1_elem in node1_elems:
2274 if not isVolumeFound:
2275 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2276 nb_nodes = self.GetElemNbNodes(node1_elem)
2277 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2278 volume_elem = node1_elem
2279 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2280 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2281 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2282 isVolumeFound = True
2283 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2284 self.SplitQuad([face_id], False) # diagonal 2-4
2285 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2286 isVolumeFound = True
2287 self.SplitQuad([face_id], True) # diagonal 1-3
2288 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2289 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2290 isVolumeFound = True
2291 self.SplitQuad([face_id], True) # diagonal 1-3
2293 ## @brief Splits hexahedrons into tetrahedrons.
2295 # This operation uses pattern mapping functionality for splitting.
2296 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2297 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2298 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2299 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2300 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2301 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2302 # @return TRUE in case of success, FALSE otherwise.
2303 # @ingroup l1_auxiliary
2304 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2305 # Pattern: 5.---------.6
2310 # (0,0,1) 4.---------.7 * |
2317 # (0,0,0) 0.---------.3
2318 pattern_tetra = "!!! Nb of points: \n 8 \n\
2328 !!! Indices of points of 6 tetras: \n\
2336 pattern = self.smeshpyD.GetPattern()
2337 isDone = pattern.LoadFromFile(pattern_tetra)
2339 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2342 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2343 isDone = pattern.MakeMesh(self.mesh, False, False)
2344 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2346 # split quafrangle faces near triangular facets of volumes
2347 self.SplitQuadsNearTriangularFacets()
2351 ## @brief Split hexahedrons into prisms.
2353 # Uses the pattern mapping functionality for splitting.
2354 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2355 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2356 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2357 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2358 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2359 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2360 # @return TRUE in case of success, FALSE otherwise.
2361 # @ingroup l1_auxiliary
2362 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2363 # Pattern: 5.---------.6
2368 # (0,0,1) 4.---------.7 |
2375 # (0,0,0) 0.---------.3
2376 pattern_prism = "!!! Nb of points: \n 8 \n\
2386 !!! Indices of points of 2 prisms: \n\
2390 pattern = self.smeshpyD.GetPattern()
2391 isDone = pattern.LoadFromFile(pattern_prism)
2393 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2396 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2397 isDone = pattern.MakeMesh(self.mesh, False, False)
2398 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2400 # Splits quafrangle faces near triangular facets of volumes
2401 self.SplitQuadsNearTriangularFacets()
2405 ## Smoothes elements
2406 # @param IDsOfElements the list if ids of elements to smooth
2407 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2408 # Note that nodes built on edges and boundary nodes are always fixed.
2409 # @param MaxNbOfIterations the maximum number of iterations
2410 # @param MaxAspectRatio varies in range [1.0, inf]
2411 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2412 # @return TRUE in case of success, FALSE otherwise.
2413 # @ingroup l2_modif_smooth
2414 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2415 MaxNbOfIterations, MaxAspectRatio, Method):
2416 if IDsOfElements == []:
2417 IDsOfElements = self.GetElementsId()
2418 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2419 self.mesh.SetParameters(Parameters)
2420 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2421 MaxNbOfIterations, MaxAspectRatio, Method)
2423 ## Smoothes elements which belong to the given object
2424 # @param theObject the object to smooth
2425 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2426 # Note that nodes built on edges and boundary nodes are always fixed.
2427 # @param MaxNbOfIterations the maximum number of iterations
2428 # @param MaxAspectRatio varies in range [1.0, inf]
2429 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2430 # @return TRUE in case of success, FALSE otherwise.
2431 # @ingroup l2_modif_smooth
2432 def SmoothObject(self, theObject, IDsOfFixedNodes,
2433 MaxNbOfIterations, MaxAspectRatio, Method):
2434 if ( isinstance( theObject, Mesh )):
2435 theObject = theObject.GetMesh()
2436 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2437 MaxNbOfIterations, MaxAspectRatio, Method)
2439 ## Parametrically smoothes the given elements
2440 # @param IDsOfElements the list if ids of elements to smooth
2441 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2442 # Note that nodes built on edges and boundary nodes are always fixed.
2443 # @param MaxNbOfIterations the maximum number of iterations
2444 # @param MaxAspectRatio varies in range [1.0, inf]
2445 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2446 # @return TRUE in case of success, FALSE otherwise.
2447 # @ingroup l2_modif_smooth
2448 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2449 MaxNbOfIterations, MaxAspectRatio, Method):
2450 if IDsOfElements == []:
2451 IDsOfElements = self.GetElementsId()
2452 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2453 self.mesh.SetParameters(Parameters)
2454 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2455 MaxNbOfIterations, MaxAspectRatio, Method)
2457 ## Parametrically smoothes the elements which belong to the given object
2458 # @param theObject the object to smooth
2459 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2460 # Note that nodes built on edges and boundary nodes are always fixed.
2461 # @param MaxNbOfIterations the maximum number of iterations
2462 # @param MaxAspectRatio varies in range [1.0, inf]
2463 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2464 # @return TRUE in case of success, FALSE otherwise.
2465 # @ingroup l2_modif_smooth
2466 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2467 MaxNbOfIterations, MaxAspectRatio, Method):
2468 if ( isinstance( theObject, Mesh )):
2469 theObject = theObject.GetMesh()
2470 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2471 MaxNbOfIterations, MaxAspectRatio, Method)
2473 ## Converts the mesh to quadratic, deletes old elements, replacing
2474 # them with quadratic with the same id.
2475 # @ingroup l2_modif_tofromqu
2476 def ConvertToQuadratic(self, theForce3d):
2477 self.editor.ConvertToQuadratic(theForce3d)
2479 ## Converts the mesh from quadratic to ordinary,
2480 # deletes old quadratic elements, \n replacing
2481 # them with ordinary mesh elements with the same id.
2482 # @return TRUE in case of success, FALSE otherwise.
2483 # @ingroup l2_modif_tofromqu
2484 def ConvertFromQuadratic(self):
2485 return self.editor.ConvertFromQuadratic()
2487 ## Renumber mesh nodes
2488 # @ingroup l2_modif_renumber
2489 def RenumberNodes(self):
2490 self.editor.RenumberNodes()
2492 ## Renumber mesh elements
2493 # @ingroup l2_modif_renumber
2494 def RenumberElements(self):
2495 self.editor.RenumberElements()
2497 ## Generates new elements by rotation of the elements around the axis
2498 # @param IDsOfElements the list of ids of elements to sweep
2499 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2500 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2501 # @param NbOfSteps the number of steps
2502 # @param Tolerance tolerance
2503 # @param MakeGroups forces the generation of new groups from existing ones
2504 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2505 # of all steps, else - size of each step
2506 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2507 # @ingroup l2_modif_extrurev
2508 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2509 MakeGroups=False, TotalAngle=False):
2511 if isinstance(AngleInRadians,str):
2513 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2515 AngleInRadians = DegreesToRadians(AngleInRadians)
2516 if IDsOfElements == []:
2517 IDsOfElements = self.GetElementsId()
2518 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2519 Axis = self.smeshpyD.GetAxisStruct(Axis)
2520 Axis,AxisParameters = ParseAxisStruct(Axis)
2521 if TotalAngle and NbOfSteps:
2522 AngleInRadians /= NbOfSteps
2523 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2524 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2525 self.mesh.SetParameters(Parameters)
2527 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2528 AngleInRadians, NbOfSteps, Tolerance)
2529 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2532 ## Generates new elements by rotation of the elements of object around the axis
2533 # @param theObject object which elements should be sweeped
2534 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2535 # @param AngleInRadians the angle of Rotation
2536 # @param NbOfSteps number of steps
2537 # @param Tolerance tolerance
2538 # @param MakeGroups forces the generation of new groups from existing ones
2539 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2540 # of all steps, else - size of each step
2541 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2542 # @ingroup l2_modif_extrurev
2543 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2544 MakeGroups=False, TotalAngle=False):
2546 if isinstance(AngleInRadians,str):
2548 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2550 AngleInRadians = DegreesToRadians(AngleInRadians)
2551 if ( isinstance( theObject, Mesh )):
2552 theObject = theObject.GetMesh()
2553 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2554 Axis = self.smeshpyD.GetAxisStruct(Axis)
2555 Axis,AxisParameters = ParseAxisStruct(Axis)
2556 if TotalAngle and NbOfSteps:
2557 AngleInRadians /= NbOfSteps
2558 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2559 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2560 self.mesh.SetParameters(Parameters)
2562 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2563 NbOfSteps, Tolerance)
2564 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2567 ## Generates new elements by rotation of the elements of object around the axis
2568 # @param theObject object which elements should be sweeped
2569 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2570 # @param AngleInRadians the angle of Rotation
2571 # @param NbOfSteps number of steps
2572 # @param Tolerance tolerance
2573 # @param MakeGroups forces the generation of new groups from existing ones
2574 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2575 # of all steps, else - size of each step
2576 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2577 # @ingroup l2_modif_extrurev
2578 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2579 MakeGroups=False, TotalAngle=False):
2581 if isinstance(AngleInRadians,str):
2583 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2585 AngleInRadians = DegreesToRadians(AngleInRadians)
2586 if ( isinstance( theObject, Mesh )):
2587 theObject = theObject.GetMesh()
2588 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2589 Axis = self.smeshpyD.GetAxisStruct(Axis)
2590 Axis,AxisParameters = ParseAxisStruct(Axis)
2591 if TotalAngle and NbOfSteps:
2592 AngleInRadians /= NbOfSteps
2593 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2594 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2595 self.mesh.SetParameters(Parameters)
2597 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2598 NbOfSteps, Tolerance)
2599 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2602 ## Generates new elements by rotation of the elements of object around the axis
2603 # @param theObject object which elements should be sweeped
2604 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2605 # @param AngleInRadians the angle of Rotation
2606 # @param NbOfSteps number of steps
2607 # @param Tolerance tolerance
2608 # @param MakeGroups forces the generation of new groups from existing ones
2609 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2610 # of all steps, else - size of each step
2611 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2612 # @ingroup l2_modif_extrurev
2613 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2614 MakeGroups=False, TotalAngle=False):
2616 if isinstance(AngleInRadians,str):
2618 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2620 AngleInRadians = DegreesToRadians(AngleInRadians)
2621 if ( isinstance( theObject, Mesh )):
2622 theObject = theObject.GetMesh()
2623 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2624 Axis = self.smeshpyD.GetAxisStruct(Axis)
2625 Axis,AxisParameters = ParseAxisStruct(Axis)
2626 if TotalAngle and NbOfSteps:
2627 AngleInRadians /= NbOfSteps
2628 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2629 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2630 self.mesh.SetParameters(Parameters)
2632 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2633 NbOfSteps, Tolerance)
2634 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2637 ## Generates new elements by extrusion of the elements with given ids
2638 # @param IDsOfElements the list of elements ids for extrusion
2639 # @param StepVector vector, defining the direction and value of extrusion
2640 # @param NbOfSteps the number of steps
2641 # @param MakeGroups forces the generation of new groups from existing ones
2642 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2643 # @ingroup l2_modif_extrurev
2644 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2645 if IDsOfElements == []:
2646 IDsOfElements = self.GetElementsId()
2647 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2648 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2649 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2650 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2651 Parameters = StepVectorParameters + var_separator + Parameters
2652 self.mesh.SetParameters(Parameters)
2654 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2655 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2658 ## Generates new elements by extrusion of the elements with given ids
2659 # @param IDsOfElements is ids of elements
2660 # @param StepVector vector, defining the direction and value of extrusion
2661 # @param NbOfSteps the number of steps
2662 # @param ExtrFlags sets flags for extrusion
2663 # @param SewTolerance uses for comparing locations of nodes if flag
2664 # EXTRUSION_FLAG_SEW is set
2665 # @param MakeGroups forces the generation of new groups from existing ones
2666 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2667 # @ingroup l2_modif_extrurev
2668 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2669 ExtrFlags, SewTolerance, MakeGroups=False):
2670 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2671 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2673 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2674 ExtrFlags, SewTolerance)
2675 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2676 ExtrFlags, SewTolerance)
2679 ## Generates new elements by extrusion of the elements which belong to the object
2680 # @param theObject the object which elements should be processed
2681 # @param StepVector vector, defining the direction and value of extrusion
2682 # @param NbOfSteps the number of steps
2683 # @param MakeGroups forces the generation of new groups from existing ones
2684 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2685 # @ingroup l2_modif_extrurev
2686 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2687 if ( isinstance( theObject, Mesh )):
2688 theObject = theObject.GetMesh()
2689 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2690 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2691 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2692 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2693 Parameters = StepVectorParameters + var_separator + Parameters
2694 self.mesh.SetParameters(Parameters)
2696 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2697 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2700 ## Generates new elements by extrusion of the elements which belong to the object
2701 # @param theObject object which elements should be processed
2702 # @param StepVector vector, defining the direction and value of extrusion
2703 # @param NbOfSteps the number of steps
2704 # @param MakeGroups to generate new groups from existing ones
2705 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2706 # @ingroup l2_modif_extrurev
2707 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2708 if ( isinstance( theObject, Mesh )):
2709 theObject = theObject.GetMesh()
2710 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2711 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2712 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2713 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2714 Parameters = StepVectorParameters + var_separator + Parameters
2715 self.mesh.SetParameters(Parameters)
2717 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2718 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2721 ## Generates new elements by extrusion of the elements which belong to the object
2722 # @param theObject object which elements should be processed
2723 # @param StepVector vector, defining the direction and value of extrusion
2724 # @param NbOfSteps the number of steps
2725 # @param MakeGroups forces the generation of new groups from existing ones
2726 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2727 # @ingroup l2_modif_extrurev
2728 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2729 if ( isinstance( theObject, Mesh )):
2730 theObject = theObject.GetMesh()
2731 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2732 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2733 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2734 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2735 Parameters = StepVectorParameters + var_separator + Parameters
2736 self.mesh.SetParameters(Parameters)
2738 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2739 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2744 ## Generates new elements by extrusion of the given elements
2745 # The path of extrusion must be a meshed edge.
2746 # @param Base mesh or list of ids of elements for extrusion
2747 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2748 # @param NodeStart the start node from Path. Defines the direction of extrusion
2749 # @param HasAngles allows the shape to be rotated around the path
2750 # to get the resulting mesh in a helical fashion
2751 # @param Angles list of angles in radians
2752 # @param LinearVariation forces the computation of rotation angles as linear
2753 # variation of the given Angles along path steps
2754 # @param HasRefPoint allows using the reference point
2755 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2756 # The User can specify any point as the Reference Point.
2757 # @param MakeGroups forces the generation of new groups from existing ones
2758 # @param ElemType type of elements for extrusion (if param Base is a mesh)
2759 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2760 # only SMESH::Extrusion_Error otherwise
2761 # @ingroup l2_modif_extrurev
2762 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2763 HasAngles, Angles, LinearVariation,
2764 HasRefPoint, RefPoint, MakeGroups, ElemType):
2765 Angles,AnglesParameters = ParseAngles(Angles)
2766 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2767 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2768 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2770 Parameters = AnglesParameters + var_separator + RefPointParameters
2771 self.mesh.SetParameters(Parameters)
2773 if isinstance(Base,list):
2775 if Base == []: IDsOfElements = self.GetElementsId()
2776 else: IDsOfElements = Base
2777 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2778 HasAngles, Angles, LinearVariation,
2779 HasRefPoint, RefPoint, MakeGroups, ElemType)
2781 if isinstance(Base,Mesh):
2782 return self.editor.ExtrusionAlongPathObjX(Base.GetMesh(), Path, NodeStart,
2783 HasAngles, Angles, LinearVariation,
2784 HasRefPoint, RefPoint, MakeGroups, ElemType)
2786 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2789 ## Generates new elements by extrusion of the given elements
2790 # The path of extrusion must be a meshed edge.
2791 # @param IDsOfElements ids of elements
2792 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2793 # @param PathShape shape(edge) defines the sub-mesh for the path
2794 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2795 # @param HasAngles allows the shape to be rotated around the path
2796 # to get the resulting mesh in a helical fashion
2797 # @param Angles list of angles in radians
2798 # @param HasRefPoint allows using the reference point
2799 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2800 # The User can specify any point as the Reference Point.
2801 # @param MakeGroups forces the generation of new groups from existing ones
2802 # @param LinearVariation forces the computation of rotation angles as linear
2803 # variation of the given Angles along path steps
2804 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2805 # only SMESH::Extrusion_Error otherwise
2806 # @ingroup l2_modif_extrurev
2807 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2808 HasAngles, Angles, HasRefPoint, RefPoint,
2809 MakeGroups=False, LinearVariation=False):
2810 Angles,AnglesParameters = ParseAngles(Angles)
2811 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2812 if IDsOfElements == []:
2813 IDsOfElements = self.GetElementsId()
2814 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2815 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2817 if ( isinstance( PathMesh, Mesh )):
2818 PathMesh = PathMesh.GetMesh()
2819 if HasAngles and Angles and LinearVariation:
2820 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2822 Parameters = AnglesParameters + var_separator + RefPointParameters
2823 self.mesh.SetParameters(Parameters)
2825 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2826 PathShape, NodeStart, HasAngles,
2827 Angles, HasRefPoint, RefPoint)
2828 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2829 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2831 ## Generates new elements by extrusion of the elements which belong to the object
2832 # The path of extrusion must be a meshed edge.
2833 # @param theObject the object which elements should be processed
2834 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2835 # @param PathShape shape(edge) defines the sub-mesh for the path
2836 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2837 # @param HasAngles allows the shape to be rotated around the path
2838 # to get the resulting mesh in a helical fashion
2839 # @param Angles list of angles
2840 # @param HasRefPoint allows using the reference point
2841 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2842 # The User can specify any point as the Reference Point.
2843 # @param MakeGroups forces the generation of new groups from existing ones
2844 # @param LinearVariation forces the computation of rotation angles as linear
2845 # variation of the given Angles along path steps
2846 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2847 # only SMESH::Extrusion_Error otherwise
2848 # @ingroup l2_modif_extrurev
2849 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2850 HasAngles, Angles, HasRefPoint, RefPoint,
2851 MakeGroups=False, LinearVariation=False):
2852 Angles,AnglesParameters = ParseAngles(Angles)
2853 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2854 if ( isinstance( theObject, Mesh )):
2855 theObject = theObject.GetMesh()
2856 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2857 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2858 if ( isinstance( PathMesh, Mesh )):
2859 PathMesh = PathMesh.GetMesh()
2860 if HasAngles and Angles and LinearVariation:
2861 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2863 Parameters = AnglesParameters + var_separator + RefPointParameters
2864 self.mesh.SetParameters(Parameters)
2866 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2867 PathShape, NodeStart, HasAngles,
2868 Angles, HasRefPoint, RefPoint)
2869 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2870 NodeStart, HasAngles, Angles, HasRefPoint,
2873 ## Generates new elements by extrusion of the elements which belong to the object
2874 # The path of extrusion must be a meshed edge.
2875 # @param theObject the object which elements should be processed
2876 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2877 # @param PathShape shape(edge) defines the sub-mesh for the path
2878 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2879 # @param HasAngles allows the shape to be rotated around the path
2880 # to get the resulting mesh in a helical fashion
2881 # @param Angles list of angles
2882 # @param HasRefPoint allows using the reference point
2883 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2884 # The User can specify any point as the Reference Point.
2885 # @param MakeGroups forces the generation of new groups from existing ones
2886 # @param LinearVariation forces the computation of rotation angles as linear
2887 # variation of the given Angles along path steps
2888 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2889 # only SMESH::Extrusion_Error otherwise
2890 # @ingroup l2_modif_extrurev
2891 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
2892 HasAngles, Angles, HasRefPoint, RefPoint,
2893 MakeGroups=False, LinearVariation=False):
2894 Angles,AnglesParameters = ParseAngles(Angles)
2895 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2896 if ( isinstance( theObject, Mesh )):
2897 theObject = theObject.GetMesh()
2898 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2899 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2900 if ( isinstance( PathMesh, Mesh )):
2901 PathMesh = PathMesh.GetMesh()
2902 if HasAngles and Angles and LinearVariation:
2903 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2905 Parameters = AnglesParameters + var_separator + RefPointParameters
2906 self.mesh.SetParameters(Parameters)
2908 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
2909 PathShape, NodeStart, HasAngles,
2910 Angles, HasRefPoint, RefPoint)
2911 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
2912 NodeStart, HasAngles, Angles, HasRefPoint,
2915 ## Generates new elements by extrusion of the elements which belong to the object
2916 # The path of extrusion must be a meshed edge.
2917 # @param theObject the object which elements should be processed
2918 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2919 # @param PathShape shape(edge) defines the sub-mesh for the path
2920 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2921 # @param HasAngles allows the shape to be rotated around the path
2922 # to get the resulting mesh in a helical fashion
2923 # @param Angles list of angles
2924 # @param HasRefPoint allows using the reference point
2925 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2926 # The User can specify any point as the Reference Point.
2927 # @param MakeGroups forces the generation of new groups from existing ones
2928 # @param LinearVariation forces the computation of rotation angles as linear
2929 # variation of the given Angles along path steps
2930 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2931 # only SMESH::Extrusion_Error otherwise
2932 # @ingroup l2_modif_extrurev
2933 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
2934 HasAngles, Angles, HasRefPoint, RefPoint,
2935 MakeGroups=False, LinearVariation=False):
2936 Angles,AnglesParameters = ParseAngles(Angles)
2937 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2938 if ( isinstance( theObject, Mesh )):
2939 theObject = theObject.GetMesh()
2940 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2941 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2942 if ( isinstance( PathMesh, Mesh )):
2943 PathMesh = PathMesh.GetMesh()
2944 if HasAngles and Angles and LinearVariation:
2945 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2947 Parameters = AnglesParameters + var_separator + RefPointParameters
2948 self.mesh.SetParameters(Parameters)
2950 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
2951 PathShape, NodeStart, HasAngles,
2952 Angles, HasRefPoint, RefPoint)
2953 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
2954 NodeStart, HasAngles, Angles, HasRefPoint,
2957 ## Creates a symmetrical copy of mesh elements
2958 # @param IDsOfElements list of elements ids
2959 # @param Mirror is AxisStruct or geom object(point, line, plane)
2960 # @param theMirrorType is POINT, AXIS or PLANE
2961 # If the Mirror is a geom object this parameter is unnecessary
2962 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2963 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2964 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2965 # @ingroup l2_modif_trsf
2966 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2967 if IDsOfElements == []:
2968 IDsOfElements = self.GetElementsId()
2969 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2970 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2971 Mirror,Parameters = ParseAxisStruct(Mirror)
2972 self.mesh.SetParameters(Parameters)
2973 if Copy and MakeGroups:
2974 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2975 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2978 ## Creates a new mesh by a symmetrical copy of mesh elements
2979 # @param IDsOfElements the list of elements ids
2980 # @param Mirror is AxisStruct or geom object (point, line, plane)
2981 # @param theMirrorType is POINT, AXIS or PLANE
2982 # If the Mirror is a geom object this parameter is unnecessary
2983 # @param MakeGroups to generate new groups from existing ones
2984 # @param NewMeshName a name of the new mesh to create
2985 # @return instance of Mesh class
2986 # @ingroup l2_modif_trsf
2987 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2988 if IDsOfElements == []:
2989 IDsOfElements = self.GetElementsId()
2990 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2991 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2992 Mirror,Parameters = ParseAxisStruct(Mirror)
2993 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2994 MakeGroups, NewMeshName)
2995 mesh.SetParameters(Parameters)
2996 return Mesh(self.smeshpyD,self.geompyD,mesh)
2998 ## Creates a symmetrical copy of the object
2999 # @param theObject mesh, submesh or group
3000 # @param Mirror AxisStruct or geom object (point, line, plane)
3001 # @param theMirrorType is POINT, AXIS or PLANE
3002 # If the Mirror is a geom object this parameter is unnecessary
3003 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3004 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3005 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3006 # @ingroup l2_modif_trsf
3007 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3008 if ( isinstance( theObject, Mesh )):
3009 theObject = theObject.GetMesh()
3010 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3011 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3012 Mirror,Parameters = ParseAxisStruct(Mirror)
3013 self.mesh.SetParameters(Parameters)
3014 if Copy and MakeGroups:
3015 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3016 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3019 ## Creates a new mesh by a symmetrical copy of the object
3020 # @param theObject mesh, submesh or group
3021 # @param Mirror AxisStruct or geom object (point, line, plane)
3022 # @param theMirrorType POINT, AXIS or PLANE
3023 # If the Mirror is a geom object this parameter is unnecessary
3024 # @param MakeGroups forces the generation of new groups from existing ones
3025 # @param NewMeshName the name of the new mesh to create
3026 # @return instance of Mesh class
3027 # @ingroup l2_modif_trsf
3028 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3029 if ( isinstance( theObject, Mesh )):
3030 theObject = theObject.GetMesh()
3031 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3032 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3033 Mirror,Parameters = ParseAxisStruct(Mirror)
3034 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3035 MakeGroups, NewMeshName)
3036 mesh.SetParameters(Parameters)
3037 return Mesh( self.smeshpyD,self.geompyD,mesh )
3039 ## Translates the elements
3040 # @param IDsOfElements list of elements ids
3041 # @param Vector the direction of translation (DirStruct or vector)
3042 # @param Copy allows copying the translated elements
3043 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3044 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3045 # @ingroup l2_modif_trsf
3046 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3047 if IDsOfElements == []:
3048 IDsOfElements = self.GetElementsId()
3049 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3050 Vector = self.smeshpyD.GetDirStruct(Vector)
3051 Vector,Parameters = ParseDirStruct(Vector)
3052 self.mesh.SetParameters(Parameters)
3053 if Copy and MakeGroups:
3054 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3055 self.editor.Translate(IDsOfElements, Vector, Copy)
3058 ## Creates a new mesh of translated elements
3059 # @param IDsOfElements list of elements ids
3060 # @param Vector the direction of translation (DirStruct or vector)
3061 # @param MakeGroups forces the generation of new groups from existing ones
3062 # @param NewMeshName the name of the newly created mesh
3063 # @return instance of Mesh class
3064 # @ingroup l2_modif_trsf
3065 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3066 if IDsOfElements == []:
3067 IDsOfElements = self.GetElementsId()
3068 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3069 Vector = self.smeshpyD.GetDirStruct(Vector)
3070 Vector,Parameters = ParseDirStruct(Vector)
3071 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3072 mesh.SetParameters(Parameters)
3073 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3075 ## Translates the object
3076 # @param theObject the object to translate (mesh, submesh, or group)
3077 # @param Vector direction of translation (DirStruct or geom vector)
3078 # @param Copy allows copying the translated elements
3079 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3080 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3081 # @ingroup l2_modif_trsf
3082 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3083 if ( isinstance( theObject, Mesh )):
3084 theObject = theObject.GetMesh()
3085 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3086 Vector = self.smeshpyD.GetDirStruct(Vector)
3087 Vector,Parameters = ParseDirStruct(Vector)
3088 self.mesh.SetParameters(Parameters)
3089 if Copy and MakeGroups:
3090 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3091 self.editor.TranslateObject(theObject, Vector, Copy)
3094 ## Creates a new mesh from the translated object
3095 # @param theObject the object to translate (mesh, submesh, or group)
3096 # @param Vector the direction of translation (DirStruct or geom vector)
3097 # @param MakeGroups forces the generation of new groups from existing ones
3098 # @param NewMeshName the name of the newly created mesh
3099 # @return instance of Mesh class
3100 # @ingroup l2_modif_trsf
3101 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3102 if (isinstance(theObject, Mesh)):
3103 theObject = theObject.GetMesh()
3104 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3105 Vector = self.smeshpyD.GetDirStruct(Vector)
3106 Vector,Parameters = ParseDirStruct(Vector)
3107 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3108 mesh.SetParameters(Parameters)
3109 return Mesh( self.smeshpyD, self.geompyD, mesh )
3111 ## Rotates the elements
3112 # @param IDsOfElements list of elements ids
3113 # @param Axis the axis of rotation (AxisStruct or geom line)
3114 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3115 # @param Copy allows copying the rotated elements
3116 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3117 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3118 # @ingroup l2_modif_trsf
3119 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3121 if isinstance(AngleInRadians,str):
3123 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3125 AngleInRadians = DegreesToRadians(AngleInRadians)
3126 if IDsOfElements == []:
3127 IDsOfElements = self.GetElementsId()
3128 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3129 Axis = self.smeshpyD.GetAxisStruct(Axis)
3130 Axis,AxisParameters = ParseAxisStruct(Axis)
3131 Parameters = AxisParameters + var_separator + Parameters
3132 self.mesh.SetParameters(Parameters)
3133 if Copy and MakeGroups:
3134 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3135 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3138 ## Creates a new mesh of rotated elements
3139 # @param IDsOfElements list of element ids
3140 # @param Axis the axis of rotation (AxisStruct or geom line)
3141 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3142 # @param MakeGroups forces the generation of new groups from existing ones
3143 # @param NewMeshName the name of the newly created mesh
3144 # @return instance of Mesh class
3145 # @ingroup l2_modif_trsf
3146 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3148 if isinstance(AngleInRadians,str):
3150 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3152 AngleInRadians = DegreesToRadians(AngleInRadians)
3153 if IDsOfElements == []:
3154 IDsOfElements = self.GetElementsId()
3155 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3156 Axis = self.smeshpyD.GetAxisStruct(Axis)
3157 Axis,AxisParameters = ParseAxisStruct(Axis)
3158 Parameters = AxisParameters + var_separator + Parameters
3159 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3160 MakeGroups, NewMeshName)
3161 mesh.SetParameters(Parameters)
3162 return Mesh( self.smeshpyD, self.geompyD, mesh )
3164 ## Rotates the object
3165 # @param theObject the object to rotate( mesh, submesh, or group)
3166 # @param Axis the axis of rotation (AxisStruct or geom line)
3167 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3168 # @param Copy allows copying the rotated elements
3169 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3170 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3171 # @ingroup l2_modif_trsf
3172 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3174 if isinstance(AngleInRadians,str):
3176 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3178 AngleInRadians = DegreesToRadians(AngleInRadians)
3179 if (isinstance(theObject, Mesh)):
3180 theObject = theObject.GetMesh()
3181 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3182 Axis = self.smeshpyD.GetAxisStruct(Axis)
3183 Axis,AxisParameters = ParseAxisStruct(Axis)
3184 Parameters = AxisParameters + ":" + Parameters
3185 self.mesh.SetParameters(Parameters)
3186 if Copy and MakeGroups:
3187 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3188 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3191 ## Creates a new mesh from the rotated object
3192 # @param theObject the object to rotate (mesh, submesh, or group)
3193 # @param Axis the axis of rotation (AxisStruct or geom line)
3194 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3195 # @param MakeGroups forces the generation of new groups from existing ones
3196 # @param NewMeshName the name of the newly created mesh
3197 # @return instance of Mesh class
3198 # @ingroup l2_modif_trsf
3199 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3201 if isinstance(AngleInRadians,str):
3203 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3205 AngleInRadians = DegreesToRadians(AngleInRadians)
3206 if (isinstance( theObject, Mesh )):
3207 theObject = theObject.GetMesh()
3208 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3209 Axis = self.smeshpyD.GetAxisStruct(Axis)
3210 Axis,AxisParameters = ParseAxisStruct(Axis)
3211 Parameters = AxisParameters + ":" + Parameters
3212 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3213 MakeGroups, NewMeshName)
3214 mesh.SetParameters(Parameters)
3215 return Mesh( self.smeshpyD, self.geompyD, mesh )
3217 ## Finds groups of ajacent nodes within Tolerance.
3218 # @param Tolerance the value of tolerance
3219 # @return the list of groups of nodes
3220 # @ingroup l2_modif_trsf
3221 def FindCoincidentNodes (self, Tolerance):
3222 return self.editor.FindCoincidentNodes(Tolerance)
3224 ## Finds groups of ajacent nodes within Tolerance.
3225 # @param Tolerance the value of tolerance
3226 # @param SubMeshOrGroup SubMesh or Group
3227 # @return the list of groups of nodes
3228 # @ingroup l2_modif_trsf
3229 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3230 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3233 # @param GroupsOfNodes the list of groups of nodes
3234 # @ingroup l2_modif_trsf
3235 def MergeNodes (self, GroupsOfNodes):
3236 self.editor.MergeNodes(GroupsOfNodes)
3238 ## Finds the elements built on the same nodes.
3239 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3240 # @return a list of groups of equal elements
3241 # @ingroup l2_modif_trsf
3242 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3243 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3245 ## Merges elements in each given group.
3246 # @param GroupsOfElementsID groups of elements for merging
3247 # @ingroup l2_modif_trsf
3248 def MergeElements(self, GroupsOfElementsID):
3249 self.editor.MergeElements(GroupsOfElementsID)
3251 ## Leaves one element and removes all other elements built on the same nodes.
3252 # @ingroup l2_modif_trsf
3253 def MergeEqualElements(self):
3254 self.editor.MergeEqualElements()
3256 ## Sews free borders
3257 # @return SMESH::Sew_Error
3258 # @ingroup l2_modif_trsf
3259 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3260 FirstNodeID2, SecondNodeID2, LastNodeID2,
3261 CreatePolygons, CreatePolyedrs):
3262 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3263 FirstNodeID2, SecondNodeID2, LastNodeID2,
3264 CreatePolygons, CreatePolyedrs)
3266 ## Sews conform free borders
3267 # @return SMESH::Sew_Error
3268 # @ingroup l2_modif_trsf
3269 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3270 FirstNodeID2, SecondNodeID2):
3271 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3272 FirstNodeID2, SecondNodeID2)
3274 ## Sews border to side
3275 # @return SMESH::Sew_Error
3276 # @ingroup l2_modif_trsf
3277 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3278 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3279 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3280 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3282 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3283 # merged with the nodes of elements of Side2.
3284 # The number of elements in theSide1 and in theSide2 must be
3285 # equal and they should have similar nodal connectivity.
3286 # The nodes to merge should belong to side borders and
3287 # the first node should be linked to the second.
3288 # @return SMESH::Sew_Error
3289 # @ingroup l2_modif_trsf
3290 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3291 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3292 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3293 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3294 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3295 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3297 ## Sets new nodes for the given element.
3298 # @param ide the element id
3299 # @param newIDs nodes ids
3300 # @return If the number of nodes does not correspond to the type of element - returns false
3301 # @ingroup l2_modif_edit
3302 def ChangeElemNodes(self, ide, newIDs):
3303 return self.editor.ChangeElemNodes(ide, newIDs)
3305 ## If during the last operation of MeshEditor some nodes were
3306 # created, this method returns the list of their IDs, \n
3307 # if new nodes were not created - returns empty list
3308 # @return the list of integer values (can be empty)
3309 # @ingroup l1_auxiliary
3310 def GetLastCreatedNodes(self):
3311 return self.editor.GetLastCreatedNodes()
3313 ## If during the last operation of MeshEditor some elements were
3314 # created this method returns the list of their IDs, \n
3315 # if new elements were not created - returns empty list
3316 # @return the list of integer values (can be empty)
3317 # @ingroup l1_auxiliary
3318 def GetLastCreatedElems(self):
3319 return self.editor.GetLastCreatedElems()
3321 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3322 # @param theNodes identifiers of nodes to be doubled
3323 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3324 # nodes. If list of element identifiers is empty then nodes are doubled but
3325 # they not assigned to elements
3326 # @return TRUE if operation has been completed successfully, FALSE otherwise
3327 # @ingroup l2_modif_edit
3328 def DoubleNodes(self, theNodes, theModifiedElems):
3329 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3331 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3332 # This method provided for convenience works as DoubleNodes() described above.
3333 # @param theNodes identifiers of node to be doubled
3334 # @param theModifiedElems identifiers of elements to be updated
3335 # @return TRUE if operation has been completed successfully, FALSE otherwise
3336 # @ingroup l2_modif_edit
3337 def DoubleNode(self, theNodeId, theModifiedElems):
3338 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3340 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3341 # This method provided for convenience works as DoubleNodes() described above.
3342 # @param theNodes group of nodes to be doubled
3343 # @param theModifiedElems group of elements to be updated.
3344 # @return TRUE if operation has been completed successfully, FALSE otherwise
3345 # @ingroup l2_modif_edit
3346 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3347 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3349 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3350 # This method provided for convenience works as DoubleNodes() described above.
3351 # @param theNodes list of groups of nodes to be doubled
3352 # @param theModifiedElems list of groups of elements to be updated.
3353 # @return TRUE if operation has been completed successfully, FALSE otherwise
3354 # @ingroup l2_modif_edit
3355 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3356 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3358 ## The mother class to define algorithm, it is not recommended to use it directly.
3361 # @ingroup l2_algorithms
3362 class Mesh_Algorithm:
3363 # @class Mesh_Algorithm
3364 # @brief Class Mesh_Algorithm
3366 #def __init__(self,smesh):
3374 ## Finds a hypothesis in the study by its type name and parameters.
3375 # Finds only the hypotheses created in smeshpyD engine.
3376 # @return SMESH.SMESH_Hypothesis
3377 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3378 study = smeshpyD.GetCurrentStudy()
3379 #to do: find component by smeshpyD object, not by its data type
3380 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3381 if scomp is not None:
3382 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3383 # Check if the root label of the hypotheses exists
3384 if res and hypRoot is not None:
3385 iter = study.NewChildIterator(hypRoot)
3386 # Check all published hypotheses
3388 hypo_so_i = iter.Value()
3389 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3390 if attr is not None:
3391 anIOR = attr.Value()
3392 hypo_o_i = salome.orb.string_to_object(anIOR)
3393 if hypo_o_i is not None:
3394 # Check if this is a hypothesis
3395 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3396 if hypo_i is not None:
3397 # Check if the hypothesis belongs to current engine
3398 if smeshpyD.GetObjectId(hypo_i) > 0:
3399 # Check if this is the required hypothesis
3400 if hypo_i.GetName() == hypname:
3402 if CompareMethod(hypo_i, args):
3416 ## Finds the algorithm in the study by its type name.
3417 # Finds only the algorithms, which have been created in smeshpyD engine.
3418 # @return SMESH.SMESH_Algo
3419 def FindAlgorithm (self, algoname, smeshpyD):
3420 study = smeshpyD.GetCurrentStudy()
3421 #to do: find component by smeshpyD object, not by its data type
3422 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3423 if scomp is not None:
3424 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3425 # Check if the root label of the algorithms exists
3426 if res and hypRoot is not None:
3427 iter = study.NewChildIterator(hypRoot)
3428 # Check all published algorithms
3430 algo_so_i = iter.Value()
3431 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3432 if attr is not None:
3433 anIOR = attr.Value()
3434 algo_o_i = salome.orb.string_to_object(anIOR)
3435 if algo_o_i is not None:
3436 # Check if this is an algorithm
3437 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3438 if algo_i is not None:
3439 # Checks if the algorithm belongs to the current engine
3440 if smeshpyD.GetObjectId(algo_i) > 0:
3441 # Check if this is the required algorithm
3442 if algo_i.GetName() == algoname:
3455 ## If the algorithm is global, returns 0; \n
3456 # else returns the submesh associated to this algorithm.
3457 def GetSubMesh(self):
3460 ## Returns the wrapped mesher.
3461 def GetAlgorithm(self):
3464 ## Gets the list of hypothesis that can be used with this algorithm
3465 def GetCompatibleHypothesis(self):
3468 mylist = self.algo.GetCompatibleHypothesis()
3471 ## Gets the name of the algorithm
3475 ## Sets the name to the algorithm
3476 def SetName(self, name):
3477 self.mesh.smeshpyD.SetName(self.algo, name)
3479 ## Gets the id of the algorithm
3481 return self.algo.GetId()
3484 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3486 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3487 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3489 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3491 self.Assign(algo, mesh, geom)
3495 def Assign(self, algo, mesh, geom):
3497 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3504 name = GetName(geom)
3506 name = mesh.geompyD.SubShapeName(geom, piece)
3507 mesh.geompyD.addToStudyInFather(piece, geom, name)
3508 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3511 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3512 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3514 def CompareHyp (self, hyp, args):
3515 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3518 def CompareEqualHyp (self, hyp, args):
3522 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3523 UseExisting=0, CompareMethod=""):
3526 if CompareMethod == "": CompareMethod = self.CompareHyp
3527 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3530 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3536 a = a + s + str(args[i])
3540 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3542 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3543 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3546 ## Returns entry of the shape to mesh in the study
3547 def MainShapeEntry(self):
3549 if not self.mesh or not self.mesh.GetMesh(): return entry
3550 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3551 study = self.mesh.smeshpyD.GetCurrentStudy()
3552 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3553 sobj = study.FindObjectIOR(ior)
3554 if sobj: entry = sobj.GetID()
3555 if not entry: return ""
3558 # Public class: Mesh_Segment
3559 # --------------------------
3561 ## Class to define a segment 1D algorithm for discretization
3564 # @ingroup l3_algos_basic
3565 class Mesh_Segment(Mesh_Algorithm):
3567 ## Private constructor.
3568 def __init__(self, mesh, geom=0):
3569 Mesh_Algorithm.__init__(self)
3570 self.Create(mesh, geom, "Regular_1D")
3572 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3573 # @param l for the length of segments that cut an edge
3574 # @param UseExisting if ==true - searches for an existing hypothesis created with
3575 # the same parameters, else (default) - creates a new one
3576 # @param p precision, used for calculation of the number of segments.
3577 # The precision should be a positive, meaningful value within the range [0,1].
3578 # In general, the number of segments is calculated with the formula:
3579 # nb = ceil((edge_length / l) - p)
3580 # Function ceil rounds its argument to the higher integer.
3581 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3582 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3583 # p=1 means rounding of (edge_length / l) to the lower integer.
3584 # Default value is 1e-07.
3585 # @return an instance of StdMeshers_LocalLength hypothesis
3586 # @ingroup l3_hypos_1dhyps
3587 def LocalLength(self, l, UseExisting=0, p=1e-07):
3588 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3589 CompareMethod=self.CompareLocalLength)
3595 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3596 def CompareLocalLength(self, hyp, args):
3597 if IsEqual(hyp.GetLength(), args[0]):
3598 return IsEqual(hyp.GetPrecision(), args[1])
3601 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3602 # @param length is optional maximal allowed length of segment, if it is omitted
3603 # the preestimated length is used that depends on geometry size
3604 # @param UseExisting if ==true - searches for an existing hypothesis created with
3605 # the same parameters, else (default) - create a new one
3606 # @return an instance of StdMeshers_MaxLength hypothesis
3607 # @ingroup l3_hypos_1dhyps
3608 def MaxSize(self, length=0.0, UseExisting=0):
3609 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3612 hyp.SetLength(length)
3614 # set preestimated length
3615 gen = self.mesh.smeshpyD
3616 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3617 self.mesh.GetMesh(), self.mesh.GetShape(),
3619 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3621 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3624 hyp.SetUsePreestimatedLength( length == 0.0 )
3627 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3628 # @param n for the number of segments that cut an edge
3629 # @param s for the scale factor (optional)
3630 # @param reversedEdges is a list of edges to mesh using reversed orientation
3631 # @param UseExisting if ==true - searches for an existing hypothesis created with
3632 # the same parameters, else (default) - create a new one
3633 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3634 # @ingroup l3_hypos_1dhyps
3635 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3636 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3637 reversedEdges, UseExisting = [], reversedEdges
3638 entry = self.MainShapeEntry()
3640 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3641 UseExisting=UseExisting,
3642 CompareMethod=self.CompareNumberOfSegments)
3644 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3645 UseExisting=UseExisting,
3646 CompareMethod=self.CompareNumberOfSegments)
3647 hyp.SetDistrType( 1 )
3648 hyp.SetScaleFactor(s)
3649 hyp.SetNumberOfSegments(n)
3650 hyp.SetReversedEdges( reversedEdges )
3651 hyp.SetObjectEntry( entry )
3655 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3656 def CompareNumberOfSegments(self, hyp, args):
3657 if hyp.GetNumberOfSegments() == args[0]:
3659 if hyp.GetReversedEdges() == args[1]:
3660 if not args[1] or hyp.GetObjectEntry() == args[2]:
3663 if hyp.GetReversedEdges() == args[2]:
3664 if not args[2] or hyp.GetObjectEntry() == args[3]:
3665 if hyp.GetDistrType() == 1:
3666 if IsEqual(hyp.GetScaleFactor(), args[1]):
3670 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3671 # @param start defines the length of the first segment
3672 # @param end defines the length of the last segment
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) - creates a new one
3676 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3677 # @ingroup l3_hypos_1dhyps
3678 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3679 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3680 reversedEdges, UseExisting = [], reversedEdges
3681 entry = self.MainShapeEntry()
3682 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
3683 UseExisting=UseExisting,
3684 CompareMethod=self.CompareArithmetic1D)
3685 hyp.SetStartLength(start)
3686 hyp.SetEndLength(end)
3687 hyp.SetReversedEdges( reversedEdges )
3688 hyp.SetObjectEntry( entry )
3692 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3693 def CompareArithmetic1D(self, hyp, args):
3694 if IsEqual(hyp.GetLength(1), args[0]):
3695 if IsEqual(hyp.GetLength(0), args[1]):
3696 if hyp.GetReversedEdges() == args[2]:
3697 if not args[2] or hyp.GetObjectEntry() == args[3]:
3701 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3702 # @param start defines the length of the first segment
3703 # @param end defines the length of the last segment
3704 # @param reversedEdges is a list of edges to mesh using reversed orientation
3705 # @param UseExisting if ==true - searches for an existing hypothesis created with
3706 # the same parameters, else (default) - creates a new one
3707 # @return an instance of StdMeshers_StartEndLength hypothesis
3708 # @ingroup l3_hypos_1dhyps
3709 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3710 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3711 reversedEdges, UseExisting = [], reversedEdges
3712 entry = self.MainShapeEntry()
3713 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3714 UseExisting=UseExisting,
3715 CompareMethod=self.CompareStartEndLength)
3716 hyp.SetStartLength(start)
3717 hyp.SetEndLength(end)
3718 hyp.SetReversedEdges( reversedEdges )
3719 hyp.SetObjectEntry( entry )
3722 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3723 def CompareStartEndLength(self, hyp, args):
3724 if IsEqual(hyp.GetLength(1), args[0]):
3725 if IsEqual(hyp.GetLength(0), args[1]):
3726 if hyp.GetReversedEdges() == args[2]:
3727 if not args[2] or hyp.GetObjectEntry() == args[3]:
3731 ## Defines "Deflection1D" hypothesis
3732 # @param d for the deflection
3733 # @param UseExisting if ==true - searches for an existing hypothesis created with
3734 # the same parameters, else (default) - create a new one
3735 # @ingroup l3_hypos_1dhyps
3736 def Deflection1D(self, d, UseExisting=0):
3737 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3738 CompareMethod=self.CompareDeflection1D)
3739 hyp.SetDeflection(d)
3742 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3743 def CompareDeflection1D(self, hyp, args):
3744 return IsEqual(hyp.GetDeflection(), args[0])
3746 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3747 # the opposite side in case of quadrangular faces
3748 # @ingroup l3_hypos_additi
3749 def Propagation(self):
3750 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3752 ## Defines "AutomaticLength" hypothesis
3753 # @param fineness for the fineness [0-1]
3754 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3755 # same parameters, else (default) - create a new one
3756 # @ingroup l3_hypos_1dhyps
3757 def AutomaticLength(self, fineness=0, UseExisting=0):
3758 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3759 CompareMethod=self.CompareAutomaticLength)
3760 hyp.SetFineness( fineness )
3763 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3764 def CompareAutomaticLength(self, hyp, args):
3765 return IsEqual(hyp.GetFineness(), args[0])
3767 ## Defines "SegmentLengthAroundVertex" hypothesis
3768 # @param length for the segment length
3769 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3770 # Any other integer value means that the hypothesis will be set on the
3771 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3772 # @param UseExisting if ==true - searches for an existing hypothesis created with
3773 # the same parameters, else (default) - creates a new one
3774 # @ingroup l3_algos_segmarv
3775 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3777 store_geom = self.geom
3778 if type(vertex) is types.IntType:
3779 if vertex == 0 or vertex == 1:
3780 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3788 if self.geom is None:
3789 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3790 name = GetName(self.geom)
3792 piece = self.mesh.geom
3793 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3794 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3795 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3797 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3799 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3800 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3802 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3803 CompareMethod=self.CompareLengthNearVertex)
3804 self.geom = store_geom
3805 hyp.SetLength( length )
3808 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3809 # @ingroup l3_algos_segmarv
3810 def CompareLengthNearVertex(self, hyp, args):
3811 return IsEqual(hyp.GetLength(), args[0])
3813 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3814 # If the 2D mesher sees that all boundary edges are quadratic,
3815 # it generates quadratic faces, else it generates linear faces using
3816 # medium nodes as if they are vertices.
3817 # The 3D mesher generates quadratic volumes only if all boundary faces
3818 # are quadratic, else it fails.
3820 # @ingroup l3_hypos_additi
3821 def QuadraticMesh(self):
3822 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3825 # Public class: Mesh_CompositeSegment
3826 # --------------------------
3828 ## Defines a segment 1D algorithm for discretization
3830 # @ingroup l3_algos_basic
3831 class Mesh_CompositeSegment(Mesh_Segment):
3833 ## Private constructor.
3834 def __init__(self, mesh, geom=0):
3835 self.Create(mesh, geom, "CompositeSegment_1D")
3838 # Public class: Mesh_Segment_Python
3839 # ---------------------------------
3841 ## Defines a segment 1D algorithm for discretization with python function
3843 # @ingroup l3_algos_basic
3844 class Mesh_Segment_Python(Mesh_Segment):
3846 ## Private constructor.
3847 def __init__(self, mesh, geom=0):
3848 import Python1dPlugin
3849 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3851 ## Defines "PythonSplit1D" hypothesis
3852 # @param n for the number of segments that cut an edge
3853 # @param func for the python function that calculates the length of all segments
3854 # @param UseExisting if ==true - searches for the existing hypothesis created with
3855 # the same parameters, else (default) - creates a new one
3856 # @ingroup l3_hypos_1dhyps
3857 def PythonSplit1D(self, n, func, UseExisting=0):
3858 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3859 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3860 hyp.SetNumberOfSegments(n)
3861 hyp.SetPythonLog10RatioFunction(func)
3864 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3865 def ComparePythonSplit1D(self, hyp, args):
3866 #if hyp.GetNumberOfSegments() == args[0]:
3867 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3871 # Public class: Mesh_Triangle
3872 # ---------------------------
3874 ## Defines a triangle 2D algorithm
3876 # @ingroup l3_algos_basic
3877 class Mesh_Triangle(Mesh_Algorithm):
3886 ## Private constructor.
3887 def __init__(self, mesh, algoType, geom=0):
3888 Mesh_Algorithm.__init__(self)
3890 self.algoType = algoType
3891 if algoType == MEFISTO:
3892 self.Create(mesh, geom, "MEFISTO_2D")
3894 elif algoType == BLSURF:
3896 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3897 #self.SetPhysicalMesh() - PAL19680
3898 elif algoType == NETGEN:
3900 print "Warning: NETGENPlugin module unavailable"
3902 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3904 elif algoType == NETGEN_2D:
3906 print "Warning: NETGENPlugin module unavailable"
3908 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3911 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3912 # @param area for the maximum area of each triangle
3913 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3914 # same parameters, else (default) - creates a new one
3916 # Only for algoType == MEFISTO || NETGEN_2D
3917 # @ingroup l3_hypos_2dhyps
3918 def MaxElementArea(self, area, UseExisting=0):
3919 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3920 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3921 CompareMethod=self.CompareMaxElementArea)
3922 elif self.algoType == NETGEN:
3923 hyp = self.Parameters(SIMPLE)
3924 hyp.SetMaxElementArea(area)
3927 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3928 def CompareMaxElementArea(self, hyp, args):
3929 return IsEqual(hyp.GetMaxElementArea(), args[0])
3931 ## Defines "LengthFromEdges" hypothesis to build triangles
3932 # based on the length of the edges taken from the wire
3934 # Only for algoType == MEFISTO || NETGEN_2D
3935 # @ingroup l3_hypos_2dhyps
3936 def LengthFromEdges(self):
3937 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3938 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3940 elif self.algoType == NETGEN:
3941 hyp = self.Parameters(SIMPLE)
3942 hyp.LengthFromEdges()
3945 ## Sets a way to define size of mesh elements to generate.
3946 # @param thePhysicalMesh is: DefaultSize or Custom.
3947 # @ingroup l3_hypos_blsurf
3948 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3949 # Parameter of BLSURF algo
3950 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3952 ## Sets size of mesh elements to generate.
3953 # @ingroup l3_hypos_blsurf
3954 def SetPhySize(self, theVal):
3955 # Parameter of BLSURF algo
3956 self.Parameters().SetPhySize(theVal)
3958 ## Sets lower boundary of mesh element size (PhySize).
3959 # @ingroup l3_hypos_blsurf
3960 def SetPhyMin(self, theVal=-1):
3961 # Parameter of BLSURF algo
3962 self.Parameters().SetPhyMin(theVal)
3964 ## Sets upper boundary of mesh element size (PhySize).
3965 # @ingroup l3_hypos_blsurf
3966 def SetPhyMax(self, theVal=-1):
3967 # Parameter of BLSURF algo
3968 self.Parameters().SetPhyMax(theVal)
3970 ## Sets a way to define maximum angular deflection of mesh from CAD model.
3971 # @param theGeometricMesh is: DefaultGeom or Custom
3972 # @ingroup l3_hypos_blsurf
3973 def SetGeometricMesh(self, theGeometricMesh=0):
3974 # Parameter of BLSURF algo
3975 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3976 self.params.SetGeometricMesh(theGeometricMesh)
3978 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3979 # @ingroup l3_hypos_blsurf
3980 def SetAngleMeshS(self, theVal=_angleMeshS):
3981 # Parameter of BLSURF algo
3982 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3983 self.params.SetAngleMeshS(theVal)
3985 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3986 # @ingroup l3_hypos_blsurf
3987 def SetAngleMeshC(self, theVal=_angleMeshS):
3988 # Parameter of BLSURF algo
3989 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3990 self.params.SetAngleMeshC(theVal)
3992 ## Sets lower boundary of mesh element size computed to respect angular deflection.
3993 # @ingroup l3_hypos_blsurf
3994 def SetGeoMin(self, theVal=-1):
3995 # Parameter of BLSURF algo
3996 self.Parameters().SetGeoMin(theVal)
3998 ## Sets upper boundary of mesh element size computed to respect angular deflection.
3999 # @ingroup l3_hypos_blsurf
4000 def SetGeoMax(self, theVal=-1):
4001 # Parameter of BLSURF algo
4002 self.Parameters().SetGeoMax(theVal)
4004 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4005 # @ingroup l3_hypos_blsurf
4006 def SetGradation(self, theVal=_gradation):
4007 # Parameter of BLSURF algo
4008 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4009 self.params.SetGradation(theVal)
4011 ## Sets topology usage way.
4012 # @param way defines how mesh conformity is assured <ul>
4013 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4014 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4015 # @ingroup l3_hypos_blsurf
4016 def SetTopology(self, way):
4017 # Parameter of BLSURF algo
4018 self.Parameters().SetTopology(way)
4020 ## To respect geometrical edges or not.
4021 # @ingroup l3_hypos_blsurf
4022 def SetDecimesh(self, toIgnoreEdges=False):
4023 # Parameter of BLSURF algo
4024 self.Parameters().SetDecimesh(toIgnoreEdges)
4026 ## Sets verbosity level in the range 0 to 100.
4027 # @ingroup l3_hypos_blsurf
4028 def SetVerbosity(self, level):
4029 # Parameter of BLSURF algo
4030 self.Parameters().SetVerbosity(level)
4032 ## Sets advanced option value.
4033 # @ingroup l3_hypos_blsurf
4034 def SetOptionValue(self, optionName, level):
4035 # Parameter of BLSURF algo
4036 self.Parameters().SetOptionValue(optionName,level)
4038 ## Sets QuadAllowed flag.
4039 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4040 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4041 def SetQuadAllowed(self, toAllow=True):
4042 if self.algoType == NETGEN_2D:
4043 if toAllow: # add QuadranglePreference
4044 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4045 else: # remove QuadranglePreference
4046 for hyp in self.mesh.GetHypothesisList( self.geom ):
4047 if hyp.GetName() == "QuadranglePreference":
4048 self.mesh.RemoveHypothesis( self.geom, hyp )
4053 if self.Parameters():
4054 self.params.SetQuadAllowed(toAllow)
4057 ## Defines hypothesis having several parameters
4059 # @ingroup l3_hypos_netgen
4060 def Parameters(self, which=SOLE):
4063 if self.algoType == NETGEN:
4065 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4066 "libNETGENEngine.so", UseExisting=0)
4068 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4069 "libNETGENEngine.so", UseExisting=0)
4071 elif self.algoType == MEFISTO:
4072 print "Mefisto algo support no multi-parameter hypothesis"
4074 elif self.algoType == NETGEN_2D:
4075 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4076 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4078 elif self.algoType == BLSURF:
4079 self.params = self.Hypothesis("BLSURF_Parameters", [],
4080 "libBLSURFEngine.so", UseExisting=0)
4083 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4088 # Only for algoType == NETGEN
4089 # @ingroup l3_hypos_netgen
4090 def SetMaxSize(self, theSize):
4091 if self.Parameters():
4092 self.params.SetMaxSize(theSize)
4094 ## Sets SecondOrder flag
4096 # Only for algoType == NETGEN
4097 # @ingroup l3_hypos_netgen
4098 def SetSecondOrder(self, theVal):
4099 if self.Parameters():
4100 self.params.SetSecondOrder(theVal)
4102 ## Sets Optimize flag
4104 # Only for algoType == NETGEN
4105 # @ingroup l3_hypos_netgen
4106 def SetOptimize(self, theVal):
4107 if self.Parameters():
4108 self.params.SetOptimize(theVal)
4111 # @param theFineness is:
4112 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4114 # Only for algoType == NETGEN
4115 # @ingroup l3_hypos_netgen
4116 def SetFineness(self, theFineness):
4117 if self.Parameters():
4118 self.params.SetFineness(theFineness)
4122 # Only for algoType == NETGEN
4123 # @ingroup l3_hypos_netgen
4124 def SetGrowthRate(self, theRate):
4125 if self.Parameters():
4126 self.params.SetGrowthRate(theRate)
4128 ## Sets NbSegPerEdge
4130 # Only for algoType == NETGEN
4131 # @ingroup l3_hypos_netgen
4132 def SetNbSegPerEdge(self, theVal):
4133 if self.Parameters():
4134 self.params.SetNbSegPerEdge(theVal)
4136 ## Sets NbSegPerRadius
4138 # Only for algoType == NETGEN
4139 # @ingroup l3_hypos_netgen
4140 def SetNbSegPerRadius(self, theVal):
4141 if self.Parameters():
4142 self.params.SetNbSegPerRadius(theVal)
4144 ## Sets number of segments overriding value set by SetLocalLength()
4146 # Only for algoType == NETGEN
4147 # @ingroup l3_hypos_netgen
4148 def SetNumberOfSegments(self, theVal):
4149 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4151 ## Sets number of segments overriding value set by SetNumberOfSegments()
4153 # Only for algoType == NETGEN
4154 # @ingroup l3_hypos_netgen
4155 def SetLocalLength(self, theVal):
4156 self.Parameters(SIMPLE).SetLocalLength(theVal)
4161 # Public class: Mesh_Quadrangle
4162 # -----------------------------
4164 ## Defines a quadrangle 2D algorithm
4166 # @ingroup l3_algos_basic
4167 class Mesh_Quadrangle(Mesh_Algorithm):
4169 ## Private constructor.
4170 def __init__(self, mesh, geom=0):
4171 Mesh_Algorithm.__init__(self)
4172 self.Create(mesh, geom, "Quadrangle_2D")
4174 ## Defines "QuadranglePreference" hypothesis, forcing construction
4175 # of quadrangles if the number of nodes on the opposite edges is not the same
4176 # while the total number of nodes on edges is even
4178 # @ingroup l3_hypos_additi
4179 def QuadranglePreference(self):
4180 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4181 CompareMethod=self.CompareEqualHyp)
4184 ## Defines "TrianglePreference" hypothesis, forcing construction
4185 # of triangles in the refinement area if the number of nodes
4186 # on the opposite edges is not the same
4188 # @ingroup l3_hypos_additi
4189 def TrianglePreference(self):
4190 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4191 CompareMethod=self.CompareEqualHyp)
4194 # Public class: Mesh_Tetrahedron
4195 # ------------------------------
4197 ## Defines a tetrahedron 3D algorithm
4199 # @ingroup l3_algos_basic
4200 class Mesh_Tetrahedron(Mesh_Algorithm):
4205 ## Private constructor.
4206 def __init__(self, mesh, algoType, geom=0):
4207 Mesh_Algorithm.__init__(self)
4209 if algoType == NETGEN:
4210 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4213 elif algoType == FULL_NETGEN:
4215 print "Warning: NETGENPlugin module has not been imported."
4216 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4219 elif algoType == GHS3D:
4221 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4224 elif algoType == GHS3DPRL:
4225 import GHS3DPRLPlugin
4226 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4229 self.algoType = algoType
4231 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4232 # @param vol for the maximum volume of each tetrahedron
4233 # @param UseExisting if ==true - searches for the existing hypothesis created with
4234 # the same parameters, else (default) - creates a new one
4235 # @ingroup l3_hypos_maxvol
4236 def MaxElementVolume(self, vol, UseExisting=0):
4237 if self.algoType == NETGEN:
4238 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4239 CompareMethod=self.CompareMaxElementVolume)
4240 hyp.SetMaxElementVolume(vol)
4242 elif self.algoType == FULL_NETGEN:
4243 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4246 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4247 def CompareMaxElementVolume(self, hyp, args):
4248 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4250 ## Defines hypothesis having several parameters
4252 # @ingroup l3_hypos_netgen
4253 def Parameters(self, which=SOLE):
4257 if self.algoType == FULL_NETGEN:
4259 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4260 "libNETGENEngine.so", UseExisting=0)
4262 self.params = self.Hypothesis("NETGEN_Parameters", [],
4263 "libNETGENEngine.so", UseExisting=0)
4266 if self.algoType == GHS3D:
4267 self.params = self.Hypothesis("GHS3D_Parameters", [],
4268 "libGHS3DEngine.so", UseExisting=0)
4271 if self.algoType == GHS3DPRL:
4272 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4273 "libGHS3DPRLEngine.so", UseExisting=0)
4276 print "Algo supports no multi-parameter hypothesis"
4280 # Parameter of FULL_NETGEN
4281 # @ingroup l3_hypos_netgen
4282 def SetMaxSize(self, theSize):
4283 self.Parameters().SetMaxSize(theSize)
4285 ## Sets SecondOrder flag
4286 # Parameter of FULL_NETGEN
4287 # @ingroup l3_hypos_netgen
4288 def SetSecondOrder(self, theVal):
4289 self.Parameters().SetSecondOrder(theVal)
4291 ## Sets Optimize flag
4292 # Parameter of FULL_NETGEN
4293 # @ingroup l3_hypos_netgen
4294 def SetOptimize(self, theVal):
4295 self.Parameters().SetOptimize(theVal)
4298 # @param theFineness is:
4299 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4300 # Parameter of FULL_NETGEN
4301 # @ingroup l3_hypos_netgen
4302 def SetFineness(self, theFineness):
4303 self.Parameters().SetFineness(theFineness)
4306 # Parameter of FULL_NETGEN
4307 # @ingroup l3_hypos_netgen
4308 def SetGrowthRate(self, theRate):
4309 self.Parameters().SetGrowthRate(theRate)
4311 ## Sets NbSegPerEdge
4312 # Parameter of FULL_NETGEN
4313 # @ingroup l3_hypos_netgen
4314 def SetNbSegPerEdge(self, theVal):
4315 self.Parameters().SetNbSegPerEdge(theVal)
4317 ## Sets NbSegPerRadius
4318 # Parameter of FULL_NETGEN
4319 # @ingroup l3_hypos_netgen
4320 def SetNbSegPerRadius(self, theVal):
4321 self.Parameters().SetNbSegPerRadius(theVal)
4323 ## Sets number of segments overriding value set by SetLocalLength()
4324 # Only for algoType == NETGEN_FULL
4325 # @ingroup l3_hypos_netgen
4326 def SetNumberOfSegments(self, theVal):
4327 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4329 ## Sets number of segments overriding value set by SetNumberOfSegments()
4330 # Only for algoType == NETGEN_FULL
4331 # @ingroup l3_hypos_netgen
4332 def SetLocalLength(self, theVal):
4333 self.Parameters(SIMPLE).SetLocalLength(theVal)
4335 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4336 # Overrides value set by LengthFromEdges()
4337 # Only for algoType == NETGEN_FULL
4338 # @ingroup l3_hypos_netgen
4339 def MaxElementArea(self, area):
4340 self.Parameters(SIMPLE).SetMaxElementArea(area)
4342 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4343 # Overrides value set by MaxElementArea()
4344 # Only for algoType == NETGEN_FULL
4345 # @ingroup l3_hypos_netgen
4346 def LengthFromEdges(self):
4347 self.Parameters(SIMPLE).LengthFromEdges()
4349 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4350 # Overrides value set by MaxElementVolume()
4351 # Only for algoType == NETGEN_FULL
4352 # @ingroup l3_hypos_netgen
4353 def LengthFromFaces(self):
4354 self.Parameters(SIMPLE).LengthFromFaces()
4356 ## To mesh "holes" in a solid or not. Default is to mesh.
4357 # @ingroup l3_hypos_ghs3dh
4358 def SetToMeshHoles(self, toMesh):
4359 # Parameter of GHS3D
4360 self.Parameters().SetToMeshHoles(toMesh)
4362 ## Set Optimization level:
4363 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
4364 # Default is Medium_Optimization
4365 # @ingroup l3_hypos_ghs3dh
4366 def SetOptimizationLevel(self, level):
4367 # Parameter of GHS3D
4368 self.Parameters().SetOptimizationLevel(level)
4370 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4371 # @ingroup l3_hypos_ghs3dh
4372 def SetMaximumMemory(self, MB):
4373 # Advanced parameter of GHS3D
4374 self.Parameters().SetMaximumMemory(MB)
4376 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4377 # automatic memory adjustment mode.
4378 # @ingroup l3_hypos_ghs3dh
4379 def SetInitialMemory(self, MB):
4380 # Advanced parameter of GHS3D
4381 self.Parameters().SetInitialMemory(MB)
4383 ## Path to working directory.
4384 # @ingroup l3_hypos_ghs3dh
4385 def SetWorkingDirectory(self, path):
4386 # Advanced parameter of GHS3D
4387 self.Parameters().SetWorkingDirectory(path)
4389 ## To keep working files or remove them. Log file remains in case of errors anyway.
4390 # @ingroup l3_hypos_ghs3dh
4391 def SetKeepFiles(self, toKeep):
4392 # Advanced parameter of GHS3D and GHS3DPRL
4393 self.Parameters().SetKeepFiles(toKeep)
4395 ## To set verbose level [0-10]. <ul>
4396 #<li> 0 - no standard output,
4397 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4398 # indicates when the final mesh is being saved. In addition the software
4399 # gives indication regarding the CPU time.
4400 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4401 # histogram of the skin mesh, quality statistics histogram together with
4402 # the characteristics of the final mesh.</ul>
4403 # @ingroup l3_hypos_ghs3dh
4404 def SetVerboseLevel(self, level):
4405 # Advanced parameter of GHS3D
4406 self.Parameters().SetVerboseLevel(level)
4408 ## To create new nodes.
4409 # @ingroup l3_hypos_ghs3dh
4410 def SetToCreateNewNodes(self, toCreate):
4411 # Advanced parameter of GHS3D
4412 self.Parameters().SetToCreateNewNodes(toCreate)
4414 ## To use boundary recovery version which tries to create mesh on a very poor
4415 # quality surface mesh.
4416 # @ingroup l3_hypos_ghs3dh
4417 def SetToUseBoundaryRecoveryVersion(self, toUse):
4418 # Advanced parameter of GHS3D
4419 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4421 ## Sets command line option as text.
4422 # @ingroup l3_hypos_ghs3dh
4423 def SetTextOption(self, option):
4424 # Advanced parameter of GHS3D
4425 self.Parameters().SetTextOption(option)
4427 ## Sets MED files name and path.
4428 def SetMEDName(self, value):
4429 self.Parameters().SetMEDName(value)
4431 ## Sets the number of partition of the initial mesh
4432 def SetNbPart(self, value):
4433 self.Parameters().SetNbPart(value)
4435 ## When big mesh, start tepal in background
4436 def SetBackground(self, value):
4437 self.Parameters().SetBackground(value)
4439 # Public class: Mesh_Hexahedron
4440 # ------------------------------
4442 ## Defines a hexahedron 3D algorithm
4444 # @ingroup l3_algos_basic
4445 class Mesh_Hexahedron(Mesh_Algorithm):
4450 ## Private constructor.
4451 def __init__(self, mesh, algoType=Hexa, geom=0):
4452 Mesh_Algorithm.__init__(self)
4454 self.algoType = algoType
4456 if algoType == Hexa:
4457 self.Create(mesh, geom, "Hexa_3D")
4460 elif algoType == Hexotic:
4461 import HexoticPlugin
4462 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4465 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4466 # @ingroup l3_hypos_hexotic
4467 def MinMaxQuad(self, min=3, max=8, quad=True):
4468 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4470 self.params.SetHexesMinLevel(min)
4471 self.params.SetHexesMaxLevel(max)
4472 self.params.SetHexoticQuadrangles(quad)
4475 # Deprecated, only for compatibility!
4476 # Public class: Mesh_Netgen
4477 # ------------------------------
4479 ## Defines a NETGEN-based 2D or 3D algorithm
4480 # that needs no discrete boundary (i.e. independent)
4482 # This class is deprecated, only for compatibility!
4485 # @ingroup l3_algos_basic
4486 class Mesh_Netgen(Mesh_Algorithm):
4490 ## Private constructor.
4491 def __init__(self, mesh, is3D, geom=0):
4492 Mesh_Algorithm.__init__(self)
4495 print "Warning: NETGENPlugin module has not been imported."
4499 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4503 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4506 ## Defines the hypothesis containing parameters of the algorithm
4507 def Parameters(self):
4509 hyp = self.Hypothesis("NETGEN_Parameters", [],
4510 "libNETGENEngine.so", UseExisting=0)
4512 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4513 "libNETGENEngine.so", UseExisting=0)
4516 # Public class: Mesh_Projection1D
4517 # ------------------------------
4519 ## Defines a projection 1D algorithm
4520 # @ingroup l3_algos_proj
4522 class Mesh_Projection1D(Mesh_Algorithm):
4524 ## Private constructor.
4525 def __init__(self, mesh, geom=0):
4526 Mesh_Algorithm.__init__(self)
4527 self.Create(mesh, geom, "Projection_1D")
4529 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4530 # a mesh pattern is taken, and, optionally, the association of vertices
4531 # between the source edge and a target edge (to which a hypothesis is assigned)
4532 # @param edge from which nodes distribution is taken
4533 # @param mesh from which nodes distribution is taken (optional)
4534 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4535 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4536 # to associate with \a srcV (optional)
4537 # @param UseExisting if ==true - searches for the existing hypothesis created with
4538 # the same parameters, else (default) - creates a new one
4539 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4540 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4542 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4543 hyp.SetSourceEdge( edge )
4544 if not mesh is None and isinstance(mesh, Mesh):
4545 mesh = mesh.GetMesh()
4546 hyp.SetSourceMesh( mesh )
4547 hyp.SetVertexAssociation( srcV, tgtV )
4550 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4551 #def CompareSourceEdge(self, hyp, args):
4552 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4556 # Public class: Mesh_Projection2D
4557 # ------------------------------
4559 ## Defines a projection 2D algorithm
4560 # @ingroup l3_algos_proj
4562 class Mesh_Projection2D(Mesh_Algorithm):
4564 ## Private constructor.
4565 def __init__(self, mesh, geom=0):
4566 Mesh_Algorithm.__init__(self)
4567 self.Create(mesh, geom, "Projection_2D")
4569 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4570 # a mesh pattern is taken, and, optionally, the association of vertices
4571 # between the source face and the target face (to which a hypothesis is assigned)
4572 # @param face from which the mesh pattern is taken
4573 # @param mesh from which the mesh pattern is taken (optional)
4574 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4575 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4576 # to associate with \a srcV1 (optional)
4577 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4578 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4579 # to associate with \a srcV2 (optional)
4580 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4581 # the same parameters, else (default) - forces the creation a new one
4583 # Note: all association vertices must belong to one edge of a face
4584 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4585 srcV2=None, tgtV2=None, UseExisting=0):
4586 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4588 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4589 hyp.SetSourceFace( face )
4590 if not mesh is None and isinstance(mesh, Mesh):
4591 mesh = mesh.GetMesh()
4592 hyp.SetSourceMesh( mesh )
4593 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4596 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4597 #def CompareSourceFace(self, hyp, args):
4598 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4601 # Public class: Mesh_Projection3D
4602 # ------------------------------
4604 ## Defines a projection 3D algorithm
4605 # @ingroup l3_algos_proj
4607 class Mesh_Projection3D(Mesh_Algorithm):
4609 ## Private constructor.
4610 def __init__(self, mesh, geom=0):
4611 Mesh_Algorithm.__init__(self)
4612 self.Create(mesh, geom, "Projection_3D")
4614 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4615 # the mesh pattern is taken, and, optionally, the association of vertices
4616 # between the source and the target solid (to which a hipothesis is assigned)
4617 # @param solid from where the mesh pattern is taken
4618 # @param mesh from where the mesh pattern is taken (optional)
4619 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4620 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4621 # to associate with \a srcV1 (optional)
4622 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4623 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4624 # to associate with \a srcV2 (optional)
4625 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4626 # the same parameters, else (default) - creates a new one
4628 # Note: association vertices must belong to one edge of a solid
4629 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4630 srcV2=0, tgtV2=0, UseExisting=0):
4631 hyp = self.Hypothesis("ProjectionSource3D",
4632 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4634 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4635 hyp.SetSource3DShape( solid )
4636 if not mesh is None and isinstance(mesh, Mesh):
4637 mesh = mesh.GetMesh()
4638 hyp.SetSourceMesh( mesh )
4639 if srcV1 and srcV2 and tgtV1 and tgtV2:
4640 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4641 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4644 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4645 #def CompareSourceShape3D(self, hyp, args):
4646 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4650 # Public class: Mesh_Prism
4651 # ------------------------
4653 ## Defines a 3D extrusion algorithm
4654 # @ingroup l3_algos_3dextr
4656 class Mesh_Prism3D(Mesh_Algorithm):
4658 ## Private constructor.
4659 def __init__(self, mesh, geom=0):
4660 Mesh_Algorithm.__init__(self)
4661 self.Create(mesh, geom, "Prism_3D")
4663 # Public class: Mesh_RadialPrism
4664 # -------------------------------
4666 ## Defines a Radial Prism 3D algorithm
4667 # @ingroup l3_algos_radialp
4669 class Mesh_RadialPrism3D(Mesh_Algorithm):
4671 ## Private constructor.
4672 def __init__(self, mesh, geom=0):
4673 Mesh_Algorithm.__init__(self)
4674 self.Create(mesh, geom, "RadialPrism_3D")
4676 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4677 self.nbLayers = None
4679 ## Return 3D hypothesis holding the 1D one
4680 def Get3DHypothesis(self):
4681 return self.distribHyp
4683 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4684 # hypothesis. Returns the created hypothesis
4685 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4686 #print "OwnHypothesis",hypType
4687 if not self.nbLayers is None:
4688 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4689 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4690 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4691 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4692 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4693 self.distribHyp.SetLayerDistribution( hyp )
4696 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4697 # prisms to build between the inner and outer shells
4698 # @param n number of layers
4699 # @param UseExisting if ==true - searches for the existing hypothesis created with
4700 # the same parameters, else (default) - creates a new one
4701 def NumberOfLayers(self, n, UseExisting=0):
4702 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4703 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4704 CompareMethod=self.CompareNumberOfLayers)
4705 self.nbLayers.SetNumberOfLayers( n )
4706 return self.nbLayers
4708 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4709 def CompareNumberOfLayers(self, hyp, args):
4710 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4712 ## Defines "LocalLength" hypothesis, specifying the segment length
4713 # to build between the inner and the outer shells
4714 # @param l the length of segments
4715 # @param p the precision of rounding
4716 def LocalLength(self, l, p=1e-07):
4717 hyp = self.OwnHypothesis("LocalLength", [l,p])
4722 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4723 # prisms to build between the inner and the outer shells.
4724 # @param n the number of layers
4725 # @param s the scale factor (optional)
4726 def NumberOfSegments(self, n, s=[]):
4728 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4730 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4731 hyp.SetDistrType( 1 )
4732 hyp.SetScaleFactor(s)
4733 hyp.SetNumberOfSegments(n)
4736 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4737 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4738 # @param start the length of the first segment
4739 # @param end the length of the last segment
4740 def Arithmetic1D(self, start, end ):
4741 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4742 hyp.SetLength(start, 1)
4743 hyp.SetLength(end , 0)
4746 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4747 # to build between the inner and the outer shells as geometric length increasing
4748 # @param start for the length of the first segment
4749 # @param end for the length of the last segment
4750 def StartEndLength(self, start, end):
4751 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4752 hyp.SetLength(start, 1)
4753 hyp.SetLength(end , 0)
4756 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4757 # to build between the inner and outer shells
4758 # @param fineness defines the quality of the mesh within the range [0-1]
4759 def AutomaticLength(self, fineness=0):
4760 hyp = self.OwnHypothesis("AutomaticLength")
4761 hyp.SetFineness( fineness )
4764 # Private class: Mesh_UseExisting
4765 # -------------------------------
4766 class Mesh_UseExisting(Mesh_Algorithm):
4768 def __init__(self, dim, mesh, geom=0):
4770 self.Create(mesh, geom, "UseExisting_1D")
4772 self.Create(mesh, geom, "UseExisting_2D")
4775 import salome_notebook
4776 notebook = salome_notebook.notebook
4778 ##Return values of the notebook variables
4779 def ParseParameters(last, nbParams,nbParam, value):
4783 listSize = len(last)
4784 for n in range(0,nbParams):
4786 if counter < listSize:
4787 strResult = strResult + last[counter]
4789 strResult = strResult + ""
4791 if isinstance(value, str):
4792 if notebook.isVariable(value):
4793 result = notebook.get(value)
4794 strResult=strResult+value
4796 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
4798 strResult=strResult+str(value)
4800 if nbParams - 1 != counter:
4801 strResult=strResult+var_separator #":"
4803 return result, strResult
4805 #Wrapper class for StdMeshers_LocalLength hypothesis
4806 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
4808 ## Set Length parameter value
4809 # @param length numerical value or name of variable from notebook
4810 def SetLength(self, length):
4811 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
4812 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4813 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
4815 ## Set Precision parameter value
4816 # @param precision numerical value or name of variable from notebook
4817 def SetPrecision(self, precision):
4818 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
4819 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4820 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
4822 #Registering the new proxy for LocalLength
4823 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
4826 #Wrapper class for StdMeshers_LayerDistribution hypothesis
4827 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
4829 def SetLayerDistribution(self, hypo):
4830 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
4831 hypo.ClearParameters();
4832 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
4834 #Registering the new proxy for LayerDistribution
4835 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
4837 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
4838 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
4840 ## Set Length parameter value
4841 # @param length numerical value or name of variable from notebook
4842 def SetLength(self, length):
4843 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
4844 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
4845 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
4847 #Registering the new proxy for SegmentLengthAroundVertex
4848 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
4851 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
4852 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
4854 ## Set Length parameter value
4855 # @param length numerical value or name of variable from notebook
4856 # @param isStart true is length is Start Length, otherwise false
4857 def SetLength(self, length, isStart):
4861 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
4862 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
4863 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
4865 #Registering the new proxy for Arithmetic1D
4866 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
4868 #Wrapper class for StdMeshers_Deflection1D hypothesis
4869 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
4871 ## Set Deflection parameter value
4872 # @param deflection numerical value or name of variable from notebook
4873 def SetDeflection(self, deflection):
4874 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
4875 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
4876 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
4878 #Registering the new proxy for Deflection1D
4879 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
4881 #Wrapper class for StdMeshers_StartEndLength hypothesis
4882 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
4884 ## Set Length parameter value
4885 # @param length numerical value or name of variable from notebook
4886 # @param isStart true is length is Start Length, otherwise false
4887 def SetLength(self, length, isStart):
4891 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
4892 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
4893 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
4895 #Registering the new proxy for StartEndLength
4896 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
4898 #Wrapper class for StdMeshers_MaxElementArea hypothesis
4899 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
4901 ## Set Max Element Area parameter value
4902 # @param area numerical value or name of variable from notebook
4903 def SetMaxElementArea(self, area):
4904 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
4905 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
4906 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
4908 #Registering the new proxy for MaxElementArea
4909 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
4912 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
4913 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
4915 ## Set Max Element Volume parameter value
4916 # @param area numerical value or name of variable from notebook
4917 def SetMaxElementVolume(self, volume):
4918 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
4919 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
4920 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
4922 #Registering the new proxy for MaxElementVolume
4923 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
4926 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
4927 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
4929 ## Set Number Of Layers parameter value
4930 # @param nbLayers numerical value or name of variable from notebook
4931 def SetNumberOfLayers(self, nbLayers):
4932 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
4933 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
4934 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
4936 #Registering the new proxy for NumberOfLayers
4937 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
4939 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
4940 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
4942 ## Set Number Of Segments parameter value
4943 # @param nbSeg numerical value or name of variable from notebook
4944 def SetNumberOfSegments(self, nbSeg):
4945 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
4946 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
4947 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4948 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
4950 ## Set Scale Factor parameter value
4951 # @param factor numerical value or name of variable from notebook
4952 def SetScaleFactor(self, factor):
4953 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
4954 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4955 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
4957 #Registering the new proxy for NumberOfSegments
4958 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
4961 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
4962 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
4964 ## Set Max Size parameter value
4965 # @param maxsize numerical value or name of variable from notebook
4966 def SetMaxSize(self, maxsize):
4967 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4968 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
4969 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4970 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
4972 ## Set Growth Rate parameter value
4973 # @param value numerical value or name of variable from notebook
4974 def SetGrowthRate(self, value):
4975 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4976 value, parameters = ParseParameters(lastParameters,4,2,value)
4977 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4978 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
4980 ## Set Number of Segments per Edge parameter value
4981 # @param value numerical value or name of variable from notebook
4982 def SetNbSegPerEdge(self, value):
4983 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4984 value, parameters = ParseParameters(lastParameters,4,3,value)
4985 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4986 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
4988 ## Set Number of Segments per Radius parameter value
4989 # @param value numerical value or name of variable from notebook
4990 def SetNbSegPerRadius(self, value):
4991 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4992 value, parameters = ParseParameters(lastParameters,4,4,value)
4993 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4994 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
4996 #Registering the new proxy for NETGENPlugin_Hypothesis
4997 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5000 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5001 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5004 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5005 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5007 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5008 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5010 ## Set Number of Segments parameter value
5011 # @param nbSeg numerical value or name of variable from notebook
5012 def SetNumberOfSegments(self, nbSeg):
5013 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5014 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5015 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5016 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5018 ## Set Local Length parameter value
5019 # @param length numerical value or name of variable from notebook
5020 def SetLocalLength(self, length):
5021 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5022 length, parameters = ParseParameters(lastParameters,2,1,length)
5023 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5024 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5026 ## Set Max Element Area parameter value
5027 # @param area numerical value or name of variable from notebook
5028 def SetMaxElementArea(self, area):
5029 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5030 area, parameters = ParseParameters(lastParameters,2,2,area)
5031 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5032 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5034 def LengthFromEdges(self):
5035 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5037 value, parameters = ParseParameters(lastParameters,2,2,value)
5038 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5039 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5041 #Registering the new proxy for NETGEN_SimpleParameters_2D
5042 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5045 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5046 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5047 ## Set Max Element Volume parameter value
5048 # @param volume numerical value or name of variable from notebook
5049 def SetMaxElementVolume(self, volume):
5050 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5051 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5052 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5053 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5055 def LengthFromFaces(self):
5056 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5058 value, parameters = ParseParameters(lastParameters,3,3,value)
5059 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5060 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5062 #Registering the new proxy for NETGEN_SimpleParameters_3D
5063 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5065 class Pattern(SMESH._objref_SMESH_Pattern):
5067 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5069 if isinstance(theNodeIndexOnKeyPoint1,str):
5071 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5073 theNodeIndexOnKeyPoint1 -= 1
5074 theMesh.SetParameters(Parameters)
5075 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5077 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5080 if isinstance(theNode000Index,str):
5082 if isinstance(theNode001Index,str):
5084 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5086 theNode000Index -= 1
5088 theNode001Index -= 1
5089 theMesh.SetParameters(Parameters)
5090 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5092 #Registering the new proxy for Pattern
5093 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)