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 edges in the mesh
1604 # @return an integer value
1605 # @ingroup l1_meshinfo
1607 return self.mesh.NbEdges()
1609 ## Returns the number of edges with the given order in the mesh
1610 # @param elementOrder the order of elements:
1611 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1612 # @return an integer value
1613 # @ingroup l1_meshinfo
1614 def NbEdgesOfOrder(self, elementOrder):
1615 return self.mesh.NbEdgesOfOrder(elementOrder)
1617 ## Returns the number of faces in the mesh
1618 # @return an integer value
1619 # @ingroup l1_meshinfo
1621 return self.mesh.NbFaces()
1623 ## Returns the number of faces with the given order in the mesh
1624 # @param elementOrder the order of elements:
1625 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1626 # @return an integer value
1627 # @ingroup l1_meshinfo
1628 def NbFacesOfOrder(self, elementOrder):
1629 return self.mesh.NbFacesOfOrder(elementOrder)
1631 ## Returns the number of triangles in the mesh
1632 # @return an integer value
1633 # @ingroup l1_meshinfo
1634 def NbTriangles(self):
1635 return self.mesh.NbTriangles()
1637 ## Returns the number of triangles with the given order in the mesh
1638 # @param elementOrder is the order of elements:
1639 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1640 # @return an integer value
1641 # @ingroup l1_meshinfo
1642 def NbTrianglesOfOrder(self, elementOrder):
1643 return self.mesh.NbTrianglesOfOrder(elementOrder)
1645 ## Returns the number of quadrangles in the mesh
1646 # @return an integer value
1647 # @ingroup l1_meshinfo
1648 def NbQuadrangles(self):
1649 return self.mesh.NbQuadrangles()
1651 ## Returns the number of quadrangles with the given order in the mesh
1652 # @param elementOrder the order of elements:
1653 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1654 # @return an integer value
1655 # @ingroup l1_meshinfo
1656 def NbQuadranglesOfOrder(self, elementOrder):
1657 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1659 ## Returns the number of polygons in the mesh
1660 # @return an integer value
1661 # @ingroup l1_meshinfo
1662 def NbPolygons(self):
1663 return self.mesh.NbPolygons()
1665 ## Returns the number of volumes in the mesh
1666 # @return an integer value
1667 # @ingroup l1_meshinfo
1668 def NbVolumes(self):
1669 return self.mesh.NbVolumes()
1671 ## Returns the number of volumes with the given order in the mesh
1672 # @param elementOrder the order of elements:
1673 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1674 # @return an integer value
1675 # @ingroup l1_meshinfo
1676 def NbVolumesOfOrder(self, elementOrder):
1677 return self.mesh.NbVolumesOfOrder(elementOrder)
1679 ## Returns the number of tetrahedrons in the mesh
1680 # @return an integer value
1681 # @ingroup l1_meshinfo
1683 return self.mesh.NbTetras()
1685 ## Returns the number of tetrahedrons with the given order in the mesh
1686 # @param elementOrder the order of elements:
1687 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1688 # @return an integer value
1689 # @ingroup l1_meshinfo
1690 def NbTetrasOfOrder(self, elementOrder):
1691 return self.mesh.NbTetrasOfOrder(elementOrder)
1693 ## Returns the number of hexahedrons in the mesh
1694 # @return an integer value
1695 # @ingroup l1_meshinfo
1697 return self.mesh.NbHexas()
1699 ## Returns the number of hexahedrons with the given order in the mesh
1700 # @param elementOrder the order of elements:
1701 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1702 # @return an integer value
1703 # @ingroup l1_meshinfo
1704 def NbHexasOfOrder(self, elementOrder):
1705 return self.mesh.NbHexasOfOrder(elementOrder)
1707 ## Returns the number of pyramids in the mesh
1708 # @return an integer value
1709 # @ingroup l1_meshinfo
1710 def NbPyramids(self):
1711 return self.mesh.NbPyramids()
1713 ## Returns the number of pyramids with the given order in the mesh
1714 # @param elementOrder the order of elements:
1715 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1716 # @return an integer value
1717 # @ingroup l1_meshinfo
1718 def NbPyramidsOfOrder(self, elementOrder):
1719 return self.mesh.NbPyramidsOfOrder(elementOrder)
1721 ## Returns the number of prisms in the mesh
1722 # @return an integer value
1723 # @ingroup l1_meshinfo
1725 return self.mesh.NbPrisms()
1727 ## Returns the number of prisms with the given order in the mesh
1728 # @param elementOrder the order of elements:
1729 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1730 # @return an integer value
1731 # @ingroup l1_meshinfo
1732 def NbPrismsOfOrder(self, elementOrder):
1733 return self.mesh.NbPrismsOfOrder(elementOrder)
1735 ## Returns the number of polyhedrons in the mesh
1736 # @return an integer value
1737 # @ingroup l1_meshinfo
1738 def NbPolyhedrons(self):
1739 return self.mesh.NbPolyhedrons()
1741 ## Returns the number of submeshes in the mesh
1742 # @return an integer value
1743 # @ingroup l1_meshinfo
1744 def NbSubMesh(self):
1745 return self.mesh.NbSubMesh()
1747 ## Returns the list of mesh elements IDs
1748 # @return the list of integer values
1749 # @ingroup l1_meshinfo
1750 def GetElementsId(self):
1751 return self.mesh.GetElementsId()
1753 ## Returns the list of IDs of mesh elements with the given type
1754 # @param elementType the required type of elements
1755 # @return list of integer values
1756 # @ingroup l1_meshinfo
1757 def GetElementsByType(self, elementType):
1758 return self.mesh.GetElementsByType(elementType)
1760 ## Returns the list of mesh nodes IDs
1761 # @return the list of integer values
1762 # @ingroup l1_meshinfo
1763 def GetNodesId(self):
1764 return self.mesh.GetNodesId()
1766 # Get the information about mesh elements:
1767 # ------------------------------------
1769 ## Returns the type of mesh element
1770 # @return the value from SMESH::ElementType enumeration
1771 # @ingroup l1_meshinfo
1772 def GetElementType(self, id, iselem):
1773 return self.mesh.GetElementType(id, iselem)
1775 ## Returns the list of submesh elements IDs
1776 # @param Shape a geom object(subshape) IOR
1777 # Shape must be the subshape of a ShapeToMesh()
1778 # @return the list of integer values
1779 # @ingroup l1_meshinfo
1780 def GetSubMeshElementsId(self, Shape):
1781 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1782 ShapeID = Shape.GetSubShapeIndices()[0]
1785 return self.mesh.GetSubMeshElementsId(ShapeID)
1787 ## Returns the list of submesh nodes IDs
1788 # @param Shape a geom object(subshape) IOR
1789 # Shape must be the subshape of a ShapeToMesh()
1790 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1791 # @return the list of integer values
1792 # @ingroup l1_meshinfo
1793 def GetSubMeshNodesId(self, Shape, all):
1794 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1795 ShapeID = Shape.GetSubShapeIndices()[0]
1798 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1800 ## Returns type of elements on given shape
1801 # @param Shape a geom object(subshape) IOR
1802 # Shape must be a subshape of a ShapeToMesh()
1803 # @return element type
1804 # @ingroup l1_meshinfo
1805 def GetSubMeshElementType(self, Shape):
1806 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1807 ShapeID = Shape.GetSubShapeIndices()[0]
1810 return self.mesh.GetSubMeshElementType(ShapeID)
1812 ## Gets the mesh description
1813 # @return string value
1814 # @ingroup l1_meshinfo
1816 return self.mesh.Dump()
1819 # Get the information about nodes and elements of a mesh by its IDs:
1820 # -----------------------------------------------------------
1822 ## Gets XYZ coordinates of a node
1823 # \n If there is no nodes for the given ID - returns an empty list
1824 # @return a list of double precision values
1825 # @ingroup l1_meshinfo
1826 def GetNodeXYZ(self, id):
1827 return self.mesh.GetNodeXYZ(id)
1829 ## Returns list of IDs of inverse elements for the given node
1830 # \n If there is no node for the given ID - returns an empty list
1831 # @return a list of integer values
1832 # @ingroup l1_meshinfo
1833 def GetNodeInverseElements(self, id):
1834 return self.mesh.GetNodeInverseElements(id)
1836 ## @brief Returns the position of a node on the shape
1837 # @return SMESH::NodePosition
1838 # @ingroup l1_meshinfo
1839 def GetNodePosition(self,NodeID):
1840 return self.mesh.GetNodePosition(NodeID)
1842 ## If the given element is a node, returns the ID of shape
1843 # \n If there is no node for the given ID - returns -1
1844 # @return an integer value
1845 # @ingroup l1_meshinfo
1846 def GetShapeID(self, id):
1847 return self.mesh.GetShapeID(id)
1849 ## Returns the ID of the result shape after
1850 # FindShape() from SMESH_MeshEditor for the given element
1851 # \n If there is no element for the given ID - returns -1
1852 # @return an integer value
1853 # @ingroup l1_meshinfo
1854 def GetShapeIDForElem(self,id):
1855 return self.mesh.GetShapeIDForElem(id)
1857 ## Returns the number of nodes for the given element
1858 # \n If there is no element for the given ID - returns -1
1859 # @return an integer value
1860 # @ingroup l1_meshinfo
1861 def GetElemNbNodes(self, id):
1862 return self.mesh.GetElemNbNodes(id)
1864 ## Returns the node ID the given index for the given element
1865 # \n If there is no element for the given ID - returns -1
1866 # \n If there is no node for the given index - returns -2
1867 # @return an integer value
1868 # @ingroup l1_meshinfo
1869 def GetElemNode(self, id, index):
1870 return self.mesh.GetElemNode(id, index)
1872 ## Returns the IDs of nodes of the given element
1873 # @return a list of integer values
1874 # @ingroup l1_meshinfo
1875 def GetElemNodes(self, id):
1876 return self.mesh.GetElemNodes(id)
1878 ## Returns true if the given node is the medium node in the given quadratic element
1879 # @ingroup l1_meshinfo
1880 def IsMediumNode(self, elementID, nodeID):
1881 return self.mesh.IsMediumNode(elementID, nodeID)
1883 ## Returns true if the given node is the medium node in one of quadratic elements
1884 # @ingroup l1_meshinfo
1885 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1886 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1888 ## Returns the number of edges for the given element
1889 # @ingroup l1_meshinfo
1890 def ElemNbEdges(self, id):
1891 return self.mesh.ElemNbEdges(id)
1893 ## Returns the number of faces for the given element
1894 # @ingroup l1_meshinfo
1895 def ElemNbFaces(self, id):
1896 return self.mesh.ElemNbFaces(id)
1898 ## Returns true if the given element is a polygon
1899 # @ingroup l1_meshinfo
1900 def IsPoly(self, id):
1901 return self.mesh.IsPoly(id)
1903 ## Returns true if the given element is quadratic
1904 # @ingroup l1_meshinfo
1905 def IsQuadratic(self, id):
1906 return self.mesh.IsQuadratic(id)
1908 ## Returns XYZ coordinates of the barycenter of the given element
1909 # \n If there is no element for the given ID - returns an empty list
1910 # @return a list of three double values
1911 # @ingroup l1_meshinfo
1912 def BaryCenter(self, id):
1913 return self.mesh.BaryCenter(id)
1916 # Mesh edition (SMESH_MeshEditor functionality):
1917 # ---------------------------------------------
1919 ## Removes the elements from the mesh by ids
1920 # @param IDsOfElements is a list of ids of elements to remove
1921 # @return True or False
1922 # @ingroup l2_modif_del
1923 def RemoveElements(self, IDsOfElements):
1924 return self.editor.RemoveElements(IDsOfElements)
1926 ## Removes nodes from mesh by ids
1927 # @param IDsOfNodes is a list of ids of nodes to remove
1928 # @return True or False
1929 # @ingroup l2_modif_del
1930 def RemoveNodes(self, IDsOfNodes):
1931 return self.editor.RemoveNodes(IDsOfNodes)
1933 ## Add a node to the mesh by coordinates
1934 # @return Id of the new node
1935 # @ingroup l2_modif_add
1936 def AddNode(self, x, y, z):
1937 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
1938 self.mesh.SetParameters(Parameters)
1939 return self.editor.AddNode( x, y, z)
1941 ## Creates a linear or quadratic edge (this is determined
1942 # by the number of given nodes).
1943 # @param IDsOfNodes the list of node IDs for creation of the element.
1944 # The order of nodes in this list should correspond to the description
1945 # of MED. \n This description is located by the following link:
1946 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1947 # @return the Id of the new edge
1948 # @ingroup l2_modif_add
1949 def AddEdge(self, IDsOfNodes):
1950 return self.editor.AddEdge(IDsOfNodes)
1952 ## Creates a linear or quadratic face (this is determined
1953 # by the number of given nodes).
1954 # @param IDsOfNodes the list of node IDs for creation of the element.
1955 # The order of nodes in this list should correspond to the description
1956 # of MED. \n This description is located by the following link:
1957 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1958 # @return the Id of the new face
1959 # @ingroup l2_modif_add
1960 def AddFace(self, IDsOfNodes):
1961 return self.editor.AddFace(IDsOfNodes)
1963 ## Adds a polygonal face to the mesh by the list of node IDs
1964 # @param IdsOfNodes the list of node IDs for creation of the element.
1965 # @return the Id of the new face
1966 # @ingroup l2_modif_add
1967 def AddPolygonalFace(self, IdsOfNodes):
1968 return self.editor.AddPolygonalFace(IdsOfNodes)
1970 ## Creates both simple and quadratic volume (this is determined
1971 # by the number of given nodes).
1972 # @param IDsOfNodes the list of node IDs for creation of the element.
1973 # The order of nodes in this list should correspond to the description
1974 # of MED. \n This description is located by the following link:
1975 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1976 # @return the Id of the new volumic element
1977 # @ingroup l2_modif_add
1978 def AddVolume(self, IDsOfNodes):
1979 return self.editor.AddVolume(IDsOfNodes)
1981 ## Creates a volume of many faces, giving nodes for each face.
1982 # @param IdsOfNodes the list of node IDs for volume creation face by face.
1983 # @param Quantities the list of integer values, Quantities[i]
1984 # gives the quantity of nodes in face number i.
1985 # @return the Id of the new volumic element
1986 # @ingroup l2_modif_add
1987 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1988 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1990 ## Creates a volume of many faces, giving the IDs of the existing faces.
1991 # @param IdsOfFaces the list of face IDs for volume creation.
1993 # Note: The created volume will refer only to the nodes
1994 # of the given faces, not to the faces themselves.
1995 # @return the Id of the new volumic element
1996 # @ingroup l2_modif_add
1997 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1998 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2001 ## @brief Binds a node to a vertex
2002 # @param NodeID a node ID
2003 # @param Vertex a vertex or vertex ID
2004 # @return True if succeed else raises an exception
2005 # @ingroup l2_modif_add
2006 def SetNodeOnVertex(self, NodeID, Vertex):
2007 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2008 VertexID = Vertex.GetSubShapeIndices()[0]
2012 self.editor.SetNodeOnVertex(NodeID, VertexID)
2013 except SALOME.SALOME_Exception, inst:
2014 raise ValueError, inst.details.text
2018 ## @brief Stores the node position on an edge
2019 # @param NodeID a node ID
2020 # @param Edge an edge or edge ID
2021 # @param paramOnEdge a parameter on the edge where the node is located
2022 # @return True if succeed else raises an exception
2023 # @ingroup l2_modif_add
2024 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2025 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2026 EdgeID = Edge.GetSubShapeIndices()[0]
2030 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2031 except SALOME.SALOME_Exception, inst:
2032 raise ValueError, inst.details.text
2035 ## @brief Stores node position on a face
2036 # @param NodeID a node ID
2037 # @param Face a face or face ID
2038 # @param u U parameter on the face where the node is located
2039 # @param v V parameter on the face where the node is located
2040 # @return True if succeed else raises an exception
2041 # @ingroup l2_modif_add
2042 def SetNodeOnFace(self, NodeID, Face, u, v):
2043 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2044 FaceID = Face.GetSubShapeIndices()[0]
2048 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2049 except SALOME.SALOME_Exception, inst:
2050 raise ValueError, inst.details.text
2053 ## @brief Binds a node to a solid
2054 # @param NodeID a node ID
2055 # @param Solid a solid or solid ID
2056 # @return True if succeed else raises an exception
2057 # @ingroup l2_modif_add
2058 def SetNodeInVolume(self, NodeID, Solid):
2059 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2060 SolidID = Solid.GetSubShapeIndices()[0]
2064 self.editor.SetNodeInVolume(NodeID, SolidID)
2065 except SALOME.SALOME_Exception, inst:
2066 raise ValueError, inst.details.text
2069 ## @brief Bind an element to a shape
2070 # @param ElementID an element ID
2071 # @param Shape a shape or shape ID
2072 # @return True if succeed else raises an exception
2073 # @ingroup l2_modif_add
2074 def SetMeshElementOnShape(self, ElementID, Shape):
2075 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2076 ShapeID = Shape.GetSubShapeIndices()[0]
2080 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2081 except SALOME.SALOME_Exception, inst:
2082 raise ValueError, inst.details.text
2086 ## Moves the node with the given id
2087 # @param NodeID the id of the node
2088 # @param x a new X coordinate
2089 # @param y a new Y coordinate
2090 # @param z a new Z coordinate
2091 # @return True if succeed else False
2092 # @ingroup l2_modif_movenode
2093 def MoveNode(self, NodeID, x, y, z):
2094 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2095 self.mesh.SetParameters(Parameters)
2096 return self.editor.MoveNode(NodeID, x, y, z)
2098 ## Finds the node closest to a point and moves it to a point location
2099 # @param x the X coordinate of a point
2100 # @param y the Y coordinate of a point
2101 # @param z the Z coordinate of a point
2102 # @return the ID of a node
2103 # @ingroup l2_modif_throughp
2104 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2105 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2106 self.mesh.SetParameters(Parameters)
2107 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2109 ## Finds the node closest to a point
2110 # @param x the X coordinate of a point
2111 # @param y the Y coordinate of a point
2112 # @param z the Z coordinate of a point
2113 # @return the ID of a node
2114 # @ingroup l2_modif_throughp
2115 def FindNodeClosestTo(self, x, y, z):
2116 preview = self.mesh.GetMeshEditPreviewer()
2117 return preview.MoveClosestNodeToPoint(x, y, z, -1)
2119 ## Finds the node closest to a point and moves it to a point location
2120 # @param x the X coordinate of a point
2121 # @param y the Y coordinate of a point
2122 # @param z the Z coordinate of a point
2123 # @return the ID of a moved node
2124 # @ingroup l2_modif_throughp
2125 def MeshToPassThroughAPoint(self, x, y, z):
2126 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2128 ## Replaces two neighbour triangles sharing Node1-Node2 link
2129 # with the triangles built on the same 4 nodes but having other common link.
2130 # @param NodeID1 the ID of the first node
2131 # @param NodeID2 the ID of the second node
2132 # @return false if proper faces were not found
2133 # @ingroup l2_modif_invdiag
2134 def InverseDiag(self, NodeID1, NodeID2):
2135 return self.editor.InverseDiag(NodeID1, NodeID2)
2137 ## Replaces two neighbour triangles sharing Node1-Node2 link
2138 # with a quadrangle built on the same 4 nodes.
2139 # @param NodeID1 the ID of the first node
2140 # @param NodeID2 the ID of the second node
2141 # @return false if proper faces were not found
2142 # @ingroup l2_modif_unitetri
2143 def DeleteDiag(self, NodeID1, NodeID2):
2144 return self.editor.DeleteDiag(NodeID1, NodeID2)
2146 ## Reorients elements by ids
2147 # @param IDsOfElements if undefined reorients all mesh elements
2148 # @return True if succeed else False
2149 # @ingroup l2_modif_changori
2150 def Reorient(self, IDsOfElements=None):
2151 if IDsOfElements == None:
2152 IDsOfElements = self.GetElementsId()
2153 return self.editor.Reorient(IDsOfElements)
2155 ## Reorients all elements of the object
2156 # @param theObject mesh, submesh or group
2157 # @return True if succeed else False
2158 # @ingroup l2_modif_changori
2159 def ReorientObject(self, theObject):
2160 if ( isinstance( theObject, Mesh )):
2161 theObject = theObject.GetMesh()
2162 return self.editor.ReorientObject(theObject)
2164 ## Fuses the neighbouring triangles into quadrangles.
2165 # @param IDsOfElements The triangles to be fused,
2166 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2167 # @param MaxAngle is the maximum angle between element normals at which the fusion
2168 # is still performed; theMaxAngle is mesured in radians.
2169 # Also it could be a name of variable which defines angle in degrees.
2170 # @return TRUE in case of success, FALSE otherwise.
2171 # @ingroup l2_modif_unitetri
2172 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2174 if isinstance(MaxAngle,str):
2176 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2178 MaxAngle = DegreesToRadians(MaxAngle)
2179 if IDsOfElements == []:
2180 IDsOfElements = self.GetElementsId()
2181 self.mesh.SetParameters(Parameters)
2183 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2184 Functor = theCriterion
2186 Functor = self.smeshpyD.GetFunctor(theCriterion)
2187 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2189 ## Fuses the neighbouring triangles of the object into quadrangles
2190 # @param theObject is mesh, submesh or group
2191 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2192 # @param MaxAngle a max angle between element normals at which the fusion
2193 # is still performed; theMaxAngle is mesured in radians.
2194 # @return TRUE in case of success, FALSE otherwise.
2195 # @ingroup l2_modif_unitetri
2196 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2197 if ( isinstance( theObject, Mesh )):
2198 theObject = theObject.GetMesh()
2199 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2201 ## Splits quadrangles into triangles.
2202 # @param IDsOfElements the faces to be splitted.
2203 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2204 # @return TRUE in case of success, FALSE otherwise.
2205 # @ingroup l2_modif_cutquadr
2206 def QuadToTri (self, IDsOfElements, theCriterion):
2207 if IDsOfElements == []:
2208 IDsOfElements = self.GetElementsId()
2209 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2211 ## Splits quadrangles into triangles.
2212 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2213 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2214 # @return TRUE in case of success, FALSE otherwise.
2215 # @ingroup l2_modif_cutquadr
2216 def QuadToTriObject (self, theObject, theCriterion):
2217 if ( isinstance( theObject, Mesh )):
2218 theObject = theObject.GetMesh()
2219 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2221 ## Splits quadrangles into triangles.
2222 # @param IDsOfElements the faces to be splitted
2223 # @param Diag13 is used to choose a diagonal for splitting.
2224 # @return TRUE in case of success, FALSE otherwise.
2225 # @ingroup l2_modif_cutquadr
2226 def SplitQuad (self, IDsOfElements, Diag13):
2227 if IDsOfElements == []:
2228 IDsOfElements = self.GetElementsId()
2229 return self.editor.SplitQuad(IDsOfElements, Diag13)
2231 ## Splits quadrangles into triangles.
2232 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2233 # @param Diag13 is used to choose a diagonal for splitting.
2234 # @return TRUE in case of success, FALSE otherwise.
2235 # @ingroup l2_modif_cutquadr
2236 def SplitQuadObject (self, theObject, Diag13):
2237 if ( isinstance( theObject, Mesh )):
2238 theObject = theObject.GetMesh()
2239 return self.editor.SplitQuadObject(theObject, Diag13)
2241 ## Finds a better splitting of the given quadrangle.
2242 # @param IDOfQuad the ID of the quadrangle to be splitted.
2243 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2244 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2245 # diagonal is better, 0 if error occurs.
2246 # @ingroup l2_modif_cutquadr
2247 def BestSplit (self, IDOfQuad, theCriterion):
2248 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2250 ## Splits quadrangle faces near triangular facets of volumes
2252 # @ingroup l1_auxiliary
2253 def SplitQuadsNearTriangularFacets(self):
2254 faces_array = self.GetElementsByType(SMESH.FACE)
2255 for face_id in faces_array:
2256 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2257 quad_nodes = self.mesh.GetElemNodes(face_id)
2258 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2259 isVolumeFound = False
2260 for node1_elem in node1_elems:
2261 if not isVolumeFound:
2262 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2263 nb_nodes = self.GetElemNbNodes(node1_elem)
2264 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2265 volume_elem = node1_elem
2266 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2267 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2268 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2269 isVolumeFound = True
2270 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2271 self.SplitQuad([face_id], False) # diagonal 2-4
2272 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2273 isVolumeFound = True
2274 self.SplitQuad([face_id], True) # diagonal 1-3
2275 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2276 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2277 isVolumeFound = True
2278 self.SplitQuad([face_id], True) # diagonal 1-3
2280 ## @brief Splits hexahedrons into tetrahedrons.
2282 # This operation uses pattern mapping functionality for splitting.
2283 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2284 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2285 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2286 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2287 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2288 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2289 # @return TRUE in case of success, FALSE otherwise.
2290 # @ingroup l1_auxiliary
2291 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2292 # Pattern: 5.---------.6
2297 # (0,0,1) 4.---------.7 * |
2304 # (0,0,0) 0.---------.3
2305 pattern_tetra = "!!! Nb of points: \n 8 \n\
2315 !!! Indices of points of 6 tetras: \n\
2323 pattern = self.smeshpyD.GetPattern()
2324 isDone = pattern.LoadFromFile(pattern_tetra)
2326 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2329 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2330 isDone = pattern.MakeMesh(self.mesh, False, False)
2331 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2333 # split quafrangle faces near triangular facets of volumes
2334 self.SplitQuadsNearTriangularFacets()
2338 ## @brief Split hexahedrons into prisms.
2340 # Uses the pattern mapping functionality for splitting.
2341 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2342 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2343 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2344 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2345 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2346 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2347 # @return TRUE in case of success, FALSE otherwise.
2348 # @ingroup l1_auxiliary
2349 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2350 # Pattern: 5.---------.6
2355 # (0,0,1) 4.---------.7 |
2362 # (0,0,0) 0.---------.3
2363 pattern_prism = "!!! Nb of points: \n 8 \n\
2373 !!! Indices of points of 2 prisms: \n\
2377 pattern = self.smeshpyD.GetPattern()
2378 isDone = pattern.LoadFromFile(pattern_prism)
2380 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2383 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2384 isDone = pattern.MakeMesh(self.mesh, False, False)
2385 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2387 # Splits quafrangle faces near triangular facets of volumes
2388 self.SplitQuadsNearTriangularFacets()
2392 ## Smoothes elements
2393 # @param IDsOfElements the list if ids of elements to smooth
2394 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2395 # Note that nodes built on edges and boundary nodes are always fixed.
2396 # @param MaxNbOfIterations the maximum number of iterations
2397 # @param MaxAspectRatio varies in range [1.0, inf]
2398 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2399 # @return TRUE in case of success, FALSE otherwise.
2400 # @ingroup l2_modif_smooth
2401 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2402 MaxNbOfIterations, MaxAspectRatio, Method):
2403 if IDsOfElements == []:
2404 IDsOfElements = self.GetElementsId()
2405 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2406 self.mesh.SetParameters(Parameters)
2407 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2408 MaxNbOfIterations, MaxAspectRatio, Method)
2410 ## Smoothes elements which belong to the given object
2411 # @param theObject the object to smooth
2412 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2413 # Note that nodes built on edges and boundary nodes are always fixed.
2414 # @param MaxNbOfIterations the maximum number of iterations
2415 # @param MaxAspectRatio varies in range [1.0, inf]
2416 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2417 # @return TRUE in case of success, FALSE otherwise.
2418 # @ingroup l2_modif_smooth
2419 def SmoothObject(self, theObject, IDsOfFixedNodes,
2420 MaxNbOfIterations, MaxAspectRatio, Method):
2421 if ( isinstance( theObject, Mesh )):
2422 theObject = theObject.GetMesh()
2423 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2424 MaxNbOfIterations, MaxAspectRatio, Method)
2426 ## Parametrically smoothes the given elements
2427 # @param IDsOfElements the list if ids of elements to smooth
2428 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2429 # Note that nodes built on edges and boundary nodes are always fixed.
2430 # @param MaxNbOfIterations the maximum number of iterations
2431 # @param MaxAspectRatio varies in range [1.0, inf]
2432 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2433 # @return TRUE in case of success, FALSE otherwise.
2434 # @ingroup l2_modif_smooth
2435 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2436 MaxNbOfIterations, MaxAspectRatio, Method):
2437 if IDsOfElements == []:
2438 IDsOfElements = self.GetElementsId()
2439 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2440 self.mesh.SetParameters(Parameters)
2441 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2442 MaxNbOfIterations, MaxAspectRatio, Method)
2444 ## Parametrically smoothes the elements which belong to the given object
2445 # @param theObject the object to smooth
2446 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2447 # Note that nodes built on edges and boundary nodes are always fixed.
2448 # @param MaxNbOfIterations the maximum number of iterations
2449 # @param MaxAspectRatio varies in range [1.0, inf]
2450 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2451 # @return TRUE in case of success, FALSE otherwise.
2452 # @ingroup l2_modif_smooth
2453 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2454 MaxNbOfIterations, MaxAspectRatio, Method):
2455 if ( isinstance( theObject, Mesh )):
2456 theObject = theObject.GetMesh()
2457 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2458 MaxNbOfIterations, MaxAspectRatio, Method)
2460 ## Converts the mesh to quadratic, deletes old elements, replacing
2461 # them with quadratic with the same id.
2462 # @ingroup l2_modif_tofromqu
2463 def ConvertToQuadratic(self, theForce3d):
2464 self.editor.ConvertToQuadratic(theForce3d)
2466 ## Converts the mesh from quadratic to ordinary,
2467 # deletes old quadratic elements, \n replacing
2468 # them with ordinary mesh elements with the same id.
2469 # @return TRUE in case of success, FALSE otherwise.
2470 # @ingroup l2_modif_tofromqu
2471 def ConvertFromQuadratic(self):
2472 return self.editor.ConvertFromQuadratic()
2474 ## Renumber mesh nodes
2475 # @ingroup l2_modif_renumber
2476 def RenumberNodes(self):
2477 self.editor.RenumberNodes()
2479 ## Renumber mesh elements
2480 # @ingroup l2_modif_renumber
2481 def RenumberElements(self):
2482 self.editor.RenumberElements()
2484 ## Generates new elements by rotation of the elements around the axis
2485 # @param IDsOfElements the list of ids of elements to sweep
2486 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2487 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2488 # @param NbOfSteps the number of steps
2489 # @param Tolerance tolerance
2490 # @param MakeGroups forces the generation of new groups from existing ones
2491 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2492 # of all steps, else - size of each step
2493 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2494 # @ingroup l2_modif_extrurev
2495 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2496 MakeGroups=False, TotalAngle=False):
2498 if isinstance(AngleInRadians,str):
2500 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2502 AngleInRadians = DegreesToRadians(AngleInRadians)
2503 if IDsOfElements == []:
2504 IDsOfElements = self.GetElementsId()
2505 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2506 Axis = self.smeshpyD.GetAxisStruct(Axis)
2507 Axis,AxisParameters = ParseAxisStruct(Axis)
2508 if TotalAngle and NbOfSteps:
2509 AngleInRadians /= NbOfSteps
2510 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2511 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2512 self.mesh.SetParameters(Parameters)
2514 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2515 AngleInRadians, NbOfSteps, Tolerance)
2516 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2519 ## Generates new elements by rotation of the elements of object around the axis
2520 # @param theObject object which elements should be sweeped
2521 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2522 # @param AngleInRadians the angle of Rotation
2523 # @param NbOfSteps number of steps
2524 # @param Tolerance tolerance
2525 # @param MakeGroups forces the generation of new groups from existing ones
2526 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2527 # of all steps, else - size of each step
2528 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2529 # @ingroup l2_modif_extrurev
2530 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2531 MakeGroups=False, TotalAngle=False):
2533 if isinstance(AngleInRadians,str):
2535 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2537 AngleInRadians = DegreesToRadians(AngleInRadians)
2538 if ( isinstance( theObject, Mesh )):
2539 theObject = theObject.GetMesh()
2540 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2541 Axis = self.smeshpyD.GetAxisStruct(Axis)
2542 Axis,AxisParameters = ParseAxisStruct(Axis)
2543 if TotalAngle and NbOfSteps:
2544 AngleInRadians /= NbOfSteps
2545 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2546 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2547 self.mesh.SetParameters(Parameters)
2549 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2550 NbOfSteps, Tolerance)
2551 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2554 ## Generates new elements by rotation of the elements of object around the axis
2555 # @param theObject object which elements should be sweeped
2556 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2557 # @param AngleInRadians the angle of Rotation
2558 # @param NbOfSteps number of steps
2559 # @param Tolerance tolerance
2560 # @param MakeGroups forces the generation of new groups from existing ones
2561 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2562 # of all steps, else - size of each step
2563 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2564 # @ingroup l2_modif_extrurev
2565 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2566 MakeGroups=False, TotalAngle=False):
2568 if isinstance(AngleInRadians,str):
2570 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2572 AngleInRadians = DegreesToRadians(AngleInRadians)
2573 if ( isinstance( theObject, Mesh )):
2574 theObject = theObject.GetMesh()
2575 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2576 Axis = self.smeshpyD.GetAxisStruct(Axis)
2577 Axis,AxisParameters = ParseAxisStruct(Axis)
2578 if TotalAngle and NbOfSteps:
2579 AngleInRadians /= NbOfSteps
2580 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2581 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2582 self.mesh.SetParameters(Parameters)
2584 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2585 NbOfSteps, Tolerance)
2586 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2589 ## Generates new elements by rotation of the elements of object around the axis
2590 # @param theObject object which elements should be sweeped
2591 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2592 # @param AngleInRadians the angle of Rotation
2593 # @param NbOfSteps number of steps
2594 # @param Tolerance tolerance
2595 # @param MakeGroups forces the generation of new groups from existing ones
2596 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2597 # of all steps, else - size of each step
2598 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2599 # @ingroup l2_modif_extrurev
2600 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2601 MakeGroups=False, TotalAngle=False):
2603 if isinstance(AngleInRadians,str):
2605 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2607 AngleInRadians = DegreesToRadians(AngleInRadians)
2608 if ( isinstance( theObject, Mesh )):
2609 theObject = theObject.GetMesh()
2610 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2611 Axis = self.smeshpyD.GetAxisStruct(Axis)
2612 Axis,AxisParameters = ParseAxisStruct(Axis)
2613 if TotalAngle and NbOfSteps:
2614 AngleInRadians /= NbOfSteps
2615 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2616 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2617 self.mesh.SetParameters(Parameters)
2619 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2620 NbOfSteps, Tolerance)
2621 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2624 ## Generates new elements by extrusion of the elements with given ids
2625 # @param IDsOfElements the list of elements ids for extrusion
2626 # @param StepVector vector, defining the direction and value of extrusion
2627 # @param NbOfSteps the number of steps
2628 # @param MakeGroups forces the generation of new groups from existing ones
2629 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2630 # @ingroup l2_modif_extrurev
2631 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2632 if IDsOfElements == []:
2633 IDsOfElements = self.GetElementsId()
2634 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2635 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2636 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2637 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2638 Parameters = StepVectorParameters + var_separator + Parameters
2639 self.mesh.SetParameters(Parameters)
2641 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2642 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2645 ## Generates new elements by extrusion of the elements with given ids
2646 # @param IDsOfElements is ids of elements
2647 # @param StepVector vector, defining the direction and value of extrusion
2648 # @param NbOfSteps the number of steps
2649 # @param ExtrFlags sets flags for extrusion
2650 # @param SewTolerance uses for comparing locations of nodes if flag
2651 # EXTRUSION_FLAG_SEW is set
2652 # @param MakeGroups forces the generation of new groups from existing ones
2653 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2654 # @ingroup l2_modif_extrurev
2655 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2656 ExtrFlags, SewTolerance, MakeGroups=False):
2657 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2658 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2660 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2661 ExtrFlags, SewTolerance)
2662 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2663 ExtrFlags, SewTolerance)
2666 ## Generates new elements by extrusion of the elements which belong to the object
2667 # @param theObject the object which elements should be processed
2668 # @param StepVector vector, defining the direction and value of extrusion
2669 # @param NbOfSteps the number of steps
2670 # @param MakeGroups forces the generation of new groups from existing ones
2671 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2672 # @ingroup l2_modif_extrurev
2673 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2674 if ( isinstance( theObject, Mesh )):
2675 theObject = theObject.GetMesh()
2676 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2677 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2678 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2679 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2680 Parameters = StepVectorParameters + var_separator + Parameters
2681 self.mesh.SetParameters(Parameters)
2683 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2684 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2687 ## Generates new elements by extrusion of the elements which belong to the object
2688 # @param theObject object which elements should be processed
2689 # @param StepVector vector, defining the direction and value of extrusion
2690 # @param NbOfSteps the number of steps
2691 # @param MakeGroups to generate new groups from existing ones
2692 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2693 # @ingroup l2_modif_extrurev
2694 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2695 if ( isinstance( theObject, Mesh )):
2696 theObject = theObject.GetMesh()
2697 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2698 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2699 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2700 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2701 Parameters = StepVectorParameters + var_separator + Parameters
2702 self.mesh.SetParameters(Parameters)
2704 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2705 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2708 ## Generates new elements by extrusion of the elements which belong to the object
2709 # @param theObject object which elements should be processed
2710 # @param StepVector vector, defining the direction and value of extrusion
2711 # @param NbOfSteps the number of steps
2712 # @param MakeGroups forces the generation of new groups from existing ones
2713 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2714 # @ingroup l2_modif_extrurev
2715 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2716 if ( isinstance( theObject, Mesh )):
2717 theObject = theObject.GetMesh()
2718 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2719 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2720 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2721 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2722 Parameters = StepVectorParameters + var_separator + Parameters
2723 self.mesh.SetParameters(Parameters)
2725 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2726 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2731 ## Generates new elements by extrusion of the given elements
2732 # The path of extrusion must be a meshed edge.
2733 # @param Base mesh or list of ids of elements for extrusion
2734 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2735 # @param NodeStart the start node from Path. Defines the direction of extrusion
2736 # @param HasAngles allows the shape to be rotated around the path
2737 # to get the resulting mesh in a helical fashion
2738 # @param Angles list of angles in radians
2739 # @param LinearVariation forces the computation of rotation angles as linear
2740 # variation of the given Angles along path steps
2741 # @param HasRefPoint allows using the reference point
2742 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2743 # The User can specify any point as the Reference Point.
2744 # @param MakeGroups forces the generation of new groups from existing ones
2745 # @param ElemType type of elements for extrusion (if param Base is a mesh)
2746 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2747 # only SMESH::Extrusion_Error otherwise
2748 # @ingroup l2_modif_extrurev
2749 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2750 HasAngles, Angles, LinearVariation,
2751 HasRefPoint, RefPoint, MakeGroups, ElemType):
2752 Angles,AnglesParameters = ParseAngles(Angles)
2753 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2754 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2755 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2757 Parameters = AnglesParameters + var_separator + RefPointParameters
2758 self.mesh.SetParameters(Parameters)
2760 if isinstance(Base,list):
2762 if Base == []: IDsOfElements = self.GetElementsId()
2763 else: IDsOfElements = Base
2764 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2765 HasAngles, Angles, LinearVariation,
2766 HasRefPoint, RefPoint, MakeGroups, ElemType)
2768 if isinstance(Base,Mesh):
2769 return self.editor.ExtrusionAlongPathObjX(Base.GetMesh(), Path, NodeStart,
2770 HasAngles, Angles, LinearVariation,
2771 HasRefPoint, RefPoint, MakeGroups, ElemType)
2773 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2776 ## Generates new elements by extrusion of the given elements
2777 # The path of extrusion must be a meshed edge.
2778 # @param IDsOfElements ids of elements
2779 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2780 # @param PathShape shape(edge) defines the sub-mesh for the path
2781 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2782 # @param HasAngles allows the shape to be rotated around the path
2783 # to get the resulting mesh in a helical fashion
2784 # @param Angles list of angles in radians
2785 # @param HasRefPoint allows using the reference point
2786 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2787 # The User can specify any point as the Reference Point.
2788 # @param MakeGroups forces the generation of new groups from existing ones
2789 # @param LinearVariation forces the computation of rotation angles as linear
2790 # variation of the given Angles along path steps
2791 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2792 # only SMESH::Extrusion_Error otherwise
2793 # @ingroup l2_modif_extrurev
2794 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2795 HasAngles, Angles, HasRefPoint, RefPoint,
2796 MakeGroups=False, LinearVariation=False):
2797 Angles,AnglesParameters = ParseAngles(Angles)
2798 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2799 if IDsOfElements == []:
2800 IDsOfElements = self.GetElementsId()
2801 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2802 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2804 if ( isinstance( PathMesh, Mesh )):
2805 PathMesh = PathMesh.GetMesh()
2806 if HasAngles and Angles and LinearVariation:
2807 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2809 Parameters = AnglesParameters + var_separator + RefPointParameters
2810 self.mesh.SetParameters(Parameters)
2812 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2813 PathShape, NodeStart, HasAngles,
2814 Angles, HasRefPoint, RefPoint)
2815 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2816 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2818 ## Generates new elements by extrusion of the elements which belong to the object
2819 # The path of extrusion must be a meshed edge.
2820 # @param theObject the object which elements should be processed
2821 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2822 # @param PathShape shape(edge) defines the sub-mesh for the path
2823 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2824 # @param HasAngles allows the shape to be rotated around the path
2825 # to get the resulting mesh in a helical fashion
2826 # @param Angles list of angles
2827 # @param HasRefPoint allows using the reference point
2828 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2829 # The User can specify any point as the Reference Point.
2830 # @param MakeGroups forces the generation of new groups from existing ones
2831 # @param LinearVariation forces the computation of rotation angles as linear
2832 # variation of the given Angles along path steps
2833 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2834 # only SMESH::Extrusion_Error otherwise
2835 # @ingroup l2_modif_extrurev
2836 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2837 HasAngles, Angles, HasRefPoint, RefPoint,
2838 MakeGroups=False, LinearVariation=False):
2839 Angles,AnglesParameters = ParseAngles(Angles)
2840 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2841 if ( isinstance( theObject, Mesh )):
2842 theObject = theObject.GetMesh()
2843 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2844 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2845 if ( isinstance( PathMesh, Mesh )):
2846 PathMesh = PathMesh.GetMesh()
2847 if HasAngles and Angles and LinearVariation:
2848 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2850 Parameters = AnglesParameters + var_separator + RefPointParameters
2851 self.mesh.SetParameters(Parameters)
2853 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2854 PathShape, NodeStart, HasAngles,
2855 Angles, HasRefPoint, RefPoint)
2856 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2857 NodeStart, HasAngles, Angles, HasRefPoint,
2860 ## Generates new elements by extrusion of the elements which belong to the object
2861 # The path of extrusion must be a meshed edge.
2862 # @param theObject the object which elements should be processed
2863 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2864 # @param PathShape shape(edge) defines the sub-mesh for the path
2865 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2866 # @param HasAngles allows the shape to be rotated around the path
2867 # to get the resulting mesh in a helical fashion
2868 # @param Angles list of angles
2869 # @param HasRefPoint allows using the reference point
2870 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2871 # The User can specify any point as the Reference Point.
2872 # @param MakeGroups forces the generation of new groups from existing ones
2873 # @param LinearVariation forces the computation of rotation angles as linear
2874 # variation of the given Angles along path steps
2875 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2876 # only SMESH::Extrusion_Error otherwise
2877 # @ingroup l2_modif_extrurev
2878 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
2879 HasAngles, Angles, HasRefPoint, RefPoint,
2880 MakeGroups=False, LinearVariation=False):
2881 Angles,AnglesParameters = ParseAngles(Angles)
2882 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2883 if ( isinstance( theObject, Mesh )):
2884 theObject = theObject.GetMesh()
2885 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2886 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2887 if ( isinstance( PathMesh, Mesh )):
2888 PathMesh = PathMesh.GetMesh()
2889 if HasAngles and Angles and LinearVariation:
2890 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2892 Parameters = AnglesParameters + var_separator + RefPointParameters
2893 self.mesh.SetParameters(Parameters)
2895 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
2896 PathShape, NodeStart, HasAngles,
2897 Angles, HasRefPoint, RefPoint)
2898 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
2899 NodeStart, HasAngles, Angles, HasRefPoint,
2902 ## Generates new elements by extrusion of the elements which belong to the object
2903 # The path of extrusion must be a meshed edge.
2904 # @param theObject the object which elements should be processed
2905 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2906 # @param PathShape shape(edge) defines the sub-mesh for the path
2907 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2908 # @param HasAngles allows the shape to be rotated around the path
2909 # to get the resulting mesh in a helical fashion
2910 # @param Angles list of angles
2911 # @param HasRefPoint allows using the reference point
2912 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2913 # The User can specify any point as the Reference Point.
2914 # @param MakeGroups forces the generation of new groups from existing ones
2915 # @param LinearVariation forces the computation of rotation angles as linear
2916 # variation of the given Angles along path steps
2917 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2918 # only SMESH::Extrusion_Error otherwise
2919 # @ingroup l2_modif_extrurev
2920 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
2921 HasAngles, Angles, HasRefPoint, RefPoint,
2922 MakeGroups=False, LinearVariation=False):
2923 Angles,AnglesParameters = ParseAngles(Angles)
2924 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2925 if ( isinstance( theObject, Mesh )):
2926 theObject = theObject.GetMesh()
2927 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2928 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2929 if ( isinstance( PathMesh, Mesh )):
2930 PathMesh = PathMesh.GetMesh()
2931 if HasAngles and Angles and LinearVariation:
2932 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2934 Parameters = AnglesParameters + var_separator + RefPointParameters
2935 self.mesh.SetParameters(Parameters)
2937 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
2938 PathShape, NodeStart, HasAngles,
2939 Angles, HasRefPoint, RefPoint)
2940 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
2941 NodeStart, HasAngles, Angles, HasRefPoint,
2944 ## Creates a symmetrical copy of mesh elements
2945 # @param IDsOfElements list of elements ids
2946 # @param Mirror is AxisStruct or geom object(point, line, plane)
2947 # @param theMirrorType is POINT, AXIS or PLANE
2948 # If the Mirror is a geom object this parameter is unnecessary
2949 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2950 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2951 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2952 # @ingroup l2_modif_trsf
2953 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2954 if IDsOfElements == []:
2955 IDsOfElements = self.GetElementsId()
2956 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2957 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2958 Mirror,Parameters = ParseAxisStruct(Mirror)
2959 self.mesh.SetParameters(Parameters)
2960 if Copy and MakeGroups:
2961 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2962 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2965 ## Creates a new mesh by a symmetrical copy of mesh elements
2966 # @param IDsOfElements the list of elements ids
2967 # @param Mirror is AxisStruct or geom object (point, line, plane)
2968 # @param theMirrorType is POINT, AXIS or PLANE
2969 # If the Mirror is a geom object this parameter is unnecessary
2970 # @param MakeGroups to generate new groups from existing ones
2971 # @param NewMeshName a name of the new mesh to create
2972 # @return instance of Mesh class
2973 # @ingroup l2_modif_trsf
2974 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2975 if IDsOfElements == []:
2976 IDsOfElements = self.GetElementsId()
2977 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2978 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2979 Mirror,Parameters = ParseAxisStruct(Mirror)
2980 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2981 MakeGroups, NewMeshName)
2982 mesh.SetParameters(Parameters)
2983 return Mesh(self.smeshpyD,self.geompyD,mesh)
2985 ## Creates a symmetrical copy of the object
2986 # @param theObject mesh, submesh or group
2987 # @param Mirror AxisStruct or geom object (point, line, plane)
2988 # @param theMirrorType is POINT, AXIS or PLANE
2989 # If the Mirror is a geom object this parameter is unnecessary
2990 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2991 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2992 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2993 # @ingroup l2_modif_trsf
2994 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2995 if ( isinstance( theObject, Mesh )):
2996 theObject = theObject.GetMesh()
2997 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2998 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2999 Mirror,Parameters = ParseAxisStruct(Mirror)
3000 self.mesh.SetParameters(Parameters)
3001 if Copy and MakeGroups:
3002 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3003 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3006 ## Creates a new mesh by a symmetrical copy of the object
3007 # @param theObject mesh, submesh or group
3008 # @param Mirror AxisStruct or geom object (point, line, plane)
3009 # @param theMirrorType POINT, AXIS or PLANE
3010 # If the Mirror is a geom object this parameter is unnecessary
3011 # @param MakeGroups forces the generation of new groups from existing ones
3012 # @param NewMeshName the name of the new mesh to create
3013 # @return instance of Mesh class
3014 # @ingroup l2_modif_trsf
3015 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3016 if ( isinstance( theObject, Mesh )):
3017 theObject = theObject.GetMesh()
3018 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3019 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3020 Mirror,Parameters = ParseAxisStruct(Mirror)
3021 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3022 MakeGroups, NewMeshName)
3023 mesh.SetParameters(Parameters)
3024 return Mesh( self.smeshpyD,self.geompyD,mesh )
3026 ## Translates the elements
3027 # @param IDsOfElements list of elements ids
3028 # @param Vector the direction of translation (DirStruct or vector)
3029 # @param Copy allows copying the translated elements
3030 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3031 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3032 # @ingroup l2_modif_trsf
3033 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3034 if IDsOfElements == []:
3035 IDsOfElements = self.GetElementsId()
3036 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3037 Vector = self.smeshpyD.GetDirStruct(Vector)
3038 Vector,Parameters = ParseDirStruct(Vector)
3039 self.mesh.SetParameters(Parameters)
3040 if Copy and MakeGroups:
3041 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3042 self.editor.Translate(IDsOfElements, Vector, Copy)
3045 ## Creates a new mesh of translated elements
3046 # @param IDsOfElements list of elements ids
3047 # @param Vector the direction of translation (DirStruct or vector)
3048 # @param MakeGroups forces the generation of new groups from existing ones
3049 # @param NewMeshName the name of the newly created mesh
3050 # @return instance of Mesh class
3051 # @ingroup l2_modif_trsf
3052 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3053 if IDsOfElements == []:
3054 IDsOfElements = self.GetElementsId()
3055 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3056 Vector = self.smeshpyD.GetDirStruct(Vector)
3057 Vector,Parameters = ParseDirStruct(Vector)
3058 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3059 mesh.SetParameters(Parameters)
3060 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3062 ## Translates the object
3063 # @param theObject the object to translate (mesh, submesh, or group)
3064 # @param Vector direction of translation (DirStruct or geom vector)
3065 # @param Copy allows copying the translated elements
3066 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3067 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3068 # @ingroup l2_modif_trsf
3069 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3070 if ( isinstance( theObject, Mesh )):
3071 theObject = theObject.GetMesh()
3072 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3073 Vector = self.smeshpyD.GetDirStruct(Vector)
3074 Vector,Parameters = ParseDirStruct(Vector)
3075 self.mesh.SetParameters(Parameters)
3076 if Copy and MakeGroups:
3077 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3078 self.editor.TranslateObject(theObject, Vector, Copy)
3081 ## Creates a new mesh from the translated object
3082 # @param theObject the object to translate (mesh, submesh, or group)
3083 # @param Vector the direction of translation (DirStruct or geom vector)
3084 # @param MakeGroups forces the generation of new groups from existing ones
3085 # @param NewMeshName the name of the newly created mesh
3086 # @return instance of Mesh class
3087 # @ingroup l2_modif_trsf
3088 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3089 if (isinstance(theObject, Mesh)):
3090 theObject = theObject.GetMesh()
3091 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3092 Vector = self.smeshpyD.GetDirStruct(Vector)
3093 Vector,Parameters = ParseDirStruct(Vector)
3094 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3095 mesh.SetParameters(Parameters)
3096 return Mesh( self.smeshpyD, self.geompyD, mesh )
3098 ## Rotates the elements
3099 # @param IDsOfElements list of elements ids
3100 # @param Axis the axis of rotation (AxisStruct or geom line)
3101 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3102 # @param Copy allows copying the rotated elements
3103 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3104 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3105 # @ingroup l2_modif_trsf
3106 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3108 if isinstance(AngleInRadians,str):
3110 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3112 AngleInRadians = DegreesToRadians(AngleInRadians)
3113 if IDsOfElements == []:
3114 IDsOfElements = self.GetElementsId()
3115 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3116 Axis = self.smeshpyD.GetAxisStruct(Axis)
3117 Axis,AxisParameters = ParseAxisStruct(Axis)
3118 Parameters = AxisParameters + var_separator + Parameters
3119 self.mesh.SetParameters(Parameters)
3120 if Copy and MakeGroups:
3121 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3122 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3125 ## Creates a new mesh of rotated elements
3126 # @param IDsOfElements list of element ids
3127 # @param Axis the axis of rotation (AxisStruct or geom line)
3128 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3129 # @param MakeGroups forces the generation of new groups from existing ones
3130 # @param NewMeshName the name of the newly created mesh
3131 # @return instance of Mesh class
3132 # @ingroup l2_modif_trsf
3133 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3135 if isinstance(AngleInRadians,str):
3137 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3139 AngleInRadians = DegreesToRadians(AngleInRadians)
3140 if IDsOfElements == []:
3141 IDsOfElements = self.GetElementsId()
3142 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3143 Axis = self.smeshpyD.GetAxisStruct(Axis)
3144 Axis,AxisParameters = ParseAxisStruct(Axis)
3145 Parameters = AxisParameters + var_separator + Parameters
3146 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3147 MakeGroups, NewMeshName)
3148 mesh.SetParameters(Parameters)
3149 return Mesh( self.smeshpyD, self.geompyD, mesh )
3151 ## Rotates the object
3152 # @param theObject the object to rotate( mesh, submesh, or group)
3153 # @param Axis the axis of rotation (AxisStruct or geom line)
3154 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3155 # @param Copy allows copying the rotated elements
3156 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3157 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3158 # @ingroup l2_modif_trsf
3159 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3161 if isinstance(AngleInRadians,str):
3163 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3165 AngleInRadians = DegreesToRadians(AngleInRadians)
3166 if (isinstance(theObject, Mesh)):
3167 theObject = theObject.GetMesh()
3168 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3169 Axis = self.smeshpyD.GetAxisStruct(Axis)
3170 Axis,AxisParameters = ParseAxisStruct(Axis)
3171 Parameters = AxisParameters + ":" + Parameters
3172 self.mesh.SetParameters(Parameters)
3173 if Copy and MakeGroups:
3174 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3175 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3178 ## Creates a new mesh from the rotated object
3179 # @param theObject the object to rotate (mesh, submesh, or group)
3180 # @param Axis the axis of rotation (AxisStruct or geom line)
3181 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3182 # @param MakeGroups forces the generation of new groups from existing ones
3183 # @param NewMeshName the name of the newly created mesh
3184 # @return instance of Mesh class
3185 # @ingroup l2_modif_trsf
3186 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3188 if isinstance(AngleInRadians,str):
3190 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3192 AngleInRadians = DegreesToRadians(AngleInRadians)
3193 if (isinstance( theObject, Mesh )):
3194 theObject = theObject.GetMesh()
3195 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3196 Axis = self.smeshpyD.GetAxisStruct(Axis)
3197 Axis,AxisParameters = ParseAxisStruct(Axis)
3198 Parameters = AxisParameters + ":" + Parameters
3199 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3200 MakeGroups, NewMeshName)
3201 mesh.SetParameters(Parameters)
3202 return Mesh( self.smeshpyD, self.geompyD, mesh )
3204 ## Finds groups of ajacent nodes within Tolerance.
3205 # @param Tolerance the value of tolerance
3206 # @return the list of groups of nodes
3207 # @ingroup l2_modif_trsf
3208 def FindCoincidentNodes (self, Tolerance):
3209 return self.editor.FindCoincidentNodes(Tolerance)
3211 ## Finds groups of ajacent nodes within Tolerance.
3212 # @param Tolerance the value of tolerance
3213 # @param SubMeshOrGroup SubMesh or Group
3214 # @return the list of groups of nodes
3215 # @ingroup l2_modif_trsf
3216 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3217 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3220 # @param GroupsOfNodes the list of groups of nodes
3221 # @ingroup l2_modif_trsf
3222 def MergeNodes (self, GroupsOfNodes):
3223 self.editor.MergeNodes(GroupsOfNodes)
3225 ## Finds the elements built on the same nodes.
3226 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3227 # @return a list of groups of equal elements
3228 # @ingroup l2_modif_trsf
3229 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3230 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3232 ## Merges elements in each given group.
3233 # @param GroupsOfElementsID groups of elements for merging
3234 # @ingroup l2_modif_trsf
3235 def MergeElements(self, GroupsOfElementsID):
3236 self.editor.MergeElements(GroupsOfElementsID)
3238 ## Leaves one element and removes all other elements built on the same nodes.
3239 # @ingroup l2_modif_trsf
3240 def MergeEqualElements(self):
3241 self.editor.MergeEqualElements()
3243 ## Sews free borders
3244 # @return SMESH::Sew_Error
3245 # @ingroup l2_modif_trsf
3246 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3247 FirstNodeID2, SecondNodeID2, LastNodeID2,
3248 CreatePolygons, CreatePolyedrs):
3249 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3250 FirstNodeID2, SecondNodeID2, LastNodeID2,
3251 CreatePolygons, CreatePolyedrs)
3253 ## Sews conform free borders
3254 # @return SMESH::Sew_Error
3255 # @ingroup l2_modif_trsf
3256 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3257 FirstNodeID2, SecondNodeID2):
3258 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3259 FirstNodeID2, SecondNodeID2)
3261 ## Sews border to side
3262 # @return SMESH::Sew_Error
3263 # @ingroup l2_modif_trsf
3264 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3265 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3266 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3267 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3269 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3270 # merged with the nodes of elements of Side2.
3271 # The number of elements in theSide1 and in theSide2 must be
3272 # equal and they should have similar nodal connectivity.
3273 # The nodes to merge should belong to side borders and
3274 # the first node should be linked to the second.
3275 # @return SMESH::Sew_Error
3276 # @ingroup l2_modif_trsf
3277 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3278 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3279 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3280 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3281 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3282 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3284 ## Sets new nodes for the given element.
3285 # @param ide the element id
3286 # @param newIDs nodes ids
3287 # @return If the number of nodes does not correspond to the type of element - returns false
3288 # @ingroup l2_modif_edit
3289 def ChangeElemNodes(self, ide, newIDs):
3290 return self.editor.ChangeElemNodes(ide, newIDs)
3292 ## If during the last operation of MeshEditor some nodes were
3293 # created, this method returns the list of their IDs, \n
3294 # if new nodes were not created - returns empty list
3295 # @return the list of integer values (can be empty)
3296 # @ingroup l1_auxiliary
3297 def GetLastCreatedNodes(self):
3298 return self.editor.GetLastCreatedNodes()
3300 ## If during the last operation of MeshEditor some elements were
3301 # created this method returns the list of their IDs, \n
3302 # if new elements were not created - returns empty list
3303 # @return the list of integer values (can be empty)
3304 # @ingroup l1_auxiliary
3305 def GetLastCreatedElems(self):
3306 return self.editor.GetLastCreatedElems()
3308 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3309 # @param theNodes identifiers of nodes to be doubled
3310 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3311 # nodes. If list of element identifiers is empty then nodes are doubled but
3312 # they not assigned to elements
3313 # @return TRUE if operation has been completed successfully, FALSE otherwise
3314 # @ingroup l2_modif_edit
3315 def DoubleNodes(self, theNodes, theModifiedElems):
3316 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3318 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3319 # This method provided for convenience works as DoubleNodes() described above.
3320 # @param theNodes identifiers of node to be doubled
3321 # @param theModifiedElems identifiers of elements to be updated
3322 # @return TRUE if operation has been completed successfully, FALSE otherwise
3323 # @ingroup l2_modif_edit
3324 def DoubleNode(self, theNodeId, theModifiedElems):
3325 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3327 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3328 # This method provided for convenience works as DoubleNodes() described above.
3329 # @param theNodes group of nodes to be doubled
3330 # @param theModifiedElems group of elements to be updated.
3331 # @return TRUE if operation has been completed successfully, FALSE otherwise
3332 # @ingroup l2_modif_edit
3333 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3334 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3336 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3337 # This method provided for convenience works as DoubleNodes() described above.
3338 # @param theNodes list of groups of nodes to be doubled
3339 # @param theModifiedElems list of groups of elements to be updated.
3340 # @return TRUE if operation has been completed successfully, FALSE otherwise
3341 # @ingroup l2_modif_edit
3342 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3343 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3345 ## The mother class to define algorithm, it is not recommended to use it directly.
3348 # @ingroup l2_algorithms
3349 class Mesh_Algorithm:
3350 # @class Mesh_Algorithm
3351 # @brief Class Mesh_Algorithm
3353 #def __init__(self,smesh):
3361 ## Finds a hypothesis in the study by its type name and parameters.
3362 # Finds only the hypotheses created in smeshpyD engine.
3363 # @return SMESH.SMESH_Hypothesis
3364 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3365 study = smeshpyD.GetCurrentStudy()
3366 #to do: find component by smeshpyD object, not by its data type
3367 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3368 if scomp is not None:
3369 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3370 # Check if the root label of the hypotheses exists
3371 if res and hypRoot is not None:
3372 iter = study.NewChildIterator(hypRoot)
3373 # Check all published hypotheses
3375 hypo_so_i = iter.Value()
3376 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3377 if attr is not None:
3378 anIOR = attr.Value()
3379 hypo_o_i = salome.orb.string_to_object(anIOR)
3380 if hypo_o_i is not None:
3381 # Check if this is a hypothesis
3382 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3383 if hypo_i is not None:
3384 # Check if the hypothesis belongs to current engine
3385 if smeshpyD.GetObjectId(hypo_i) > 0:
3386 # Check if this is the required hypothesis
3387 if hypo_i.GetName() == hypname:
3389 if CompareMethod(hypo_i, args):
3403 ## Finds the algorithm in the study by its type name.
3404 # Finds only the algorithms, which have been created in smeshpyD engine.
3405 # @return SMESH.SMESH_Algo
3406 def FindAlgorithm (self, algoname, smeshpyD):
3407 study = smeshpyD.GetCurrentStudy()
3408 #to do: find component by smeshpyD object, not by its data type
3409 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3410 if scomp is not None:
3411 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3412 # Check if the root label of the algorithms exists
3413 if res and hypRoot is not None:
3414 iter = study.NewChildIterator(hypRoot)
3415 # Check all published algorithms
3417 algo_so_i = iter.Value()
3418 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3419 if attr is not None:
3420 anIOR = attr.Value()
3421 algo_o_i = salome.orb.string_to_object(anIOR)
3422 if algo_o_i is not None:
3423 # Check if this is an algorithm
3424 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3425 if algo_i is not None:
3426 # Checks if the algorithm belongs to the current engine
3427 if smeshpyD.GetObjectId(algo_i) > 0:
3428 # Check if this is the required algorithm
3429 if algo_i.GetName() == algoname:
3442 ## If the algorithm is global, returns 0; \n
3443 # else returns the submesh associated to this algorithm.
3444 def GetSubMesh(self):
3447 ## Returns the wrapped mesher.
3448 def GetAlgorithm(self):
3451 ## Gets the list of hypothesis that can be used with this algorithm
3452 def GetCompatibleHypothesis(self):
3455 mylist = self.algo.GetCompatibleHypothesis()
3458 ## Gets the name of the algorithm
3462 ## Sets the name to the algorithm
3463 def SetName(self, name):
3464 self.mesh.smeshpyD.SetName(self.algo, name)
3466 ## Gets the id of the algorithm
3468 return self.algo.GetId()
3471 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3473 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3474 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3476 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3478 self.Assign(algo, mesh, geom)
3482 def Assign(self, algo, mesh, geom):
3484 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3491 name = GetName(geom)
3493 name = mesh.geompyD.SubShapeName(geom, piece)
3494 mesh.geompyD.addToStudyInFather(piece, geom, name)
3495 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3498 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3499 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3501 def CompareHyp (self, hyp, args):
3502 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3505 def CompareEqualHyp (self, hyp, args):
3509 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3510 UseExisting=0, CompareMethod=""):
3513 if CompareMethod == "": CompareMethod = self.CompareHyp
3514 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3517 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3523 a = a + s + str(args[i])
3527 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3529 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3530 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3533 ## Returns entry of the shape to mesh in the study
3534 def MainShapeEntry(self):
3536 if not self.mesh or not self.mesh.GetMesh(): return entry
3537 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3538 study = self.mesh.smeshpyD.GetCurrentStudy()
3539 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3540 sobj = study.FindObjectIOR(ior)
3541 if sobj: entry = sobj.GetID()
3542 if not entry: return ""
3545 # Public class: Mesh_Segment
3546 # --------------------------
3548 ## Class to define a segment 1D algorithm for discretization
3551 # @ingroup l3_algos_basic
3552 class Mesh_Segment(Mesh_Algorithm):
3554 ## Private constructor.
3555 def __init__(self, mesh, geom=0):
3556 Mesh_Algorithm.__init__(self)
3557 self.Create(mesh, geom, "Regular_1D")
3559 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3560 # @param l for the length of segments that cut an edge
3561 # @param UseExisting if ==true - searches for an existing hypothesis created with
3562 # the same parameters, else (default) - creates a new one
3563 # @param p precision, used for calculation of the number of segments.
3564 # The precision should be a positive, meaningful value within the range [0,1].
3565 # In general, the number of segments is calculated with the formula:
3566 # nb = ceil((edge_length / l) - p)
3567 # Function ceil rounds its argument to the higher integer.
3568 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3569 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3570 # p=1 means rounding of (edge_length / l) to the lower integer.
3571 # Default value is 1e-07.
3572 # @return an instance of StdMeshers_LocalLength hypothesis
3573 # @ingroup l3_hypos_1dhyps
3574 def LocalLength(self, l, UseExisting=0, p=1e-07):
3575 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3576 CompareMethod=self.CompareLocalLength)
3582 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3583 def CompareLocalLength(self, hyp, args):
3584 if IsEqual(hyp.GetLength(), args[0]):
3585 return IsEqual(hyp.GetPrecision(), args[1])
3588 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3589 # @param length is optional maximal allowed length of segment, if it is omitted
3590 # the preestimated length is used that depends on geometry size
3591 # @param UseExisting if ==true - searches for an existing hypothesis created with
3592 # the same parameters, else (default) - create a new one
3593 # @return an instance of StdMeshers_MaxLength hypothesis
3594 # @ingroup l3_hypos_1dhyps
3595 def MaxSize(self, length=0.0, UseExisting=0):
3596 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3599 hyp.SetLength(length)
3601 # set preestimated length
3602 gen = self.mesh.smeshpyD
3603 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3604 self.mesh.GetMesh(), self.mesh.GetShape(),
3606 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3608 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3611 hyp.SetUsePreestimatedLength( length == 0.0 )
3614 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3615 # @param n for the number of segments that cut an edge
3616 # @param s for the scale factor (optional)
3617 # @param reversedEdges is a list of edges to mesh using reversed orientation
3618 # @param UseExisting if ==true - searches for an existing hypothesis created with
3619 # the same parameters, else (default) - create a new one
3620 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3621 # @ingroup l3_hypos_1dhyps
3622 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3623 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3624 reversedEdges, UseExisting = [], reversedEdges
3625 entry = self.MainShapeEntry()
3627 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3628 UseExisting=UseExisting,
3629 CompareMethod=self.CompareNumberOfSegments)
3631 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3632 UseExisting=UseExisting,
3633 CompareMethod=self.CompareNumberOfSegments)
3634 hyp.SetDistrType( 1 )
3635 hyp.SetScaleFactor(s)
3636 hyp.SetNumberOfSegments(n)
3637 hyp.SetReversedEdges( reversedEdges )
3638 hyp.SetObjectEntry( entry )
3642 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3643 def CompareNumberOfSegments(self, hyp, args):
3644 if hyp.GetNumberOfSegments() == args[0]:
3646 if hyp.GetReversedEdges() == args[1]:
3647 if not args[1] or hyp.GetObjectEntry() == args[2]:
3650 if hyp.GetReversedEdges() == args[2]:
3651 if not args[2] or hyp.GetObjectEntry() == args[3]:
3652 if hyp.GetDistrType() == 1:
3653 if IsEqual(hyp.GetScaleFactor(), args[1]):
3657 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3658 # @param start defines the length of the first segment
3659 # @param end defines the length of the last segment
3660 # @param reversedEdges is a list of edges to mesh using reversed orientation
3661 # @param UseExisting if ==true - searches for an existing hypothesis created with
3662 # the same parameters, else (default) - creates a new one
3663 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3664 # @ingroup l3_hypos_1dhyps
3665 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3666 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3667 reversedEdges, UseExisting = [], reversedEdges
3668 entry = self.MainShapeEntry()
3669 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
3670 UseExisting=UseExisting,
3671 CompareMethod=self.CompareArithmetic1D)
3672 hyp.SetStartLength(start)
3673 hyp.SetEndLength(end)
3674 hyp.SetReversedEdges( reversedEdges )
3675 hyp.SetObjectEntry( entry )
3679 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3680 def CompareArithmetic1D(self, hyp, args):
3681 if IsEqual(hyp.GetLength(1), args[0]):
3682 if IsEqual(hyp.GetLength(0), args[1]):
3683 if hyp.GetReversedEdges() == args[2]:
3684 if not args[2] or hyp.GetObjectEntry() == args[3]:
3688 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3689 # @param start defines the length of the first segment
3690 # @param end defines the length of the last segment
3691 # @param reversedEdges is a list of edges to mesh using reversed orientation
3692 # @param UseExisting if ==true - searches for an existing hypothesis created with
3693 # the same parameters, else (default) - creates a new one
3694 # @return an instance of StdMeshers_StartEndLength hypothesis
3695 # @ingroup l3_hypos_1dhyps
3696 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3697 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3698 reversedEdges, UseExisting = [], reversedEdges
3699 entry = self.MainShapeEntry()
3700 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3701 UseExisting=UseExisting,
3702 CompareMethod=self.CompareStartEndLength)
3703 hyp.SetStartLength(start)
3704 hyp.SetEndLength(end)
3705 hyp.SetReversedEdges( reversedEdges )
3706 hyp.SetObjectEntry( entry )
3709 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3710 def CompareStartEndLength(self, hyp, args):
3711 if IsEqual(hyp.GetLength(1), args[0]):
3712 if IsEqual(hyp.GetLength(0), args[1]):
3713 if hyp.GetReversedEdges() == args[2]:
3714 if not args[2] or hyp.GetObjectEntry() == args[3]:
3718 ## Defines "Deflection1D" hypothesis
3719 # @param d for the deflection
3720 # @param UseExisting if ==true - searches for an existing hypothesis created with
3721 # the same parameters, else (default) - create a new one
3722 # @ingroup l3_hypos_1dhyps
3723 def Deflection1D(self, d, UseExisting=0):
3724 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3725 CompareMethod=self.CompareDeflection1D)
3726 hyp.SetDeflection(d)
3729 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3730 def CompareDeflection1D(self, hyp, args):
3731 return IsEqual(hyp.GetDeflection(), args[0])
3733 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3734 # the opposite side in case of quadrangular faces
3735 # @ingroup l3_hypos_additi
3736 def Propagation(self):
3737 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3739 ## Defines "AutomaticLength" hypothesis
3740 # @param fineness for the fineness [0-1]
3741 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3742 # same parameters, else (default) - create a new one
3743 # @ingroup l3_hypos_1dhyps
3744 def AutomaticLength(self, fineness=0, UseExisting=0):
3745 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3746 CompareMethod=self.CompareAutomaticLength)
3747 hyp.SetFineness( fineness )
3750 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3751 def CompareAutomaticLength(self, hyp, args):
3752 return IsEqual(hyp.GetFineness(), args[0])
3754 ## Defines "SegmentLengthAroundVertex" hypothesis
3755 # @param length for the segment length
3756 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3757 # Any other integer value means that the hypothesis will be set on the
3758 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3759 # @param UseExisting if ==true - searches for an existing hypothesis created with
3760 # the same parameters, else (default) - creates a new one
3761 # @ingroup l3_algos_segmarv
3762 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3764 store_geom = self.geom
3765 if type(vertex) is types.IntType:
3766 if vertex == 0 or vertex == 1:
3767 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3775 if self.geom is None:
3776 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3777 name = GetName(self.geom)
3779 piece = self.mesh.geom
3780 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3781 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3782 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3784 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3786 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3787 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3789 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3790 CompareMethod=self.CompareLengthNearVertex)
3791 self.geom = store_geom
3792 hyp.SetLength( length )
3795 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3796 # @ingroup l3_algos_segmarv
3797 def CompareLengthNearVertex(self, hyp, args):
3798 return IsEqual(hyp.GetLength(), args[0])
3800 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3801 # If the 2D mesher sees that all boundary edges are quadratic,
3802 # it generates quadratic faces, else it generates linear faces using
3803 # medium nodes as if they are vertices.
3804 # The 3D mesher generates quadratic volumes only if all boundary faces
3805 # are quadratic, else it fails.
3807 # @ingroup l3_hypos_additi
3808 def QuadraticMesh(self):
3809 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3812 # Public class: Mesh_CompositeSegment
3813 # --------------------------
3815 ## Defines a segment 1D algorithm for discretization
3817 # @ingroup l3_algos_basic
3818 class Mesh_CompositeSegment(Mesh_Segment):
3820 ## Private constructor.
3821 def __init__(self, mesh, geom=0):
3822 self.Create(mesh, geom, "CompositeSegment_1D")
3825 # Public class: Mesh_Segment_Python
3826 # ---------------------------------
3828 ## Defines a segment 1D algorithm for discretization with python function
3830 # @ingroup l3_algos_basic
3831 class Mesh_Segment_Python(Mesh_Segment):
3833 ## Private constructor.
3834 def __init__(self, mesh, geom=0):
3835 import Python1dPlugin
3836 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3838 ## Defines "PythonSplit1D" hypothesis
3839 # @param n for the number of segments that cut an edge
3840 # @param func for the python function that calculates the length of all segments
3841 # @param UseExisting if ==true - searches for the existing hypothesis created with
3842 # the same parameters, else (default) - creates a new one
3843 # @ingroup l3_hypos_1dhyps
3844 def PythonSplit1D(self, n, func, UseExisting=0):
3845 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3846 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3847 hyp.SetNumberOfSegments(n)
3848 hyp.SetPythonLog10RatioFunction(func)
3851 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3852 def ComparePythonSplit1D(self, hyp, args):
3853 #if hyp.GetNumberOfSegments() == args[0]:
3854 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3858 # Public class: Mesh_Triangle
3859 # ---------------------------
3861 ## Defines a triangle 2D algorithm
3863 # @ingroup l3_algos_basic
3864 class Mesh_Triangle(Mesh_Algorithm):
3873 ## Private constructor.
3874 def __init__(self, mesh, algoType, geom=0):
3875 Mesh_Algorithm.__init__(self)
3877 self.algoType = algoType
3878 if algoType == MEFISTO:
3879 self.Create(mesh, geom, "MEFISTO_2D")
3881 elif algoType == BLSURF:
3883 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3884 #self.SetPhysicalMesh() - PAL19680
3885 elif algoType == NETGEN:
3887 print "Warning: NETGENPlugin module unavailable"
3889 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3891 elif algoType == NETGEN_2D:
3893 print "Warning: NETGENPlugin module unavailable"
3895 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3898 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3899 # @param area for the maximum area of each triangle
3900 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3901 # same parameters, else (default) - creates a new one
3903 # Only for algoType == MEFISTO || NETGEN_2D
3904 # @ingroup l3_hypos_2dhyps
3905 def MaxElementArea(self, area, UseExisting=0):
3906 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3907 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3908 CompareMethod=self.CompareMaxElementArea)
3909 elif self.algoType == NETGEN:
3910 hyp = self.Parameters(SIMPLE)
3911 hyp.SetMaxElementArea(area)
3914 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3915 def CompareMaxElementArea(self, hyp, args):
3916 return IsEqual(hyp.GetMaxElementArea(), args[0])
3918 ## Defines "LengthFromEdges" hypothesis to build triangles
3919 # based on the length of the edges taken from the wire
3921 # Only for algoType == MEFISTO || NETGEN_2D
3922 # @ingroup l3_hypos_2dhyps
3923 def LengthFromEdges(self):
3924 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3925 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3927 elif self.algoType == NETGEN:
3928 hyp = self.Parameters(SIMPLE)
3929 hyp.LengthFromEdges()
3932 ## Sets a way to define size of mesh elements to generate.
3933 # @param thePhysicalMesh is: DefaultSize or Custom.
3934 # @ingroup l3_hypos_blsurf
3935 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3936 # Parameter of BLSURF algo
3937 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3939 ## Sets size of mesh elements to generate.
3940 # @ingroup l3_hypos_blsurf
3941 def SetPhySize(self, theVal):
3942 # Parameter of BLSURF algo
3943 self.Parameters().SetPhySize(theVal)
3945 ## Sets lower boundary of mesh element size (PhySize).
3946 # @ingroup l3_hypos_blsurf
3947 def SetPhyMin(self, theVal=-1):
3948 # Parameter of BLSURF algo
3949 self.Parameters().SetPhyMin(theVal)
3951 ## Sets upper boundary of mesh element size (PhySize).
3952 # @ingroup l3_hypos_blsurf
3953 def SetPhyMax(self, theVal=-1):
3954 # Parameter of BLSURF algo
3955 self.Parameters().SetPhyMax(theVal)
3957 ## Sets a way to define maximum angular deflection of mesh from CAD model.
3958 # @param theGeometricMesh is: DefaultGeom or Custom
3959 # @ingroup l3_hypos_blsurf
3960 def SetGeometricMesh(self, theGeometricMesh=0):
3961 # Parameter of BLSURF algo
3962 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3963 self.params.SetGeometricMesh(theGeometricMesh)
3965 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3966 # @ingroup l3_hypos_blsurf
3967 def SetAngleMeshS(self, theVal=_angleMeshS):
3968 # Parameter of BLSURF algo
3969 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3970 self.params.SetAngleMeshS(theVal)
3972 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3973 # @ingroup l3_hypos_blsurf
3974 def SetAngleMeshC(self, theVal=_angleMeshS):
3975 # Parameter of BLSURF algo
3976 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3977 self.params.SetAngleMeshC(theVal)
3979 ## Sets lower boundary of mesh element size computed to respect angular deflection.
3980 # @ingroup l3_hypos_blsurf
3981 def SetGeoMin(self, theVal=-1):
3982 # Parameter of BLSURF algo
3983 self.Parameters().SetGeoMin(theVal)
3985 ## Sets upper boundary of mesh element size computed to respect angular deflection.
3986 # @ingroup l3_hypos_blsurf
3987 def SetGeoMax(self, theVal=-1):
3988 # Parameter of BLSURF algo
3989 self.Parameters().SetGeoMax(theVal)
3991 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3992 # @ingroup l3_hypos_blsurf
3993 def SetGradation(self, theVal=_gradation):
3994 # Parameter of BLSURF algo
3995 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3996 self.params.SetGradation(theVal)
3998 ## Sets topology usage way.
3999 # @param way defines how mesh conformity is assured <ul>
4000 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4001 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4002 # @ingroup l3_hypos_blsurf
4003 def SetTopology(self, way):
4004 # Parameter of BLSURF algo
4005 self.Parameters().SetTopology(way)
4007 ## To respect geometrical edges or not.
4008 # @ingroup l3_hypos_blsurf
4009 def SetDecimesh(self, toIgnoreEdges=False):
4010 # Parameter of BLSURF algo
4011 self.Parameters().SetDecimesh(toIgnoreEdges)
4013 ## Sets verbosity level in the range 0 to 100.
4014 # @ingroup l3_hypos_blsurf
4015 def SetVerbosity(self, level):
4016 # Parameter of BLSURF algo
4017 self.Parameters().SetVerbosity(level)
4019 ## Sets advanced option value.
4020 # @ingroup l3_hypos_blsurf
4021 def SetOptionValue(self, optionName, level):
4022 # Parameter of BLSURF algo
4023 self.Parameters().SetOptionValue(optionName,level)
4025 ## Sets QuadAllowed flag.
4026 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4027 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4028 def SetQuadAllowed(self, toAllow=True):
4029 if self.algoType == NETGEN_2D:
4030 if toAllow: # add QuadranglePreference
4031 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4032 else: # remove QuadranglePreference
4033 for hyp in self.mesh.GetHypothesisList( self.geom ):
4034 if hyp.GetName() == "QuadranglePreference":
4035 self.mesh.RemoveHypothesis( self.geom, hyp )
4040 if self.Parameters():
4041 self.params.SetQuadAllowed(toAllow)
4044 ## Defines hypothesis having several parameters
4046 # @ingroup l3_hypos_netgen
4047 def Parameters(self, which=SOLE):
4050 if self.algoType == NETGEN:
4052 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4053 "libNETGENEngine.so", UseExisting=0)
4055 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4056 "libNETGENEngine.so", UseExisting=0)
4058 elif self.algoType == MEFISTO:
4059 print "Mefisto algo support no multi-parameter hypothesis"
4061 elif self.algoType == NETGEN_2D:
4062 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4063 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4065 elif self.algoType == BLSURF:
4066 self.params = self.Hypothesis("BLSURF_Parameters", [],
4067 "libBLSURFEngine.so", UseExisting=0)
4070 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4075 # Only for algoType == NETGEN
4076 # @ingroup l3_hypos_netgen
4077 def SetMaxSize(self, theSize):
4078 if self.Parameters():
4079 self.params.SetMaxSize(theSize)
4081 ## Sets SecondOrder flag
4083 # Only for algoType == NETGEN
4084 # @ingroup l3_hypos_netgen
4085 def SetSecondOrder(self, theVal):
4086 if self.Parameters():
4087 self.params.SetSecondOrder(theVal)
4089 ## Sets Optimize flag
4091 # Only for algoType == NETGEN
4092 # @ingroup l3_hypos_netgen
4093 def SetOptimize(self, theVal):
4094 if self.Parameters():
4095 self.params.SetOptimize(theVal)
4098 # @param theFineness is:
4099 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4101 # Only for algoType == NETGEN
4102 # @ingroup l3_hypos_netgen
4103 def SetFineness(self, theFineness):
4104 if self.Parameters():
4105 self.params.SetFineness(theFineness)
4109 # Only for algoType == NETGEN
4110 # @ingroup l3_hypos_netgen
4111 def SetGrowthRate(self, theRate):
4112 if self.Parameters():
4113 self.params.SetGrowthRate(theRate)
4115 ## Sets NbSegPerEdge
4117 # Only for algoType == NETGEN
4118 # @ingroup l3_hypos_netgen
4119 def SetNbSegPerEdge(self, theVal):
4120 if self.Parameters():
4121 self.params.SetNbSegPerEdge(theVal)
4123 ## Sets NbSegPerRadius
4125 # Only for algoType == NETGEN
4126 # @ingroup l3_hypos_netgen
4127 def SetNbSegPerRadius(self, theVal):
4128 if self.Parameters():
4129 self.params.SetNbSegPerRadius(theVal)
4131 ## Sets number of segments overriding value set by SetLocalLength()
4133 # Only for algoType == NETGEN
4134 # @ingroup l3_hypos_netgen
4135 def SetNumberOfSegments(self, theVal):
4136 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4138 ## Sets number of segments overriding value set by SetNumberOfSegments()
4140 # Only for algoType == NETGEN
4141 # @ingroup l3_hypos_netgen
4142 def SetLocalLength(self, theVal):
4143 self.Parameters(SIMPLE).SetLocalLength(theVal)
4148 # Public class: Mesh_Quadrangle
4149 # -----------------------------
4151 ## Defines a quadrangle 2D algorithm
4153 # @ingroup l3_algos_basic
4154 class Mesh_Quadrangle(Mesh_Algorithm):
4156 ## Private constructor.
4157 def __init__(self, mesh, geom=0):
4158 Mesh_Algorithm.__init__(self)
4159 self.Create(mesh, geom, "Quadrangle_2D")
4161 ## Defines "QuadranglePreference" hypothesis, forcing construction
4162 # of quadrangles if the number of nodes on the opposite edges is not the same
4163 # while the total number of nodes on edges is even
4165 # @ingroup l3_hypos_additi
4166 def QuadranglePreference(self):
4167 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4168 CompareMethod=self.CompareEqualHyp)
4171 ## Defines "TrianglePreference" hypothesis, forcing construction
4172 # of triangles in the refinement area if the number of nodes
4173 # on the opposite edges is not the same
4175 # @ingroup l3_hypos_additi
4176 def TrianglePreference(self):
4177 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4178 CompareMethod=self.CompareEqualHyp)
4181 # Public class: Mesh_Tetrahedron
4182 # ------------------------------
4184 ## Defines a tetrahedron 3D algorithm
4186 # @ingroup l3_algos_basic
4187 class Mesh_Tetrahedron(Mesh_Algorithm):
4192 ## Private constructor.
4193 def __init__(self, mesh, algoType, geom=0):
4194 Mesh_Algorithm.__init__(self)
4196 if algoType == NETGEN:
4197 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4200 elif algoType == FULL_NETGEN:
4202 print "Warning: NETGENPlugin module has not been imported."
4203 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4206 elif algoType == GHS3D:
4208 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4211 elif algoType == GHS3DPRL:
4212 import GHS3DPRLPlugin
4213 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4216 self.algoType = algoType
4218 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4219 # @param vol for the maximum volume of each tetrahedron
4220 # @param UseExisting if ==true - searches for the existing hypothesis created with
4221 # the same parameters, else (default) - creates a new one
4222 # @ingroup l3_hypos_maxvol
4223 def MaxElementVolume(self, vol, UseExisting=0):
4224 if self.algoType == NETGEN:
4225 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4226 CompareMethod=self.CompareMaxElementVolume)
4227 hyp.SetMaxElementVolume(vol)
4229 elif self.algoType == FULL_NETGEN:
4230 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4233 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4234 def CompareMaxElementVolume(self, hyp, args):
4235 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4237 ## Defines hypothesis having several parameters
4239 # @ingroup l3_hypos_netgen
4240 def Parameters(self, which=SOLE):
4244 if self.algoType == FULL_NETGEN:
4246 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4247 "libNETGENEngine.so", UseExisting=0)
4249 self.params = self.Hypothesis("NETGEN_Parameters", [],
4250 "libNETGENEngine.so", UseExisting=0)
4253 if self.algoType == GHS3D:
4254 self.params = self.Hypothesis("GHS3D_Parameters", [],
4255 "libGHS3DEngine.so", UseExisting=0)
4258 if self.algoType == GHS3DPRL:
4259 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4260 "libGHS3DPRLEngine.so", UseExisting=0)
4263 print "Algo supports no multi-parameter hypothesis"
4267 # Parameter of FULL_NETGEN
4268 # @ingroup l3_hypos_netgen
4269 def SetMaxSize(self, theSize):
4270 self.Parameters().SetMaxSize(theSize)
4272 ## Sets SecondOrder flag
4273 # Parameter of FULL_NETGEN
4274 # @ingroup l3_hypos_netgen
4275 def SetSecondOrder(self, theVal):
4276 self.Parameters().SetSecondOrder(theVal)
4278 ## Sets Optimize flag
4279 # Parameter of FULL_NETGEN
4280 # @ingroup l3_hypos_netgen
4281 def SetOptimize(self, theVal):
4282 self.Parameters().SetOptimize(theVal)
4285 # @param theFineness is:
4286 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4287 # Parameter of FULL_NETGEN
4288 # @ingroup l3_hypos_netgen
4289 def SetFineness(self, theFineness):
4290 self.Parameters().SetFineness(theFineness)
4293 # Parameter of FULL_NETGEN
4294 # @ingroup l3_hypos_netgen
4295 def SetGrowthRate(self, theRate):
4296 self.Parameters().SetGrowthRate(theRate)
4298 ## Sets NbSegPerEdge
4299 # Parameter of FULL_NETGEN
4300 # @ingroup l3_hypos_netgen
4301 def SetNbSegPerEdge(self, theVal):
4302 self.Parameters().SetNbSegPerEdge(theVal)
4304 ## Sets NbSegPerRadius
4305 # Parameter of FULL_NETGEN
4306 # @ingroup l3_hypos_netgen
4307 def SetNbSegPerRadius(self, theVal):
4308 self.Parameters().SetNbSegPerRadius(theVal)
4310 ## Sets number of segments overriding value set by SetLocalLength()
4311 # Only for algoType == NETGEN_FULL
4312 # @ingroup l3_hypos_netgen
4313 def SetNumberOfSegments(self, theVal):
4314 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4316 ## Sets number of segments overriding value set by SetNumberOfSegments()
4317 # Only for algoType == NETGEN_FULL
4318 # @ingroup l3_hypos_netgen
4319 def SetLocalLength(self, theVal):
4320 self.Parameters(SIMPLE).SetLocalLength(theVal)
4322 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4323 # Overrides value set by LengthFromEdges()
4324 # Only for algoType == NETGEN_FULL
4325 # @ingroup l3_hypos_netgen
4326 def MaxElementArea(self, area):
4327 self.Parameters(SIMPLE).SetMaxElementArea(area)
4329 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4330 # Overrides value set by MaxElementArea()
4331 # Only for algoType == NETGEN_FULL
4332 # @ingroup l3_hypos_netgen
4333 def LengthFromEdges(self):
4334 self.Parameters(SIMPLE).LengthFromEdges()
4336 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4337 # Overrides value set by MaxElementVolume()
4338 # Only for algoType == NETGEN_FULL
4339 # @ingroup l3_hypos_netgen
4340 def LengthFromFaces(self):
4341 self.Parameters(SIMPLE).LengthFromFaces()
4343 ## To mesh "holes" in a solid or not. Default is to mesh.
4344 # @ingroup l3_hypos_ghs3dh
4345 def SetToMeshHoles(self, toMesh):
4346 # Parameter of GHS3D
4347 self.Parameters().SetToMeshHoles(toMesh)
4349 ## Set Optimization level:
4350 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
4351 # Default is Medium_Optimization
4352 # @ingroup l3_hypos_ghs3dh
4353 def SetOptimizationLevel(self, level):
4354 # Parameter of GHS3D
4355 self.Parameters().SetOptimizationLevel(level)
4357 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4358 # @ingroup l3_hypos_ghs3dh
4359 def SetMaximumMemory(self, MB):
4360 # Advanced parameter of GHS3D
4361 self.Parameters().SetMaximumMemory(MB)
4363 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4364 # automatic memory adjustment mode.
4365 # @ingroup l3_hypos_ghs3dh
4366 def SetInitialMemory(self, MB):
4367 # Advanced parameter of GHS3D
4368 self.Parameters().SetInitialMemory(MB)
4370 ## Path to working directory.
4371 # @ingroup l3_hypos_ghs3dh
4372 def SetWorkingDirectory(self, path):
4373 # Advanced parameter of GHS3D
4374 self.Parameters().SetWorkingDirectory(path)
4376 ## To keep working files or remove them. Log file remains in case of errors anyway.
4377 # @ingroup l3_hypos_ghs3dh
4378 def SetKeepFiles(self, toKeep):
4379 # Advanced parameter of GHS3D and GHS3DPRL
4380 self.Parameters().SetKeepFiles(toKeep)
4382 ## To set verbose level [0-10]. <ul>
4383 #<li> 0 - no standard output,
4384 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4385 # indicates when the final mesh is being saved. In addition the software
4386 # gives indication regarding the CPU time.
4387 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4388 # histogram of the skin mesh, quality statistics histogram together with
4389 # the characteristics of the final mesh.</ul>
4390 # @ingroup l3_hypos_ghs3dh
4391 def SetVerboseLevel(self, level):
4392 # Advanced parameter of GHS3D
4393 self.Parameters().SetVerboseLevel(level)
4395 ## To create new nodes.
4396 # @ingroup l3_hypos_ghs3dh
4397 def SetToCreateNewNodes(self, toCreate):
4398 # Advanced parameter of GHS3D
4399 self.Parameters().SetToCreateNewNodes(toCreate)
4401 ## To use boundary recovery version which tries to create mesh on a very poor
4402 # quality surface mesh.
4403 # @ingroup l3_hypos_ghs3dh
4404 def SetToUseBoundaryRecoveryVersion(self, toUse):
4405 # Advanced parameter of GHS3D
4406 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4408 ## Sets command line option as text.
4409 # @ingroup l3_hypos_ghs3dh
4410 def SetTextOption(self, option):
4411 # Advanced parameter of GHS3D
4412 self.Parameters().SetTextOption(option)
4414 ## Sets MED files name and path.
4415 def SetMEDName(self, value):
4416 self.Parameters().SetMEDName(value)
4418 ## Sets the number of partition of the initial mesh
4419 def SetNbPart(self, value):
4420 self.Parameters().SetNbPart(value)
4422 ## When big mesh, start tepal in background
4423 def SetBackground(self, value):
4424 self.Parameters().SetBackground(value)
4426 # Public class: Mesh_Hexahedron
4427 # ------------------------------
4429 ## Defines a hexahedron 3D algorithm
4431 # @ingroup l3_algos_basic
4432 class Mesh_Hexahedron(Mesh_Algorithm):
4437 ## Private constructor.
4438 def __init__(self, mesh, algoType=Hexa, geom=0):
4439 Mesh_Algorithm.__init__(self)
4441 self.algoType = algoType
4443 if algoType == Hexa:
4444 self.Create(mesh, geom, "Hexa_3D")
4447 elif algoType == Hexotic:
4448 import HexoticPlugin
4449 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4452 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4453 # @ingroup l3_hypos_hexotic
4454 def MinMaxQuad(self, min=3, max=8, quad=True):
4455 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4457 self.params.SetHexesMinLevel(min)
4458 self.params.SetHexesMaxLevel(max)
4459 self.params.SetHexoticQuadrangles(quad)
4462 # Deprecated, only for compatibility!
4463 # Public class: Mesh_Netgen
4464 # ------------------------------
4466 ## Defines a NETGEN-based 2D or 3D algorithm
4467 # that needs no discrete boundary (i.e. independent)
4469 # This class is deprecated, only for compatibility!
4472 # @ingroup l3_algos_basic
4473 class Mesh_Netgen(Mesh_Algorithm):
4477 ## Private constructor.
4478 def __init__(self, mesh, is3D, geom=0):
4479 Mesh_Algorithm.__init__(self)
4482 print "Warning: NETGENPlugin module has not been imported."
4486 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4490 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4493 ## Defines the hypothesis containing parameters of the algorithm
4494 def Parameters(self):
4496 hyp = self.Hypothesis("NETGEN_Parameters", [],
4497 "libNETGENEngine.so", UseExisting=0)
4499 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4500 "libNETGENEngine.so", UseExisting=0)
4503 # Public class: Mesh_Projection1D
4504 # ------------------------------
4506 ## Defines a projection 1D algorithm
4507 # @ingroup l3_algos_proj
4509 class Mesh_Projection1D(Mesh_Algorithm):
4511 ## Private constructor.
4512 def __init__(self, mesh, geom=0):
4513 Mesh_Algorithm.__init__(self)
4514 self.Create(mesh, geom, "Projection_1D")
4516 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4517 # a mesh pattern is taken, and, optionally, the association of vertices
4518 # between the source edge and a target edge (to which a hypothesis is assigned)
4519 # @param edge from which nodes distribution is taken
4520 # @param mesh from which nodes distribution is taken (optional)
4521 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4522 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4523 # to associate with \a srcV (optional)
4524 # @param UseExisting if ==true - searches for the existing hypothesis created with
4525 # the same parameters, else (default) - creates a new one
4526 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4527 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4529 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4530 hyp.SetSourceEdge( edge )
4531 if not mesh is None and isinstance(mesh, Mesh):
4532 mesh = mesh.GetMesh()
4533 hyp.SetSourceMesh( mesh )
4534 hyp.SetVertexAssociation( srcV, tgtV )
4537 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4538 #def CompareSourceEdge(self, hyp, args):
4539 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4543 # Public class: Mesh_Projection2D
4544 # ------------------------------
4546 ## Defines a projection 2D algorithm
4547 # @ingroup l3_algos_proj
4549 class Mesh_Projection2D(Mesh_Algorithm):
4551 ## Private constructor.
4552 def __init__(self, mesh, geom=0):
4553 Mesh_Algorithm.__init__(self)
4554 self.Create(mesh, geom, "Projection_2D")
4556 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4557 # a mesh pattern is taken, and, optionally, the association of vertices
4558 # between the source face and the target face (to which a hypothesis is assigned)
4559 # @param face from which the mesh pattern is taken
4560 # @param mesh from which the mesh pattern is taken (optional)
4561 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4562 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4563 # to associate with \a srcV1 (optional)
4564 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4565 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4566 # to associate with \a srcV2 (optional)
4567 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4568 # the same parameters, else (default) - forces the creation a new one
4570 # Note: all association vertices must belong to one edge of a face
4571 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4572 srcV2=None, tgtV2=None, UseExisting=0):
4573 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4575 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4576 hyp.SetSourceFace( face )
4577 if not mesh is None and isinstance(mesh, Mesh):
4578 mesh = mesh.GetMesh()
4579 hyp.SetSourceMesh( mesh )
4580 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4583 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4584 #def CompareSourceFace(self, hyp, args):
4585 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4588 # Public class: Mesh_Projection3D
4589 # ------------------------------
4591 ## Defines a projection 3D algorithm
4592 # @ingroup l3_algos_proj
4594 class Mesh_Projection3D(Mesh_Algorithm):
4596 ## Private constructor.
4597 def __init__(self, mesh, geom=0):
4598 Mesh_Algorithm.__init__(self)
4599 self.Create(mesh, geom, "Projection_3D")
4601 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4602 # the mesh pattern is taken, and, optionally, the association of vertices
4603 # between the source and the target solid (to which a hipothesis is assigned)
4604 # @param solid from where the mesh pattern is taken
4605 # @param mesh from where the mesh pattern is taken (optional)
4606 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4607 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4608 # to associate with \a srcV1 (optional)
4609 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4610 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4611 # to associate with \a srcV2 (optional)
4612 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4613 # the same parameters, else (default) - creates a new one
4615 # Note: association vertices must belong to one edge of a solid
4616 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4617 srcV2=0, tgtV2=0, UseExisting=0):
4618 hyp = self.Hypothesis("ProjectionSource3D",
4619 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4621 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4622 hyp.SetSource3DShape( solid )
4623 if not mesh is None and isinstance(mesh, Mesh):
4624 mesh = mesh.GetMesh()
4625 hyp.SetSourceMesh( mesh )
4626 if srcV1 and srcV2 and tgtV1 and tgtV2:
4627 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4628 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4631 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4632 #def CompareSourceShape3D(self, hyp, args):
4633 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4637 # Public class: Mesh_Prism
4638 # ------------------------
4640 ## Defines a 3D extrusion algorithm
4641 # @ingroup l3_algos_3dextr
4643 class Mesh_Prism3D(Mesh_Algorithm):
4645 ## Private constructor.
4646 def __init__(self, mesh, geom=0):
4647 Mesh_Algorithm.__init__(self)
4648 self.Create(mesh, geom, "Prism_3D")
4650 # Public class: Mesh_RadialPrism
4651 # -------------------------------
4653 ## Defines a Radial Prism 3D algorithm
4654 # @ingroup l3_algos_radialp
4656 class Mesh_RadialPrism3D(Mesh_Algorithm):
4658 ## Private constructor.
4659 def __init__(self, mesh, geom=0):
4660 Mesh_Algorithm.__init__(self)
4661 self.Create(mesh, geom, "RadialPrism_3D")
4663 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4664 self.nbLayers = None
4666 ## Return 3D hypothesis holding the 1D one
4667 def Get3DHypothesis(self):
4668 return self.distribHyp
4670 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4671 # hypothesis. Returns the created hypothesis
4672 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4673 #print "OwnHypothesis",hypType
4674 if not self.nbLayers is None:
4675 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4676 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4677 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4678 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4679 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4680 self.distribHyp.SetLayerDistribution( hyp )
4683 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4684 # prisms to build between the inner and outer shells
4685 # @param n number of layers
4686 # @param UseExisting if ==true - searches for the existing hypothesis created with
4687 # the same parameters, else (default) - creates a new one
4688 def NumberOfLayers(self, n, UseExisting=0):
4689 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4690 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4691 CompareMethod=self.CompareNumberOfLayers)
4692 self.nbLayers.SetNumberOfLayers( n )
4693 return self.nbLayers
4695 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4696 def CompareNumberOfLayers(self, hyp, args):
4697 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4699 ## Defines "LocalLength" hypothesis, specifying the segment length
4700 # to build between the inner and the outer shells
4701 # @param l the length of segments
4702 # @param p the precision of rounding
4703 def LocalLength(self, l, p=1e-07):
4704 hyp = self.OwnHypothesis("LocalLength", [l,p])
4709 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4710 # prisms to build between the inner and the outer shells.
4711 # @param n the number of layers
4712 # @param s the scale factor (optional)
4713 def NumberOfSegments(self, n, s=[]):
4715 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4717 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4718 hyp.SetDistrType( 1 )
4719 hyp.SetScaleFactor(s)
4720 hyp.SetNumberOfSegments(n)
4723 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4724 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4725 # @param start the length of the first segment
4726 # @param end the length of the last segment
4727 def Arithmetic1D(self, start, end ):
4728 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4729 hyp.SetLength(start, 1)
4730 hyp.SetLength(end , 0)
4733 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4734 # to build between the inner and the outer shells as geometric length increasing
4735 # @param start for the length of the first segment
4736 # @param end for the length of the last segment
4737 def StartEndLength(self, start, end):
4738 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4739 hyp.SetLength(start, 1)
4740 hyp.SetLength(end , 0)
4743 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4744 # to build between the inner and outer shells
4745 # @param fineness defines the quality of the mesh within the range [0-1]
4746 def AutomaticLength(self, fineness=0):
4747 hyp = self.OwnHypothesis("AutomaticLength")
4748 hyp.SetFineness( fineness )
4751 # Private class: Mesh_UseExisting
4752 # -------------------------------
4753 class Mesh_UseExisting(Mesh_Algorithm):
4755 def __init__(self, dim, mesh, geom=0):
4757 self.Create(mesh, geom, "UseExisting_1D")
4759 self.Create(mesh, geom, "UseExisting_2D")
4762 import salome_notebook
4763 notebook = salome_notebook.notebook
4765 ##Return values of the notebook variables
4766 def ParseParameters(last, nbParams,nbParam, value):
4770 listSize = len(last)
4771 for n in range(0,nbParams):
4773 if counter < listSize:
4774 strResult = strResult + last[counter]
4776 strResult = strResult + ""
4778 if isinstance(value, str):
4779 if notebook.isVariable(value):
4780 result = notebook.get(value)
4781 strResult=strResult+value
4783 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
4785 strResult=strResult+str(value)
4787 if nbParams - 1 != counter:
4788 strResult=strResult+var_separator #":"
4790 return result, strResult
4792 #Wrapper class for StdMeshers_LocalLength hypothesis
4793 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
4795 ## Set Length parameter value
4796 # @param length numerical value or name of variable from notebook
4797 def SetLength(self, length):
4798 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
4799 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4800 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
4802 ## Set Precision parameter value
4803 # @param precision numerical value or name of variable from notebook
4804 def SetPrecision(self, precision):
4805 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
4806 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4807 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
4809 #Registering the new proxy for LocalLength
4810 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
4813 #Wrapper class for StdMeshers_LayerDistribution hypothesis
4814 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
4816 def SetLayerDistribution(self, hypo):
4817 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
4818 hypo.ClearParameters();
4819 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
4821 #Registering the new proxy for LayerDistribution
4822 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
4824 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
4825 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
4827 ## Set Length parameter value
4828 # @param length numerical value or name of variable from notebook
4829 def SetLength(self, length):
4830 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
4831 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
4832 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
4834 #Registering the new proxy for SegmentLengthAroundVertex
4835 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
4838 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
4839 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
4841 ## Set Length parameter value
4842 # @param length numerical value or name of variable from notebook
4843 # @param isStart true is length is Start Length, otherwise false
4844 def SetLength(self, length, isStart):
4848 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
4849 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
4850 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
4852 #Registering the new proxy for Arithmetic1D
4853 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
4855 #Wrapper class for StdMeshers_Deflection1D hypothesis
4856 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
4858 ## Set Deflection parameter value
4859 # @param deflection numerical value or name of variable from notebook
4860 def SetDeflection(self, deflection):
4861 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
4862 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
4863 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
4865 #Registering the new proxy for Deflection1D
4866 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
4868 #Wrapper class for StdMeshers_StartEndLength hypothesis
4869 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
4871 ## Set Length parameter value
4872 # @param length numerical value or name of variable from notebook
4873 # @param isStart true is length is Start Length, otherwise false
4874 def SetLength(self, length, isStart):
4878 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
4879 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
4880 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
4882 #Registering the new proxy for StartEndLength
4883 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
4885 #Wrapper class for StdMeshers_MaxElementArea hypothesis
4886 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
4888 ## Set Max Element Area parameter value
4889 # @param area numerical value or name of variable from notebook
4890 def SetMaxElementArea(self, area):
4891 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
4892 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
4893 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
4895 #Registering the new proxy for MaxElementArea
4896 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
4899 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
4900 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
4902 ## Set Max Element Volume parameter value
4903 # @param area numerical value or name of variable from notebook
4904 def SetMaxElementVolume(self, volume):
4905 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
4906 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
4907 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
4909 #Registering the new proxy for MaxElementVolume
4910 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
4913 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
4914 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
4916 ## Set Number Of Layers parameter value
4917 # @param nbLayers numerical value or name of variable from notebook
4918 def SetNumberOfLayers(self, nbLayers):
4919 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
4920 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
4921 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
4923 #Registering the new proxy for NumberOfLayers
4924 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
4926 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
4927 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
4929 ## Set Number Of Segments parameter value
4930 # @param nbSeg numerical value or name of variable from notebook
4931 def SetNumberOfSegments(self, nbSeg):
4932 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
4933 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
4934 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4935 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
4937 ## Set Scale Factor parameter value
4938 # @param factor numerical value or name of variable from notebook
4939 def SetScaleFactor(self, factor):
4940 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
4941 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4942 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
4944 #Registering the new proxy for NumberOfSegments
4945 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
4948 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
4949 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
4951 ## Set Max Size parameter value
4952 # @param maxsize numerical value or name of variable from notebook
4953 def SetMaxSize(self, maxsize):
4954 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4955 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
4956 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4957 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
4959 ## Set Growth Rate parameter value
4960 # @param value numerical value or name of variable from notebook
4961 def SetGrowthRate(self, value):
4962 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4963 value, parameters = ParseParameters(lastParameters,4,2,value)
4964 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4965 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
4967 ## Set Number of Segments per Edge parameter value
4968 # @param value numerical value or name of variable from notebook
4969 def SetNbSegPerEdge(self, value):
4970 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4971 value, parameters = ParseParameters(lastParameters,4,3,value)
4972 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4973 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
4975 ## Set Number of Segments per Radius parameter value
4976 # @param value numerical value or name of variable from notebook
4977 def SetNbSegPerRadius(self, value):
4978 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4979 value, parameters = ParseParameters(lastParameters,4,4,value)
4980 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4981 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
4983 #Registering the new proxy for NETGENPlugin_Hypothesis
4984 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
4987 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
4988 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
4991 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
4992 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
4994 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
4995 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
4997 ## Set Number of Segments parameter value
4998 # @param nbSeg numerical value or name of variable from notebook
4999 def SetNumberOfSegments(self, nbSeg):
5000 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5001 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5002 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5003 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5005 ## Set Local Length parameter value
5006 # @param length numerical value or name of variable from notebook
5007 def SetLocalLength(self, length):
5008 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5009 length, parameters = ParseParameters(lastParameters,2,1,length)
5010 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5011 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5013 ## Set Max Element Area parameter value
5014 # @param area numerical value or name of variable from notebook
5015 def SetMaxElementArea(self, area):
5016 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5017 area, parameters = ParseParameters(lastParameters,2,2,area)
5018 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5019 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5021 def LengthFromEdges(self):
5022 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5024 value, parameters = ParseParameters(lastParameters,2,2,value)
5025 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5026 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5028 #Registering the new proxy for NETGEN_SimpleParameters_2D
5029 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5032 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5033 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5034 ## Set Max Element Volume parameter value
5035 # @param volume numerical value or name of variable from notebook
5036 def SetMaxElementVolume(self, volume):
5037 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5038 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5039 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5040 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5042 def LengthFromFaces(self):
5043 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5045 value, parameters = ParseParameters(lastParameters,3,3,value)
5046 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5047 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5049 #Registering the new proxy for NETGEN_SimpleParameters_3D
5050 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5052 class Pattern(SMESH._objref_SMESH_Pattern):
5054 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5056 if isinstance(theNodeIndexOnKeyPoint1,str):
5058 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5060 theNodeIndexOnKeyPoint1 -= 1
5061 theMesh.SetParameters(Parameters)
5062 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5064 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5067 if isinstance(theNode000Index,str):
5069 if isinstance(theNode001Index,str):
5071 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5073 theNode000Index -= 1
5075 theNode001Index -= 1
5076 theMesh.SetParameters(Parameters)
5077 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5079 #Registering the new proxy for Pattern
5080 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)