1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # Author : Francis KLOSS, OCC
32 ## @defgroup l1_auxiliary Auxiliary methods and structures
33 ## @defgroup l1_creating Creating meshes
35 ## @defgroup l2_impexp Importing and exporting meshes
36 ## @defgroup l2_construct Constructing meshes
37 ## @defgroup l2_algorithms Defining Algorithms
39 ## @defgroup l3_algos_basic Basic meshing algorithms
40 ## @defgroup l3_algos_proj Projection Algorithms
41 ## @defgroup l3_algos_radialp Radial Prism
42 ## @defgroup l3_algos_segmarv Segments around Vertex
43 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
46 ## @defgroup l2_hypotheses Defining hypotheses
48 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
49 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
50 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
51 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
52 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
53 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
54 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
55 ## @defgroup l3_hypos_additi Additional Hypotheses
58 ## @defgroup l2_submeshes Constructing submeshes
59 ## @defgroup l2_compounds Building Compounds
60 ## @defgroup l2_editing Editing Meshes
63 ## @defgroup l1_meshinfo Mesh Information
64 ## @defgroup l1_controls Quality controls and Filtering
65 ## @defgroup l1_grouping Grouping elements
67 ## @defgroup l2_grps_create Creating groups
68 ## @defgroup l2_grps_edit Editing groups
69 ## @defgroup l2_grps_operon Using operations on groups
70 ## @defgroup l2_grps_delete Deleting Groups
73 ## @defgroup l1_modifying Modifying meshes
75 ## @defgroup l2_modif_add Adding nodes and elements
76 ## @defgroup l2_modif_del Removing nodes and elements
77 ## @defgroup l2_modif_edit Modifying nodes and elements
78 ## @defgroup l2_modif_renumber Renumbering nodes and elements
79 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
80 ## @defgroup l2_modif_movenode Moving nodes
81 ## @defgroup l2_modif_throughp Mesh through point
82 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
83 ## @defgroup l2_modif_unitetri Uniting triangles
84 ## @defgroup l2_modif_changori Changing orientation of elements
85 ## @defgroup l2_modif_cutquadr Cutting quadrangles
86 ## @defgroup l2_modif_smooth Smoothing
87 ## @defgroup l2_modif_extrurev Extrusion and Revolution
88 ## @defgroup l2_modif_patterns Pattern mapping
89 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
96 import SMESH # This is necessary for back compatibility
103 # import NETGENPlugin module if possible
111 # import GHS3DPlugin module if possible
119 # import GHS3DPRLPlugin module if possible
122 import GHS3DPRLPlugin
127 # import HexoticPlugin module if possible
135 # import BLSURFPlugin module if possible
143 ## @addtogroup l1_auxiliary
146 # Types of algorithms
159 NETGEN_1D2D3D = FULL_NETGEN
160 NETGEN_FULL = FULL_NETGEN
166 # MirrorType enumeration
167 POINT = SMESH_MeshEditor.POINT
168 AXIS = SMESH_MeshEditor.AXIS
169 PLANE = SMESH_MeshEditor.PLANE
171 # Smooth_Method enumeration
172 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
173 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
175 # Fineness enumeration (for NETGEN)
183 # Optimization level of GHS3D
185 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
186 # V4.1 (partialy redefines V3.1). Issue 0020574
187 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
189 # Topology treatment way of BLSURF
190 FromCAD, PreProcess, PreProcessPlus = 0,1,2
192 # Element size flag of BLSURF
193 DefaultSize, DefaultGeom, Custom = 0,0,1
195 PrecisionConfusion = 1e-07
197 ## Converts an angle from degrees to radians
198 def DegreesToRadians(AngleInDegrees):
200 return AngleInDegrees * pi / 180.0
202 # Parametrized substitute for PointStruct
203 class PointStructStr:
212 def __init__(self, xStr, yStr, zStr):
216 if isinstance(xStr, str) and notebook.isVariable(xStr):
217 self.x = notebook.get(xStr)
220 if isinstance(yStr, str) and notebook.isVariable(yStr):
221 self.y = notebook.get(yStr)
224 if isinstance(zStr, str) and notebook.isVariable(zStr):
225 self.z = notebook.get(zStr)
229 # Parametrized substitute for PointStruct (with 6 parameters)
230 class PointStructStr6:
245 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
252 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
253 self.x1 = notebook.get(x1Str)
256 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
257 self.x2 = notebook.get(x2Str)
260 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
261 self.y1 = notebook.get(y1Str)
264 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
265 self.y2 = notebook.get(y2Str)
268 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
269 self.z1 = notebook.get(z1Str)
272 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
273 self.z2 = notebook.get(z2Str)
277 # Parametrized substitute for AxisStruct
293 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
300 if isinstance(xStr, str) and notebook.isVariable(xStr):
301 self.x = notebook.get(xStr)
304 if isinstance(yStr, str) and notebook.isVariable(yStr):
305 self.y = notebook.get(yStr)
308 if isinstance(zStr, str) and notebook.isVariable(zStr):
309 self.z = notebook.get(zStr)
312 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
313 self.dx = notebook.get(dxStr)
316 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
317 self.dy = notebook.get(dyStr)
320 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
321 self.dz = notebook.get(dzStr)
325 # Parametrized substitute for DirStruct
328 def __init__(self, pointStruct):
329 self.pointStruct = pointStruct
331 # Returns value of the parameter
332 def ParseValue(Parameter, ConvertToRadians = False):
334 if isinstance(Parameter, str):
335 p = notebook.get(Parameter)
337 notebook.getNotebook().AddExpression(Parameter)
338 p = notebook.get(Parameter)
340 p = DegreesToRadians(p)
344 # Returns the input parameter unchanged if it is a string or empty string otherwise
345 def ParseString(Parameter):
347 if isinstance(Parameter, str):
351 # Returns list of variable values from salome notebook
352 def ParsePointStruct(Point):
354 if isinstance(Point, PointStructStr):
355 Parameters.append(ParseString(Point.xStr))
356 Parameters.append(ParseString(Point.yStr))
357 Parameters.append(ParseString(Point.zStr))
358 Point = PointStruct(ParseValue(Point.x),
361 return Point, Parameters
363 # Returns list of variable values from salome notebook
364 def ParseDirStruct(Dir):
366 if isinstance(Dir, DirStructStr):
367 pntStr = Dir.pointStruct
368 if isinstance(pntStr, PointStructStr6):
369 Parameters.append(ParseString(pntStr.x1Str))
370 Parameters.append(ParseString(pntStr.x2Str))
371 Parameters.append(ParseString(pntStr.y1Str))
372 Parameters.append(ParseString(pntStr.y2Str))
373 Parameters.append(ParseString(pntStr.z1Str))
374 Parameters.append(ParseString(pntStr.z2Str))
375 Point = PointStruct(ParseValue(pntStr.x2) - ParseValue(pntStr.x1),
376 ParseValue(pntStr.y2) - ParseValue(pntStr.y1),
377 ParseValue(pntStr.z2) - ParseValue(pntStr.z1))
379 Parameters.append(ParseString(pntStr.xStr))
380 Parameters.append(ParseString(pntStr.yStr))
381 Parameters.append(ParseString(pntStr.zStr))
382 Point = PointStruct(ParseValue(pntStr.x),
383 ParseValue(pntStr.y),
384 ParseValue(pntStr.z))
385 Dir = DirStruct(Point)
386 return Dir, Parameters
388 # Returns list of variable values from salome notebook
389 def ParseAxisStruct(Axis):
391 if isinstance(Axis, AxisStructStr):
392 Parameters.append(ParseString(Axis.xStr))
393 Parameters.append(ParseString(Axis.yStr))
394 Parameters.append(ParseString(Axis.zStr))
395 Parameters.append(ParseString(Axis.dxStr))
396 Parameters.append(ParseString(Axis.dyStr))
397 Parameters.append(ParseString(Axis.dzStr))
398 Axis = AxisStruct(ParseValue(Axis.x),
404 return Axis, Parameters
406 ## Return list of variable values from salome notebook
407 def ParseAngles(list):
410 for parameter in list:
411 Result.append(ParseValue(parameter, True))
412 Parameters.append(ParseString(parameter))
414 return Result, Parameters
416 def IsEqual(val1, val2, tol=PrecisionConfusion):
417 if abs(val1 - val2) < tol:
425 ior = salome.orb.object_to_string(obj)
426 sobj = salome.myStudy.FindObjectIOR(ior)
430 attr = sobj.FindAttribute("AttributeName")[1]
433 ## Prints error message if a hypothesis was not assigned.
434 def TreatHypoStatus(status, hypName, geomName, isAlgo):
436 hypType = "algorithm"
438 hypType = "hypothesis"
440 if status == HYP_UNKNOWN_FATAL :
441 reason = "for unknown reason"
442 elif status == HYP_INCOMPATIBLE :
443 reason = "this hypothesis mismatches the algorithm"
444 elif status == HYP_NOTCONFORM :
445 reason = "a non-conform mesh would be built"
446 elif status == HYP_ALREADY_EXIST :
447 reason = hypType + " of the same dimension is already assigned to this shape"
448 elif status == HYP_BAD_DIM :
449 reason = hypType + " mismatches the shape"
450 elif status == HYP_CONCURENT :
451 reason = "there are concurrent hypotheses on sub-shapes"
452 elif status == HYP_BAD_SUBSHAPE :
453 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
454 elif status == HYP_BAD_GEOMETRY:
455 reason = "geometry mismatches the expectation of the algorithm"
456 elif status == HYP_HIDDEN_ALGO:
457 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
458 elif status == HYP_HIDING_ALGO:
459 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
460 elif status == HYP_NEED_SHAPE:
461 reason = "Algorithm can't work without shape"
464 hypName = '"' + hypName + '"'
465 geomName= '"' + geomName+ '"'
466 if status < HYP_UNKNOWN_FATAL:
467 print hypName, "was assigned to", geomName,"but", reason
469 print hypName, "was not assigned to",geomName,":", reason
472 ## Check meshing plugin availability
473 def CheckPlugin(plugin):
474 if plugin == NETGEN and noNETGENPlugin:
475 print "Warning: NETGENPlugin module unavailable"
477 elif plugin == GHS3D and noGHS3DPlugin:
478 print "Warning: GHS3DPlugin module unavailable"
480 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
481 print "Warning: GHS3DPRLPlugin module unavailable"
483 elif plugin == Hexotic and noHexoticPlugin:
484 print "Warning: HexoticPlugin module unavailable"
486 elif plugin == BLSURF and noBLSURFPlugin:
487 print "Warning: BLSURFPlugin module unavailable"
491 # end of l1_auxiliary
494 # All methods of this class are accessible directly from the smesh.py package.
495 class smeshDC(SMESH._objref_SMESH_Gen):
497 ## Sets the current study and Geometry component
498 # @ingroup l1_auxiliary
499 def init_smesh(self,theStudy,geompyD):
500 self.SetCurrentStudy(theStudy,geompyD)
502 ## Creates an empty Mesh. This mesh can have an underlying geometry.
503 # @param obj the Geometrical object on which the mesh is built. If not defined,
504 # the mesh will have no underlying geometry.
505 # @param name the name for the new mesh.
506 # @return an instance of Mesh class.
507 # @ingroup l2_construct
508 def Mesh(self, obj=0, name=0):
509 if isinstance(obj,str):
511 return Mesh(self,self.geompyD,obj,name)
513 ## Returns a long value from enumeration
514 # Should be used for SMESH.FunctorType enumeration
515 # @ingroup l1_controls
516 def EnumToLong(self,theItem):
519 ## Gets PointStruct from vertex
520 # @param theVertex a GEOM object(vertex)
521 # @return SMESH.PointStruct
522 # @ingroup l1_auxiliary
523 def GetPointStruct(self,theVertex):
524 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
525 return PointStruct(x,y,z)
527 ## Gets DirStruct from vector
528 # @param theVector a GEOM object(vector)
529 # @return SMESH.DirStruct
530 # @ingroup l1_auxiliary
531 def GetDirStruct(self,theVector):
532 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
533 if(len(vertices) != 2):
534 print "Error: vector object is incorrect."
536 p1 = self.geompyD.PointCoordinates(vertices[0])
537 p2 = self.geompyD.PointCoordinates(vertices[1])
538 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
539 dirst = DirStruct(pnt)
542 ## Makes DirStruct from a triplet
543 # @param x,y,z vector components
544 # @return SMESH.DirStruct
545 # @ingroup l1_auxiliary
546 def MakeDirStruct(self,x,y,z):
547 pnt = PointStruct(x,y,z)
548 return DirStruct(pnt)
550 ## Get AxisStruct from object
551 # @param theObj a GEOM object (line or plane)
552 # @return SMESH.AxisStruct
553 # @ingroup l1_auxiliary
554 def GetAxisStruct(self,theObj):
555 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
557 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
558 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
559 vertex1 = self.geompyD.PointCoordinates(vertex1)
560 vertex2 = self.geompyD.PointCoordinates(vertex2)
561 vertex3 = self.geompyD.PointCoordinates(vertex3)
562 vertex4 = self.geompyD.PointCoordinates(vertex4)
563 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
564 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
565 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] ]
566 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
568 elif len(edges) == 1:
569 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
570 p1 = self.geompyD.PointCoordinates( vertex1 )
571 p2 = self.geompyD.PointCoordinates( vertex2 )
572 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
576 # From SMESH_Gen interface:
577 # ------------------------
579 ## Sets the given name to the object
580 # @param obj the object to rename
581 # @param name a new object name
582 # @ingroup l1_auxiliary
583 def SetName(self, obj, name):
584 if isinstance( obj, Mesh ):
586 elif isinstance( obj, Mesh_Algorithm ):
587 obj = obj.GetAlgorithm()
588 ior = salome.orb.object_to_string(obj)
589 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
591 ## Sets the current mode
592 # @ingroup l1_auxiliary
593 def SetEmbeddedMode( self,theMode ):
594 #self.SetEmbeddedMode(theMode)
595 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
597 ## Gets the current mode
598 # @ingroup l1_auxiliary
599 def IsEmbeddedMode(self):
600 #return self.IsEmbeddedMode()
601 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
603 ## Sets the current study
604 # @ingroup l1_auxiliary
605 def SetCurrentStudy( self, theStudy, geompyD = None ):
606 #self.SetCurrentStudy(theStudy)
609 geompyD = geompy.geom
612 self.SetGeomEngine(geompyD)
613 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
615 ## Gets the current study
616 # @ingroup l1_auxiliary
617 def GetCurrentStudy(self):
618 #return self.GetCurrentStudy()
619 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
621 ## Creates a Mesh object importing data from the given UNV file
622 # @return an instance of Mesh class
624 def CreateMeshesFromUNV( self,theFileName ):
625 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
626 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
629 ## Creates a Mesh object(s) importing data from the given MED file
630 # @return a list of Mesh class instances
632 def CreateMeshesFromMED( self,theFileName ):
633 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
635 for iMesh in range(len(aSmeshMeshes)) :
636 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
637 aMeshes.append(aMesh)
638 return aMeshes, aStatus
640 ## Creates a Mesh object importing data from the given STL file
641 # @return an instance of Mesh class
643 def CreateMeshesFromSTL( self, theFileName ):
644 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
645 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
648 ## From SMESH_Gen interface
649 # @return the list of integer values
650 # @ingroup l1_auxiliary
651 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
652 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
654 ## From SMESH_Gen interface. Creates a pattern
655 # @return an instance of SMESH_Pattern
657 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
658 # @ingroup l2_modif_patterns
659 def GetPattern(self):
660 return SMESH._objref_SMESH_Gen.GetPattern(self)
662 ## Sets number of segments per diagonal of boundary box of geometry by which
663 # default segment length of appropriate 1D hypotheses is defined.
664 # Default value is 10
665 # @ingroup l1_auxiliary
666 def SetBoundaryBoxSegmentation(self, nbSegments):
667 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
669 ## Concatenate the given meshes into one mesh.
670 # @return an instance of Mesh class
671 # @param meshes the meshes to combine into one mesh
672 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
673 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
674 # @param mergeTolerance tolerance for merging nodes
675 # @param allGroups forces creation of groups of all elements
676 def Concatenate( self, meshes, uniteIdenticalGroups,
677 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
678 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
680 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
681 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
683 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
684 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
685 geompyDC.SetParameters(aSmeshMesh, Parameters)
686 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
689 # Filtering. Auxiliary functions:
690 # ------------------------------
692 ## Creates an empty criterion
693 # @return SMESH.Filter.Criterion
694 # @ingroup l1_controls
695 def GetEmptyCriterion(self):
696 Type = self.EnumToLong(FT_Undefined)
697 Compare = self.EnumToLong(FT_Undefined)
701 UnaryOp = self.EnumToLong(FT_Undefined)
702 BinaryOp = self.EnumToLong(FT_Undefined)
705 Precision = -1 ##@1e-07
706 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
707 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
709 ## Creates a criterion by the given parameters
710 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
711 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
712 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
713 # @param Treshold the threshold value (range of ids as string, shape, numeric)
714 # @param UnaryOp FT_LogicalNOT or FT_Undefined
715 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
716 # FT_Undefined (must be for the last criterion of all criteria)
717 # @return SMESH.Filter.Criterion
718 # @ingroup l1_controls
719 def GetCriterion(self,elementType,
721 Compare = FT_EqualTo,
723 UnaryOp=FT_Undefined,
724 BinaryOp=FT_Undefined):
725 aCriterion = self.GetEmptyCriterion()
726 aCriterion.TypeOfElement = elementType
727 aCriterion.Type = self.EnumToLong(CritType)
731 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
732 aCriterion.Compare = self.EnumToLong(Compare)
733 elif Compare == "=" or Compare == "==":
734 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
736 aCriterion.Compare = self.EnumToLong(FT_LessThan)
738 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
740 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
743 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
744 FT_BelongToCylinder, FT_LyingOnGeom]:
745 # Checks the treshold
746 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
747 aCriterion.ThresholdStr = GetName(aTreshold)
748 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
750 print "Error: The treshold should be a shape."
752 elif CritType == FT_RangeOfIds:
753 # Checks the treshold
754 if isinstance(aTreshold, str):
755 aCriterion.ThresholdStr = aTreshold
757 print "Error: The treshold should be a string."
759 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
760 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
761 # At this point the treshold is unnecessary
762 if aTreshold == FT_LogicalNOT:
763 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
764 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
765 aCriterion.BinaryOp = aTreshold
769 aTreshold = float(aTreshold)
770 aCriterion.Threshold = aTreshold
772 print "Error: The treshold should be a number."
775 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
776 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
778 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
779 aCriterion.BinaryOp = self.EnumToLong(Treshold)
781 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
782 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
784 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
785 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
789 ## Creates a filter with the given parameters
790 # @param elementType the type of elements in the group
791 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
792 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
793 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
794 # @param UnaryOp FT_LogicalNOT or FT_Undefined
795 # @return SMESH_Filter
796 # @ingroup l1_controls
797 def GetFilter(self,elementType,
798 CritType=FT_Undefined,
801 UnaryOp=FT_Undefined):
802 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
803 aFilterMgr = self.CreateFilterManager()
804 aFilter = aFilterMgr.CreateFilter()
806 aCriteria.append(aCriterion)
807 aFilter.SetCriteria(aCriteria)
810 ## Creates a numerical functor by its type
811 # @param theCriterion FT_...; functor type
812 # @return SMESH_NumericalFunctor
813 # @ingroup l1_controls
814 def GetFunctor(self,theCriterion):
815 aFilterMgr = self.CreateFilterManager()
816 if theCriterion == FT_AspectRatio:
817 return aFilterMgr.CreateAspectRatio()
818 elif theCriterion == FT_AspectRatio3D:
819 return aFilterMgr.CreateAspectRatio3D()
820 elif theCriterion == FT_Warping:
821 return aFilterMgr.CreateWarping()
822 elif theCriterion == FT_MinimumAngle:
823 return aFilterMgr.CreateMinimumAngle()
824 elif theCriterion == FT_Taper:
825 return aFilterMgr.CreateTaper()
826 elif theCriterion == FT_Skew:
827 return aFilterMgr.CreateSkew()
828 elif theCriterion == FT_Area:
829 return aFilterMgr.CreateArea()
830 elif theCriterion == FT_Volume3D:
831 return aFilterMgr.CreateVolume3D()
832 elif theCriterion == FT_MultiConnection:
833 return aFilterMgr.CreateMultiConnection()
834 elif theCriterion == FT_MultiConnection2D:
835 return aFilterMgr.CreateMultiConnection2D()
836 elif theCriterion == FT_Length:
837 return aFilterMgr.CreateLength()
838 elif theCriterion == FT_Length2D:
839 return aFilterMgr.CreateLength2D()
841 print "Error: given parameter is not numerucal functor type."
843 ## Creates hypothesis
844 # @param theHType mesh hypothesis type (string)
845 # @param theLibName mesh plug-in library name
846 # @return created hypothesis instance
847 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
848 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
850 ## Gets the mesh stattistic
851 # @return dictionary type element - count of elements
852 # @ingroup l1_meshinfo
853 def GetMeshInfo(self, obj):
854 if isinstance( obj, Mesh ):
857 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
858 values = obj.GetMeshInfo()
859 for i in range(SMESH.Entity_Last._v):
860 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
865 #Registering the new proxy for SMESH_Gen
866 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
872 ## This class allows defining and managing a mesh.
873 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
874 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
875 # new nodes and elements and by changing the existing entities), to get information
876 # about a mesh and to export a mesh into different formats.
885 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
886 # sets the GUI name of this mesh to \a name.
887 # @param smeshpyD an instance of smeshDC class
888 # @param geompyD an instance of geompyDC class
889 # @param obj Shape to be meshed or SMESH_Mesh object
890 # @param name Study name of the mesh
891 # @ingroup l2_construct
892 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
893 self.smeshpyD=smeshpyD
898 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
900 self.mesh = self.smeshpyD.CreateMesh(self.geom)
901 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
904 self.mesh = self.smeshpyD.CreateEmptyMesh()
906 self.smeshpyD.SetName(self.mesh, name)
908 self.smeshpyD.SetName(self.mesh, GetName(obj))
911 self.geom = self.mesh.GetShapeToMesh()
913 self.editor = self.mesh.GetMeshEditor()
915 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
916 # @param theMesh a SMESH_Mesh object
917 # @ingroup l2_construct
918 def SetMesh(self, theMesh):
920 self.geom = self.mesh.GetShapeToMesh()
922 ## Returns the mesh, that is an instance of SMESH_Mesh interface
923 # @return a SMESH_Mesh object
924 # @ingroup l2_construct
928 ## Gets the name of the mesh
929 # @return the name of the mesh as a string
930 # @ingroup l2_construct
932 name = GetName(self.GetMesh())
935 ## Sets a name to the mesh
936 # @param name a new name of the mesh
937 # @ingroup l2_construct
938 def SetName(self, name):
939 self.smeshpyD.SetName(self.GetMesh(), name)
941 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
942 # The subMesh object gives access to the IDs of nodes and elements.
943 # @param theSubObject a geometrical object (shape)
944 # @param theName a name for the submesh
945 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
946 # @ingroup l2_submeshes
947 def GetSubMesh(self, theSubObject, theName):
948 submesh = self.mesh.GetSubMesh(theSubObject, theName)
951 ## Returns the shape associated to the mesh
952 # @return a GEOM_Object
953 # @ingroup l2_construct
957 ## Associates the given shape to the mesh (entails the recreation of the mesh)
958 # @param geom the shape to be meshed (GEOM_Object)
959 # @ingroup l2_construct
960 def SetShape(self, geom):
961 self.mesh = self.smeshpyD.CreateMesh(geom)
963 ## Returns true if the hypotheses are defined well
964 # @param theSubObject a subshape of a mesh shape
965 # @return True or False
966 # @ingroup l2_construct
967 def IsReadyToCompute(self, theSubObject):
968 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
970 ## Returns errors of hypotheses definition.
971 # The list of errors is empty if everything is OK.
972 # @param theSubObject a subshape of a mesh shape
973 # @return a list of errors
974 # @ingroup l2_construct
975 def GetAlgoState(self, theSubObject):
976 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
978 ## Returns a geometrical object on which the given element was built.
979 # The returned geometrical object, if not nil, is either found in the
980 # study or published by this method with the given name
981 # @param theElementID the id of the mesh element
982 # @param theGeomName the user-defined name of the geometrical object
983 # @return GEOM::GEOM_Object instance
984 # @ingroup l2_construct
985 def GetGeometryByMeshElement(self, theElementID, theGeomName):
986 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
988 ## Returns the mesh dimension depending on the dimension of the underlying shape
989 # @return mesh dimension as an integer value [0,3]
990 # @ingroup l1_auxiliary
991 def MeshDimension(self):
992 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
993 if len( shells ) > 0 :
995 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
997 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1003 ## Creates a segment discretization 1D algorithm.
1004 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1005 # \n If the optional \a geom parameter is not set, this algorithm is global.
1006 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1007 # @param algo the type of the required algorithm. Possible values are:
1009 # - smesh.PYTHON for discretization via a python function,
1010 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1011 # @param geom If defined is the subshape to be meshed
1012 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1013 # @ingroup l3_algos_basic
1014 def Segment(self, algo=REGULAR, geom=0):
1015 ## if Segment(geom) is called by mistake
1016 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1017 algo, geom = geom, algo
1018 if not algo: algo = REGULAR
1021 return Mesh_Segment(self, geom)
1022 elif algo == PYTHON:
1023 return Mesh_Segment_Python(self, geom)
1024 elif algo == COMPOSITE:
1025 return Mesh_CompositeSegment(self, geom)
1027 return Mesh_Segment(self, geom)
1029 ## Enables creation of nodes and segments usable by 2D algoritms.
1030 # The added nodes and segments must be bound to edges and vertices by
1031 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1032 # If the optional \a geom parameter is not set, this algorithm is global.
1033 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1034 # @param geom the subshape to be manually meshed
1035 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1036 # @ingroup l3_algos_basic
1037 def UseExistingSegments(self, geom=0):
1038 algo = Mesh_UseExisting(1,self,geom)
1039 return algo.GetAlgorithm()
1041 ## Enables creation of nodes and faces usable by 3D algoritms.
1042 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1043 # and SetMeshElementOnShape()
1044 # If the optional \a geom parameter is not set, this algorithm is global.
1045 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1046 # @param geom the subshape to be manually meshed
1047 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1048 # @ingroup l3_algos_basic
1049 def UseExistingFaces(self, geom=0):
1050 algo = Mesh_UseExisting(2,self,geom)
1051 return algo.GetAlgorithm()
1053 ## Creates a triangle 2D algorithm for faces.
1054 # If the optional \a geom parameter is not set, this algorithm is global.
1055 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1056 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1057 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1058 # @return an instance of Mesh_Triangle algorithm
1059 # @ingroup l3_algos_basic
1060 def Triangle(self, algo=MEFISTO, geom=0):
1061 ## if Triangle(geom) is called by mistake
1062 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1066 return Mesh_Triangle(self, algo, geom)
1068 ## Creates a quadrangle 2D algorithm for faces.
1069 # If the optional \a geom parameter is not set, this algorithm is global.
1070 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1071 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1072 # @return an instance of Mesh_Quadrangle algorithm
1073 # @ingroup l3_algos_basic
1074 def Quadrangle(self, geom=0):
1075 return Mesh_Quadrangle(self, geom)
1077 ## Creates a tetrahedron 3D algorithm for solids.
1078 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1079 # If the optional \a geom parameter is not set, this algorithm is global.
1080 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1081 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1082 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1083 # @return an instance of Mesh_Tetrahedron algorithm
1084 # @ingroup l3_algos_basic
1085 def Tetrahedron(self, algo=NETGEN, geom=0):
1086 ## if Tetrahedron(geom) is called by mistake
1087 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1088 algo, geom = geom, algo
1089 if not algo: algo = NETGEN
1091 return Mesh_Tetrahedron(self, algo, geom)
1093 ## Creates a hexahedron 3D algorithm for solids.
1094 # If the optional \a geom parameter is not set, this algorithm is global.
1095 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1096 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1097 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1098 # @return an instance of Mesh_Hexahedron algorithm
1099 # @ingroup l3_algos_basic
1100 def Hexahedron(self, algo=Hexa, geom=0):
1101 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1102 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1103 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1104 elif geom == 0: algo, geom = Hexa, algo
1105 return Mesh_Hexahedron(self, algo, geom)
1107 ## Deprecated, used only for compatibility!
1108 # @return an instance of Mesh_Netgen algorithm
1109 # @ingroup l3_algos_basic
1110 def Netgen(self, is3D, geom=0):
1111 return Mesh_Netgen(self, is3D, geom)
1113 ## Creates a projection 1D algorithm for edges.
1114 # If the optional \a geom parameter is not set, this algorithm is global.
1115 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1116 # @param geom If defined, the subshape to be meshed
1117 # @return an instance of Mesh_Projection1D algorithm
1118 # @ingroup l3_algos_proj
1119 def Projection1D(self, geom=0):
1120 return Mesh_Projection1D(self, geom)
1122 ## Creates a projection 2D algorithm for faces.
1123 # If the optional \a geom parameter is not set, this algorithm is global.
1124 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1125 # @param geom If defined, the subshape to be meshed
1126 # @return an instance of Mesh_Projection2D algorithm
1127 # @ingroup l3_algos_proj
1128 def Projection2D(self, geom=0):
1129 return Mesh_Projection2D(self, geom)
1131 ## Creates a projection 3D algorithm for solids.
1132 # If the optional \a geom parameter is not set, this algorithm is global.
1133 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1134 # @param geom If defined, the subshape to be meshed
1135 # @return an instance of Mesh_Projection3D algorithm
1136 # @ingroup l3_algos_proj
1137 def Projection3D(self, geom=0):
1138 return Mesh_Projection3D(self, geom)
1140 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1141 # If the optional \a geom parameter is not set, this algorithm is global.
1142 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1143 # @param geom If defined, the subshape to be meshed
1144 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1145 # @ingroup l3_algos_radialp l3_algos_3dextr
1146 def Prism(self, geom=0):
1150 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1151 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1152 if nbSolids == 0 or nbSolids == nbShells:
1153 return Mesh_Prism3D(self, geom)
1154 return Mesh_RadialPrism3D(self, geom)
1156 ## Evaluates size of prospective mesh on a shape
1157 # @return True or False
1158 def Evaluate(self, geom=0):
1159 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1161 geom = self.mesh.GetShapeToMesh()
1164 return self.smeshpyD.Evaluate(self.mesh, geom)
1167 ## Computes the mesh and returns the status of the computation
1168 # @return True or False
1169 # @ingroup l2_construct
1170 def Compute(self, geom=0):
1171 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1173 geom = self.mesh.GetShapeToMesh()
1178 ok = self.smeshpyD.Compute(self.mesh, geom)
1179 except SALOME.SALOME_Exception, ex:
1180 print "Mesh computation failed, exception caught:"
1181 print " ", ex.details.text
1184 print "Mesh computation failed, exception caught:"
1185 traceback.print_exc()
1187 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1190 if err.isGlobalAlgo:
1198 reason = '%s %sD algorithm is missing' % (glob, dim)
1199 elif err.state == HYP_MISSING:
1200 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1201 % (glob, dim, name, dim))
1202 elif err.state == HYP_NOTCONFORM:
1203 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1204 elif err.state == HYP_BAD_PARAMETER:
1205 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1206 % ( glob, dim, name ))
1207 elif err.state == HYP_BAD_GEOMETRY:
1208 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1209 'geometry' % ( glob, dim, name ))
1211 reason = "For unknown reason."+\
1212 " Revise Mesh.Compute() implementation in smeshDC.py!"
1214 if allReasons != "":
1217 allReasons += reason
1219 if allReasons != "":
1220 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1224 print '"' + GetName(self.mesh) + '"',"has not been computed."
1227 if salome.sg.hasDesktop():
1228 smeshgui = salome.ImportComponentGUI("SMESH")
1229 smeshgui.Init(self.mesh.GetStudyId())
1230 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1231 salome.sg.updateObjBrowser(1)
1235 ## Removes all nodes and elements
1236 # @ingroup l2_construct
1239 if salome.sg.hasDesktop():
1240 smeshgui = salome.ImportComponentGUI("SMESH")
1241 smeshgui.Init(self.mesh.GetStudyId())
1242 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1243 salome.sg.updateObjBrowser(1)
1245 ## Removes all nodes and elements of indicated shape
1246 # @ingroup l2_construct
1247 def ClearSubMesh(self, geomId):
1248 self.mesh.ClearSubMesh(geomId)
1249 if salome.sg.hasDesktop():
1250 smeshgui = salome.ImportComponentGUI("SMESH")
1251 smeshgui.Init(self.mesh.GetStudyId())
1252 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1253 salome.sg.updateObjBrowser(1)
1255 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1256 # @param fineness [0,-1] defines mesh fineness
1257 # @return True or False
1258 # @ingroup l3_algos_basic
1259 def AutomaticTetrahedralization(self, fineness=0):
1260 dim = self.MeshDimension()
1262 self.RemoveGlobalHypotheses()
1263 self.Segment().AutomaticLength(fineness)
1265 self.Triangle().LengthFromEdges()
1268 self.Tetrahedron(NETGEN)
1270 return self.Compute()
1272 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1273 # @param fineness [0,-1] defines mesh fineness
1274 # @return True or False
1275 # @ingroup l3_algos_basic
1276 def AutomaticHexahedralization(self, fineness=0):
1277 dim = self.MeshDimension()
1278 # assign the hypotheses
1279 self.RemoveGlobalHypotheses()
1280 self.Segment().AutomaticLength(fineness)
1287 return self.Compute()
1289 ## Assigns a hypothesis
1290 # @param hyp a hypothesis to assign
1291 # @param geom a subhape of mesh geometry
1292 # @return SMESH.Hypothesis_Status
1293 # @ingroup l2_hypotheses
1294 def AddHypothesis(self, hyp, geom=0):
1295 if isinstance( hyp, Mesh_Algorithm ):
1296 hyp = hyp.GetAlgorithm()
1301 geom = self.mesh.GetShapeToMesh()
1303 status = self.mesh.AddHypothesis(geom, hyp)
1304 isAlgo = hyp._narrow( SMESH_Algo )
1305 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1308 ## Unassigns a hypothesis
1309 # @param hyp a hypothesis to unassign
1310 # @param geom a subshape of mesh geometry
1311 # @return SMESH.Hypothesis_Status
1312 # @ingroup l2_hypotheses
1313 def RemoveHypothesis(self, hyp, geom=0):
1314 if isinstance( hyp, Mesh_Algorithm ):
1315 hyp = hyp.GetAlgorithm()
1320 status = self.mesh.RemoveHypothesis(geom, hyp)
1323 ## Gets the list of hypotheses added on a geometry
1324 # @param geom a subshape of mesh geometry
1325 # @return the sequence of SMESH_Hypothesis
1326 # @ingroup l2_hypotheses
1327 def GetHypothesisList(self, geom):
1328 return self.mesh.GetHypothesisList( geom )
1330 ## Removes all global hypotheses
1331 # @ingroup l2_hypotheses
1332 def RemoveGlobalHypotheses(self):
1333 current_hyps = self.mesh.GetHypothesisList( self.geom )
1334 for hyp in current_hyps:
1335 self.mesh.RemoveHypothesis( self.geom, hyp )
1339 ## Creates a mesh group based on the geometric object \a grp
1340 # and gives a \a name, \n if this parameter is not defined
1341 # the name is the same as the geometric group name \n
1342 # Note: Works like GroupOnGeom().
1343 # @param grp a geometric group, a vertex, an edge, a face or a solid
1344 # @param name the name of the mesh group
1345 # @return SMESH_GroupOnGeom
1346 # @ingroup l2_grps_create
1347 def Group(self, grp, name=""):
1348 return self.GroupOnGeom(grp, name)
1350 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1351 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1352 # @param f the file name
1353 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1354 # @param opt boolean parameter for creating/not creating
1355 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1356 # @ingroup l2_impexp
1357 def ExportToMED(self, f, version, opt=0):
1358 self.mesh.ExportToMED(f, opt, version)
1360 ## Exports the mesh in a file in MED format
1361 # @param f is the file name
1362 # @param auto_groups boolean parameter for creating/not creating
1363 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1364 # the typical use is auto_groups=false.
1365 # @param version MED format version(MED_V2_1 or MED_V2_2)
1366 # @ingroup l2_impexp
1367 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1368 self.mesh.ExportToMED(f, auto_groups, version)
1370 ## Exports the mesh in a file in DAT format
1371 # @param f the file name
1372 # @ingroup l2_impexp
1373 def ExportDAT(self, f):
1374 self.mesh.ExportDAT(f)
1376 ## Exports the mesh in a file in UNV format
1377 # @param f the file name
1378 # @ingroup l2_impexp
1379 def ExportUNV(self, f):
1380 self.mesh.ExportUNV(f)
1382 ## Export the mesh in a file in STL format
1383 # @param f the file name
1384 # @param ascii defines the file encoding
1385 # @ingroup l2_impexp
1386 def ExportSTL(self, f, ascii=1):
1387 self.mesh.ExportSTL(f, ascii)
1390 # Operations with groups:
1391 # ----------------------
1393 ## Creates an empty mesh group
1394 # @param elementType the type of elements in the group
1395 # @param name the name of the mesh group
1396 # @return SMESH_Group
1397 # @ingroup l2_grps_create
1398 def CreateEmptyGroup(self, elementType, name):
1399 return self.mesh.CreateGroup(elementType, name)
1401 ## Creates a mesh group based on the geometrical object \a grp
1402 # and gives a \a name, \n if this parameter is not defined
1403 # the name is the same as the geometrical group name
1404 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1405 # @param name the name of the mesh group
1406 # @param typ the type of elements in the group. If not set, it is
1407 # automatically detected by the type of the geometry
1408 # @return SMESH_GroupOnGeom
1409 # @ingroup l2_grps_create
1410 def GroupOnGeom(self, grp, name="", typ=None):
1412 name = grp.GetName()
1415 tgeo = str(grp.GetShapeType())
1416 if tgeo == "VERTEX":
1418 elif tgeo == "EDGE":
1420 elif tgeo == "FACE":
1422 elif tgeo == "SOLID":
1424 elif tgeo == "SHELL":
1426 elif tgeo == "COMPOUND":
1427 try: # it raises on a compound of compounds
1428 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1429 print "Mesh.Group: empty geometric group", GetName( grp )
1434 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1436 tgeo = self.geompyD.GetType(grp)
1437 if tgeo == geompyDC.ShapeType["VERTEX"]:
1439 elif tgeo == geompyDC.ShapeType["EDGE"]:
1441 elif tgeo == geompyDC.ShapeType["FACE"]:
1443 elif tgeo == geompyDC.ShapeType["SOLID"]:
1449 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1450 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1451 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1459 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1462 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1464 ## Creates a mesh group by the given ids of elements
1465 # @param groupName the name of the mesh group
1466 # @param elementType the type of elements in the group
1467 # @param elemIDs the list of ids
1468 # @return SMESH_Group
1469 # @ingroup l2_grps_create
1470 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1471 group = self.mesh.CreateGroup(elementType, groupName)
1475 ## Creates a mesh group by the given conditions
1476 # @param groupName the name of the mesh group
1477 # @param elementType the type of elements in the group
1478 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1479 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1480 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1481 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1482 # @return SMESH_Group
1483 # @ingroup l2_grps_create
1487 CritType=FT_Undefined,
1490 UnaryOp=FT_Undefined):
1491 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1492 group = self.MakeGroupByCriterion(groupName, aCriterion)
1495 ## Creates a mesh group by the given criterion
1496 # @param groupName the name of the mesh group
1497 # @param Criterion the instance of Criterion class
1498 # @return SMESH_Group
1499 # @ingroup l2_grps_create
1500 def MakeGroupByCriterion(self, groupName, Criterion):
1501 aFilterMgr = self.smeshpyD.CreateFilterManager()
1502 aFilter = aFilterMgr.CreateFilter()
1504 aCriteria.append(Criterion)
1505 aFilter.SetCriteria(aCriteria)
1506 group = self.MakeGroupByFilter(groupName, aFilter)
1509 ## Creates a mesh group by the given criteria (list of criteria)
1510 # @param groupName the name of the mesh group
1511 # @param theCriteria the list of criteria
1512 # @return SMESH_Group
1513 # @ingroup l2_grps_create
1514 def MakeGroupByCriteria(self, groupName, theCriteria):
1515 aFilterMgr = self.smeshpyD.CreateFilterManager()
1516 aFilter = aFilterMgr.CreateFilter()
1517 aFilter.SetCriteria(theCriteria)
1518 group = self.MakeGroupByFilter(groupName, aFilter)
1521 ## Creates a mesh group by the given filter
1522 # @param groupName the name of the mesh group
1523 # @param theFilter the instance of Filter class
1524 # @return SMESH_Group
1525 # @ingroup l2_grps_create
1526 def MakeGroupByFilter(self, groupName, theFilter):
1527 anIds = theFilter.GetElementsId(self.mesh)
1528 anElemType = theFilter.GetElementType()
1529 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1532 ## Passes mesh elements through the given filter and return IDs of fitting elements
1533 # @param theFilter SMESH_Filter
1534 # @return a list of ids
1535 # @ingroup l1_controls
1536 def GetIdsFromFilter(self, theFilter):
1537 return theFilter.GetElementsId(self.mesh)
1539 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1540 # Returns a list of special structures (borders).
1541 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1542 # @ingroup l1_controls
1543 def GetFreeBorders(self):
1544 aFilterMgr = self.smeshpyD.CreateFilterManager()
1545 aPredicate = aFilterMgr.CreateFreeEdges()
1546 aPredicate.SetMesh(self.mesh)
1547 aBorders = aPredicate.GetBorders()
1551 # @ingroup l2_grps_delete
1552 def RemoveGroup(self, group):
1553 self.mesh.RemoveGroup(group)
1555 ## Removes a group with its contents
1556 # @ingroup l2_grps_delete
1557 def RemoveGroupWithContents(self, group):
1558 self.mesh.RemoveGroupWithContents(group)
1560 ## Gets the list of groups existing in the mesh
1561 # @return a sequence of SMESH_GroupBase
1562 # @ingroup l2_grps_create
1563 def GetGroups(self):
1564 return self.mesh.GetGroups()
1566 ## Gets the number of groups existing in the mesh
1567 # @return the quantity of groups as an integer value
1568 # @ingroup l2_grps_create
1570 return self.mesh.NbGroups()
1572 ## Gets the list of names of groups existing in the mesh
1573 # @return list of strings
1574 # @ingroup l2_grps_create
1575 def GetGroupNames(self):
1576 groups = self.GetGroups()
1578 for group in groups:
1579 names.append(group.GetName())
1582 ## Produces a union of two groups
1583 # A new group is created. All mesh elements that are
1584 # present in the initial groups are added to the new one
1585 # @return an instance of SMESH_Group
1586 # @ingroup l2_grps_operon
1587 def UnionGroups(self, group1, group2, name):
1588 return self.mesh.UnionGroups(group1, group2, name)
1590 ## Produces a union list of groups
1591 # New group is created. All mesh elements that are present in
1592 # initial groups are added to the new one
1593 # @return an instance of SMESH_Group
1594 # @ingroup l2_grps_operon
1595 def UnionListOfGroups(self, groups, name):
1596 return self.mesh.UnionListOfGroups(groups, name)
1598 ## Prodices an intersection of two groups
1599 # A new group is created. All mesh elements that are common
1600 # for the two initial groups are added to the new one.
1601 # @return an instance of SMESH_Group
1602 # @ingroup l2_grps_operon
1603 def IntersectGroups(self, group1, group2, name):
1604 return self.mesh.IntersectGroups(group1, group2, name)
1606 ## Produces an intersection of groups
1607 # New group is created. All mesh elements that are present in all
1608 # initial groups simultaneously are added to the new one
1609 # @return an instance of SMESH_Group
1610 # @ingroup l2_grps_operon
1611 def IntersectListOfGroups(self, groups, name):
1612 return self.mesh.IntersectListOfGroups(groups, name)
1614 ## Produces a cut of two groups
1615 # A new group is created. All mesh elements that are present in
1616 # the main group but are not present in the tool group are added to the new one
1617 # @return an instance of SMESH_Group
1618 # @ingroup l2_grps_operon
1619 def CutGroups(self, main_group, tool_group, name):
1620 return self.mesh.CutGroups(main_group, tool_group, name)
1622 ## Produces a cut of groups
1623 # A new group is created. All mesh elements that are present in main groups
1624 # but do not present in tool groups are added to the new one
1625 # @return an instance of SMESH_Group
1626 # @ingroup l2_grps_operon
1627 def CutListOfGroups(self, main_groups, tool_groups, name):
1628 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1630 ## Produces a group of elements with specified element type using list of existing groups
1631 # A new group is created. System
1632 # 1) extract all nodes on which groups elements are built
1633 # 2) combine all elements of specified dimension laying on these nodes
1634 # @return an instance of SMESH_Group
1635 # @ingroup l2_grps_operon
1636 def CreateDimGroup(self, groups, elem_type, name):
1637 return self.mesh.CreateDimGroup(groups, elem_type, name)
1640 ## Convert group on geom into standalone group
1641 # @ingroup l2_grps_delete
1642 def ConvertToStandalone(self, group):
1643 return self.mesh.ConvertToStandalone(group)
1645 # Get some info about mesh:
1646 # ------------------------
1648 ## Returns the log of nodes and elements added or removed
1649 # since the previous clear of the log.
1650 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1651 # @return list of log_block structures:
1656 # @ingroup l1_auxiliary
1657 def GetLog(self, clearAfterGet):
1658 return self.mesh.GetLog(clearAfterGet)
1660 ## Clears the log of nodes and elements added or removed since the previous
1661 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1662 # @ingroup l1_auxiliary
1664 self.mesh.ClearLog()
1666 ## Toggles auto color mode on the object.
1667 # @param theAutoColor the flag which toggles auto color mode.
1668 # @ingroup l1_auxiliary
1669 def SetAutoColor(self, theAutoColor):
1670 self.mesh.SetAutoColor(theAutoColor)
1672 ## Gets flag of object auto color mode.
1673 # @return True or False
1674 # @ingroup l1_auxiliary
1675 def GetAutoColor(self):
1676 return self.mesh.GetAutoColor()
1678 ## Gets the internal ID
1679 # @return integer value, which is the internal Id of the mesh
1680 # @ingroup l1_auxiliary
1682 return self.mesh.GetId()
1685 # @return integer value, which is the study Id of the mesh
1686 # @ingroup l1_auxiliary
1687 def GetStudyId(self):
1688 return self.mesh.GetStudyId()
1690 ## Checks the group names for duplications.
1691 # Consider the maximum group name length stored in MED file.
1692 # @return True or False
1693 # @ingroup l1_auxiliary
1694 def HasDuplicatedGroupNamesMED(self):
1695 return self.mesh.HasDuplicatedGroupNamesMED()
1697 ## Obtains the mesh editor tool
1698 # @return an instance of SMESH_MeshEditor
1699 # @ingroup l1_modifying
1700 def GetMeshEditor(self):
1701 return self.mesh.GetMeshEditor()
1704 # @return an instance of SALOME_MED::MESH
1705 # @ingroup l1_auxiliary
1706 def GetMEDMesh(self):
1707 return self.mesh.GetMEDMesh()
1710 # Get informations about mesh contents:
1711 # ------------------------------------
1713 ## Gets the mesh stattistic
1714 # @return dictionary type element - count of elements
1715 # @ingroup l1_meshinfo
1716 def GetMeshInfo(self, obj = None):
1717 if not obj: obj = self.mesh
1718 return self.smeshpyD.GetMeshInfo(obj)
1720 ## Returns the number of nodes in the mesh
1721 # @return an integer value
1722 # @ingroup l1_meshinfo
1724 return self.mesh.NbNodes()
1726 ## Returns the number of elements in the mesh
1727 # @return an integer value
1728 # @ingroup l1_meshinfo
1729 def NbElements(self):
1730 return self.mesh.NbElements()
1732 ## Returns the number of 0d elements in the mesh
1733 # @return an integer value
1734 # @ingroup l1_meshinfo
1735 def Nb0DElements(self):
1736 return self.mesh.Nb0DElements()
1738 ## Returns the number of edges in the mesh
1739 # @return an integer value
1740 # @ingroup l1_meshinfo
1742 return self.mesh.NbEdges()
1744 ## Returns the number of edges with the given order in the mesh
1745 # @param elementOrder the order of elements:
1746 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1747 # @return an integer value
1748 # @ingroup l1_meshinfo
1749 def NbEdgesOfOrder(self, elementOrder):
1750 return self.mesh.NbEdgesOfOrder(elementOrder)
1752 ## Returns the number of faces in the mesh
1753 # @return an integer value
1754 # @ingroup l1_meshinfo
1756 return self.mesh.NbFaces()
1758 ## Returns the number of faces with the given order in the mesh
1759 # @param elementOrder the order of elements:
1760 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1761 # @return an integer value
1762 # @ingroup l1_meshinfo
1763 def NbFacesOfOrder(self, elementOrder):
1764 return self.mesh.NbFacesOfOrder(elementOrder)
1766 ## Returns the number of triangles in the mesh
1767 # @return an integer value
1768 # @ingroup l1_meshinfo
1769 def NbTriangles(self):
1770 return self.mesh.NbTriangles()
1772 ## Returns the number of triangles with the given order in the mesh
1773 # @param elementOrder is the order of elements:
1774 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1775 # @return an integer value
1776 # @ingroup l1_meshinfo
1777 def NbTrianglesOfOrder(self, elementOrder):
1778 return self.mesh.NbTrianglesOfOrder(elementOrder)
1780 ## Returns the number of quadrangles in the mesh
1781 # @return an integer value
1782 # @ingroup l1_meshinfo
1783 def NbQuadrangles(self):
1784 return self.mesh.NbQuadrangles()
1786 ## Returns the number of quadrangles with the given order in the mesh
1787 # @param elementOrder the order of elements:
1788 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1789 # @return an integer value
1790 # @ingroup l1_meshinfo
1791 def NbQuadranglesOfOrder(self, elementOrder):
1792 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1794 ## Returns the number of polygons in the mesh
1795 # @return an integer value
1796 # @ingroup l1_meshinfo
1797 def NbPolygons(self):
1798 return self.mesh.NbPolygons()
1800 ## Returns the number of volumes in the mesh
1801 # @return an integer value
1802 # @ingroup l1_meshinfo
1803 def NbVolumes(self):
1804 return self.mesh.NbVolumes()
1806 ## Returns the number of volumes with the given order in the mesh
1807 # @param elementOrder the order of elements:
1808 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1809 # @return an integer value
1810 # @ingroup l1_meshinfo
1811 def NbVolumesOfOrder(self, elementOrder):
1812 return self.mesh.NbVolumesOfOrder(elementOrder)
1814 ## Returns the number of tetrahedrons in the mesh
1815 # @return an integer value
1816 # @ingroup l1_meshinfo
1818 return self.mesh.NbTetras()
1820 ## Returns the number of tetrahedrons with the given order in the mesh
1821 # @param elementOrder the order of elements:
1822 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1823 # @return an integer value
1824 # @ingroup l1_meshinfo
1825 def NbTetrasOfOrder(self, elementOrder):
1826 return self.mesh.NbTetrasOfOrder(elementOrder)
1828 ## Returns the number of hexahedrons in the mesh
1829 # @return an integer value
1830 # @ingroup l1_meshinfo
1832 return self.mesh.NbHexas()
1834 ## Returns the number of hexahedrons with the given order in the mesh
1835 # @param elementOrder the order of elements:
1836 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1837 # @return an integer value
1838 # @ingroup l1_meshinfo
1839 def NbHexasOfOrder(self, elementOrder):
1840 return self.mesh.NbHexasOfOrder(elementOrder)
1842 ## Returns the number of pyramids in the mesh
1843 # @return an integer value
1844 # @ingroup l1_meshinfo
1845 def NbPyramids(self):
1846 return self.mesh.NbPyramids()
1848 ## Returns the number of pyramids with the given order in the mesh
1849 # @param elementOrder the order of elements:
1850 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1851 # @return an integer value
1852 # @ingroup l1_meshinfo
1853 def NbPyramidsOfOrder(self, elementOrder):
1854 return self.mesh.NbPyramidsOfOrder(elementOrder)
1856 ## Returns the number of prisms in the mesh
1857 # @return an integer value
1858 # @ingroup l1_meshinfo
1860 return self.mesh.NbPrisms()
1862 ## Returns the number of prisms with the given order in the mesh
1863 # @param elementOrder the order of elements:
1864 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1865 # @return an integer value
1866 # @ingroup l1_meshinfo
1867 def NbPrismsOfOrder(self, elementOrder):
1868 return self.mesh.NbPrismsOfOrder(elementOrder)
1870 ## Returns the number of polyhedrons in the mesh
1871 # @return an integer value
1872 # @ingroup l1_meshinfo
1873 def NbPolyhedrons(self):
1874 return self.mesh.NbPolyhedrons()
1876 ## Returns the number of submeshes in the mesh
1877 # @return an integer value
1878 # @ingroup l1_meshinfo
1879 def NbSubMesh(self):
1880 return self.mesh.NbSubMesh()
1882 ## Returns the list of mesh elements IDs
1883 # @return the list of integer values
1884 # @ingroup l1_meshinfo
1885 def GetElementsId(self):
1886 return self.mesh.GetElementsId()
1888 ## Returns the list of IDs of mesh elements with the given type
1889 # @param elementType the required type of elements
1890 # @return list of integer values
1891 # @ingroup l1_meshinfo
1892 def GetElementsByType(self, elementType):
1893 return self.mesh.GetElementsByType(elementType)
1895 ## Returns the list of mesh nodes IDs
1896 # @return the list of integer values
1897 # @ingroup l1_meshinfo
1898 def GetNodesId(self):
1899 return self.mesh.GetNodesId()
1901 # Get the information about mesh elements:
1902 # ------------------------------------
1904 ## Returns the type of mesh element
1905 # @return the value from SMESH::ElementType enumeration
1906 # @ingroup l1_meshinfo
1907 def GetElementType(self, id, iselem):
1908 return self.mesh.GetElementType(id, iselem)
1910 ## Returns the list of submesh elements IDs
1911 # @param Shape a geom object(subshape) IOR
1912 # Shape must be the subshape of a ShapeToMesh()
1913 # @return the list of integer values
1914 # @ingroup l1_meshinfo
1915 def GetSubMeshElementsId(self, Shape):
1916 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1917 ShapeID = Shape.GetSubShapeIndices()[0]
1920 return self.mesh.GetSubMeshElementsId(ShapeID)
1922 ## Returns the list of submesh nodes IDs
1923 # @param Shape a geom object(subshape) IOR
1924 # Shape must be the subshape of a ShapeToMesh()
1925 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1926 # @return the list of integer values
1927 # @ingroup l1_meshinfo
1928 def GetSubMeshNodesId(self, Shape, all):
1929 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1930 ShapeID = Shape.GetSubShapeIndices()[0]
1933 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1935 ## Returns type of elements on given shape
1936 # @param Shape a geom object(subshape) IOR
1937 # Shape must be a subshape of a ShapeToMesh()
1938 # @return element type
1939 # @ingroup l1_meshinfo
1940 def GetSubMeshElementType(self, Shape):
1941 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1942 ShapeID = Shape.GetSubShapeIndices()[0]
1945 return self.mesh.GetSubMeshElementType(ShapeID)
1947 ## Gets the mesh description
1948 # @return string value
1949 # @ingroup l1_meshinfo
1951 return self.mesh.Dump()
1954 # Get the information about nodes and elements of a mesh by its IDs:
1955 # -----------------------------------------------------------
1957 ## Gets XYZ coordinates of a node
1958 # \n If there is no nodes for the given ID - returns an empty list
1959 # @return a list of double precision values
1960 # @ingroup l1_meshinfo
1961 def GetNodeXYZ(self, id):
1962 return self.mesh.GetNodeXYZ(id)
1964 ## Returns list of IDs of inverse elements for the given node
1965 # \n If there is no node for the given ID - returns an empty list
1966 # @return a list of integer values
1967 # @ingroup l1_meshinfo
1968 def GetNodeInverseElements(self, id):
1969 return self.mesh.GetNodeInverseElements(id)
1971 ## @brief Returns the position of a node on the shape
1972 # @return SMESH::NodePosition
1973 # @ingroup l1_meshinfo
1974 def GetNodePosition(self,NodeID):
1975 return self.mesh.GetNodePosition(NodeID)
1977 ## If the given element is a node, returns the ID of shape
1978 # \n If there is no node for the given ID - returns -1
1979 # @return an integer value
1980 # @ingroup l1_meshinfo
1981 def GetShapeID(self, id):
1982 return self.mesh.GetShapeID(id)
1984 ## Returns the ID of the result shape after
1985 # FindShape() from SMESH_MeshEditor for the given element
1986 # \n If there is no element for the given ID - returns -1
1987 # @return an integer value
1988 # @ingroup l1_meshinfo
1989 def GetShapeIDForElem(self,id):
1990 return self.mesh.GetShapeIDForElem(id)
1992 ## Returns the number of nodes for the given element
1993 # \n If there is no element for the given ID - returns -1
1994 # @return an integer value
1995 # @ingroup l1_meshinfo
1996 def GetElemNbNodes(self, id):
1997 return self.mesh.GetElemNbNodes(id)
1999 ## Returns the node ID the given index for the given element
2000 # \n If there is no element for the given ID - returns -1
2001 # \n If there is no node for the given index - returns -2
2002 # @return an integer value
2003 # @ingroup l1_meshinfo
2004 def GetElemNode(self, id, index):
2005 return self.mesh.GetElemNode(id, index)
2007 ## Returns the IDs of nodes of the given element
2008 # @return a list of integer values
2009 # @ingroup l1_meshinfo
2010 def GetElemNodes(self, id):
2011 return self.mesh.GetElemNodes(id)
2013 ## Returns true if the given node is the medium node in the given quadratic element
2014 # @ingroup l1_meshinfo
2015 def IsMediumNode(self, elementID, nodeID):
2016 return self.mesh.IsMediumNode(elementID, nodeID)
2018 ## Returns true if the given node is the medium node in one of quadratic elements
2019 # @ingroup l1_meshinfo
2020 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2021 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2023 ## Returns the number of edges for the given element
2024 # @ingroup l1_meshinfo
2025 def ElemNbEdges(self, id):
2026 return self.mesh.ElemNbEdges(id)
2028 ## Returns the number of faces for the given element
2029 # @ingroup l1_meshinfo
2030 def ElemNbFaces(self, id):
2031 return self.mesh.ElemNbFaces(id)
2033 ## Returns true if the given element is a polygon
2034 # @ingroup l1_meshinfo
2035 def IsPoly(self, id):
2036 return self.mesh.IsPoly(id)
2038 ## Returns true if the given element is quadratic
2039 # @ingroup l1_meshinfo
2040 def IsQuadratic(self, id):
2041 return self.mesh.IsQuadratic(id)
2043 ## Returns XYZ coordinates of the barycenter of the given element
2044 # \n If there is no element for the given ID - returns an empty list
2045 # @return a list of three double values
2046 # @ingroup l1_meshinfo
2047 def BaryCenter(self, id):
2048 return self.mesh.BaryCenter(id)
2051 # Mesh edition (SMESH_MeshEditor functionality):
2052 # ---------------------------------------------
2054 ## Removes the elements from the mesh by ids
2055 # @param IDsOfElements is a list of ids of elements to remove
2056 # @return True or False
2057 # @ingroup l2_modif_del
2058 def RemoveElements(self, IDsOfElements):
2059 return self.editor.RemoveElements(IDsOfElements)
2061 ## Removes nodes from mesh by ids
2062 # @param IDsOfNodes is a list of ids of nodes to remove
2063 # @return True or False
2064 # @ingroup l2_modif_del
2065 def RemoveNodes(self, IDsOfNodes):
2066 return self.editor.RemoveNodes(IDsOfNodes)
2068 ## Add a node to the mesh by coordinates
2069 # @return Id of the new node
2070 # @ingroup l2_modif_add
2071 def AddNode(self, x, y, z):
2072 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2073 geompyDC.SetParameters(self.mesh, Parameters)
2074 return self.editor.AddNode( x, y, z)
2076 ## Creates a 0D element on a node with given number.
2077 # @param IDOfNode the ID of node for creation of the element.
2078 # @return the Id of the new 0D element
2079 # @ingroup l2_modif_add
2080 def Add0DElement(self, IDOfNode):
2081 return self.editor.Add0DElement(IDOfNode)
2083 ## Creates a linear or quadratic edge (this is determined
2084 # by the number of given nodes).
2085 # @param IDsOfNodes the list of node IDs for creation of the element.
2086 # The order of nodes in this list should correspond to the description
2087 # of MED. \n This description is located by the following link:
2088 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2089 # @return the Id of the new edge
2090 # @ingroup l2_modif_add
2091 def AddEdge(self, IDsOfNodes):
2092 return self.editor.AddEdge(IDsOfNodes)
2094 ## Creates a linear or quadratic face (this is determined
2095 # by the number of given nodes).
2096 # @param IDsOfNodes the list of node IDs for creation of the element.
2097 # The order of nodes in this list should correspond to the description
2098 # of MED. \n This description is located by the following link:
2099 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2100 # @return the Id of the new face
2101 # @ingroup l2_modif_add
2102 def AddFace(self, IDsOfNodes):
2103 return self.editor.AddFace(IDsOfNodes)
2105 ## Adds a polygonal face to the mesh by the list of node IDs
2106 # @param IdsOfNodes the list of node IDs for creation of the element.
2107 # @return the Id of the new face
2108 # @ingroup l2_modif_add
2109 def AddPolygonalFace(self, IdsOfNodes):
2110 return self.editor.AddPolygonalFace(IdsOfNodes)
2112 ## Creates both simple and quadratic volume (this is determined
2113 # by the number of given nodes).
2114 # @param IDsOfNodes the list of node IDs for creation of the element.
2115 # The order of nodes in this list should correspond to the description
2116 # of MED. \n This description is located by the following link:
2117 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2118 # @return the Id of the new volumic element
2119 # @ingroup l2_modif_add
2120 def AddVolume(self, IDsOfNodes):
2121 return self.editor.AddVolume(IDsOfNodes)
2123 ## Creates a volume of many faces, giving nodes for each face.
2124 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2125 # @param Quantities the list of integer values, Quantities[i]
2126 # gives the quantity of nodes in face number i.
2127 # @return the Id of the new volumic element
2128 # @ingroup l2_modif_add
2129 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2130 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2132 ## Creates a volume of many faces, giving the IDs of the existing faces.
2133 # @param IdsOfFaces the list of face IDs for volume creation.
2135 # Note: The created volume will refer only to the nodes
2136 # of the given faces, not to the faces themselves.
2137 # @return the Id of the new volumic element
2138 # @ingroup l2_modif_add
2139 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2140 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2143 ## @brief Binds a node to a vertex
2144 # @param NodeID a node ID
2145 # @param Vertex a vertex or vertex ID
2146 # @return True if succeed else raises an exception
2147 # @ingroup l2_modif_add
2148 def SetNodeOnVertex(self, NodeID, Vertex):
2149 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2150 VertexID = Vertex.GetSubShapeIndices()[0]
2154 self.editor.SetNodeOnVertex(NodeID, VertexID)
2155 except SALOME.SALOME_Exception, inst:
2156 raise ValueError, inst.details.text
2160 ## @brief Stores the node position on an edge
2161 # @param NodeID a node ID
2162 # @param Edge an edge or edge ID
2163 # @param paramOnEdge a parameter on the edge where the node is located
2164 # @return True if succeed else raises an exception
2165 # @ingroup l2_modif_add
2166 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2167 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2168 EdgeID = Edge.GetSubShapeIndices()[0]
2172 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2173 except SALOME.SALOME_Exception, inst:
2174 raise ValueError, inst.details.text
2177 ## @brief Stores node position on a face
2178 # @param NodeID a node ID
2179 # @param Face a face or face ID
2180 # @param u U parameter on the face where the node is located
2181 # @param v V parameter on the face where the node is located
2182 # @return True if succeed else raises an exception
2183 # @ingroup l2_modif_add
2184 def SetNodeOnFace(self, NodeID, Face, u, v):
2185 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2186 FaceID = Face.GetSubShapeIndices()[0]
2190 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2191 except SALOME.SALOME_Exception, inst:
2192 raise ValueError, inst.details.text
2195 ## @brief Binds a node to a solid
2196 # @param NodeID a node ID
2197 # @param Solid a solid or solid ID
2198 # @return True if succeed else raises an exception
2199 # @ingroup l2_modif_add
2200 def SetNodeInVolume(self, NodeID, Solid):
2201 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2202 SolidID = Solid.GetSubShapeIndices()[0]
2206 self.editor.SetNodeInVolume(NodeID, SolidID)
2207 except SALOME.SALOME_Exception, inst:
2208 raise ValueError, inst.details.text
2211 ## @brief Bind an element to a shape
2212 # @param ElementID an element ID
2213 # @param Shape a shape or shape ID
2214 # @return True if succeed else raises an exception
2215 # @ingroup l2_modif_add
2216 def SetMeshElementOnShape(self, ElementID, Shape):
2217 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2218 ShapeID = Shape.GetSubShapeIndices()[0]
2222 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2223 except SALOME.SALOME_Exception, inst:
2224 raise ValueError, inst.details.text
2228 ## Moves the node with the given id
2229 # @param NodeID the id of the node
2230 # @param x a new X coordinate
2231 # @param y a new Y coordinate
2232 # @param z a new Z coordinate
2233 # @return True if succeed else False
2234 # @ingroup l2_modif_movenode
2235 def MoveNode(self, NodeID, x, y, z):
2236 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2237 geompyDC.SetParameters(self.mesh, Parameters)
2238 return self.editor.MoveNode(NodeID, x, y, z)
2240 ## Finds the node closest to a point and moves it to a point location
2241 # @param x the X coordinate of a point
2242 # @param y the Y coordinate of a point
2243 # @param z the Z coordinate of a point
2244 # @param NodeID if specified (>0), the node with this ID is moved,
2245 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2246 # @return the ID of a node
2247 # @ingroup l2_modif_throughp
2248 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2249 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2250 geompyDC.SetParameters(self.mesh, Parameters)
2251 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2253 ## Finds the node closest to a point
2254 # @param x the X coordinate of a point
2255 # @param y the Y coordinate of a point
2256 # @param z the Z coordinate of a point
2257 # @return the ID of a node
2258 # @ingroup l2_modif_throughp
2259 def FindNodeClosestTo(self, x, y, z):
2260 #preview = self.mesh.GetMeshEditPreviewer()
2261 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2262 return self.editor.FindNodeClosestTo(x, y, z)
2264 ## Finds the elements where a point lays IN or ON
2265 # @param x the X coordinate of a point
2266 # @param y the Y coordinate of a point
2267 # @param z the Z coordinate of a point
2268 # @param elementType type of elements to find (SMESH.ALL type
2269 # means elements of any type excluding nodes and 0D elements)
2270 # @return list of IDs of found elements
2271 # @ingroup l2_modif_throughp
2272 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2273 return self.editor.FindElementsByPoint(x, y, z, elementType)
2276 ## Finds the node closest to a point and moves it to a point location
2277 # @param x the X coordinate of a point
2278 # @param y the Y coordinate of a point
2279 # @param z the Z coordinate of a point
2280 # @return the ID of a moved node
2281 # @ingroup l2_modif_throughp
2282 def MeshToPassThroughAPoint(self, x, y, z):
2283 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2285 ## Replaces two neighbour triangles sharing Node1-Node2 link
2286 # with the triangles built on the same 4 nodes but having other common link.
2287 # @param NodeID1 the ID of the first node
2288 # @param NodeID2 the ID of the second node
2289 # @return false if proper faces were not found
2290 # @ingroup l2_modif_invdiag
2291 def InverseDiag(self, NodeID1, NodeID2):
2292 return self.editor.InverseDiag(NodeID1, NodeID2)
2294 ## Replaces two neighbour triangles sharing Node1-Node2 link
2295 # with a quadrangle built on the same 4 nodes.
2296 # @param NodeID1 the ID of the first node
2297 # @param NodeID2 the ID of the second node
2298 # @return false if proper faces were not found
2299 # @ingroup l2_modif_unitetri
2300 def DeleteDiag(self, NodeID1, NodeID2):
2301 return self.editor.DeleteDiag(NodeID1, NodeID2)
2303 ## Reorients elements by ids
2304 # @param IDsOfElements if undefined reorients all mesh elements
2305 # @return True if succeed else False
2306 # @ingroup l2_modif_changori
2307 def Reorient(self, IDsOfElements=None):
2308 if IDsOfElements == None:
2309 IDsOfElements = self.GetElementsId()
2310 return self.editor.Reorient(IDsOfElements)
2312 ## Reorients all elements of the object
2313 # @param theObject mesh, submesh or group
2314 # @return True if succeed else False
2315 # @ingroup l2_modif_changori
2316 def ReorientObject(self, theObject):
2317 if ( isinstance( theObject, Mesh )):
2318 theObject = theObject.GetMesh()
2319 return self.editor.ReorientObject(theObject)
2321 ## Fuses the neighbouring triangles into quadrangles.
2322 # @param IDsOfElements The triangles to be fused,
2323 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2324 # @param MaxAngle is the maximum angle between element normals at which the fusion
2325 # is still performed; theMaxAngle is mesured in radians.
2326 # Also it could be a name of variable which defines angle in degrees.
2327 # @return TRUE in case of success, FALSE otherwise.
2328 # @ingroup l2_modif_unitetri
2329 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2331 if isinstance(MaxAngle,str):
2333 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2335 MaxAngle = DegreesToRadians(MaxAngle)
2336 if IDsOfElements == []:
2337 IDsOfElements = self.GetElementsId()
2338 geompyDC.SetParameters(self.mesh, Parameters)
2340 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2341 Functor = theCriterion
2343 Functor = self.smeshpyD.GetFunctor(theCriterion)
2344 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2346 ## Fuses the neighbouring triangles of the object into quadrangles
2347 # @param theObject is mesh, submesh or group
2348 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2349 # @param MaxAngle a max angle between element normals at which the fusion
2350 # is still performed; theMaxAngle is mesured in radians.
2351 # @return TRUE in case of success, FALSE otherwise.
2352 # @ingroup l2_modif_unitetri
2353 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2354 if ( isinstance( theObject, Mesh )):
2355 theObject = theObject.GetMesh()
2356 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2358 ## Splits quadrangles into triangles.
2359 # @param IDsOfElements the faces to be splitted.
2360 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2361 # @return TRUE in case of success, FALSE otherwise.
2362 # @ingroup l2_modif_cutquadr
2363 def QuadToTri (self, IDsOfElements, theCriterion):
2364 if IDsOfElements == []:
2365 IDsOfElements = self.GetElementsId()
2366 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2368 ## Splits quadrangles into triangles.
2369 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2370 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2371 # @return TRUE in case of success, FALSE otherwise.
2372 # @ingroup l2_modif_cutquadr
2373 def QuadToTriObject (self, theObject, theCriterion):
2374 if ( isinstance( theObject, Mesh )):
2375 theObject = theObject.GetMesh()
2376 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2378 ## Splits quadrangles into triangles.
2379 # @param IDsOfElements the faces to be splitted
2380 # @param Diag13 is used to choose a diagonal for splitting.
2381 # @return TRUE in case of success, FALSE otherwise.
2382 # @ingroup l2_modif_cutquadr
2383 def SplitQuad (self, IDsOfElements, Diag13):
2384 if IDsOfElements == []:
2385 IDsOfElements = self.GetElementsId()
2386 return self.editor.SplitQuad(IDsOfElements, Diag13)
2388 ## Splits quadrangles into triangles.
2389 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2390 # @param Diag13 is used to choose a diagonal for splitting.
2391 # @return TRUE in case of success, FALSE otherwise.
2392 # @ingroup l2_modif_cutquadr
2393 def SplitQuadObject (self, theObject, Diag13):
2394 if ( isinstance( theObject, Mesh )):
2395 theObject = theObject.GetMesh()
2396 return self.editor.SplitQuadObject(theObject, Diag13)
2398 ## Finds a better splitting of the given quadrangle.
2399 # @param IDOfQuad the ID of the quadrangle to be splitted.
2400 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2401 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2402 # diagonal is better, 0 if error occurs.
2403 # @ingroup l2_modif_cutquadr
2404 def BestSplit (self, IDOfQuad, theCriterion):
2405 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2407 ## Splits quadrangle faces near triangular facets of volumes
2409 # @ingroup l1_auxiliary
2410 def SplitQuadsNearTriangularFacets(self):
2411 faces_array = self.GetElementsByType(SMESH.FACE)
2412 for face_id in faces_array:
2413 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2414 quad_nodes = self.mesh.GetElemNodes(face_id)
2415 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2416 isVolumeFound = False
2417 for node1_elem in node1_elems:
2418 if not isVolumeFound:
2419 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2420 nb_nodes = self.GetElemNbNodes(node1_elem)
2421 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2422 volume_elem = node1_elem
2423 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2424 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2425 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2426 isVolumeFound = True
2427 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2428 self.SplitQuad([face_id], False) # diagonal 2-4
2429 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2430 isVolumeFound = True
2431 self.SplitQuad([face_id], True) # diagonal 1-3
2432 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2433 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2434 isVolumeFound = True
2435 self.SplitQuad([face_id], True) # diagonal 1-3
2437 ## @brief Splits hexahedrons into tetrahedrons.
2439 # This operation uses pattern mapping functionality for splitting.
2440 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2441 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2442 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2443 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2444 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2445 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2446 # @return TRUE in case of success, FALSE otherwise.
2447 # @ingroup l1_auxiliary
2448 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2449 # Pattern: 5.---------.6
2454 # (0,0,1) 4.---------.7 * |
2461 # (0,0,0) 0.---------.3
2462 pattern_tetra = "!!! Nb of points: \n 8 \n\
2472 !!! Indices of points of 6 tetras: \n\
2480 pattern = self.smeshpyD.GetPattern()
2481 isDone = pattern.LoadFromFile(pattern_tetra)
2483 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2486 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2487 isDone = pattern.MakeMesh(self.mesh, False, False)
2488 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2490 # split quafrangle faces near triangular facets of volumes
2491 self.SplitQuadsNearTriangularFacets()
2495 ## @brief Split hexahedrons into prisms.
2497 # Uses the pattern mapping functionality for splitting.
2498 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2499 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2500 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2501 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2502 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2503 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2504 # @return TRUE in case of success, FALSE otherwise.
2505 # @ingroup l1_auxiliary
2506 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2507 # Pattern: 5.---------.6
2512 # (0,0,1) 4.---------.7 |
2519 # (0,0,0) 0.---------.3
2520 pattern_prism = "!!! Nb of points: \n 8 \n\
2530 !!! Indices of points of 2 prisms: \n\
2534 pattern = self.smeshpyD.GetPattern()
2535 isDone = pattern.LoadFromFile(pattern_prism)
2537 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2540 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2541 isDone = pattern.MakeMesh(self.mesh, False, False)
2542 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2544 # Splits quafrangle faces near triangular facets of volumes
2545 self.SplitQuadsNearTriangularFacets()
2549 ## Smoothes elements
2550 # @param IDsOfElements the list if ids of elements to smooth
2551 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2552 # Note that nodes built on edges and boundary nodes are always fixed.
2553 # @param MaxNbOfIterations the maximum number of iterations
2554 # @param MaxAspectRatio varies in range [1.0, inf]
2555 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2556 # @return TRUE in case of success, FALSE otherwise.
2557 # @ingroup l2_modif_smooth
2558 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2559 MaxNbOfIterations, MaxAspectRatio, Method):
2560 if IDsOfElements == []:
2561 IDsOfElements = self.GetElementsId()
2562 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2563 geompyDC.SetParameters(self.mesh, Parameters)
2564 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2565 MaxNbOfIterations, MaxAspectRatio, Method)
2567 ## Smoothes elements which belong to the given object
2568 # @param theObject the object to smooth
2569 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2570 # Note that nodes built on edges and boundary nodes are always fixed.
2571 # @param MaxNbOfIterations the maximum number of iterations
2572 # @param MaxAspectRatio varies in range [1.0, inf]
2573 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2574 # @return TRUE in case of success, FALSE otherwise.
2575 # @ingroup l2_modif_smooth
2576 def SmoothObject(self, theObject, IDsOfFixedNodes,
2577 MaxNbOfIterations, MaxAspectRatio, Method):
2578 if ( isinstance( theObject, Mesh )):
2579 theObject = theObject.GetMesh()
2580 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2581 MaxNbOfIterations, MaxAspectRatio, Method)
2583 ## Parametrically smoothes the given elements
2584 # @param IDsOfElements the list if ids of elements to smooth
2585 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2586 # Note that nodes built on edges and boundary nodes are always fixed.
2587 # @param MaxNbOfIterations the maximum number of iterations
2588 # @param MaxAspectRatio varies in range [1.0, inf]
2589 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2590 # @return TRUE in case of success, FALSE otherwise.
2591 # @ingroup l2_modif_smooth
2592 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2593 MaxNbOfIterations, MaxAspectRatio, Method):
2594 if IDsOfElements == []:
2595 IDsOfElements = self.GetElementsId()
2596 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2597 geompyDC.SetParameters(self.mesh, Parameters)
2598 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2599 MaxNbOfIterations, MaxAspectRatio, Method)
2601 ## Parametrically smoothes the elements which belong to the given object
2602 # @param theObject the object to smooth
2603 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2604 # Note that nodes built on edges and boundary nodes are always fixed.
2605 # @param MaxNbOfIterations the maximum number of iterations
2606 # @param MaxAspectRatio varies in range [1.0, inf]
2607 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2608 # @return TRUE in case of success, FALSE otherwise.
2609 # @ingroup l2_modif_smooth
2610 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2611 MaxNbOfIterations, MaxAspectRatio, Method):
2612 if ( isinstance( theObject, Mesh )):
2613 theObject = theObject.GetMesh()
2614 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2615 MaxNbOfIterations, MaxAspectRatio, Method)
2617 ## Converts the mesh to quadratic, deletes old elements, replacing
2618 # them with quadratic with the same id.
2619 # @ingroup l2_modif_tofromqu
2620 def ConvertToQuadratic(self, theForce3d):
2621 self.editor.ConvertToQuadratic(theForce3d)
2623 ## Converts the mesh from quadratic to ordinary,
2624 # deletes old quadratic elements, \n replacing
2625 # them with ordinary mesh elements with the same id.
2626 # @return TRUE in case of success, FALSE otherwise.
2627 # @ingroup l2_modif_tofromqu
2628 def ConvertFromQuadratic(self):
2629 return self.editor.ConvertFromQuadratic()
2631 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2632 # @return TRUE if operation has been completed successfully, FALSE otherwise
2633 # @ingroup l2_modif_edit
2634 def Make2DMeshFrom3D(self):
2635 return self.editor. Make2DMeshFrom3D()
2637 ## Renumber mesh nodes
2638 # @ingroup l2_modif_renumber
2639 def RenumberNodes(self):
2640 self.editor.RenumberNodes()
2642 ## Renumber mesh elements
2643 # @ingroup l2_modif_renumber
2644 def RenumberElements(self):
2645 self.editor.RenumberElements()
2647 ## Generates new elements by rotation of the elements around the axis
2648 # @param IDsOfElements the list of ids of elements to sweep
2649 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2650 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2651 # @param NbOfSteps the number of steps
2652 # @param Tolerance tolerance
2653 # @param MakeGroups forces the generation of new groups from existing ones
2654 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2655 # of all steps, else - size of each step
2656 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2657 # @ingroup l2_modif_extrurev
2658 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2659 MakeGroups=False, TotalAngle=False):
2661 if isinstance(AngleInRadians,str):
2663 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2665 AngleInRadians = DegreesToRadians(AngleInRadians)
2666 if IDsOfElements == []:
2667 IDsOfElements = self.GetElementsId()
2668 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2669 Axis = self.smeshpyD.GetAxisStruct(Axis)
2670 Axis,AxisParameters = ParseAxisStruct(Axis)
2671 if TotalAngle and NbOfSteps:
2672 AngleInRadians /= NbOfSteps
2673 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2674 Parameters = AxisParameters + AngleParameters + Parameters
2675 geompyDC.SetParameters(self.mesh, Parameters)
2677 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2678 AngleInRadians, NbOfSteps, Tolerance)
2679 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2682 ## Generates new elements by rotation of the elements of object around the axis
2683 # @param theObject object which elements should be sweeped
2684 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2685 # @param AngleInRadians the angle of Rotation
2686 # @param NbOfSteps number of steps
2687 # @param Tolerance tolerance
2688 # @param MakeGroups forces the generation of new groups from existing ones
2689 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2690 # of all steps, else - size of each step
2691 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2692 # @ingroup l2_modif_extrurev
2693 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2694 MakeGroups=False, TotalAngle=False):
2696 if isinstance(AngleInRadians,str):
2698 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2700 AngleInRadians = DegreesToRadians(AngleInRadians)
2701 if ( isinstance( theObject, Mesh )):
2702 theObject = theObject.GetMesh()
2703 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2704 Axis = self.smeshpyD.GetAxisStruct(Axis)
2705 Axis,AxisParameters = ParseAxisStruct(Axis)
2706 if TotalAngle and NbOfSteps:
2707 AngleInRadians /= NbOfSteps
2708 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2709 Parameters = AxisParameters + AngleParameters + Parameters
2710 geompyDC.SetParameters(self.mesh, Parameters)
2712 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2713 NbOfSteps, Tolerance)
2714 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2717 ## Generates new elements by rotation of the elements of object around the axis
2718 # @param theObject object which elements should be sweeped
2719 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2720 # @param AngleInRadians the angle of Rotation
2721 # @param NbOfSteps number of steps
2722 # @param Tolerance tolerance
2723 # @param MakeGroups forces the generation of new groups from existing ones
2724 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2725 # of all steps, else - size of each step
2726 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2727 # @ingroup l2_modif_extrurev
2728 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2729 MakeGroups=False, TotalAngle=False):
2731 if isinstance(AngleInRadians,str):
2733 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2735 AngleInRadians = DegreesToRadians(AngleInRadians)
2736 if ( isinstance( theObject, Mesh )):
2737 theObject = theObject.GetMesh()
2738 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2739 Axis = self.smeshpyD.GetAxisStruct(Axis)
2740 Axis,AxisParameters = ParseAxisStruct(Axis)
2741 if TotalAngle and NbOfSteps:
2742 AngleInRadians /= NbOfSteps
2743 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2744 Parameters = AxisParameters + AngleParameters + Parameters
2745 geompyDC.SetParameters(self.mesh, Parameters)
2747 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2748 NbOfSteps, Tolerance)
2749 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2752 ## Generates new elements by rotation of the elements of object around the axis
2753 # @param theObject object which elements should be sweeped
2754 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2755 # @param AngleInRadians the angle of Rotation
2756 # @param NbOfSteps number of steps
2757 # @param Tolerance tolerance
2758 # @param MakeGroups forces the generation of new groups from existing ones
2759 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2760 # of all steps, else - size of each step
2761 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2762 # @ingroup l2_modif_extrurev
2763 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2764 MakeGroups=False, TotalAngle=False):
2766 if isinstance(AngleInRadians,str):
2768 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2770 AngleInRadians = DegreesToRadians(AngleInRadians)
2771 if ( isinstance( theObject, Mesh )):
2772 theObject = theObject.GetMesh()
2773 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2774 Axis = self.smeshpyD.GetAxisStruct(Axis)
2775 Axis,AxisParameters = ParseAxisStruct(Axis)
2776 if TotalAngle and NbOfSteps:
2777 AngleInRadians /= NbOfSteps
2778 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2779 Parameters = AxisParameters + AngleParameters + Parameters
2780 geompyDC.SetParameters(self.mesh, Parameters)
2782 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2783 NbOfSteps, Tolerance)
2784 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2787 ## Generates new elements by extrusion of the elements with given ids
2788 # @param IDsOfElements the list of elements ids for extrusion
2789 # @param StepVector vector, defining the direction and value of extrusion
2790 # @param NbOfSteps the number of steps
2791 # @param MakeGroups forces the generation of new groups from existing ones
2792 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2793 # @ingroup l2_modif_extrurev
2794 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2795 if IDsOfElements == []:
2796 IDsOfElements = self.GetElementsId()
2797 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2798 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2799 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2800 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2801 Parameters = StepVectorParameters + Parameters
2802 geompyDC.SetParameters(self.mesh, Parameters)
2804 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2805 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2808 ## Generates new elements by extrusion of the elements with given ids
2809 # @param IDsOfElements is ids of elements
2810 # @param StepVector vector, defining the direction and value of extrusion
2811 # @param NbOfSteps the number of steps
2812 # @param ExtrFlags sets flags for extrusion
2813 # @param SewTolerance uses for comparing locations of nodes if flag
2814 # EXTRUSION_FLAG_SEW is set
2815 # @param MakeGroups forces the generation of new groups from existing ones
2816 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2817 # @ingroup l2_modif_extrurev
2818 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2819 ExtrFlags, SewTolerance, MakeGroups=False):
2820 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2821 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2823 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2824 ExtrFlags, SewTolerance)
2825 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2826 ExtrFlags, SewTolerance)
2829 ## Generates new elements by extrusion of the elements which belong to the object
2830 # @param theObject the object which elements should be processed
2831 # @param StepVector vector, defining the direction and value of extrusion
2832 # @param NbOfSteps the number of steps
2833 # @param MakeGroups forces the generation of new groups from existing ones
2834 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2835 # @ingroup l2_modif_extrurev
2836 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2837 if ( isinstance( theObject, Mesh )):
2838 theObject = theObject.GetMesh()
2839 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2840 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2841 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2842 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2843 Parameters = StepVectorParameters + Parameters
2844 geompyDC.SetParameters(self.mesh, Parameters)
2846 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2847 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2850 ## Generates new elements by extrusion of the elements which belong to the object
2851 # @param theObject object which elements should be processed
2852 # @param StepVector vector, defining the direction and value of extrusion
2853 # @param NbOfSteps the number of steps
2854 # @param MakeGroups to generate new groups from existing ones
2855 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2856 # @ingroup l2_modif_extrurev
2857 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2858 if ( isinstance( theObject, Mesh )):
2859 theObject = theObject.GetMesh()
2860 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2861 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2862 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2863 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2864 Parameters = StepVectorParameters + Parameters
2865 geompyDC.SetParameters(self.mesh, Parameters)
2867 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2868 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2871 ## Generates new elements by extrusion of the elements which belong to the object
2872 # @param theObject object which elements should be processed
2873 # @param StepVector vector, defining the direction and value of extrusion
2874 # @param NbOfSteps the number of steps
2875 # @param MakeGroups forces the generation of new groups from existing ones
2876 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2877 # @ingroup l2_modif_extrurev
2878 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2879 if ( isinstance( theObject, Mesh )):
2880 theObject = theObject.GetMesh()
2881 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2882 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2883 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2884 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2885 Parameters = StepVectorParameters + Parameters
2886 geompyDC.SetParameters(self.mesh, Parameters)
2888 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2889 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2894 ## Generates new elements by extrusion of the given elements
2895 # The path of extrusion must be a meshed edge.
2896 # @param Base mesh or list of ids of elements for extrusion
2897 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2898 # @param NodeStart the start node from Path. Defines the direction of extrusion
2899 # @param HasAngles allows the shape to be rotated around the path
2900 # to get the resulting mesh in a helical fashion
2901 # @param Angles list of angles in radians
2902 # @param LinearVariation forces the computation of rotation angles as linear
2903 # variation of the given Angles along path steps
2904 # @param HasRefPoint allows using the reference point
2905 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2906 # The User can specify any point as the Reference Point.
2907 # @param MakeGroups forces the generation of new groups from existing ones
2908 # @param ElemType type of elements for extrusion (if param Base is a mesh)
2909 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2910 # only SMESH::Extrusion_Error otherwise
2911 # @ingroup l2_modif_extrurev
2912 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2913 HasAngles, Angles, LinearVariation,
2914 HasRefPoint, RefPoint, MakeGroups, ElemType):
2915 Angles,AnglesParameters = ParseAngles(Angles)
2916 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2917 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2918 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2920 if ( isinstance( Path, Mesh )):
2921 Path = Path.GetMesh()
2922 Parameters = AnglesParameters + RefPointParameters
2923 geompyDC.SetParameters(self.mesh, Parameters)
2925 if isinstance(Base,list):
2927 if Base == []: IDsOfElements = self.GetElementsId()
2928 else: IDsOfElements = Base
2929 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2930 HasAngles, Angles, LinearVariation,
2931 HasRefPoint, RefPoint, MakeGroups, ElemType)
2933 if isinstance(Base,Mesh):
2934 Base = Base.GetMesh()
2935 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
2936 HasAngles, Angles, LinearVariation,
2937 HasRefPoint, RefPoint, MakeGroups, ElemType)
2939 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2942 ## Generates new elements by extrusion of the given elements
2943 # The path of extrusion must be a meshed edge.
2944 # @param IDsOfElements ids of elements
2945 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2946 # @param PathShape shape(edge) defines the sub-mesh for the path
2947 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2948 # @param HasAngles allows the shape to be rotated around the path
2949 # to get the resulting mesh in a helical fashion
2950 # @param Angles list of angles in radians
2951 # @param HasRefPoint allows using the reference point
2952 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2953 # The User can specify any point as the Reference Point.
2954 # @param MakeGroups forces the generation of new groups from existing ones
2955 # @param LinearVariation forces the computation of rotation angles as linear
2956 # variation of the given Angles along path steps
2957 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2958 # only SMESH::Extrusion_Error otherwise
2959 # @ingroup l2_modif_extrurev
2960 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2961 HasAngles, Angles, HasRefPoint, RefPoint,
2962 MakeGroups=False, LinearVariation=False):
2963 Angles,AnglesParameters = ParseAngles(Angles)
2964 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2965 if IDsOfElements == []:
2966 IDsOfElements = self.GetElementsId()
2967 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2968 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2970 if ( isinstance( PathMesh, Mesh )):
2971 PathMesh = PathMesh.GetMesh()
2972 if HasAngles and Angles and LinearVariation:
2973 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2975 Parameters = AnglesParameters + RefPointParameters
2976 geompyDC.SetParameters(self.mesh, Parameters)
2978 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2979 PathShape, NodeStart, HasAngles,
2980 Angles, HasRefPoint, RefPoint)
2981 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2982 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2984 ## Generates new elements by extrusion of the elements which belong to the object
2985 # The path of extrusion must be a meshed edge.
2986 # @param theObject the object which elements should be processed
2987 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2988 # @param PathShape shape(edge) defines the sub-mesh for the path
2989 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2990 # @param HasAngles allows the shape to be rotated around the path
2991 # to get the resulting mesh in a helical fashion
2992 # @param Angles list of angles
2993 # @param HasRefPoint allows using the reference point
2994 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2995 # The User can specify any point as the Reference Point.
2996 # @param MakeGroups forces the generation of new groups from existing ones
2997 # @param LinearVariation forces the computation of rotation angles as linear
2998 # variation of the given Angles along path steps
2999 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3000 # only SMESH::Extrusion_Error otherwise
3001 # @ingroup l2_modif_extrurev
3002 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3003 HasAngles, Angles, HasRefPoint, RefPoint,
3004 MakeGroups=False, LinearVariation=False):
3005 Angles,AnglesParameters = ParseAngles(Angles)
3006 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3007 if ( isinstance( theObject, Mesh )):
3008 theObject = theObject.GetMesh()
3009 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3010 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3011 if ( isinstance( PathMesh, Mesh )):
3012 PathMesh = PathMesh.GetMesh()
3013 if HasAngles and Angles and LinearVariation:
3014 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3016 Parameters = AnglesParameters + RefPointParameters
3017 geompyDC.SetParameters(self.mesh, Parameters)
3019 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3020 PathShape, NodeStart, HasAngles,
3021 Angles, HasRefPoint, RefPoint)
3022 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3023 NodeStart, HasAngles, Angles, HasRefPoint,
3026 ## Generates new elements by extrusion of the elements which belong to the object
3027 # The path of extrusion must be a meshed edge.
3028 # @param theObject the object which elements should be processed
3029 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3030 # @param PathShape shape(edge) defines the sub-mesh for the path
3031 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3032 # @param HasAngles allows the shape to be rotated around the path
3033 # to get the resulting mesh in a helical fashion
3034 # @param Angles list of angles
3035 # @param HasRefPoint allows using the reference point
3036 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3037 # The User can specify any point as the Reference Point.
3038 # @param MakeGroups forces the generation of new groups from existing ones
3039 # @param LinearVariation forces the computation of rotation angles as linear
3040 # variation of the given Angles along path steps
3041 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3042 # only SMESH::Extrusion_Error otherwise
3043 # @ingroup l2_modif_extrurev
3044 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3045 HasAngles, Angles, HasRefPoint, RefPoint,
3046 MakeGroups=False, LinearVariation=False):
3047 Angles,AnglesParameters = ParseAngles(Angles)
3048 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3049 if ( isinstance( theObject, Mesh )):
3050 theObject = theObject.GetMesh()
3051 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3052 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3053 if ( isinstance( PathMesh, Mesh )):
3054 PathMesh = PathMesh.GetMesh()
3055 if HasAngles and Angles and LinearVariation:
3056 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3058 Parameters = AnglesParameters + RefPointParameters
3059 geompyDC.SetParameters(self.mesh, Parameters)
3061 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3062 PathShape, NodeStart, HasAngles,
3063 Angles, HasRefPoint, RefPoint)
3064 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3065 NodeStart, HasAngles, Angles, HasRefPoint,
3068 ## Generates new elements by extrusion of the elements which belong to the object
3069 # The path of extrusion must be a meshed edge.
3070 # @param theObject the object which elements should be processed
3071 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3072 # @param PathShape shape(edge) defines the sub-mesh for the path
3073 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3074 # @param HasAngles allows the shape to be rotated around the path
3075 # to get the resulting mesh in a helical fashion
3076 # @param Angles list of angles
3077 # @param HasRefPoint allows using the reference point
3078 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3079 # The User can specify any point as the Reference Point.
3080 # @param MakeGroups forces the generation of new groups from existing ones
3081 # @param LinearVariation forces the computation of rotation angles as linear
3082 # variation of the given Angles along path steps
3083 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3084 # only SMESH::Extrusion_Error otherwise
3085 # @ingroup l2_modif_extrurev
3086 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3087 HasAngles, Angles, HasRefPoint, RefPoint,
3088 MakeGroups=False, LinearVariation=False):
3089 Angles,AnglesParameters = ParseAngles(Angles)
3090 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3091 if ( isinstance( theObject, Mesh )):
3092 theObject = theObject.GetMesh()
3093 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3094 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3095 if ( isinstance( PathMesh, Mesh )):
3096 PathMesh = PathMesh.GetMesh()
3097 if HasAngles and Angles and LinearVariation:
3098 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3100 Parameters = AnglesParameters + RefPointParameters
3101 geompyDC.SetParameters(self.mesh, Parameters)
3103 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3104 PathShape, NodeStart, HasAngles,
3105 Angles, HasRefPoint, RefPoint)
3106 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3107 NodeStart, HasAngles, Angles, HasRefPoint,
3110 ## Creates a symmetrical copy of mesh elements
3111 # @param IDsOfElements list of elements ids
3112 # @param Mirror is AxisStruct or geom object(point, line, plane)
3113 # @param theMirrorType is POINT, AXIS or PLANE
3114 # If the Mirror is a geom object this parameter is unnecessary
3115 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3116 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3117 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3118 # @ingroup l2_modif_trsf
3119 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3120 if IDsOfElements == []:
3121 IDsOfElements = self.GetElementsId()
3122 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3123 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3124 Mirror,Parameters = ParseAxisStruct(Mirror)
3125 geompyDC.SetParameters(self.mesh, Parameters)
3126 if Copy and MakeGroups:
3127 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3128 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3131 ## Creates a new mesh by a symmetrical copy of mesh elements
3132 # @param IDsOfElements the list of elements ids
3133 # @param Mirror is AxisStruct or geom object (point, line, plane)
3134 # @param theMirrorType is POINT, AXIS or PLANE
3135 # If the Mirror is a geom object this parameter is unnecessary
3136 # @param MakeGroups to generate new groups from existing ones
3137 # @param NewMeshName a name of the new mesh to create
3138 # @return instance of Mesh class
3139 # @ingroup l2_modif_trsf
3140 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3141 if IDsOfElements == []:
3142 IDsOfElements = self.GetElementsId()
3143 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3144 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3145 Mirror,Parameters = ParseAxisStruct(Mirror)
3146 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3147 MakeGroups, NewMeshName)
3148 geompyDC.SetParameters(mesh, Parameters)
3149 return Mesh(self.smeshpyD,self.geompyD,mesh)
3151 ## Creates a symmetrical copy of the object
3152 # @param theObject mesh, submesh or group
3153 # @param Mirror AxisStruct or geom object (point, line, plane)
3154 # @param theMirrorType is POINT, AXIS or PLANE
3155 # If the Mirror is a geom object this parameter is unnecessary
3156 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3157 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3158 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3159 # @ingroup l2_modif_trsf
3160 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3161 if ( isinstance( theObject, Mesh )):
3162 theObject = theObject.GetMesh()
3163 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3164 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3165 Mirror,Parameters = ParseAxisStruct(Mirror)
3166 geompyDC.SetParameters(self.mesh, Parameters)
3167 if Copy and MakeGroups:
3168 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3169 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3172 ## Creates a new mesh by a symmetrical copy of the object
3173 # @param theObject mesh, submesh or group
3174 # @param Mirror AxisStruct or geom object (point, line, plane)
3175 # @param theMirrorType POINT, AXIS or PLANE
3176 # If the Mirror is a geom object this parameter is unnecessary
3177 # @param MakeGroups forces the generation of new groups from existing ones
3178 # @param NewMeshName the name of the new mesh to create
3179 # @return instance of Mesh class
3180 # @ingroup l2_modif_trsf
3181 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3182 if ( isinstance( theObject, Mesh )):
3183 theObject = theObject.GetMesh()
3184 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3185 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3186 Mirror,Parameters = ParseAxisStruct(Mirror)
3187 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3188 MakeGroups, NewMeshName)
3189 geompyDC.SetParameters(mesh, Parameters)
3190 return Mesh( self.smeshpyD,self.geompyD,mesh )
3192 ## Translates the elements
3193 # @param IDsOfElements list of elements ids
3194 # @param Vector the direction of translation (DirStruct or vector)
3195 # @param Copy allows copying the translated elements
3196 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3197 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3198 # @ingroup l2_modif_trsf
3199 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3200 if IDsOfElements == []:
3201 IDsOfElements = self.GetElementsId()
3202 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3203 Vector = self.smeshpyD.GetDirStruct(Vector)
3204 Vector,Parameters = ParseDirStruct(Vector)
3205 geompyDC.SetParameters(self.mesh, Parameters)
3206 if Copy and MakeGroups:
3207 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3208 self.editor.Translate(IDsOfElements, Vector, Copy)
3211 ## Creates a new mesh of translated elements
3212 # @param IDsOfElements list of elements ids
3213 # @param Vector the direction of translation (DirStruct or vector)
3214 # @param MakeGroups forces the generation of new groups from existing ones
3215 # @param NewMeshName the name of the newly created mesh
3216 # @return instance of Mesh class
3217 # @ingroup l2_modif_trsf
3218 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3219 if IDsOfElements == []:
3220 IDsOfElements = self.GetElementsId()
3221 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3222 Vector = self.smeshpyD.GetDirStruct(Vector)
3223 Vector,Parameters = ParseDirStruct(Vector)
3224 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3225 geompyDC.SetParameters(mesh, Parameters)
3226 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3228 ## Translates the object
3229 # @param theObject the object to translate (mesh, submesh, or group)
3230 # @param Vector direction of translation (DirStruct or geom vector)
3231 # @param Copy allows copying the translated elements
3232 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3233 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3234 # @ingroup l2_modif_trsf
3235 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3236 if ( isinstance( theObject, Mesh )):
3237 theObject = theObject.GetMesh()
3238 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3239 Vector = self.smeshpyD.GetDirStruct(Vector)
3240 Vector,Parameters = ParseDirStruct(Vector)
3241 geompyDC.SetParameters(self.mesh, Parameters)
3242 if Copy and MakeGroups:
3243 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3244 self.editor.TranslateObject(theObject, Vector, Copy)
3247 ## Creates a new mesh from the translated object
3248 # @param theObject the object to translate (mesh, submesh, or group)
3249 # @param Vector the direction of translation (DirStruct or geom vector)
3250 # @param MakeGroups forces the generation of new groups from existing ones
3251 # @param NewMeshName the name of the newly created mesh
3252 # @return instance of Mesh class
3253 # @ingroup l2_modif_trsf
3254 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3255 if (isinstance(theObject, Mesh)):
3256 theObject = theObject.GetMesh()
3257 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3258 Vector = self.smeshpyD.GetDirStruct(Vector)
3259 Vector,Parameters = ParseDirStruct(Vector)
3260 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3261 geompyDC.SetParameters(mesh, Parameters)
3262 return Mesh( self.smeshpyD, self.geompyD, mesh )
3264 ## Rotates the elements
3265 # @param IDsOfElements list of elements ids
3266 # @param Axis the axis of rotation (AxisStruct or geom line)
3267 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3268 # @param Copy allows copying the rotated elements
3269 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3270 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3271 # @ingroup l2_modif_trsf
3272 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3274 if isinstance(AngleInRadians,str):
3276 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3278 AngleInRadians = DegreesToRadians(AngleInRadians)
3279 if IDsOfElements == []:
3280 IDsOfElements = self.GetElementsId()
3281 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3282 Axis = self.smeshpyD.GetAxisStruct(Axis)
3283 Axis,AxisParameters = ParseAxisStruct(Axis)
3284 Parameters = AxisParameters + Parameters
3285 geompyDC.SetParameters(self.mesh, Parameters)
3286 if Copy and MakeGroups:
3287 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3288 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3291 ## Creates a new mesh of rotated elements
3292 # @param IDsOfElements list of element ids
3293 # @param Axis the axis of rotation (AxisStruct or geom line)
3294 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3295 # @param MakeGroups forces the generation of new groups from existing ones
3296 # @param NewMeshName the name of the newly created mesh
3297 # @return instance of Mesh class
3298 # @ingroup l2_modif_trsf
3299 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3301 if isinstance(AngleInRadians,str):
3303 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3305 AngleInRadians = DegreesToRadians(AngleInRadians)
3306 if IDsOfElements == []:
3307 IDsOfElements = self.GetElementsId()
3308 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3309 Axis = self.smeshpyD.GetAxisStruct(Axis)
3310 Axis,AxisParameters = ParseAxisStruct(Axis)
3311 Parameters = AxisParameters + Parameters
3312 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3313 MakeGroups, NewMeshName)
3314 geompyDC.SetParameters(mesh, Parameters)
3315 return Mesh( self.smeshpyD, self.geompyD, mesh )
3317 ## Rotates the object
3318 # @param theObject the object to rotate( mesh, submesh, or group)
3319 # @param Axis the axis of rotation (AxisStruct or geom line)
3320 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3321 # @param Copy allows copying the rotated elements
3322 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3323 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3324 # @ingroup l2_modif_trsf
3325 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3327 if isinstance(AngleInRadians,str):
3329 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3331 AngleInRadians = DegreesToRadians(AngleInRadians)
3332 if (isinstance(theObject, Mesh)):
3333 theObject = theObject.GetMesh()
3334 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3335 Axis = self.smeshpyD.GetAxisStruct(Axis)
3336 Axis,AxisParameters = ParseAxisStruct(Axis)
3337 Parameters = AxisParameters + Parameters
3338 geompyDC.SetParameters(self.mesh, Parameters)
3339 if Copy and MakeGroups:
3340 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3341 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3344 ## Creates a new mesh from the rotated object
3345 # @param theObject the object to rotate (mesh, submesh, or group)
3346 # @param Axis the axis of rotation (AxisStruct or geom line)
3347 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3348 # @param MakeGroups forces the generation of new groups from existing ones
3349 # @param NewMeshName the name of the newly created mesh
3350 # @return instance of Mesh class
3351 # @ingroup l2_modif_trsf
3352 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3354 if isinstance(AngleInRadians,str):
3356 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3358 AngleInRadians = DegreesToRadians(AngleInRadians)
3359 if (isinstance( theObject, Mesh )):
3360 theObject = theObject.GetMesh()
3361 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3362 Axis = self.smeshpyD.GetAxisStruct(Axis)
3363 Axis,AxisParameters = ParseAxisStruct(Axis)
3364 Parameters = AxisParameters + Parameters
3365 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3366 MakeGroups, NewMeshName)
3367 geompyDC.SetParameters(mesh, Parameters)
3368 return Mesh( self.smeshpyD, self.geompyD, mesh )
3370 ## Finds groups of ajacent nodes within Tolerance.
3371 # @param Tolerance the value of tolerance
3372 # @return the list of groups of nodes
3373 # @ingroup l2_modif_trsf
3374 def FindCoincidentNodes (self, Tolerance):
3375 return self.editor.FindCoincidentNodes(Tolerance)
3377 ## Finds groups of ajacent nodes within Tolerance.
3378 # @param Tolerance the value of tolerance
3379 # @param SubMeshOrGroup SubMesh or Group
3380 # @return the list of groups of nodes
3381 # @ingroup l2_modif_trsf
3382 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3383 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3386 # @param GroupsOfNodes the list of groups of nodes
3387 # @ingroup l2_modif_trsf
3388 def MergeNodes (self, GroupsOfNodes):
3389 self.editor.MergeNodes(GroupsOfNodes)
3391 ## Finds the elements built on the same nodes.
3392 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3393 # @return a list of groups of equal elements
3394 # @ingroup l2_modif_trsf
3395 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3396 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3397 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3398 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3400 ## Merges elements in each given group.
3401 # @param GroupsOfElementsID groups of elements for merging
3402 # @ingroup l2_modif_trsf
3403 def MergeElements(self, GroupsOfElementsID):
3404 self.editor.MergeElements(GroupsOfElementsID)
3406 ## Leaves one element and removes all other elements built on the same nodes.
3407 # @ingroup l2_modif_trsf
3408 def MergeEqualElements(self):
3409 self.editor.MergeEqualElements()
3411 ## Sews free borders
3412 # @return SMESH::Sew_Error
3413 # @ingroup l2_modif_trsf
3414 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3415 FirstNodeID2, SecondNodeID2, LastNodeID2,
3416 CreatePolygons, CreatePolyedrs):
3417 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3418 FirstNodeID2, SecondNodeID2, LastNodeID2,
3419 CreatePolygons, CreatePolyedrs)
3421 ## Sews conform free borders
3422 # @return SMESH::Sew_Error
3423 # @ingroup l2_modif_trsf
3424 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3425 FirstNodeID2, SecondNodeID2):
3426 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3427 FirstNodeID2, SecondNodeID2)
3429 ## Sews border to side
3430 # @return SMESH::Sew_Error
3431 # @ingroup l2_modif_trsf
3432 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3433 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3434 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3435 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3437 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3438 # merged with the nodes of elements of Side2.
3439 # The number of elements in theSide1 and in theSide2 must be
3440 # equal and they should have similar nodal connectivity.
3441 # The nodes to merge should belong to side borders and
3442 # the first node should be linked to the second.
3443 # @return SMESH::Sew_Error
3444 # @ingroup l2_modif_trsf
3445 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3446 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3447 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3448 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3449 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3450 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3452 ## Sets new nodes for the given element.
3453 # @param ide the element id
3454 # @param newIDs nodes ids
3455 # @return If the number of nodes does not correspond to the type of element - returns false
3456 # @ingroup l2_modif_edit
3457 def ChangeElemNodes(self, ide, newIDs):
3458 return self.editor.ChangeElemNodes(ide, newIDs)
3460 ## If during the last operation of MeshEditor some nodes were
3461 # created, this method returns the list of their IDs, \n
3462 # if new nodes were not created - returns empty list
3463 # @return the list of integer values (can be empty)
3464 # @ingroup l1_auxiliary
3465 def GetLastCreatedNodes(self):
3466 return self.editor.GetLastCreatedNodes()
3468 ## If during the last operation of MeshEditor some elements were
3469 # created this method returns the list of their IDs, \n
3470 # if new elements were not created - returns empty list
3471 # @return the list of integer values (can be empty)
3472 # @ingroup l1_auxiliary
3473 def GetLastCreatedElems(self):
3474 return self.editor.GetLastCreatedElems()
3476 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3477 # @param theNodes identifiers of nodes to be doubled
3478 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3479 # nodes. If list of element identifiers is empty then nodes are doubled but
3480 # they not assigned to elements
3481 # @return TRUE if operation has been completed successfully, FALSE otherwise
3482 # @ingroup l2_modif_edit
3483 def DoubleNodes(self, theNodes, theModifiedElems):
3484 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3486 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3487 # This method provided for convenience works as DoubleNodes() described above.
3488 # @param theNodes identifiers of node to be doubled
3489 # @param theModifiedElems identifiers of elements to be updated
3490 # @return TRUE if operation has been completed successfully, FALSE otherwise
3491 # @ingroup l2_modif_edit
3492 def DoubleNode(self, theNodeId, theModifiedElems):
3493 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3495 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3496 # This method provided for convenience works as DoubleNodes() described above.
3497 # @param theNodes group of nodes to be doubled
3498 # @param theModifiedElems group of elements to be updated.
3499 # @return TRUE if operation has been completed successfully, FALSE otherwise
3500 # @ingroup l2_modif_edit
3501 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3502 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3504 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3505 # This method provided for convenience works as DoubleNodes() described above.
3506 # @param theNodes list of groups of nodes to be doubled
3507 # @param theModifiedElems list of groups of elements to be updated.
3508 # @return TRUE if operation has been completed successfully, FALSE otherwise
3509 # @ingroup l2_modif_edit
3510 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3511 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3513 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3514 # @param theElems - the list of elements (edges or faces) to be replicated
3515 # The nodes for duplication could be found from these elements
3516 # @param theNodesNot - list of nodes to NOT replicate
3517 # @param theAffectedElems - the list of elements (cells and edges) to which the
3518 # replicated nodes should be associated to.
3519 # @return TRUE if operation has been completed successfully, FALSE otherwise
3520 # @ingroup l2_modif_edit
3521 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3522 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3524 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3525 # @param theElems - the list of elements (edges or faces) to be replicated
3526 # The nodes for duplication could be found from these elements
3527 # @param theNodesNot - list of nodes to NOT replicate
3528 # @param theShape - shape to detect affected elements (element which geometric center
3529 # located on or inside shape).
3530 # The replicated nodes should be associated to affected elements.
3531 # @return TRUE if operation has been completed successfully, FALSE otherwise
3532 # @ingroup l2_modif_edit
3533 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3534 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3536 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3537 # This method provided for convenience works as DoubleNodes() described above.
3538 # @param theElems - group of of elements (edges or faces) to be replicated
3539 # @param theNodesNot - group of nodes not to replicated
3540 # @param theAffectedElems - group of elements to which the replicated nodes
3541 # should be associated to.
3542 # @ingroup l2_modif_edit
3543 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
3544 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3546 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3547 # This method provided for convenience works as DoubleNodes() described above.
3548 # @param theElems - group of of elements (edges or faces) to be replicated
3549 # @param theNodesNot - group of nodes not to replicated
3550 # @param theShape - shape to detect affected elements (element which geometric center
3551 # located on or inside shape).
3552 # The replicated nodes should be associated to affected elements.
3553 # @ingroup l2_modif_edit
3554 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3555 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theShape)
3557 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3558 # This method provided for convenience works as DoubleNodes() described above.
3559 # @param theElems - list of groups of elements (edges or faces) to be replicated
3560 # @param theNodesNot - list of groups of nodes not to replicated
3561 # @param theAffectedElems - group of elements to which the replicated nodes
3562 # should be associated to.
3563 # @return TRUE if operation has been completed successfully, FALSE otherwise
3564 # @ingroup l2_modif_edit
3565 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3566 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3568 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3569 # This method provided for convenience works as DoubleNodes() described above.
3570 # @param theElems - list of groups of elements (edges or faces) to be replicated
3571 # @param theNodesNot - list of groups of nodes not to replicated
3572 # @param theShape - shape to detect affected elements (element which geometric center
3573 # located on or inside shape).
3574 # The replicated nodes should be associated to affected elements.
3575 # @return TRUE if operation has been completed successfully, FALSE otherwise
3576 # @ingroup l2_modif_edit
3577 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3578 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3580 ## The mother class to define algorithm, it is not recommended to use it directly.
3583 # @ingroup l2_algorithms
3584 class Mesh_Algorithm:
3585 # @class Mesh_Algorithm
3586 # @brief Class Mesh_Algorithm
3588 #def __init__(self,smesh):
3596 ## Finds a hypothesis in the study by its type name and parameters.
3597 # Finds only the hypotheses created in smeshpyD engine.
3598 # @return SMESH.SMESH_Hypothesis
3599 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3600 study = smeshpyD.GetCurrentStudy()
3601 #to do: find component by smeshpyD object, not by its data type
3602 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3603 if scomp is not None:
3604 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3605 # Check if the root label of the hypotheses exists
3606 if res and hypRoot is not None:
3607 iter = study.NewChildIterator(hypRoot)
3608 # Check all published hypotheses
3610 hypo_so_i = iter.Value()
3611 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3612 if attr is not None:
3613 anIOR = attr.Value()
3614 hypo_o_i = salome.orb.string_to_object(anIOR)
3615 if hypo_o_i is not None:
3616 # Check if this is a hypothesis
3617 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3618 if hypo_i is not None:
3619 # Check if the hypothesis belongs to current engine
3620 if smeshpyD.GetObjectId(hypo_i) > 0:
3621 # Check if this is the required hypothesis
3622 if hypo_i.GetName() == hypname:
3624 if CompareMethod(hypo_i, args):
3638 ## Finds the algorithm in the study by its type name.
3639 # Finds only the algorithms, which have been created in smeshpyD engine.
3640 # @return SMESH.SMESH_Algo
3641 def FindAlgorithm (self, algoname, smeshpyD):
3642 study = smeshpyD.GetCurrentStudy()
3643 #to do: find component by smeshpyD object, not by its data type
3644 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3645 if scomp is not None:
3646 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3647 # Check if the root label of the algorithms exists
3648 if res and hypRoot is not None:
3649 iter = study.NewChildIterator(hypRoot)
3650 # Check all published algorithms
3652 algo_so_i = iter.Value()
3653 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3654 if attr is not None:
3655 anIOR = attr.Value()
3656 algo_o_i = salome.orb.string_to_object(anIOR)
3657 if algo_o_i is not None:
3658 # Check if this is an algorithm
3659 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3660 if algo_i is not None:
3661 # Checks if the algorithm belongs to the current engine
3662 if smeshpyD.GetObjectId(algo_i) > 0:
3663 # Check if this is the required algorithm
3664 if algo_i.GetName() == algoname:
3677 ## If the algorithm is global, returns 0; \n
3678 # else returns the submesh associated to this algorithm.
3679 def GetSubMesh(self):
3682 ## Returns the wrapped mesher.
3683 def GetAlgorithm(self):
3686 ## Gets the list of hypothesis that can be used with this algorithm
3687 def GetCompatibleHypothesis(self):
3690 mylist = self.algo.GetCompatibleHypothesis()
3693 ## Gets the name of the algorithm
3697 ## Sets the name to the algorithm
3698 def SetName(self, name):
3699 self.mesh.smeshpyD.SetName(self.algo, name)
3701 ## Gets the id of the algorithm
3703 return self.algo.GetId()
3706 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3708 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3709 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3711 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3713 self.Assign(algo, mesh, geom)
3717 def Assign(self, algo, mesh, geom):
3719 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3726 name = GetName(geom)
3728 name = mesh.geompyD.SubShapeName(geom, piece)
3729 mesh.geompyD.addToStudyInFather(piece, geom, name)
3730 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3733 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3734 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3736 def CompareHyp (self, hyp, args):
3737 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3740 def CompareEqualHyp (self, hyp, args):
3744 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3745 UseExisting=0, CompareMethod=""):
3748 if CompareMethod == "": CompareMethod = self.CompareHyp
3749 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3752 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3758 a = a + s + str(args[i])
3762 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3764 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3765 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3768 ## Returns entry of the shape to mesh in the study
3769 def MainShapeEntry(self):
3771 if not self.mesh or not self.mesh.GetMesh(): return entry
3772 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3773 study = self.mesh.smeshpyD.GetCurrentStudy()
3774 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3775 sobj = study.FindObjectIOR(ior)
3776 if sobj: entry = sobj.GetID()
3777 if not entry: return ""
3780 # Public class: Mesh_Segment
3781 # --------------------------
3783 ## Class to define a segment 1D algorithm for discretization
3786 # @ingroup l3_algos_basic
3787 class Mesh_Segment(Mesh_Algorithm):
3789 ## Private constructor.
3790 def __init__(self, mesh, geom=0):
3791 Mesh_Algorithm.__init__(self)
3792 self.Create(mesh, geom, "Regular_1D")
3794 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3795 # @param l for the length of segments that cut an edge
3796 # @param UseExisting if ==true - searches for an existing hypothesis created with
3797 # the same parameters, else (default) - creates a new one
3798 # @param p precision, used for calculation of the number of segments.
3799 # The precision should be a positive, meaningful value within the range [0,1].
3800 # In general, the number of segments is calculated with the formula:
3801 # nb = ceil((edge_length / l) - p)
3802 # Function ceil rounds its argument to the higher integer.
3803 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3804 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3805 # p=1 means rounding of (edge_length / l) to the lower integer.
3806 # Default value is 1e-07.
3807 # @return an instance of StdMeshers_LocalLength hypothesis
3808 # @ingroup l3_hypos_1dhyps
3809 def LocalLength(self, l, UseExisting=0, p=1e-07):
3810 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3811 CompareMethod=self.CompareLocalLength)
3817 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3818 def CompareLocalLength(self, hyp, args):
3819 if IsEqual(hyp.GetLength(), args[0]):
3820 return IsEqual(hyp.GetPrecision(), args[1])
3823 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3824 # @param length is optional maximal allowed length of segment, if it is omitted
3825 # the preestimated length is used that depends on geometry size
3826 # @param UseExisting if ==true - searches for an existing hypothesis created with
3827 # the same parameters, else (default) - create a new one
3828 # @return an instance of StdMeshers_MaxLength hypothesis
3829 # @ingroup l3_hypos_1dhyps
3830 def MaxSize(self, length=0.0, UseExisting=0):
3831 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3834 hyp.SetLength(length)
3836 # set preestimated length
3837 gen = self.mesh.smeshpyD
3838 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3839 self.mesh.GetMesh(), self.mesh.GetShape(),
3841 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3843 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3846 hyp.SetUsePreestimatedLength( length == 0.0 )
3849 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3850 # @param n for the number of segments that cut an edge
3851 # @param s for the scale factor (optional)
3852 # @param reversedEdges is a list of edges to mesh using reversed orientation
3853 # @param UseExisting if ==true - searches for an existing hypothesis created with
3854 # the same parameters, else (default) - create a new one
3855 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3856 # @ingroup l3_hypos_1dhyps
3857 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3858 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3859 reversedEdges, UseExisting = [], reversedEdges
3860 entry = self.MainShapeEntry()
3862 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3863 UseExisting=UseExisting,
3864 CompareMethod=self.CompareNumberOfSegments)
3866 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3867 UseExisting=UseExisting,
3868 CompareMethod=self.CompareNumberOfSegments)
3869 hyp.SetDistrType( 1 )
3870 hyp.SetScaleFactor(s)
3871 hyp.SetNumberOfSegments(n)
3872 hyp.SetReversedEdges( reversedEdges )
3873 hyp.SetObjectEntry( entry )
3877 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3878 def CompareNumberOfSegments(self, hyp, args):
3879 if hyp.GetNumberOfSegments() == args[0]:
3881 if hyp.GetReversedEdges() == args[1]:
3882 if not args[1] or hyp.GetObjectEntry() == args[2]:
3885 if hyp.GetReversedEdges() == args[2]:
3886 if not args[2] or hyp.GetObjectEntry() == args[3]:
3887 if hyp.GetDistrType() == 1:
3888 if IsEqual(hyp.GetScaleFactor(), args[1]):
3892 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3893 # @param start defines the length of the first segment
3894 # @param end defines the length of the last segment
3895 # @param reversedEdges is a list of edges to mesh using reversed orientation
3896 # @param UseExisting if ==true - searches for an existing hypothesis created with
3897 # the same parameters, else (default) - creates a new one
3898 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3899 # @ingroup l3_hypos_1dhyps
3900 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3901 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3902 reversedEdges, UseExisting = [], reversedEdges
3903 entry = self.MainShapeEntry()
3904 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
3905 UseExisting=UseExisting,
3906 CompareMethod=self.CompareArithmetic1D)
3907 hyp.SetStartLength(start)
3908 hyp.SetEndLength(end)
3909 hyp.SetReversedEdges( reversedEdges )
3910 hyp.SetObjectEntry( entry )
3914 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3915 def CompareArithmetic1D(self, hyp, args):
3916 if IsEqual(hyp.GetLength(1), args[0]):
3917 if IsEqual(hyp.GetLength(0), args[1]):
3918 if hyp.GetReversedEdges() == args[2]:
3919 if not args[2] or hyp.GetObjectEntry() == args[3]:
3924 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
3925 # on curve from 0 to 1 (additionally it is neecessary to check
3926 # orientation of edges and create list of reversed edges if it is
3927 # needed) and sets numbers of segments between given points (default
3928 # values are equals 1
3929 # @param points defines the list of parameters on curve
3930 # @param nbSegs defines the list of numbers of segments
3931 # @param reversedEdges is a list of edges to mesh using reversed orientation
3932 # @param UseExisting if ==true - searches for an existing hypothesis created with
3933 # the same parameters, else (default) - creates a new one
3934 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3935 # @ingroup l3_hypos_1dhyps
3936 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
3937 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3938 reversedEdges, UseExisting = [], reversedEdges
3939 entry = self.MainShapeEntry()
3940 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
3941 UseExisting=UseExisting,
3942 CompareMethod=self.CompareArithmetic1D)
3943 hyp.SetPoints(points)
3944 hyp.SetNbSegments(nbSegs)
3945 hyp.SetReversedEdges(reversedEdges)
3946 hyp.SetObjectEntry(entry)
3950 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
3951 ## as the given arguments
3952 def CompareFixedPoints1D(self, hyp, args):
3953 if hyp.GetPoints() == args[0]:
3954 if hyp.GetNbSegments() == args[1]:
3955 if hyp.GetReversedEdges() == args[2]:
3956 if not args[2] or hyp.GetObjectEntry() == args[3]:
3962 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3963 # @param start defines the length of the first segment
3964 # @param end defines the length of the last segment
3965 # @param reversedEdges is a list of edges to mesh using reversed orientation
3966 # @param UseExisting if ==true - searches for an existing hypothesis created with
3967 # the same parameters, else (default) - creates a new one
3968 # @return an instance of StdMeshers_StartEndLength hypothesis
3969 # @ingroup l3_hypos_1dhyps
3970 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3971 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3972 reversedEdges, UseExisting = [], reversedEdges
3973 entry = self.MainShapeEntry()
3974 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3975 UseExisting=UseExisting,
3976 CompareMethod=self.CompareStartEndLength)
3977 hyp.SetStartLength(start)
3978 hyp.SetEndLength(end)
3979 hyp.SetReversedEdges( reversedEdges )
3980 hyp.SetObjectEntry( entry )
3983 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3984 def CompareStartEndLength(self, hyp, args):
3985 if IsEqual(hyp.GetLength(1), args[0]):
3986 if IsEqual(hyp.GetLength(0), args[1]):
3987 if hyp.GetReversedEdges() == args[2]:
3988 if not args[2] or hyp.GetObjectEntry() == args[3]:
3992 ## Defines "Deflection1D" hypothesis
3993 # @param d for the deflection
3994 # @param UseExisting if ==true - searches for an existing hypothesis created with
3995 # the same parameters, else (default) - create a new one
3996 # @ingroup l3_hypos_1dhyps
3997 def Deflection1D(self, d, UseExisting=0):
3998 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3999 CompareMethod=self.CompareDeflection1D)
4000 hyp.SetDeflection(d)
4003 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4004 def CompareDeflection1D(self, hyp, args):
4005 return IsEqual(hyp.GetDeflection(), args[0])
4007 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4008 # the opposite side in case of quadrangular faces
4009 # @ingroup l3_hypos_additi
4010 def Propagation(self):
4011 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4013 ## Defines "AutomaticLength" hypothesis
4014 # @param fineness for the fineness [0-1]
4015 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4016 # same parameters, else (default) - create a new one
4017 # @ingroup l3_hypos_1dhyps
4018 def AutomaticLength(self, fineness=0, UseExisting=0):
4019 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4020 CompareMethod=self.CompareAutomaticLength)
4021 hyp.SetFineness( fineness )
4024 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4025 def CompareAutomaticLength(self, hyp, args):
4026 return IsEqual(hyp.GetFineness(), args[0])
4028 ## Defines "SegmentLengthAroundVertex" hypothesis
4029 # @param length for the segment length
4030 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4031 # Any other integer value means that the hypothesis will be set on the
4032 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4033 # @param UseExisting if ==true - searches for an existing hypothesis created with
4034 # the same parameters, else (default) - creates a new one
4035 # @ingroup l3_algos_segmarv
4036 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4038 store_geom = self.geom
4039 if type(vertex) is types.IntType:
4040 if vertex == 0 or vertex == 1:
4041 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4049 if self.geom is None:
4050 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4051 name = GetName(self.geom)
4053 piece = self.mesh.geom
4054 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4055 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4056 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4058 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4060 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4061 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4063 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4064 CompareMethod=self.CompareLengthNearVertex)
4065 self.geom = store_geom
4066 hyp.SetLength( length )
4069 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4070 # @ingroup l3_algos_segmarv
4071 def CompareLengthNearVertex(self, hyp, args):
4072 return IsEqual(hyp.GetLength(), args[0])
4074 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4075 # If the 2D mesher sees that all boundary edges are quadratic,
4076 # it generates quadratic faces, else it generates linear faces using
4077 # medium nodes as if they are vertices.
4078 # The 3D mesher generates quadratic volumes only if all boundary faces
4079 # are quadratic, else it fails.
4081 # @ingroup l3_hypos_additi
4082 def QuadraticMesh(self):
4083 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4086 # Public class: Mesh_CompositeSegment
4087 # --------------------------
4089 ## Defines a segment 1D algorithm for discretization
4091 # @ingroup l3_algos_basic
4092 class Mesh_CompositeSegment(Mesh_Segment):
4094 ## Private constructor.
4095 def __init__(self, mesh, geom=0):
4096 self.Create(mesh, geom, "CompositeSegment_1D")
4099 # Public class: Mesh_Segment_Python
4100 # ---------------------------------
4102 ## Defines a segment 1D algorithm for discretization with python function
4104 # @ingroup l3_algos_basic
4105 class Mesh_Segment_Python(Mesh_Segment):
4107 ## Private constructor.
4108 def __init__(self, mesh, geom=0):
4109 import Python1dPlugin
4110 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4112 ## Defines "PythonSplit1D" hypothesis
4113 # @param n for the number of segments that cut an edge
4114 # @param func for the python function that calculates the length of all segments
4115 # @param UseExisting if ==true - searches for the existing hypothesis created with
4116 # the same parameters, else (default) - creates a new one
4117 # @ingroup l3_hypos_1dhyps
4118 def PythonSplit1D(self, n, func, UseExisting=0):
4119 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4120 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4121 hyp.SetNumberOfSegments(n)
4122 hyp.SetPythonLog10RatioFunction(func)
4125 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4126 def ComparePythonSplit1D(self, hyp, args):
4127 #if hyp.GetNumberOfSegments() == args[0]:
4128 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4132 # Public class: Mesh_Triangle
4133 # ---------------------------
4135 ## Defines a triangle 2D algorithm
4137 # @ingroup l3_algos_basic
4138 class Mesh_Triangle(Mesh_Algorithm):
4147 ## Private constructor.
4148 def __init__(self, mesh, algoType, geom=0):
4149 Mesh_Algorithm.__init__(self)
4151 self.algoType = algoType
4152 if algoType == MEFISTO:
4153 self.Create(mesh, geom, "MEFISTO_2D")
4155 elif algoType == BLSURF:
4157 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4158 #self.SetPhysicalMesh() - PAL19680
4159 elif algoType == NETGEN:
4161 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4163 elif algoType == NETGEN_2D:
4165 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4168 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4169 # @param area for the maximum area of each triangle
4170 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4171 # same parameters, else (default) - creates a new one
4173 # Only for algoType == MEFISTO || NETGEN_2D
4174 # @ingroup l3_hypos_2dhyps
4175 def MaxElementArea(self, area, UseExisting=0):
4176 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4177 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4178 CompareMethod=self.CompareMaxElementArea)
4179 elif self.algoType == NETGEN:
4180 hyp = self.Parameters(SIMPLE)
4181 hyp.SetMaxElementArea(area)
4184 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4185 def CompareMaxElementArea(self, hyp, args):
4186 return IsEqual(hyp.GetMaxElementArea(), args[0])
4188 ## Defines "LengthFromEdges" hypothesis to build triangles
4189 # based on the length of the edges taken from the wire
4191 # Only for algoType == MEFISTO || NETGEN_2D
4192 # @ingroup l3_hypos_2dhyps
4193 def LengthFromEdges(self):
4194 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4195 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4197 elif self.algoType == NETGEN:
4198 hyp = self.Parameters(SIMPLE)
4199 hyp.LengthFromEdges()
4202 ## Sets a way to define size of mesh elements to generate.
4203 # @param thePhysicalMesh is: DefaultSize or Custom.
4204 # @ingroup l3_hypos_blsurf
4205 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4206 # Parameter of BLSURF algo
4207 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4209 ## Sets size of mesh elements to generate.
4210 # @ingroup l3_hypos_blsurf
4211 def SetPhySize(self, theVal):
4212 # Parameter of BLSURF algo
4213 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4214 self.Parameters().SetPhySize(theVal)
4216 ## Sets lower boundary of mesh element size (PhySize).
4217 # @ingroup l3_hypos_blsurf
4218 def SetPhyMin(self, theVal=-1):
4219 # Parameter of BLSURF algo
4220 self.Parameters().SetPhyMin(theVal)
4222 ## Sets upper boundary of mesh element size (PhySize).
4223 # @ingroup l3_hypos_blsurf
4224 def SetPhyMax(self, theVal=-1):
4225 # Parameter of BLSURF algo
4226 self.Parameters().SetPhyMax(theVal)
4228 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4229 # @param theGeometricMesh is: DefaultGeom or Custom
4230 # @ingroup l3_hypos_blsurf
4231 def SetGeometricMesh(self, theGeometricMesh=0):
4232 # Parameter of BLSURF algo
4233 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4234 self.params.SetGeometricMesh(theGeometricMesh)
4236 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4237 # @ingroup l3_hypos_blsurf
4238 def SetAngleMeshS(self, theVal=_angleMeshS):
4239 # Parameter of BLSURF algo
4240 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4241 self.params.SetAngleMeshS(theVal)
4243 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4244 # @ingroup l3_hypos_blsurf
4245 def SetAngleMeshC(self, theVal=_angleMeshS):
4246 # Parameter of BLSURF algo
4247 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4248 self.params.SetAngleMeshC(theVal)
4250 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4251 # @ingroup l3_hypos_blsurf
4252 def SetGeoMin(self, theVal=-1):
4253 # Parameter of BLSURF algo
4254 self.Parameters().SetGeoMin(theVal)
4256 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4257 # @ingroup l3_hypos_blsurf
4258 def SetGeoMax(self, theVal=-1):
4259 # Parameter of BLSURF algo
4260 self.Parameters().SetGeoMax(theVal)
4262 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4263 # @ingroup l3_hypos_blsurf
4264 def SetGradation(self, theVal=_gradation):
4265 # Parameter of BLSURF algo
4266 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4267 self.params.SetGradation(theVal)
4269 ## Sets topology usage way.
4270 # @param way defines how mesh conformity is assured <ul>
4271 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4272 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4273 # @ingroup l3_hypos_blsurf
4274 def SetTopology(self, way):
4275 # Parameter of BLSURF algo
4276 self.Parameters().SetTopology(way)
4278 ## To respect geometrical edges or not.
4279 # @ingroup l3_hypos_blsurf
4280 def SetDecimesh(self, toIgnoreEdges=False):
4281 # Parameter of BLSURF algo
4282 self.Parameters().SetDecimesh(toIgnoreEdges)
4284 ## Sets verbosity level in the range 0 to 100.
4285 # @ingroup l3_hypos_blsurf
4286 def SetVerbosity(self, level):
4287 # Parameter of BLSURF algo
4288 self.Parameters().SetVerbosity(level)
4290 ## Sets advanced option value.
4291 # @ingroup l3_hypos_blsurf
4292 def SetOptionValue(self, optionName, level):
4293 # Parameter of BLSURF algo
4294 self.Parameters().SetOptionValue(optionName,level)
4296 ## Sets QuadAllowed flag.
4297 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4298 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4299 def SetQuadAllowed(self, toAllow=True):
4300 if self.algoType == NETGEN_2D:
4301 if toAllow: # add QuadranglePreference
4302 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4303 else: # remove QuadranglePreference
4304 for hyp in self.mesh.GetHypothesisList( self.geom ):
4305 if hyp.GetName() == "QuadranglePreference":
4306 self.mesh.RemoveHypothesis( self.geom, hyp )
4311 if self.Parameters():
4312 self.params.SetQuadAllowed(toAllow)
4315 ## Defines hypothesis having several parameters
4317 # @ingroup l3_hypos_netgen
4318 def Parameters(self, which=SOLE):
4321 if self.algoType == NETGEN:
4323 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4324 "libNETGENEngine.so", UseExisting=0)
4326 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4327 "libNETGENEngine.so", UseExisting=0)
4329 elif self.algoType == MEFISTO:
4330 print "Mefisto algo support no multi-parameter hypothesis"
4332 elif self.algoType == NETGEN_2D:
4333 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4334 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4336 elif self.algoType == BLSURF:
4337 self.params = self.Hypothesis("BLSURF_Parameters", [],
4338 "libBLSURFEngine.so", UseExisting=0)
4341 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4346 # Only for algoType == NETGEN
4347 # @ingroup l3_hypos_netgen
4348 def SetMaxSize(self, theSize):
4349 if self.Parameters():
4350 self.params.SetMaxSize(theSize)
4352 ## Sets SecondOrder flag
4354 # Only for algoType == NETGEN
4355 # @ingroup l3_hypos_netgen
4356 def SetSecondOrder(self, theVal):
4357 if self.Parameters():
4358 self.params.SetSecondOrder(theVal)
4360 ## Sets Optimize flag
4362 # Only for algoType == NETGEN
4363 # @ingroup l3_hypos_netgen
4364 def SetOptimize(self, theVal):
4365 if self.Parameters():
4366 self.params.SetOptimize(theVal)
4369 # @param theFineness is:
4370 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4372 # Only for algoType == NETGEN
4373 # @ingroup l3_hypos_netgen
4374 def SetFineness(self, theFineness):
4375 if self.Parameters():
4376 self.params.SetFineness(theFineness)
4380 # Only for algoType == NETGEN
4381 # @ingroup l3_hypos_netgen
4382 def SetGrowthRate(self, theRate):
4383 if self.Parameters():
4384 self.params.SetGrowthRate(theRate)
4386 ## Sets NbSegPerEdge
4388 # Only for algoType == NETGEN
4389 # @ingroup l3_hypos_netgen
4390 def SetNbSegPerEdge(self, theVal):
4391 if self.Parameters():
4392 self.params.SetNbSegPerEdge(theVal)
4394 ## Sets NbSegPerRadius
4396 # Only for algoType == NETGEN
4397 # @ingroup l3_hypos_netgen
4398 def SetNbSegPerRadius(self, theVal):
4399 if self.Parameters():
4400 self.params.SetNbSegPerRadius(theVal)
4402 ## Sets number of segments overriding value set by SetLocalLength()
4404 # Only for algoType == NETGEN
4405 # @ingroup l3_hypos_netgen
4406 def SetNumberOfSegments(self, theVal):
4407 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4409 ## Sets number of segments overriding value set by SetNumberOfSegments()
4411 # Only for algoType == NETGEN
4412 # @ingroup l3_hypos_netgen
4413 def SetLocalLength(self, theVal):
4414 self.Parameters(SIMPLE).SetLocalLength(theVal)
4419 # Public class: Mesh_Quadrangle
4420 # -----------------------------
4422 ## Defines a quadrangle 2D algorithm
4424 # @ingroup l3_algos_basic
4425 class Mesh_Quadrangle(Mesh_Algorithm):
4427 ## Private constructor.
4428 def __init__(self, mesh, geom=0):
4429 Mesh_Algorithm.__init__(self)
4430 self.Create(mesh, geom, "Quadrangle_2D")
4432 ## Defines "QuadranglePreference" hypothesis, forcing construction
4433 # of quadrangles if the number of nodes on the opposite edges is not the same
4434 # while the total number of nodes on edges is even
4436 # @ingroup l3_hypos_additi
4437 def QuadranglePreference(self):
4438 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4439 CompareMethod=self.CompareEqualHyp)
4442 ## Defines "TrianglePreference" hypothesis, forcing construction
4443 # of triangles in the refinement area if the number of nodes
4444 # on the opposite edges is not the same
4446 # @ingroup l3_hypos_additi
4447 def TrianglePreference(self):
4448 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4449 CompareMethod=self.CompareEqualHyp)
4452 # Public class: Mesh_Tetrahedron
4453 # ------------------------------
4455 ## Defines a tetrahedron 3D algorithm
4457 # @ingroup l3_algos_basic
4458 class Mesh_Tetrahedron(Mesh_Algorithm):
4463 ## Private constructor.
4464 def __init__(self, mesh, algoType, geom=0):
4465 Mesh_Algorithm.__init__(self)
4467 if algoType == NETGEN:
4469 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4472 elif algoType == FULL_NETGEN:
4474 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4477 elif algoType == GHS3D:
4479 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4482 elif algoType == GHS3DPRL:
4483 CheckPlugin(GHS3DPRL)
4484 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4487 self.algoType = algoType
4489 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4490 # @param vol for the maximum volume of each tetrahedron
4491 # @param UseExisting if ==true - searches for the existing hypothesis created with
4492 # the same parameters, else (default) - creates a new one
4493 # @ingroup l3_hypos_maxvol
4494 def MaxElementVolume(self, vol, UseExisting=0):
4495 if self.algoType == NETGEN:
4496 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4497 CompareMethod=self.CompareMaxElementVolume)
4498 hyp.SetMaxElementVolume(vol)
4500 elif self.algoType == FULL_NETGEN:
4501 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4504 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4505 def CompareMaxElementVolume(self, hyp, args):
4506 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4508 ## Defines hypothesis having several parameters
4510 # @ingroup l3_hypos_netgen
4511 def Parameters(self, which=SOLE):
4515 if self.algoType == FULL_NETGEN:
4517 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4518 "libNETGENEngine.so", UseExisting=0)
4520 self.params = self.Hypothesis("NETGEN_Parameters", [],
4521 "libNETGENEngine.so", UseExisting=0)
4524 if self.algoType == GHS3D:
4525 self.params = self.Hypothesis("GHS3D_Parameters", [],
4526 "libGHS3DEngine.so", UseExisting=0)
4529 if self.algoType == GHS3DPRL:
4530 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4531 "libGHS3DPRLEngine.so", UseExisting=0)
4534 print "Algo supports no multi-parameter hypothesis"
4538 # Parameter of FULL_NETGEN
4539 # @ingroup l3_hypos_netgen
4540 def SetMaxSize(self, theSize):
4541 self.Parameters().SetMaxSize(theSize)
4543 ## Sets SecondOrder flag
4544 # Parameter of FULL_NETGEN
4545 # @ingroup l3_hypos_netgen
4546 def SetSecondOrder(self, theVal):
4547 self.Parameters().SetSecondOrder(theVal)
4549 ## Sets Optimize flag
4550 # Parameter of FULL_NETGEN
4551 # @ingroup l3_hypos_netgen
4552 def SetOptimize(self, theVal):
4553 self.Parameters().SetOptimize(theVal)
4556 # @param theFineness is:
4557 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4558 # Parameter of FULL_NETGEN
4559 # @ingroup l3_hypos_netgen
4560 def SetFineness(self, theFineness):
4561 self.Parameters().SetFineness(theFineness)
4564 # Parameter of FULL_NETGEN
4565 # @ingroup l3_hypos_netgen
4566 def SetGrowthRate(self, theRate):
4567 self.Parameters().SetGrowthRate(theRate)
4569 ## Sets NbSegPerEdge
4570 # Parameter of FULL_NETGEN
4571 # @ingroup l3_hypos_netgen
4572 def SetNbSegPerEdge(self, theVal):
4573 self.Parameters().SetNbSegPerEdge(theVal)
4575 ## Sets NbSegPerRadius
4576 # Parameter of FULL_NETGEN
4577 # @ingroup l3_hypos_netgen
4578 def SetNbSegPerRadius(self, theVal):
4579 self.Parameters().SetNbSegPerRadius(theVal)
4581 ## Sets number of segments overriding value set by SetLocalLength()
4582 # Only for algoType == NETGEN_FULL
4583 # @ingroup l3_hypos_netgen
4584 def SetNumberOfSegments(self, theVal):
4585 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4587 ## Sets number of segments overriding value set by SetNumberOfSegments()
4588 # Only for algoType == NETGEN_FULL
4589 # @ingroup l3_hypos_netgen
4590 def SetLocalLength(self, theVal):
4591 self.Parameters(SIMPLE).SetLocalLength(theVal)
4593 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4594 # Overrides value set by LengthFromEdges()
4595 # Only for algoType == NETGEN_FULL
4596 # @ingroup l3_hypos_netgen
4597 def MaxElementArea(self, area):
4598 self.Parameters(SIMPLE).SetMaxElementArea(area)
4600 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4601 # Overrides value set by MaxElementArea()
4602 # Only for algoType == NETGEN_FULL
4603 # @ingroup l3_hypos_netgen
4604 def LengthFromEdges(self):
4605 self.Parameters(SIMPLE).LengthFromEdges()
4607 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4608 # Overrides value set by MaxElementVolume()
4609 # Only for algoType == NETGEN_FULL
4610 # @ingroup l3_hypos_netgen
4611 def LengthFromFaces(self):
4612 self.Parameters(SIMPLE).LengthFromFaces()
4614 ## To mesh "holes" in a solid or not. Default is to mesh.
4615 # @ingroup l3_hypos_ghs3dh
4616 def SetToMeshHoles(self, toMesh):
4617 # Parameter of GHS3D
4618 self.Parameters().SetToMeshHoles(toMesh)
4620 ## Set Optimization level:
4621 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4622 # Strong_Optimization.
4623 # Default is Standard_Optimization
4624 # @ingroup l3_hypos_ghs3dh
4625 def SetOptimizationLevel(self, level):
4626 # Parameter of GHS3D
4627 self.Parameters().SetOptimizationLevel(level)
4629 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4630 # @ingroup l3_hypos_ghs3dh
4631 def SetMaximumMemory(self, MB):
4632 # Advanced parameter of GHS3D
4633 self.Parameters().SetMaximumMemory(MB)
4635 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4636 # automatic memory adjustment mode.
4637 # @ingroup l3_hypos_ghs3dh
4638 def SetInitialMemory(self, MB):
4639 # Advanced parameter of GHS3D
4640 self.Parameters().SetInitialMemory(MB)
4642 ## Path to working directory.
4643 # @ingroup l3_hypos_ghs3dh
4644 def SetWorkingDirectory(self, path):
4645 # Advanced parameter of GHS3D
4646 self.Parameters().SetWorkingDirectory(path)
4648 ## To keep working files or remove them. Log file remains in case of errors anyway.
4649 # @ingroup l3_hypos_ghs3dh
4650 def SetKeepFiles(self, toKeep):
4651 # Advanced parameter of GHS3D and GHS3DPRL
4652 self.Parameters().SetKeepFiles(toKeep)
4654 ## To set verbose level [0-10]. <ul>
4655 #<li> 0 - no standard output,
4656 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4657 # indicates when the final mesh is being saved. In addition the software
4658 # gives indication regarding the CPU time.
4659 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4660 # histogram of the skin mesh, quality statistics histogram together with
4661 # the characteristics of the final mesh.</ul>
4662 # @ingroup l3_hypos_ghs3dh
4663 def SetVerboseLevel(self, level):
4664 # Advanced parameter of GHS3D
4665 self.Parameters().SetVerboseLevel(level)
4667 ## To create new nodes.
4668 # @ingroup l3_hypos_ghs3dh
4669 def SetToCreateNewNodes(self, toCreate):
4670 # Advanced parameter of GHS3D
4671 self.Parameters().SetToCreateNewNodes(toCreate)
4673 ## To use boundary recovery version which tries to create mesh on a very poor
4674 # quality surface mesh.
4675 # @ingroup l3_hypos_ghs3dh
4676 def SetToUseBoundaryRecoveryVersion(self, toUse):
4677 # Advanced parameter of GHS3D
4678 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4680 ## Sets command line option as text.
4681 # @ingroup l3_hypos_ghs3dh
4682 def SetTextOption(self, option):
4683 # Advanced parameter of GHS3D
4684 self.Parameters().SetTextOption(option)
4686 ## Sets MED files name and path.
4687 def SetMEDName(self, value):
4688 self.Parameters().SetMEDName(value)
4690 ## Sets the number of partition of the initial mesh
4691 def SetNbPart(self, value):
4692 self.Parameters().SetNbPart(value)
4694 ## When big mesh, start tepal in background
4695 def SetBackground(self, value):
4696 self.Parameters().SetBackground(value)
4698 # Public class: Mesh_Hexahedron
4699 # ------------------------------
4701 ## Defines a hexahedron 3D algorithm
4703 # @ingroup l3_algos_basic
4704 class Mesh_Hexahedron(Mesh_Algorithm):
4709 ## Private constructor.
4710 def __init__(self, mesh, algoType=Hexa, geom=0):
4711 Mesh_Algorithm.__init__(self)
4713 self.algoType = algoType
4715 if algoType == Hexa:
4716 self.Create(mesh, geom, "Hexa_3D")
4719 elif algoType == Hexotic:
4720 CheckPlugin(Hexotic)
4721 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4724 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4725 # @ingroup l3_hypos_hexotic
4726 def MinMaxQuad(self, min=3, max=8, quad=True):
4727 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4729 self.params.SetHexesMinLevel(min)
4730 self.params.SetHexesMaxLevel(max)
4731 self.params.SetHexoticQuadrangles(quad)
4734 # Deprecated, only for compatibility!
4735 # Public class: Mesh_Netgen
4736 # ------------------------------
4738 ## Defines a NETGEN-based 2D or 3D algorithm
4739 # that needs no discrete boundary (i.e. independent)
4741 # This class is deprecated, only for compatibility!
4744 # @ingroup l3_algos_basic
4745 class Mesh_Netgen(Mesh_Algorithm):
4749 ## Private constructor.
4750 def __init__(self, mesh, is3D, geom=0):
4751 Mesh_Algorithm.__init__(self)
4757 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4761 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4764 ## Defines the hypothesis containing parameters of the algorithm
4765 def Parameters(self):
4767 hyp = self.Hypothesis("NETGEN_Parameters", [],
4768 "libNETGENEngine.so", UseExisting=0)
4770 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4771 "libNETGENEngine.so", UseExisting=0)
4774 # Public class: Mesh_Projection1D
4775 # ------------------------------
4777 ## Defines a projection 1D algorithm
4778 # @ingroup l3_algos_proj
4780 class Mesh_Projection1D(Mesh_Algorithm):
4782 ## Private constructor.
4783 def __init__(self, mesh, geom=0):
4784 Mesh_Algorithm.__init__(self)
4785 self.Create(mesh, geom, "Projection_1D")
4787 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4788 # a mesh pattern is taken, and, optionally, the association of vertices
4789 # between the source edge and a target edge (to which a hypothesis is assigned)
4790 # @param edge from which nodes distribution is taken
4791 # @param mesh from which nodes distribution is taken (optional)
4792 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4793 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4794 # to associate with \a srcV (optional)
4795 # @param UseExisting if ==true - searches for the existing hypothesis created with
4796 # the same parameters, else (default) - creates a new one
4797 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4798 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4800 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4801 hyp.SetSourceEdge( edge )
4802 if not mesh is None and isinstance(mesh, Mesh):
4803 mesh = mesh.GetMesh()
4804 hyp.SetSourceMesh( mesh )
4805 hyp.SetVertexAssociation( srcV, tgtV )
4808 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4809 #def CompareSourceEdge(self, hyp, args):
4810 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4814 # Public class: Mesh_Projection2D
4815 # ------------------------------
4817 ## Defines a projection 2D algorithm
4818 # @ingroup l3_algos_proj
4820 class Mesh_Projection2D(Mesh_Algorithm):
4822 ## Private constructor.
4823 def __init__(self, mesh, geom=0):
4824 Mesh_Algorithm.__init__(self)
4825 self.Create(mesh, geom, "Projection_2D")
4827 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4828 # a mesh pattern is taken, and, optionally, the association of vertices
4829 # between the source face and the target face (to which a hypothesis is assigned)
4830 # @param face from which the mesh pattern is taken
4831 # @param mesh from which the mesh pattern is taken (optional)
4832 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4833 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4834 # to associate with \a srcV1 (optional)
4835 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4836 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4837 # to associate with \a srcV2 (optional)
4838 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4839 # the same parameters, else (default) - forces the creation a new one
4841 # Note: all association vertices must belong to one edge of a face
4842 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4843 srcV2=None, tgtV2=None, UseExisting=0):
4844 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4846 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4847 hyp.SetSourceFace( face )
4848 if not mesh is None and isinstance(mesh, Mesh):
4849 mesh = mesh.GetMesh()
4850 hyp.SetSourceMesh( mesh )
4851 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4854 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4855 #def CompareSourceFace(self, hyp, args):
4856 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4859 # Public class: Mesh_Projection3D
4860 # ------------------------------
4862 ## Defines a projection 3D algorithm
4863 # @ingroup l3_algos_proj
4865 class Mesh_Projection3D(Mesh_Algorithm):
4867 ## Private constructor.
4868 def __init__(self, mesh, geom=0):
4869 Mesh_Algorithm.__init__(self)
4870 self.Create(mesh, geom, "Projection_3D")
4872 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4873 # the mesh pattern is taken, and, optionally, the association of vertices
4874 # between the source and the target solid (to which a hipothesis is assigned)
4875 # @param solid from where the mesh pattern is taken
4876 # @param mesh from where the mesh pattern is taken (optional)
4877 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4878 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4879 # to associate with \a srcV1 (optional)
4880 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4881 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4882 # to associate with \a srcV2 (optional)
4883 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4884 # the same parameters, else (default) - creates a new one
4886 # Note: association vertices must belong to one edge of a solid
4887 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4888 srcV2=0, tgtV2=0, UseExisting=0):
4889 hyp = self.Hypothesis("ProjectionSource3D",
4890 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4892 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4893 hyp.SetSource3DShape( solid )
4894 if not mesh is None and isinstance(mesh, Mesh):
4895 mesh = mesh.GetMesh()
4896 hyp.SetSourceMesh( mesh )
4897 if srcV1 and srcV2 and tgtV1 and tgtV2:
4898 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4899 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4902 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4903 #def CompareSourceShape3D(self, hyp, args):
4904 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4908 # Public class: Mesh_Prism
4909 # ------------------------
4911 ## Defines a 3D extrusion algorithm
4912 # @ingroup l3_algos_3dextr
4914 class Mesh_Prism3D(Mesh_Algorithm):
4916 ## Private constructor.
4917 def __init__(self, mesh, geom=0):
4918 Mesh_Algorithm.__init__(self)
4919 self.Create(mesh, geom, "Prism_3D")
4921 # Public class: Mesh_RadialPrism
4922 # -------------------------------
4924 ## Defines a Radial Prism 3D algorithm
4925 # @ingroup l3_algos_radialp
4927 class Mesh_RadialPrism3D(Mesh_Algorithm):
4929 ## Private constructor.
4930 def __init__(self, mesh, geom=0):
4931 Mesh_Algorithm.__init__(self)
4932 self.Create(mesh, geom, "RadialPrism_3D")
4934 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4935 self.nbLayers = None
4937 ## Return 3D hypothesis holding the 1D one
4938 def Get3DHypothesis(self):
4939 return self.distribHyp
4941 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4942 # hypothesis. Returns the created hypothesis
4943 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4944 #print "OwnHypothesis",hypType
4945 if not self.nbLayers is None:
4946 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4947 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4948 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4949 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4950 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4951 self.distribHyp.SetLayerDistribution( hyp )
4954 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4955 # prisms to build between the inner and outer shells
4956 # @param n number of layers
4957 # @param UseExisting if ==true - searches for the existing hypothesis created with
4958 # the same parameters, else (default) - creates a new one
4959 def NumberOfLayers(self, n, UseExisting=0):
4960 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4961 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4962 CompareMethod=self.CompareNumberOfLayers)
4963 self.nbLayers.SetNumberOfLayers( n )
4964 return self.nbLayers
4966 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4967 def CompareNumberOfLayers(self, hyp, args):
4968 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4970 ## Defines "LocalLength" hypothesis, specifying the segment length
4971 # to build between the inner and the outer shells
4972 # @param l the length of segments
4973 # @param p the precision of rounding
4974 def LocalLength(self, l, p=1e-07):
4975 hyp = self.OwnHypothesis("LocalLength", [l,p])
4980 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4981 # prisms to build between the inner and the outer shells.
4982 # @param n the number of layers
4983 # @param s the scale factor (optional)
4984 def NumberOfSegments(self, n, s=[]):
4986 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4988 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4989 hyp.SetDistrType( 1 )
4990 hyp.SetScaleFactor(s)
4991 hyp.SetNumberOfSegments(n)
4994 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4995 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4996 # @param start the length of the first segment
4997 # @param end the length of the last segment
4998 def Arithmetic1D(self, start, end ):
4999 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5000 hyp.SetLength(start, 1)
5001 hyp.SetLength(end , 0)
5004 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5005 # to build between the inner and the outer shells as geometric length increasing
5006 # @param start for the length of the first segment
5007 # @param end for the length of the last segment
5008 def StartEndLength(self, start, end):
5009 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5010 hyp.SetLength(start, 1)
5011 hyp.SetLength(end , 0)
5014 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5015 # to build between the inner and outer shells
5016 # @param fineness defines the quality of the mesh within the range [0-1]
5017 def AutomaticLength(self, fineness=0):
5018 hyp = self.OwnHypothesis("AutomaticLength")
5019 hyp.SetFineness( fineness )
5022 # Public class: Mesh_RadialQuadrangle1D2D
5023 # -------------------------------
5025 ## Defines a Radial Quadrangle 1D2D algorithm
5026 # @ingroup l2_algos_radialq
5028 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5030 ## Private constructor.
5031 def __init__(self, mesh, geom=0):
5032 Mesh_Algorithm.__init__(self)
5033 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5035 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5036 self.nbLayers = None
5038 ## Return 2D hypothesis holding the 1D one
5039 def Get2DHypothesis(self):
5040 return self.distribHyp
5042 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5043 # hypothesis. Returns the created hypothesis
5044 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5045 #print "OwnHypothesis",hypType
5046 if not self.nbLayers is None:
5047 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5048 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5049 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5050 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5051 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5052 self.distribHyp.SetLayerDistribution( hyp )
5055 ## Defines "NumberOfLayers2D" hypothesis, specifying the number of layers
5056 # @param n number of layers
5057 # @param UseExisting if ==true - searches for the existing hypothesis created with
5058 # the same parameters, else (default) - creates a new one
5059 def NumberOfLayers2D(self, n, UseExisting=0):
5060 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5061 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5062 CompareMethod=self.CompareNumberOfLayers)
5063 self.nbLayers.SetNumberOfLayers( n )
5064 return self.nbLayers
5066 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5067 def CompareNumberOfLayers(self, hyp, args):
5068 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5070 ## Defines "LocalLength" hypothesis, specifying the segment length
5071 # @param l the length of segments
5072 # @param p the precision of rounding
5073 def LocalLength(self, l, p=1e-07):
5074 hyp = self.OwnHypothesis("LocalLength", [l,p])
5079 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5080 # @param n the number of layers
5081 # @param s the scale factor (optional)
5082 def NumberOfSegments(self, n, s=[]):
5084 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5086 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5087 hyp.SetDistrType( 1 )
5088 hyp.SetScaleFactor(s)
5089 hyp.SetNumberOfSegments(n)
5092 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5093 # with a length that changes in arithmetic progression
5094 # @param start the length of the first segment
5095 # @param end the length of the last segment
5096 def Arithmetic1D(self, start, end ):
5097 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5098 hyp.SetLength(start, 1)
5099 hyp.SetLength(end , 0)
5102 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5103 # as geometric length increasing
5104 # @param start for the length of the first segment
5105 # @param end for the length of the last segment
5106 def StartEndLength(self, start, end):
5107 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5108 hyp.SetLength(start, 1)
5109 hyp.SetLength(end , 0)
5112 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5113 # @param fineness defines the quality of the mesh within the range [0-1]
5114 def AutomaticLength(self, fineness=0):
5115 hyp = self.OwnHypothesis("AutomaticLength")
5116 hyp.SetFineness( fineness )
5120 # Private class: Mesh_UseExisting
5121 # -------------------------------
5122 class Mesh_UseExisting(Mesh_Algorithm):
5124 def __init__(self, dim, mesh, geom=0):
5126 self.Create(mesh, geom, "UseExisting_1D")
5128 self.Create(mesh, geom, "UseExisting_2D")
5131 import salome_notebook
5132 notebook = salome_notebook.notebook
5134 ##Return values of the notebook variables
5135 def ParseParameters(last, nbParams, nbParam, value):
5136 #print "ParseParameters", last, nbParams, nbParam, value
5140 listSize = len(last)
5141 for n in range(0,nbParams):
5143 if counter < listSize:
5144 strResult.append( last[counter] )
5146 strResult = strResult
5148 strResult.append(ParseString(value))
5149 result = ParseValue(value)
5151 return result, strResult
5153 #Wrapper class for StdMeshers_LocalLength hypothesis
5154 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5156 ## Set Length parameter value
5157 # @param length numerical value or name of variable from notebook
5158 def SetLength(self, length):
5159 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetParameters(self),2,1,length)
5160 geompyDC.SetParameters(self, parameters)
5161 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5163 ## Set Precision parameter value
5164 # @param precision numerical value or name of variable from notebook
5165 def SetPrecision(self, precision):
5166 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetParameters(self),2,2,precision)
5167 geompyDC.SetParameters(self, parameters)
5168 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5170 #Registering the new proxy for LocalLength
5171 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5174 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5175 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5177 def SetLayerDistribution(self, hypo):
5178 geompyDC.SetParameters(self, hypo.GetParameters())
5179 geompyDC.SetParameters(hypo, [])
5180 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5182 #Registering the new proxy for LayerDistribution
5183 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5185 #Wrapper class for StdMeshers_LayerDistribution2D hypothesis
5186 class LayerDistribution2D(StdMeshers._objref_StdMeshers_LayerDistribution2D):
5188 def SetLayerDistribution(self, hypo):
5189 geompyDC.SetParameters(self, hypo.GetParameters())
5190 geompyDC.SetParameters(hypo, [])
5191 StdMeshers._objref_StdMeshers_LayerDistribution2D.SetLayerDistribution(self,hypo)
5193 #Registering the new proxy for LayerDistribution
5194 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution2D._NP_RepositoryId, LayerDistribution2D)
5196 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5197 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5199 ## Set Length parameter value
5200 # @param length numerical value or name of variable from notebook
5201 def SetLength(self, length):
5202 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetParameters(self),1,1,length)
5203 geompyDC.SetParameters(self, parameters)
5204 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5206 #Registering the new proxy for SegmentLengthAroundVertex
5207 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5210 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5211 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5213 ## Set Length parameter value
5214 # @param length numerical value or name of variable from notebook
5215 # @param isStart true is length is Start Length, otherwise false
5216 def SetLength(self, length, isStart):
5220 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetParameters(self),2,nb,length)
5221 geompyDC.SetParameters(self, parameters)
5222 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5224 ## Set Start Length parameter value
5225 # @param length numerical value or name of variable from notebook
5226 def SetStartLength(self, length):
5227 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetParameters(self),2,1,length)
5228 geompyDC.SetParameters(self, parameters)
5229 StdMeshers._objref_StdMeshers_Arithmetic1D.SetStartLength(self,length)
5231 ## Set End Length parameter value
5232 # @param length numerical value or name of variable from notebook
5233 def SetEndLength(self, length):
5234 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetParameters(self),2,2,length)
5235 geompyDC.SetParameters(self, parameters)
5236 StdMeshers._objref_StdMeshers_Arithmetic1D.SetEndLength(self,length)
5238 #Registering the new proxy for Arithmetic1D
5239 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5241 #Wrapper class for StdMeshers_Deflection1D hypothesis
5242 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5244 ## Set Deflection parameter value
5245 # @param deflection numerical value or name of variable from notebook
5246 def SetDeflection(self, deflection):
5247 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetParameters(self),1,1,deflection)
5248 geompyDC.SetParameters(self, parameters)
5249 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5251 #Registering the new proxy for Deflection1D
5252 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5254 #Wrapper class for StdMeshers_StartEndLength hypothesis
5255 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5257 ## Set Length parameter value
5258 # @param length numerical value or name of variable from notebook
5259 # @param isStart true is length is Start Length, otherwise false
5260 def SetLength(self, length, isStart):
5264 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetParameters(self),2,nb,length)
5265 geompyDC.SetParameters(self, parameters)
5266 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5268 #Registering the new proxy for StartEndLength
5269 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5271 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5272 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5274 ## Set Max Element Area parameter value
5275 # @param area numerical value or name of variable from notebook
5276 def SetMaxElementArea(self, area):
5277 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetParameters(self),1,1,area)
5278 geompyDC.SetParameters(self, parameters)
5279 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5281 #Registering the new proxy for MaxElementArea
5282 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5285 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5286 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5288 ## Set Max Element Volume parameter value
5289 # @param volume numerical value or name of variable from notebook
5290 def SetMaxElementVolume(self, volume):
5291 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetParameters(self),1,1,volume)
5292 geompyDC.SetParameters(self, parameters)
5293 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5295 #Registering the new proxy for MaxElementVolume
5296 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5299 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5300 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5302 ## Set Number Of Layers parameter value
5303 # @param nbLayers numerical value or name of variable from notebook
5304 def SetNumberOfLayers(self, nbLayers):
5305 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetParameters(self),1,1,nbLayers)
5306 geompyDC.SetParameters(self, parameters)
5307 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5309 #Registering the new proxy for NumberOfLayers
5310 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5312 #Wrapper class for StdMeshers_NumberOfLayers2D hypothesis
5313 class NumberOfLayers2D(StdMeshers._objref_StdMeshers_NumberOfLayers2D):
5315 ## Set Number Of Layers parameter value
5316 # @param nbLayers numerical value or name of variable from notebook
5317 def SetNumberOfLayers(self, nbLayers):
5318 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers2D.GetParameters(self),1,1,nbLayers)
5319 geompyDC.SetParameters(self, parameters)
5320 StdMeshers._objref_StdMeshers_NumberOfLayers2D.SetNumberOfLayers(self,nbLayers)
5322 #Registering the new proxy for NumberOfLayers2D
5323 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers2D._NP_RepositoryId, NumberOfLayers2D)
5325 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5326 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5328 ## Set Number Of Segments parameter value
5329 # @param nbSeg numerical value or name of variable from notebook
5330 def SetNumberOfSegments(self, nbSeg):
5331 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetParameters(self)
5332 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5333 geompyDC.SetParameters(self, parameters)
5334 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5336 ## Set Scale Factor parameter value
5337 # @param factor numerical value or name of variable from notebook
5338 def SetScaleFactor(self, factor):
5339 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetParameters(self),2,2,factor)
5340 geompyDC.SetParameters(self, parameters)
5341 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5343 #Registering the new proxy for NumberOfSegments
5344 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5346 if not noNETGENPlugin:
5347 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5348 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5350 ## Set Max Size parameter value
5351 # @param maxsize numerical value or name of variable from notebook
5352 def SetMaxSize(self, maxsize):
5353 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetParameters(self)
5354 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5355 geompyDC.SetParameters(self, parameters)
5356 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5358 ## Set Growth Rate parameter value
5359 # @param value numerical value or name of variable from notebook
5360 def SetGrowthRate(self, value):
5361 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetParameters(self)
5362 value, parameters = ParseParameters(lastParameters,4,2,value)
5363 geompyDC.SetParameters(self, parameters)
5364 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5366 ## Set Number of Segments per Edge parameter value
5367 # @param value numerical value or name of variable from notebook
5368 def SetNbSegPerEdge(self, value):
5369 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetParameters(self)
5370 value, parameters = ParseParameters(lastParameters,4,3,value)
5371 geompyDC.SetParameters(self, parameters)
5372 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5374 ## Set Number of Segments per Radius parameter value
5375 # @param value numerical value or name of variable from notebook
5376 def SetNbSegPerRadius(self, value):
5377 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetParameters(self)
5378 value, parameters = ParseParameters(lastParameters,4,4,value)
5379 geompyDC.SetParameters(self, parameters)
5380 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5382 #Registering the new proxy for NETGENPlugin_Hypothesis
5383 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5386 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5387 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5390 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5391 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5393 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5394 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5396 ## Set Number of Segments parameter value
5397 # @param nbSeg numerical value or name of variable from notebook
5398 def SetNumberOfSegments(self, nbSeg):
5399 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetParameters(self)
5400 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5401 geompyDC.SetParameters(self, parameters)
5402 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5404 ## Set Local Length parameter value
5405 # @param length numerical value or name of variable from notebook
5406 def SetLocalLength(self, length):
5407 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetParameters(self)
5408 length, parameters = ParseParameters(lastParameters,2,1,length)
5409 geompyDC.SetParameters(self, parameters)
5410 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5412 ## Set Max Element Area parameter value
5413 # @param area numerical value or name of variable from notebook
5414 def SetMaxElementArea(self, area):
5415 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetParameters(self)
5416 area, parameters = ParseParameters(lastParameters,2,2,area)
5417 geompyDC.SetParameters(self, parameters)
5418 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5420 def LengthFromEdges(self):
5421 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetParameters(self)
5423 value, parameters = ParseParameters(lastParameters,2,2,value)
5424 geompyDC.SetParameters(self, parameters)
5425 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5427 #Registering the new proxy for NETGEN_SimpleParameters_2D
5428 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5431 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5432 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5433 ## Set Max Element Volume parameter value
5434 # @param volume numerical value or name of variable from notebook
5435 def SetMaxElementVolume(self, volume):
5436 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetParameters(self)
5437 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5438 geompyDC.SetParameters(self, parameters)
5439 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5441 def LengthFromFaces(self):
5442 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetParameters(self)
5444 value, parameters = ParseParameters(lastParameters,3,3,value)
5445 geompyDC.SetParameters(self, parameters)
5446 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5448 #Registering the new proxy for NETGEN_SimpleParameters_3D
5449 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5451 pass # if not noNETGENPlugin:
5453 class Pattern(SMESH._objref_SMESH_Pattern):
5455 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5457 if isinstance(theNodeIndexOnKeyPoint1,str):
5459 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5461 theNodeIndexOnKeyPoint1 -= 1
5462 geompyDC.SetParameters(theMesh, Parameters)
5463 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5465 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5468 if isinstance(theNode000Index,str):
5470 if isinstance(theNode001Index,str):
5472 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5474 theNode000Index -= 1
5476 theNode001Index -= 1
5477 geompyDC.SetParameters(theMesh, Parameters)
5478 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5480 #Registering the new proxy for Pattern
5481 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)