1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # Author : Francis KLOSS, OCC
30 ## @defgroup l1_auxiliary Auxiliary methods and structures
31 ## @defgroup l1_creating Creating meshes
33 ## @defgroup l2_impexp Importing and exporting meshes
34 ## @defgroup l2_construct Constructing meshes
35 ## @defgroup l2_algorithms Defining Algorithms
37 ## @defgroup l3_algos_basic Basic meshing algorithms
38 ## @defgroup l3_algos_proj Projection Algorithms
39 ## @defgroup l3_algos_radialp Radial Prism
40 ## @defgroup l3_algos_segmarv Segments around Vertex
41 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
44 ## @defgroup l2_hypotheses Defining hypotheses
46 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
47 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
48 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
49 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
50 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
51 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
52 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
53 ## @defgroup l3_hypos_additi Additional Hypotheses
56 ## @defgroup l2_submeshes Constructing submeshes
57 ## @defgroup l2_compounds Building Compounds
58 ## @defgroup l2_editing Editing Meshes
61 ## @defgroup l1_meshinfo Mesh Information
62 ## @defgroup l1_controls Quality controls and Filtering
63 ## @defgroup l1_grouping Grouping elements
65 ## @defgroup l2_grps_create Creating groups
66 ## @defgroup l2_grps_edit Editing groups
67 ## @defgroup l2_grps_operon Using operations on groups
68 ## @defgroup l2_grps_delete Deleting Groups
71 ## @defgroup l1_modifying Modifying meshes
73 ## @defgroup l2_modif_add Adding nodes and elements
74 ## @defgroup l2_modif_del Removing nodes and elements
75 ## @defgroup l2_modif_edit Modifying nodes and elements
76 ## @defgroup l2_modif_renumber Renumbering nodes and elements
77 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
78 ## @defgroup l2_modif_movenode Moving nodes
79 ## @defgroup l2_modif_throughp Mesh through point
80 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
81 ## @defgroup l2_modif_unitetri Uniting triangles
82 ## @defgroup l2_modif_changori Changing orientation of elements
83 ## @defgroup l2_modif_cutquadr Cutting quadrangles
84 ## @defgroup l2_modif_smooth Smoothing
85 ## @defgroup l2_modif_extrurev Extrusion and Revolution
86 ## @defgroup l2_modif_patterns Pattern mapping
87 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
94 import SMESH # This is necessary for back compatibility
102 # import NETGENPlugin module if possible
110 # import GHS3DPlugin module if possible
118 # import GHS3DPRLPlugin module if possible
121 import GHS3DPRLPlugin
126 # import HexoticPlugin module if possible
134 # import BLSURFPlugin module if possible
142 ## @addtogroup l1_auxiliary
145 # Types of algorithms
158 NETGEN_1D2D3D = FULL_NETGEN
159 NETGEN_FULL = FULL_NETGEN
167 # MirrorType enumeration
168 POINT = SMESH_MeshEditor.POINT
169 AXIS = SMESH_MeshEditor.AXIS
170 PLANE = SMESH_MeshEditor.PLANE
172 # Smooth_Method enumeration
173 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
174 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
176 # Fineness enumeration (for NETGEN)
184 # Optimization level of GHS3D
186 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
187 # V4.1 (partialy redefines V3.1). Issue 0020574
188 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
190 # Topology treatment way of BLSURF
191 FromCAD, PreProcess, PreProcessPlus = 0,1,2
193 # Element size flag of BLSURF
194 DefaultSize, DefaultGeom, Custom = 0,0,1
196 PrecisionConfusion = 1e-07
198 # TopAbs_State enumeration
199 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
202 ## Converts an angle from degrees to radians
203 def DegreesToRadians(AngleInDegrees):
205 return AngleInDegrees * pi / 180.0
207 # Salome notebook variable separator
210 # Parametrized substitute for PointStruct
211 class PointStructStr:
220 def __init__(self, xStr, yStr, zStr):
224 if isinstance(xStr, str) and notebook.isVariable(xStr):
225 self.x = notebook.get(xStr)
228 if isinstance(yStr, str) and notebook.isVariable(yStr):
229 self.y = notebook.get(yStr)
232 if isinstance(zStr, str) and notebook.isVariable(zStr):
233 self.z = notebook.get(zStr)
237 # Parametrized substitute for PointStruct (with 6 parameters)
238 class PointStructStr6:
253 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
260 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
261 self.x1 = notebook.get(x1Str)
264 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
265 self.x2 = notebook.get(x2Str)
268 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
269 self.y1 = notebook.get(y1Str)
272 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
273 self.y2 = notebook.get(y2Str)
276 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
277 self.z1 = notebook.get(z1Str)
280 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
281 self.z2 = notebook.get(z2Str)
285 # Parametrized substitute for AxisStruct
301 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
308 if isinstance(xStr, str) and notebook.isVariable(xStr):
309 self.x = notebook.get(xStr)
312 if isinstance(yStr, str) and notebook.isVariable(yStr):
313 self.y = notebook.get(yStr)
316 if isinstance(zStr, str) and notebook.isVariable(zStr):
317 self.z = notebook.get(zStr)
320 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
321 self.dx = notebook.get(dxStr)
324 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
325 self.dy = notebook.get(dyStr)
328 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
329 self.dz = notebook.get(dzStr)
333 # Parametrized substitute for DirStruct
336 def __init__(self, pointStruct):
337 self.pointStruct = pointStruct
339 # Returns list of variable values from salome notebook
340 def ParsePointStruct(Point):
341 Parameters = 2*var_separator
342 if isinstance(Point, PointStructStr):
343 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
344 Point = PointStruct(Point.x, Point.y, Point.z)
345 return Point, Parameters
347 # Returns list of variable values from salome notebook
348 def ParseDirStruct(Dir):
349 Parameters = 2*var_separator
350 if isinstance(Dir, DirStructStr):
351 pntStr = Dir.pointStruct
352 if isinstance(pntStr, PointStructStr6):
353 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
354 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
355 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
356 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
358 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
359 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
360 Dir = DirStruct(Point)
361 return Dir, Parameters
363 # Returns list of variable values from salome notebook
364 def ParseAxisStruct(Axis):
365 Parameters = 5*var_separator
366 if isinstance(Axis, AxisStructStr):
367 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
368 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
369 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
370 return Axis, Parameters
372 ## Return list of variable values from salome notebook
373 def ParseAngles(list):
376 for parameter in list:
377 if isinstance(parameter,str) and notebook.isVariable(parameter):
378 Result.append(DegreesToRadians(notebook.get(parameter)))
381 Result.append(parameter)
384 Parameters = Parameters + str(parameter)
385 Parameters = Parameters + var_separator
387 Parameters = Parameters[:len(Parameters)-1]
388 return Result, Parameters
390 def IsEqual(val1, val2, tol=PrecisionConfusion):
391 if abs(val1 - val2) < tol:
401 if isinstance(obj, SALOMEDS._objref_SObject):
404 ior = salome.orb.object_to_string(obj)
407 studies = salome.myStudyManager.GetOpenStudies()
408 for sname in studies:
409 s = salome.myStudyManager.GetStudyByName(sname)
411 sobj = s.FindObjectIOR(ior)
412 if not sobj: continue
413 return sobj.GetName()
414 if hasattr(obj, "GetName"):
415 # unknown CORBA object, having GetName() method
418 # unknown CORBA object, no GetName() method
421 if hasattr(obj, "GetName"):
422 # unknown non-CORBA object, having GetName() method
425 raise RuntimeError, "Null or invalid object"
427 ## Prints error message if a hypothesis was not assigned.
428 def TreatHypoStatus(status, hypName, geomName, isAlgo):
430 hypType = "algorithm"
432 hypType = "hypothesis"
434 if status == HYP_UNKNOWN_FATAL :
435 reason = "for unknown reason"
436 elif status == HYP_INCOMPATIBLE :
437 reason = "this hypothesis mismatches the algorithm"
438 elif status == HYP_NOTCONFORM :
439 reason = "a non-conform mesh would be built"
440 elif status == HYP_ALREADY_EXIST :
441 reason = hypType + " of the same dimension is already assigned to this shape"
442 elif status == HYP_BAD_DIM :
443 reason = hypType + " mismatches the shape"
444 elif status == HYP_CONCURENT :
445 reason = "there are concurrent hypotheses on sub-shapes"
446 elif status == HYP_BAD_SUBSHAPE :
447 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
448 elif status == HYP_BAD_GEOMETRY:
449 reason = "geometry mismatches the expectation of the algorithm"
450 elif status == HYP_HIDDEN_ALGO:
451 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
452 elif status == HYP_HIDING_ALGO:
453 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
454 elif status == HYP_NEED_SHAPE:
455 reason = "Algorithm can't work without shape"
458 hypName = '"' + hypName + '"'
459 geomName= '"' + geomName+ '"'
460 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
461 print hypName, "was assigned to", geomName,"but", reason
462 elif not geomName == '""':
463 print hypName, "was not assigned to",geomName,":", reason
465 print hypName, "was not assigned:", reason
468 ## Check meshing plugin availability
469 def CheckPlugin(plugin):
470 if plugin == NETGEN and noNETGENPlugin:
471 print "Warning: NETGENPlugin module unavailable"
473 elif plugin == GHS3D and noGHS3DPlugin:
474 print "Warning: GHS3DPlugin module unavailable"
476 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
477 print "Warning: GHS3DPRLPlugin module unavailable"
479 elif plugin == Hexotic and noHexoticPlugin:
480 print "Warning: HexoticPlugin module unavailable"
482 elif plugin == BLSURF and noBLSURFPlugin:
483 print "Warning: BLSURFPlugin module unavailable"
487 # end of l1_auxiliary
490 # All methods of this class are accessible directly from the smesh.py package.
491 class smeshDC(SMESH._objref_SMESH_Gen):
493 ## Sets the current study and Geometry component
494 # @ingroup l1_auxiliary
495 def init_smesh(self,theStudy,geompyD):
496 self.SetCurrentStudy(theStudy,geompyD)
498 ## Creates an empty Mesh. This mesh can have an underlying geometry.
499 # @param obj the Geometrical object on which the mesh is built. If not defined,
500 # the mesh will have no underlying geometry.
501 # @param name the name for the new mesh.
502 # @return an instance of Mesh class.
503 # @ingroup l2_construct
504 def Mesh(self, obj=0, name=0):
505 if isinstance(obj,str):
507 return Mesh(self,self.geompyD,obj,name)
509 ## Returns a long value from enumeration
510 # Should be used for SMESH.FunctorType enumeration
511 # @ingroup l1_controls
512 def EnumToLong(self,theItem):
515 ## Gets PointStruct from vertex
516 # @param theVertex a GEOM object(vertex)
517 # @return SMESH.PointStruct
518 # @ingroup l1_auxiliary
519 def GetPointStruct(self,theVertex):
520 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
521 return PointStruct(x,y,z)
523 ## Gets DirStruct from vector
524 # @param theVector a GEOM object(vector)
525 # @return SMESH.DirStruct
526 # @ingroup l1_auxiliary
527 def GetDirStruct(self,theVector):
528 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
529 if(len(vertices) != 2):
530 print "Error: vector object is incorrect."
532 p1 = self.geompyD.PointCoordinates(vertices[0])
533 p2 = self.geompyD.PointCoordinates(vertices[1])
534 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
535 dirst = DirStruct(pnt)
538 ## Makes DirStruct from a triplet
539 # @param x,y,z vector components
540 # @return SMESH.DirStruct
541 # @ingroup l1_auxiliary
542 def MakeDirStruct(self,x,y,z):
543 pnt = PointStruct(x,y,z)
544 return DirStruct(pnt)
546 ## Get AxisStruct from object
547 # @param theObj a GEOM object (line or plane)
548 # @return SMESH.AxisStruct
549 # @ingroup l1_auxiliary
550 def GetAxisStruct(self,theObj):
551 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
553 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
554 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
555 vertex1 = self.geompyD.PointCoordinates(vertex1)
556 vertex2 = self.geompyD.PointCoordinates(vertex2)
557 vertex3 = self.geompyD.PointCoordinates(vertex3)
558 vertex4 = self.geompyD.PointCoordinates(vertex4)
559 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
560 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
561 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] ]
562 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
564 elif len(edges) == 1:
565 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
566 p1 = self.geompyD.PointCoordinates( vertex1 )
567 p2 = self.geompyD.PointCoordinates( vertex2 )
568 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
572 # From SMESH_Gen interface:
573 # ------------------------
575 ## Sets the given name to the object
576 # @param obj the object to rename
577 # @param name a new object name
578 # @ingroup l1_auxiliary
579 def SetName(self, obj, name):
580 if isinstance( obj, Mesh ):
582 elif isinstance( obj, Mesh_Algorithm ):
583 obj = obj.GetAlgorithm()
584 ior = salome.orb.object_to_string(obj)
585 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
587 ## Sets the current mode
588 # @ingroup l1_auxiliary
589 def SetEmbeddedMode( self,theMode ):
590 #self.SetEmbeddedMode(theMode)
591 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
593 ## Gets the current mode
594 # @ingroup l1_auxiliary
595 def IsEmbeddedMode(self):
596 #return self.IsEmbeddedMode()
597 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
599 ## Sets the current study
600 # @ingroup l1_auxiliary
601 def SetCurrentStudy( self, theStudy, geompyD = None ):
602 #self.SetCurrentStudy(theStudy)
605 geompyD = geompy.geom
608 self.SetGeomEngine(geompyD)
609 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
611 ## Gets the current study
612 # @ingroup l1_auxiliary
613 def GetCurrentStudy(self):
614 #return self.GetCurrentStudy()
615 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
617 ## Creates a Mesh object importing data from the given UNV file
618 # @return an instance of Mesh class
620 def CreateMeshesFromUNV( self,theFileName ):
621 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
622 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
625 ## Creates a Mesh object(s) importing data from the given MED file
626 # @return a list of Mesh class instances
628 def CreateMeshesFromMED( self,theFileName ):
629 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
631 for iMesh in range(len(aSmeshMeshes)) :
632 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
633 aMeshes.append(aMesh)
634 return aMeshes, aStatus
636 ## Creates a Mesh object importing data from the given STL file
637 # @return an instance of Mesh class
639 def CreateMeshesFromSTL( self, theFileName ):
640 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
641 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
644 ## From SMESH_Gen interface
645 # @return the list of integer values
646 # @ingroup l1_auxiliary
647 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
648 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
650 ## From SMESH_Gen interface. Creates a pattern
651 # @return an instance of SMESH_Pattern
653 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
654 # @ingroup l2_modif_patterns
655 def GetPattern(self):
656 return SMESH._objref_SMESH_Gen.GetPattern(self)
658 ## Sets number of segments per diagonal of boundary box of geometry by which
659 # default segment length of appropriate 1D hypotheses is defined.
660 # Default value is 10
661 # @ingroup l1_auxiliary
662 def SetBoundaryBoxSegmentation(self, nbSegments):
663 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
665 ## Concatenate the given meshes into one mesh.
666 # @return an instance of Mesh class
667 # @param meshes the meshes to combine into one mesh
668 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
669 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
670 # @param mergeTolerance tolerance for merging nodes
671 # @param allGroups forces creation of groups of all elements
672 def Concatenate( self, meshes, uniteIdenticalGroups,
673 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
674 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
676 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
677 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
679 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
680 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
681 aSmeshMesh.SetParameters(Parameters)
682 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
685 # Filtering. Auxiliary functions:
686 # ------------------------------
688 ## Creates an empty criterion
689 # @return SMESH.Filter.Criterion
690 # @ingroup l1_controls
691 def GetEmptyCriterion(self):
692 Type = self.EnumToLong(FT_Undefined)
693 Compare = self.EnumToLong(FT_Undefined)
697 UnaryOp = self.EnumToLong(FT_Undefined)
698 BinaryOp = self.EnumToLong(FT_Undefined)
701 Precision = -1 ##@1e-07
702 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
703 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
705 ## Creates a criterion by the given parameters
706 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
707 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
708 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
709 # @param Treshold the threshold value (range of ids as string, shape, numeric)
710 # @param UnaryOp FT_LogicalNOT or FT_Undefined
711 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
712 # FT_Undefined (must be for the last criterion of all criteria)
713 # @return SMESH.Filter.Criterion
714 # @ingroup l1_controls
715 def GetCriterion(self,elementType,
717 Compare = FT_EqualTo,
719 UnaryOp=FT_Undefined,
720 BinaryOp=FT_Undefined):
721 aCriterion = self.GetEmptyCriterion()
722 aCriterion.TypeOfElement = elementType
723 aCriterion.Type = self.EnumToLong(CritType)
727 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
728 aCriterion.Compare = self.EnumToLong(Compare)
729 elif Compare == "=" or Compare == "==":
730 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
732 aCriterion.Compare = self.EnumToLong(FT_LessThan)
734 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
736 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
739 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
740 FT_BelongToCylinder, FT_LyingOnGeom]:
741 # Checks the treshold
742 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
743 aCriterion.ThresholdStr = GetName(aTreshold)
744 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
746 print "Error: The treshold should be a shape."
748 elif CritType == FT_RangeOfIds:
749 # Checks the treshold
750 if isinstance(aTreshold, str):
751 aCriterion.ThresholdStr = aTreshold
753 print "Error: The treshold should be a string."
755 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
756 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
757 # At this point the treshold is unnecessary
758 if aTreshold == FT_LogicalNOT:
759 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
760 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
761 aCriterion.BinaryOp = aTreshold
765 aTreshold = float(aTreshold)
766 aCriterion.Threshold = aTreshold
768 print "Error: The treshold should be a number."
771 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
772 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
774 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
775 aCriterion.BinaryOp = self.EnumToLong(Treshold)
777 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
778 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
780 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
781 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
785 ## Creates a filter with the given parameters
786 # @param elementType the type of elements in the group
787 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
788 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
789 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
790 # @param UnaryOp FT_LogicalNOT or FT_Undefined
791 # @return SMESH_Filter
792 # @ingroup l1_controls
793 def GetFilter(self,elementType,
794 CritType=FT_Undefined,
797 UnaryOp=FT_Undefined):
798 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
799 aFilterMgr = self.CreateFilterManager()
800 aFilter = aFilterMgr.CreateFilter()
802 aCriteria.append(aCriterion)
803 aFilter.SetCriteria(aCriteria)
806 ## Creates a numerical functor by its type
807 # @param theCriterion FT_...; functor type
808 # @return SMESH_NumericalFunctor
809 # @ingroup l1_controls
810 def GetFunctor(self,theCriterion):
811 aFilterMgr = self.CreateFilterManager()
812 if theCriterion == FT_AspectRatio:
813 return aFilterMgr.CreateAspectRatio()
814 elif theCriterion == FT_AspectRatio3D:
815 return aFilterMgr.CreateAspectRatio3D()
816 elif theCriterion == FT_Warping:
817 return aFilterMgr.CreateWarping()
818 elif theCriterion == FT_MinimumAngle:
819 return aFilterMgr.CreateMinimumAngle()
820 elif theCriterion == FT_Taper:
821 return aFilterMgr.CreateTaper()
822 elif theCriterion == FT_Skew:
823 return aFilterMgr.CreateSkew()
824 elif theCriterion == FT_Area:
825 return aFilterMgr.CreateArea()
826 elif theCriterion == FT_Volume3D:
827 return aFilterMgr.CreateVolume3D()
828 elif theCriterion == FT_MultiConnection:
829 return aFilterMgr.CreateMultiConnection()
830 elif theCriterion == FT_MultiConnection2D:
831 return aFilterMgr.CreateMultiConnection2D()
832 elif theCriterion == FT_Length:
833 return aFilterMgr.CreateLength()
834 elif theCriterion == FT_Length2D:
835 return aFilterMgr.CreateLength2D()
837 print "Error: given parameter is not numerucal functor type."
839 ## Creates hypothesis
840 # @param theHType mesh hypothesis type (string)
841 # @param theLibName mesh plug-in library name
842 # @return created hypothesis instance
843 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
844 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
846 ## Gets the mesh stattistic
847 # @return dictionary type element - count of elements
848 # @ingroup l1_meshinfo
849 def GetMeshInfo(self, obj):
850 if isinstance( obj, Mesh ):
853 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
854 values = obj.GetMeshInfo()
855 for i in range(SMESH.Entity_Last._v):
856 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
861 #Registering the new proxy for SMESH_Gen
862 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
868 ## This class allows defining and managing a mesh.
869 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
870 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
871 # new nodes and elements and by changing the existing entities), to get information
872 # about a mesh and to export a mesh into different formats.
881 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
882 # sets the GUI name of this mesh to \a name.
883 # @param smeshpyD an instance of smeshDC class
884 # @param geompyD an instance of geompyDC class
885 # @param obj Shape to be meshed or SMESH_Mesh object
886 # @param name Study name of the mesh
887 # @ingroup l2_construct
888 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
889 self.smeshpyD=smeshpyD
894 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
896 self.mesh = self.smeshpyD.CreateMesh(self.geom)
897 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
900 self.mesh = self.smeshpyD.CreateEmptyMesh()
902 self.smeshpyD.SetName(self.mesh, name)
904 self.smeshpyD.SetName(self.mesh, GetName(obj))
907 self.geom = self.mesh.GetShapeToMesh()
909 self.editor = self.mesh.GetMeshEditor()
911 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
912 # @param theMesh a SMESH_Mesh object
913 # @ingroup l2_construct
914 def SetMesh(self, theMesh):
916 self.geom = self.mesh.GetShapeToMesh()
918 ## Returns the mesh, that is an instance of SMESH_Mesh interface
919 # @return a SMESH_Mesh object
920 # @ingroup l2_construct
924 ## Gets the name of the mesh
925 # @return the name of the mesh as a string
926 # @ingroup l2_construct
928 name = GetName(self.GetMesh())
931 ## Sets a name to the mesh
932 # @param name a new name of the mesh
933 # @ingroup l2_construct
934 def SetName(self, name):
935 self.smeshpyD.SetName(self.GetMesh(), name)
937 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
938 # The subMesh object gives access to the IDs of nodes and elements.
939 # @param theSubObject a geometrical object (shape)
940 # @param theName a name for the submesh
941 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
942 # @ingroup l2_submeshes
943 def GetSubMesh(self, theSubObject, theName):
944 submesh = self.mesh.GetSubMesh(theSubObject, theName)
947 ## Returns the shape associated to the mesh
948 # @return a GEOM_Object
949 # @ingroup l2_construct
953 ## Associates the given shape to the mesh (entails the recreation of the mesh)
954 # @param geom the shape to be meshed (GEOM_Object)
955 # @ingroup l2_construct
956 def SetShape(self, geom):
957 self.mesh = self.smeshpyD.CreateMesh(geom)
959 ## Returns true if the hypotheses are defined well
960 # @param theSubObject a subshape of a mesh shape
961 # @return True or False
962 # @ingroup l2_construct
963 def IsReadyToCompute(self, theSubObject):
964 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
966 ## Returns errors of hypotheses definition.
967 # The list of errors is empty if everything is OK.
968 # @param theSubObject a subshape of a mesh shape
969 # @return a list of errors
970 # @ingroup l2_construct
971 def GetAlgoState(self, theSubObject):
972 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
974 ## Returns a geometrical object on which the given element was built.
975 # The returned geometrical object, if not nil, is either found in the
976 # study or published by this method with the given name
977 # @param theElementID the id of the mesh element
978 # @param theGeomName the user-defined name of the geometrical object
979 # @return GEOM::GEOM_Object instance
980 # @ingroup l2_construct
981 def GetGeometryByMeshElement(self, theElementID, theGeomName):
982 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
984 ## Returns the mesh dimension depending on the dimension of the underlying shape
985 # @return mesh dimension as an integer value [0,3]
986 # @ingroup l1_auxiliary
987 def MeshDimension(self):
988 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
989 if len( shells ) > 0 :
991 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
993 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
999 ## Creates a segment discretization 1D algorithm.
1000 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1001 # \n If the optional \a geom parameter is not set, this algorithm is global.
1002 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1003 # @param algo the type of the required algorithm. Possible values are:
1005 # - smesh.PYTHON for discretization via a python function,
1006 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1007 # @param geom If defined is the subshape to be meshed
1008 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1009 # @ingroup l3_algos_basic
1010 def Segment(self, algo=REGULAR, geom=0):
1011 ## if Segment(geom) is called by mistake
1012 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1013 algo, geom = geom, algo
1014 if not algo: algo = REGULAR
1017 return Mesh_Segment(self, geom)
1018 elif algo == PYTHON:
1019 return Mesh_Segment_Python(self, geom)
1020 elif algo == COMPOSITE:
1021 return Mesh_CompositeSegment(self, geom)
1023 return Mesh_Segment(self, geom)
1025 ## Enables creation of nodes and segments usable by 2D algoritms.
1026 # The added nodes and segments must be bound to edges and vertices by
1027 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1028 # If the optional \a geom parameter is not set, this algorithm is global.
1029 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1030 # @param geom the subshape to be manually meshed
1031 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1032 # @ingroup l3_algos_basic
1033 def UseExistingSegments(self, geom=0):
1034 algo = Mesh_UseExisting(1,self,geom)
1035 return algo.GetAlgorithm()
1037 ## Enables creation of nodes and faces usable by 3D algoritms.
1038 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1039 # and SetMeshElementOnShape()
1040 # If the optional \a geom parameter is not set, this algorithm is global.
1041 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1042 # @param geom the subshape to be manually meshed
1043 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1044 # @ingroup l3_algos_basic
1045 def UseExistingFaces(self, geom=0):
1046 algo = Mesh_UseExisting(2,self,geom)
1047 return algo.GetAlgorithm()
1049 ## Creates a triangle 2D algorithm for faces.
1050 # If the optional \a geom parameter is not set, this algorithm is global.
1051 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1052 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1053 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1054 # @return an instance of Mesh_Triangle algorithm
1055 # @ingroup l3_algos_basic
1056 def Triangle(self, algo=MEFISTO, geom=0):
1057 ## if Triangle(geom) is called by mistake
1058 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1061 return Mesh_Triangle(self, algo, geom)
1063 ## Creates a quadrangle 2D algorithm for faces.
1064 # If the optional \a geom parameter is not set, this algorithm is global.
1065 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1066 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1067 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1068 # @return an instance of Mesh_Quadrangle algorithm
1069 # @ingroup l3_algos_basic
1070 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1071 if algo==RADIAL_QUAD:
1072 return Mesh_RadialQuadrangle1D2D(self,geom)
1074 return Mesh_Quadrangle(self, geom)
1076 ## Creates a tetrahedron 3D algorithm for solids.
1077 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1078 # If the optional \a geom parameter is not set, this algorithm is global.
1079 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1080 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1081 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1082 # @return an instance of Mesh_Tetrahedron algorithm
1083 # @ingroup l3_algos_basic
1084 def Tetrahedron(self, algo=NETGEN, geom=0):
1085 ## if Tetrahedron(geom) is called by mistake
1086 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1087 algo, geom = geom, algo
1088 if not algo: algo = NETGEN
1090 return Mesh_Tetrahedron(self, algo, geom)
1092 ## Creates a hexahedron 3D algorithm for solids.
1093 # If the optional \a geom parameter is not set, this algorithm is global.
1094 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1095 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1096 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1097 # @return an instance of Mesh_Hexahedron algorithm
1098 # @ingroup l3_algos_basic
1099 def Hexahedron(self, algo=Hexa, geom=0):
1100 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1101 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1102 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1103 elif geom == 0: algo, geom = Hexa, algo
1104 return Mesh_Hexahedron(self, algo, geom)
1106 ## Deprecated, used only for compatibility!
1107 # @return an instance of Mesh_Netgen algorithm
1108 # @ingroup l3_algos_basic
1109 def Netgen(self, is3D, geom=0):
1110 return Mesh_Netgen(self, is3D, geom)
1112 ## Creates a projection 1D algorithm for edges.
1113 # If the optional \a geom parameter is not set, this algorithm is global.
1114 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1115 # @param geom If defined, the subshape to be meshed
1116 # @return an instance of Mesh_Projection1D algorithm
1117 # @ingroup l3_algos_proj
1118 def Projection1D(self, geom=0):
1119 return Mesh_Projection1D(self, geom)
1121 ## Creates a projection 2D algorithm for faces.
1122 # If the optional \a geom parameter is not set, this algorithm is global.
1123 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1124 # @param geom If defined, the subshape to be meshed
1125 # @return an instance of Mesh_Projection2D algorithm
1126 # @ingroup l3_algos_proj
1127 def Projection2D(self, geom=0):
1128 return Mesh_Projection2D(self, geom)
1130 ## Creates a projection 3D algorithm for solids.
1131 # If the optional \a geom parameter is not set, this algorithm is global.
1132 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1133 # @param geom If defined, the subshape to be meshed
1134 # @return an instance of Mesh_Projection3D algorithm
1135 # @ingroup l3_algos_proj
1136 def Projection3D(self, geom=0):
1137 return Mesh_Projection3D(self, geom)
1139 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1140 # If the optional \a geom parameter is not set, this algorithm is global.
1141 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1142 # @param geom If defined, the subshape to be meshed
1143 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1144 # @ingroup l3_algos_radialp l3_algos_3dextr
1145 def Prism(self, geom=0):
1149 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1150 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1151 if nbSolids == 0 or nbSolids == nbShells:
1152 return Mesh_Prism3D(self, geom)
1153 return Mesh_RadialPrism3D(self, geom)
1155 ## Evaluates size of prospective mesh on a shape
1156 # @return True or False
1157 def Evaluate(self, geom=0):
1158 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1160 geom = self.mesh.GetShapeToMesh()
1163 return self.smeshpyD.Evaluate(self.mesh, geom)
1166 ## Computes the mesh and returns the status of the computation
1167 # @return True or False
1168 # @ingroup l2_construct
1169 def Compute(self, geom=0):
1170 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1172 geom = self.mesh.GetShapeToMesh()
1177 ok = self.smeshpyD.Compute(self.mesh, geom)
1178 except SALOME.SALOME_Exception, ex:
1179 print "Mesh computation failed, exception caught:"
1180 print " ", ex.details.text
1183 print "Mesh computation failed, exception caught:"
1184 traceback.print_exc()
1188 # Treat compute errors
1189 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1190 for err in computeErrors:
1192 if self.mesh.HasShapeToMesh():
1194 mainIOR = salome.orb.object_to_string(geom)
1195 for sname in salome.myStudyManager.GetOpenStudies():
1196 s = salome.myStudyManager.GetStudyByName(sname)
1198 mainSO = s.FindObjectIOR(mainIOR)
1199 if not mainSO: continue
1200 subIt = s.NewChildIterator(mainSO)
1202 subSO = subIt.Value()
1204 obj = subSO.GetObject()
1205 if not obj: continue
1206 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1208 ids = go.GetSubShapeIndices()
1209 if len(ids) == 1 and ids[0] == err.subShapeID:
1210 shapeText = ' on "%s"' % subSO.GetName()
1213 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1215 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1217 shapeText = " on subshape #%s" % (err.subShapeID)
1219 shapeText = " on subshape #%s" % (err.subShapeID)
1221 stdErrors = ["OK", #COMPERR_OK
1222 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1223 "std::exception", #COMPERR_STD_EXCEPTION
1224 "OCC exception", #COMPERR_OCC_EXCEPTION
1225 "SALOME exception", #COMPERR_SLM_EXCEPTION
1226 "Unknown exception", #COMPERR_EXCEPTION
1227 "Memory allocation problem", #COMPERR_MEMORY_PB
1228 "Algorithm failed", #COMPERR_ALGO_FAILED
1229 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1231 if err.code < len(stdErrors): errText = stdErrors[err.code]
1233 errText = "code %s" % -err.code
1234 if errText: errText += ". "
1235 errText += err.comment
1236 if allReasons != "":allReasons += "\n"
1237 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1241 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1243 if err.isGlobalAlgo:
1251 reason = '%s %sD algorithm is missing' % (glob, dim)
1252 elif err.state == HYP_MISSING:
1253 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1254 % (glob, dim, name, dim))
1255 elif err.state == HYP_NOTCONFORM:
1256 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1257 elif err.state == HYP_BAD_PARAMETER:
1258 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1259 % ( glob, dim, name ))
1260 elif err.state == HYP_BAD_GEOMETRY:
1261 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1262 'geometry' % ( glob, dim, name ))
1264 reason = "For unknown reason."+\
1265 " Revise Mesh.Compute() implementation in smeshDC.py!"
1267 if allReasons != "":allReasons += "\n"
1268 allReasons += reason
1270 if allReasons != "":
1271 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1275 print '"' + GetName(self.mesh) + '"',"has not been computed."
1278 if salome.sg.hasDesktop():
1279 smeshgui = salome.ImportComponentGUI("SMESH")
1280 smeshgui.Init(self.mesh.GetStudyId())
1281 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1282 salome.sg.updateObjBrowser(1)
1286 ## Return submesh objects list in meshing order
1287 # @return list of list of submesh objects
1288 # @ingroup l2_construct
1289 def GetMeshOrder(self):
1290 return self.mesh.GetMeshOrder()
1292 ## Return submesh objects list in meshing order
1293 # @return list of list of submesh objects
1294 # @ingroup l2_construct
1295 def SetMeshOrder(self, submeshes):
1296 return self.mesh.SetMeshOrder(submeshes)
1298 ## Removes all nodes and elements
1299 # @ingroup l2_construct
1302 if salome.sg.hasDesktop():
1303 smeshgui = salome.ImportComponentGUI("SMESH")
1304 smeshgui.Init(self.mesh.GetStudyId())
1305 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1306 salome.sg.updateObjBrowser(1)
1308 ## Removes all nodes and elements of indicated shape
1309 # @ingroup l2_construct
1310 def ClearSubMesh(self, geomId):
1311 self.mesh.ClearSubMesh(geomId)
1312 if salome.sg.hasDesktop():
1313 smeshgui = salome.ImportComponentGUI("SMESH")
1314 smeshgui.Init(self.mesh.GetStudyId())
1315 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1316 salome.sg.updateObjBrowser(1)
1318 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1319 # @param fineness [0,-1] defines mesh fineness
1320 # @return True or False
1321 # @ingroup l3_algos_basic
1322 def AutomaticTetrahedralization(self, fineness=0):
1323 dim = self.MeshDimension()
1325 self.RemoveGlobalHypotheses()
1326 self.Segment().AutomaticLength(fineness)
1328 self.Triangle().LengthFromEdges()
1331 self.Tetrahedron(NETGEN)
1333 return self.Compute()
1335 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1336 # @param fineness [0,-1] defines mesh fineness
1337 # @return True or False
1338 # @ingroup l3_algos_basic
1339 def AutomaticHexahedralization(self, fineness=0):
1340 dim = self.MeshDimension()
1341 # assign the hypotheses
1342 self.RemoveGlobalHypotheses()
1343 self.Segment().AutomaticLength(fineness)
1350 return self.Compute()
1352 ## Assigns a hypothesis
1353 # @param hyp a hypothesis to assign
1354 # @param geom a subhape of mesh geometry
1355 # @return SMESH.Hypothesis_Status
1356 # @ingroup l2_hypotheses
1357 def AddHypothesis(self, hyp, geom=0):
1358 if isinstance( hyp, Mesh_Algorithm ):
1359 hyp = hyp.GetAlgorithm()
1364 geom = self.mesh.GetShapeToMesh()
1366 status = self.mesh.AddHypothesis(geom, hyp)
1367 isAlgo = hyp._narrow( SMESH_Algo )
1368 hyp_name = GetName( hyp )
1371 geom_name = GetName( geom )
1372 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1375 ## Unassigns a hypothesis
1376 # @param hyp a hypothesis to unassign
1377 # @param geom a subshape of mesh geometry
1378 # @return SMESH.Hypothesis_Status
1379 # @ingroup l2_hypotheses
1380 def RemoveHypothesis(self, hyp, geom=0):
1381 if isinstance( hyp, Mesh_Algorithm ):
1382 hyp = hyp.GetAlgorithm()
1387 status = self.mesh.RemoveHypothesis(geom, hyp)
1390 ## Gets the list of hypotheses added on a geometry
1391 # @param geom a subshape of mesh geometry
1392 # @return the sequence of SMESH_Hypothesis
1393 # @ingroup l2_hypotheses
1394 def GetHypothesisList(self, geom):
1395 return self.mesh.GetHypothesisList( geom )
1397 ## Removes all global hypotheses
1398 # @ingroup l2_hypotheses
1399 def RemoveGlobalHypotheses(self):
1400 current_hyps = self.mesh.GetHypothesisList( self.geom )
1401 for hyp in current_hyps:
1402 self.mesh.RemoveHypothesis( self.geom, hyp )
1406 ## Creates a mesh group based on the geometric object \a grp
1407 # and gives a \a name, \n if this parameter is not defined
1408 # the name is the same as the geometric group name \n
1409 # Note: Works like GroupOnGeom().
1410 # @param grp a geometric group, a vertex, an edge, a face or a solid
1411 # @param name the name of the mesh group
1412 # @return SMESH_GroupOnGeom
1413 # @ingroup l2_grps_create
1414 def Group(self, grp, name=""):
1415 return self.GroupOnGeom(grp, name)
1417 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1418 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1419 # @param f the file name
1420 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1421 # @param opt boolean parameter for creating/not creating
1422 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1423 # @ingroup l2_impexp
1424 def ExportToMED(self, f, version, opt=0):
1425 self.mesh.ExportToMED(f, opt, version)
1427 ## Exports the mesh in a file in MED format
1428 # @param f is the file name
1429 # @param auto_groups boolean parameter for creating/not creating
1430 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1431 # the typical use is auto_groups=false.
1432 # @param version MED format version(MED_V2_1 or MED_V2_2)
1433 # @ingroup l2_impexp
1434 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1435 self.mesh.ExportToMED(f, auto_groups, version)
1437 ## Exports the mesh in a file in DAT format
1438 # @param f the file name
1439 # @ingroup l2_impexp
1440 def ExportDAT(self, f):
1441 self.mesh.ExportDAT(f)
1443 ## Exports the mesh in a file in UNV format
1444 # @param f the file name
1445 # @ingroup l2_impexp
1446 def ExportUNV(self, f):
1447 self.mesh.ExportUNV(f)
1449 ## Export the mesh in a file in STL format
1450 # @param f the file name
1451 # @param ascii defines the file encoding
1452 # @ingroup l2_impexp
1453 def ExportSTL(self, f, ascii=1):
1454 self.mesh.ExportSTL(f, ascii)
1457 # Operations with groups:
1458 # ----------------------
1460 ## Creates an empty mesh group
1461 # @param elementType the type of elements in the group
1462 # @param name the name of the mesh group
1463 # @return SMESH_Group
1464 # @ingroup l2_grps_create
1465 def CreateEmptyGroup(self, elementType, name):
1466 return self.mesh.CreateGroup(elementType, name)
1468 ## Creates a mesh group based on the geometrical object \a grp
1469 # and gives a \a name, \n if this parameter is not defined
1470 # the name is the same as the geometrical group name
1471 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1472 # @param name the name of the mesh group
1473 # @param typ the type of elements in the group. If not set, it is
1474 # automatically detected by the type of the geometry
1475 # @return SMESH_GroupOnGeom
1476 # @ingroup l2_grps_create
1477 def GroupOnGeom(self, grp, name="", typ=None):
1479 name = grp.GetName()
1482 tgeo = str(grp.GetShapeType())
1483 if tgeo == "VERTEX":
1485 elif tgeo == "EDGE":
1487 elif tgeo == "FACE":
1489 elif tgeo == "SOLID":
1491 elif tgeo == "SHELL":
1493 elif tgeo == "COMPOUND":
1494 try: # it raises on a compound of compounds
1495 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1496 print "Mesh.Group: empty geometric group", GetName( grp )
1501 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1503 tgeo = self.geompyD.GetType(grp)
1504 if tgeo == geompyDC.ShapeType["VERTEX"]:
1506 elif tgeo == geompyDC.ShapeType["EDGE"]:
1508 elif tgeo == geompyDC.ShapeType["FACE"]:
1510 elif tgeo == geompyDC.ShapeType["SOLID"]:
1516 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1517 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1518 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1526 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1529 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1531 ## Creates a mesh group by the given ids of elements
1532 # @param groupName the name of the mesh group
1533 # @param elementType the type of elements in the group
1534 # @param elemIDs the list of ids
1535 # @return SMESH_Group
1536 # @ingroup l2_grps_create
1537 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1538 group = self.mesh.CreateGroup(elementType, groupName)
1542 ## Creates a mesh group by the given conditions
1543 # @param groupName the name of the mesh group
1544 # @param elementType the type of elements in the group
1545 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1546 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1547 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1548 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1549 # @return SMESH_Group
1550 # @ingroup l2_grps_create
1554 CritType=FT_Undefined,
1557 UnaryOp=FT_Undefined):
1558 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1559 group = self.MakeGroupByCriterion(groupName, aCriterion)
1562 ## Creates a mesh group by the given criterion
1563 # @param groupName the name of the mesh group
1564 # @param Criterion the instance of Criterion class
1565 # @return SMESH_Group
1566 # @ingroup l2_grps_create
1567 def MakeGroupByCriterion(self, groupName, Criterion):
1568 aFilterMgr = self.smeshpyD.CreateFilterManager()
1569 aFilter = aFilterMgr.CreateFilter()
1571 aCriteria.append(Criterion)
1572 aFilter.SetCriteria(aCriteria)
1573 group = self.MakeGroupByFilter(groupName, aFilter)
1576 ## Creates a mesh group by the given criteria (list of criteria)
1577 # @param groupName the name of the mesh group
1578 # @param theCriteria the list of criteria
1579 # @return SMESH_Group
1580 # @ingroup l2_grps_create
1581 def MakeGroupByCriteria(self, groupName, theCriteria):
1582 aFilterMgr = self.smeshpyD.CreateFilterManager()
1583 aFilter = aFilterMgr.CreateFilter()
1584 aFilter.SetCriteria(theCriteria)
1585 group = self.MakeGroupByFilter(groupName, aFilter)
1588 ## Creates a mesh group by the given filter
1589 # @param groupName the name of the mesh group
1590 # @param theFilter the instance of Filter class
1591 # @return SMESH_Group
1592 # @ingroup l2_grps_create
1593 def MakeGroupByFilter(self, groupName, theFilter):
1594 anIds = theFilter.GetElementsId(self.mesh)
1595 anElemType = theFilter.GetElementType()
1596 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1599 ## Passes mesh elements through the given filter and return IDs of fitting elements
1600 # @param theFilter SMESH_Filter
1601 # @return a list of ids
1602 # @ingroup l1_controls
1603 def GetIdsFromFilter(self, theFilter):
1604 return theFilter.GetElementsId(self.mesh)
1606 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1607 # Returns a list of special structures (borders).
1608 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1609 # @ingroup l1_controls
1610 def GetFreeBorders(self):
1611 aFilterMgr = self.smeshpyD.CreateFilterManager()
1612 aPredicate = aFilterMgr.CreateFreeEdges()
1613 aPredicate.SetMesh(self.mesh)
1614 aBorders = aPredicate.GetBorders()
1618 # @ingroup l2_grps_delete
1619 def RemoveGroup(self, group):
1620 self.mesh.RemoveGroup(group)
1622 ## Removes a group with its contents
1623 # @ingroup l2_grps_delete
1624 def RemoveGroupWithContents(self, group):
1625 self.mesh.RemoveGroupWithContents(group)
1627 ## Gets the list of groups existing in the mesh
1628 # @return a sequence of SMESH_GroupBase
1629 # @ingroup l2_grps_create
1630 def GetGroups(self):
1631 return self.mesh.GetGroups()
1633 ## Gets the number of groups existing in the mesh
1634 # @return the quantity of groups as an integer value
1635 # @ingroup l2_grps_create
1637 return self.mesh.NbGroups()
1639 ## Gets the list of names of groups existing in the mesh
1640 # @return list of strings
1641 # @ingroup l2_grps_create
1642 def GetGroupNames(self):
1643 groups = self.GetGroups()
1645 for group in groups:
1646 names.append(group.GetName())
1649 ## Produces a union of two groups
1650 # A new group is created. All mesh elements that are
1651 # present in the initial groups are added to the new one
1652 # @return an instance of SMESH_Group
1653 # @ingroup l2_grps_operon
1654 def UnionGroups(self, group1, group2, name):
1655 return self.mesh.UnionGroups(group1, group2, name)
1657 ## Produces a union list of groups
1658 # New group is created. All mesh elements that are present in
1659 # initial groups are added to the new one
1660 # @return an instance of SMESH_Group
1661 # @ingroup l2_grps_operon
1662 def UnionListOfGroups(self, groups, name):
1663 return self.mesh.UnionListOfGroups(groups, name)
1665 ## Prodices an intersection of two groups
1666 # A new group is created. All mesh elements that are common
1667 # for the two initial groups are added to the new one.
1668 # @return an instance of SMESH_Group
1669 # @ingroup l2_grps_operon
1670 def IntersectGroups(self, group1, group2, name):
1671 return self.mesh.IntersectGroups(group1, group2, name)
1673 ## Produces an intersection of groups
1674 # New group is created. All mesh elements that are present in all
1675 # initial groups simultaneously are added to the new one
1676 # @return an instance of SMESH_Group
1677 # @ingroup l2_grps_operon
1678 def IntersectListOfGroups(self, groups, name):
1679 return self.mesh.IntersectListOfGroups(groups, name)
1681 ## Produces a cut of two groups
1682 # A new group is created. All mesh elements that are present in
1683 # the main group but are not present in the tool group are added to the new one
1684 # @return an instance of SMESH_Group
1685 # @ingroup l2_grps_operon
1686 def CutGroups(self, main_group, tool_group, name):
1687 return self.mesh.CutGroups(main_group, tool_group, name)
1689 ## Produces a cut of groups
1690 # A new group is created. All mesh elements that are present in main groups
1691 # but do not present in tool groups are added to the new one
1692 # @return an instance of SMESH_Group
1693 # @ingroup l2_grps_operon
1694 def CutListOfGroups(self, main_groups, tool_groups, name):
1695 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1697 ## Produces a group of elements with specified element type using list of existing groups
1698 # A new group is created. System
1699 # 1) extract all nodes on which groups elements are built
1700 # 2) combine all elements of specified dimension laying on these nodes
1701 # @return an instance of SMESH_Group
1702 # @ingroup l2_grps_operon
1703 def CreateDimGroup(self, groups, elem_type, name):
1704 return self.mesh.CreateDimGroup(groups, elem_type, name)
1707 ## Convert group on geom into standalone group
1708 # @ingroup l2_grps_delete
1709 def ConvertToStandalone(self, group):
1710 return self.mesh.ConvertToStandalone(group)
1712 # Get some info about mesh:
1713 # ------------------------
1715 ## Returns the log of nodes and elements added or removed
1716 # since the previous clear of the log.
1717 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1718 # @return list of log_block structures:
1723 # @ingroup l1_auxiliary
1724 def GetLog(self, clearAfterGet):
1725 return self.mesh.GetLog(clearAfterGet)
1727 ## Clears the log of nodes and elements added or removed since the previous
1728 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1729 # @ingroup l1_auxiliary
1731 self.mesh.ClearLog()
1733 ## Toggles auto color mode on the object.
1734 # @param theAutoColor the flag which toggles auto color mode.
1735 # @ingroup l1_auxiliary
1736 def SetAutoColor(self, theAutoColor):
1737 self.mesh.SetAutoColor(theAutoColor)
1739 ## Gets flag of object auto color mode.
1740 # @return True or False
1741 # @ingroup l1_auxiliary
1742 def GetAutoColor(self):
1743 return self.mesh.GetAutoColor()
1745 ## Gets the internal ID
1746 # @return integer value, which is the internal Id of the mesh
1747 # @ingroup l1_auxiliary
1749 return self.mesh.GetId()
1752 # @return integer value, which is the study Id of the mesh
1753 # @ingroup l1_auxiliary
1754 def GetStudyId(self):
1755 return self.mesh.GetStudyId()
1757 ## Checks the group names for duplications.
1758 # Consider the maximum group name length stored in MED file.
1759 # @return True or False
1760 # @ingroup l1_auxiliary
1761 def HasDuplicatedGroupNamesMED(self):
1762 return self.mesh.HasDuplicatedGroupNamesMED()
1764 ## Obtains the mesh editor tool
1765 # @return an instance of SMESH_MeshEditor
1766 # @ingroup l1_modifying
1767 def GetMeshEditor(self):
1768 return self.mesh.GetMeshEditor()
1771 # @return an instance of SALOME_MED::MESH
1772 # @ingroup l1_auxiliary
1773 def GetMEDMesh(self):
1774 return self.mesh.GetMEDMesh()
1777 # Get informations about mesh contents:
1778 # ------------------------------------
1780 ## Gets the mesh stattistic
1781 # @return dictionary type element - count of elements
1782 # @ingroup l1_meshinfo
1783 def GetMeshInfo(self, obj = None):
1784 if not obj: obj = self.mesh
1785 return self.smeshpyD.GetMeshInfo(obj)
1787 ## Returns the number of nodes in the mesh
1788 # @return an integer value
1789 # @ingroup l1_meshinfo
1791 return self.mesh.NbNodes()
1793 ## Returns the number of elements in the mesh
1794 # @return an integer value
1795 # @ingroup l1_meshinfo
1796 def NbElements(self):
1797 return self.mesh.NbElements()
1799 ## Returns the number of 0d elements in the mesh
1800 # @return an integer value
1801 # @ingroup l1_meshinfo
1802 def Nb0DElements(self):
1803 return self.mesh.Nb0DElements()
1805 ## Returns the number of edges in the mesh
1806 # @return an integer value
1807 # @ingroup l1_meshinfo
1809 return self.mesh.NbEdges()
1811 ## Returns the number of edges with the given order in the mesh
1812 # @param elementOrder the order of elements:
1813 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1814 # @return an integer value
1815 # @ingroup l1_meshinfo
1816 def NbEdgesOfOrder(self, elementOrder):
1817 return self.mesh.NbEdgesOfOrder(elementOrder)
1819 ## Returns the number of faces in the mesh
1820 # @return an integer value
1821 # @ingroup l1_meshinfo
1823 return self.mesh.NbFaces()
1825 ## Returns the number of faces with the given order in the mesh
1826 # @param elementOrder the order of elements:
1827 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1828 # @return an integer value
1829 # @ingroup l1_meshinfo
1830 def NbFacesOfOrder(self, elementOrder):
1831 return self.mesh.NbFacesOfOrder(elementOrder)
1833 ## Returns the number of triangles in the mesh
1834 # @return an integer value
1835 # @ingroup l1_meshinfo
1836 def NbTriangles(self):
1837 return self.mesh.NbTriangles()
1839 ## Returns the number of triangles with the given order in the mesh
1840 # @param elementOrder is the order of elements:
1841 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1842 # @return an integer value
1843 # @ingroup l1_meshinfo
1844 def NbTrianglesOfOrder(self, elementOrder):
1845 return self.mesh.NbTrianglesOfOrder(elementOrder)
1847 ## Returns the number of quadrangles in the mesh
1848 # @return an integer value
1849 # @ingroup l1_meshinfo
1850 def NbQuadrangles(self):
1851 return self.mesh.NbQuadrangles()
1853 ## Returns the number of quadrangles with the given order in the mesh
1854 # @param elementOrder the order of elements:
1855 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1856 # @return an integer value
1857 # @ingroup l1_meshinfo
1858 def NbQuadranglesOfOrder(self, elementOrder):
1859 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1861 ## Returns the number of polygons in the mesh
1862 # @return an integer value
1863 # @ingroup l1_meshinfo
1864 def NbPolygons(self):
1865 return self.mesh.NbPolygons()
1867 ## Returns the number of volumes in the mesh
1868 # @return an integer value
1869 # @ingroup l1_meshinfo
1870 def NbVolumes(self):
1871 return self.mesh.NbVolumes()
1873 ## Returns the number of volumes with the given order in the mesh
1874 # @param elementOrder the order of elements:
1875 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1876 # @return an integer value
1877 # @ingroup l1_meshinfo
1878 def NbVolumesOfOrder(self, elementOrder):
1879 return self.mesh.NbVolumesOfOrder(elementOrder)
1881 ## Returns the number of tetrahedrons in the mesh
1882 # @return an integer value
1883 # @ingroup l1_meshinfo
1885 return self.mesh.NbTetras()
1887 ## Returns the number of tetrahedrons with the given order in the mesh
1888 # @param elementOrder the order of elements:
1889 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1890 # @return an integer value
1891 # @ingroup l1_meshinfo
1892 def NbTetrasOfOrder(self, elementOrder):
1893 return self.mesh.NbTetrasOfOrder(elementOrder)
1895 ## Returns the number of hexahedrons in the mesh
1896 # @return an integer value
1897 # @ingroup l1_meshinfo
1899 return self.mesh.NbHexas()
1901 ## Returns the number of hexahedrons with the given order in the mesh
1902 # @param elementOrder the order of elements:
1903 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1904 # @return an integer value
1905 # @ingroup l1_meshinfo
1906 def NbHexasOfOrder(self, elementOrder):
1907 return self.mesh.NbHexasOfOrder(elementOrder)
1909 ## Returns the number of pyramids in the mesh
1910 # @return an integer value
1911 # @ingroup l1_meshinfo
1912 def NbPyramids(self):
1913 return self.mesh.NbPyramids()
1915 ## Returns the number of pyramids with the given order in the mesh
1916 # @param elementOrder the order of elements:
1917 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1918 # @return an integer value
1919 # @ingroup l1_meshinfo
1920 def NbPyramidsOfOrder(self, elementOrder):
1921 return self.mesh.NbPyramidsOfOrder(elementOrder)
1923 ## Returns the number of prisms in the mesh
1924 # @return an integer value
1925 # @ingroup l1_meshinfo
1927 return self.mesh.NbPrisms()
1929 ## Returns the number of prisms with the given order in the mesh
1930 # @param elementOrder the order of elements:
1931 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1932 # @return an integer value
1933 # @ingroup l1_meshinfo
1934 def NbPrismsOfOrder(self, elementOrder):
1935 return self.mesh.NbPrismsOfOrder(elementOrder)
1937 ## Returns the number of polyhedrons in the mesh
1938 # @return an integer value
1939 # @ingroup l1_meshinfo
1940 def NbPolyhedrons(self):
1941 return self.mesh.NbPolyhedrons()
1943 ## Returns the number of submeshes in the mesh
1944 # @return an integer value
1945 # @ingroup l1_meshinfo
1946 def NbSubMesh(self):
1947 return self.mesh.NbSubMesh()
1949 ## Returns the list of mesh elements IDs
1950 # @return the list of integer values
1951 # @ingroup l1_meshinfo
1952 def GetElementsId(self):
1953 return self.mesh.GetElementsId()
1955 ## Returns the list of IDs of mesh elements with the given type
1956 # @param elementType the required type of elements
1957 # @return list of integer values
1958 # @ingroup l1_meshinfo
1959 def GetElementsByType(self, elementType):
1960 return self.mesh.GetElementsByType(elementType)
1962 ## Returns the list of mesh nodes IDs
1963 # @return the list of integer values
1964 # @ingroup l1_meshinfo
1965 def GetNodesId(self):
1966 return self.mesh.GetNodesId()
1968 # Get the information about mesh elements:
1969 # ------------------------------------
1971 ## Returns the type of mesh element
1972 # @return the value from SMESH::ElementType enumeration
1973 # @ingroup l1_meshinfo
1974 def GetElementType(self, id, iselem):
1975 return self.mesh.GetElementType(id, iselem)
1977 ## Returns the geometric type of mesh element
1978 # @return the value from SMESH::EntityType enumeration
1979 # @ingroup l1_meshinfo
1980 def GetElementGeomType(self, id):
1981 return self.mesh.GetElementGeomType(id)
1983 ## Returns the list of submesh elements IDs
1984 # @param Shape a geom object(subshape) IOR
1985 # Shape must be the subshape of a ShapeToMesh()
1986 # @return the list of integer values
1987 # @ingroup l1_meshinfo
1988 def GetSubMeshElementsId(self, Shape):
1989 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1990 ShapeID = Shape.GetSubShapeIndices()[0]
1993 return self.mesh.GetSubMeshElementsId(ShapeID)
1995 ## Returns the list of submesh nodes IDs
1996 # @param Shape a geom object(subshape) IOR
1997 # Shape must be the subshape of a ShapeToMesh()
1998 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1999 # @return the list of integer values
2000 # @ingroup l1_meshinfo
2001 def GetSubMeshNodesId(self, Shape, all):
2002 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2003 ShapeID = Shape.GetSubShapeIndices()[0]
2006 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2008 ## Returns type of elements on given shape
2009 # @param Shape a geom object(subshape) IOR
2010 # Shape must be a subshape of a ShapeToMesh()
2011 # @return element type
2012 # @ingroup l1_meshinfo
2013 def GetSubMeshElementType(self, Shape):
2014 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2015 ShapeID = Shape.GetSubShapeIndices()[0]
2018 return self.mesh.GetSubMeshElementType(ShapeID)
2020 ## Gets the mesh description
2021 # @return string value
2022 # @ingroup l1_meshinfo
2024 return self.mesh.Dump()
2027 # Get the information about nodes and elements of a mesh by its IDs:
2028 # -----------------------------------------------------------
2030 ## Gets XYZ coordinates of a node
2031 # \n If there is no nodes for the given ID - returns an empty list
2032 # @return a list of double precision values
2033 # @ingroup l1_meshinfo
2034 def GetNodeXYZ(self, id):
2035 return self.mesh.GetNodeXYZ(id)
2037 ## Returns list of IDs of inverse elements for the given node
2038 # \n If there is no node for the given ID - returns an empty list
2039 # @return a list of integer values
2040 # @ingroup l1_meshinfo
2041 def GetNodeInverseElements(self, id):
2042 return self.mesh.GetNodeInverseElements(id)
2044 ## @brief Returns the position of a node on the shape
2045 # @return SMESH::NodePosition
2046 # @ingroup l1_meshinfo
2047 def GetNodePosition(self,NodeID):
2048 return self.mesh.GetNodePosition(NodeID)
2050 ## If the given element is a node, returns the ID of shape
2051 # \n If there is no node for the given ID - returns -1
2052 # @return an integer value
2053 # @ingroup l1_meshinfo
2054 def GetShapeID(self, id):
2055 return self.mesh.GetShapeID(id)
2057 ## Returns the ID of the result shape after
2058 # FindShape() from SMESH_MeshEditor for the given element
2059 # \n If there is no element for the given ID - returns -1
2060 # @return an integer value
2061 # @ingroup l1_meshinfo
2062 def GetShapeIDForElem(self,id):
2063 return self.mesh.GetShapeIDForElem(id)
2065 ## Returns the number of nodes for the given element
2066 # \n If there is no element for the given ID - returns -1
2067 # @return an integer value
2068 # @ingroup l1_meshinfo
2069 def GetElemNbNodes(self, id):
2070 return self.mesh.GetElemNbNodes(id)
2072 ## Returns the node ID the given index for the given element
2073 # \n If there is no element for the given ID - returns -1
2074 # \n If there is no node for the given index - returns -2
2075 # @return an integer value
2076 # @ingroup l1_meshinfo
2077 def GetElemNode(self, id, index):
2078 return self.mesh.GetElemNode(id, index)
2080 ## Returns the IDs of nodes of the given element
2081 # @return a list of integer values
2082 # @ingroup l1_meshinfo
2083 def GetElemNodes(self, id):
2084 return self.mesh.GetElemNodes(id)
2086 ## Returns true if the given node is the medium node in the given quadratic element
2087 # @ingroup l1_meshinfo
2088 def IsMediumNode(self, elementID, nodeID):
2089 return self.mesh.IsMediumNode(elementID, nodeID)
2091 ## Returns true if the given node is the medium node in one of quadratic elements
2092 # @ingroup l1_meshinfo
2093 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2094 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2096 ## Returns the number of edges for the given element
2097 # @ingroup l1_meshinfo
2098 def ElemNbEdges(self, id):
2099 return self.mesh.ElemNbEdges(id)
2101 ## Returns the number of faces for the given element
2102 # @ingroup l1_meshinfo
2103 def ElemNbFaces(self, id):
2104 return self.mesh.ElemNbFaces(id)
2106 ## Returns nodes of given face (counted from zero) for given volumic element.
2107 # @ingroup l1_meshinfo
2108 def GetElemFaceNodes(self,elemId, faceIndex):
2109 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2111 ## Returns an element based on all given nodes.
2112 # @ingroup l1_meshinfo
2113 def FindElementByNodes(self,nodes):
2114 return self.mesh.FindElementByNodes(nodes)
2116 ## Returns true if the given element is a polygon
2117 # @ingroup l1_meshinfo
2118 def IsPoly(self, id):
2119 return self.mesh.IsPoly(id)
2121 ## Returns true if the given element is quadratic
2122 # @ingroup l1_meshinfo
2123 def IsQuadratic(self, id):
2124 return self.mesh.IsQuadratic(id)
2126 ## Returns XYZ coordinates of the barycenter of the given element
2127 # \n If there is no element for the given ID - returns an empty list
2128 # @return a list of three double values
2129 # @ingroup l1_meshinfo
2130 def BaryCenter(self, id):
2131 return self.mesh.BaryCenter(id)
2134 # Mesh edition (SMESH_MeshEditor functionality):
2135 # ---------------------------------------------
2137 ## Removes the elements from the mesh by ids
2138 # @param IDsOfElements is a list of ids of elements to remove
2139 # @return True or False
2140 # @ingroup l2_modif_del
2141 def RemoveElements(self, IDsOfElements):
2142 return self.editor.RemoveElements(IDsOfElements)
2144 ## Removes nodes from mesh by ids
2145 # @param IDsOfNodes is a list of ids of nodes to remove
2146 # @return True or False
2147 # @ingroup l2_modif_del
2148 def RemoveNodes(self, IDsOfNodes):
2149 return self.editor.RemoveNodes(IDsOfNodes)
2151 ## Add a node to the mesh by coordinates
2152 # @return Id of the new node
2153 # @ingroup l2_modif_add
2154 def AddNode(self, x, y, z):
2155 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2156 self.mesh.SetParameters(Parameters)
2157 return self.editor.AddNode( x, y, z)
2159 ## Creates a 0D element on a node with given number.
2160 # @param IDOfNode the ID of node for creation of the element.
2161 # @return the Id of the new 0D element
2162 # @ingroup l2_modif_add
2163 def Add0DElement(self, IDOfNode):
2164 return self.editor.Add0DElement(IDOfNode)
2166 ## Creates a linear or quadratic edge (this is determined
2167 # by the number of given nodes).
2168 # @param IDsOfNodes the list of node IDs for creation of the element.
2169 # The order of nodes in this list should correspond to the description
2170 # of MED. \n This description is located by the following link:
2171 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2172 # @return the Id of the new edge
2173 # @ingroup l2_modif_add
2174 def AddEdge(self, IDsOfNodes):
2175 return self.editor.AddEdge(IDsOfNodes)
2177 ## Creates a linear or quadratic face (this is determined
2178 # by the number of given nodes).
2179 # @param IDsOfNodes the list of node IDs for creation of the element.
2180 # The order of nodes in this list should correspond to the description
2181 # of MED. \n This description is located by the following link:
2182 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2183 # @return the Id of the new face
2184 # @ingroup l2_modif_add
2185 def AddFace(self, IDsOfNodes):
2186 return self.editor.AddFace(IDsOfNodes)
2188 ## Adds a polygonal face to the mesh by the list of node IDs
2189 # @param IdsOfNodes the list of node IDs for creation of the element.
2190 # @return the Id of the new face
2191 # @ingroup l2_modif_add
2192 def AddPolygonalFace(self, IdsOfNodes):
2193 return self.editor.AddPolygonalFace(IdsOfNodes)
2195 ## Creates both simple and quadratic volume (this is determined
2196 # by the number of given nodes).
2197 # @param IDsOfNodes the list of node IDs for creation of the element.
2198 # The order of nodes in this list should correspond to the description
2199 # of MED. \n This description is located by the following link:
2200 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2201 # @return the Id of the new volumic element
2202 # @ingroup l2_modif_add
2203 def AddVolume(self, IDsOfNodes):
2204 return self.editor.AddVolume(IDsOfNodes)
2206 ## Creates a volume of many faces, giving nodes for each face.
2207 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2208 # @param Quantities the list of integer values, Quantities[i]
2209 # gives the quantity of nodes in face number i.
2210 # @return the Id of the new volumic element
2211 # @ingroup l2_modif_add
2212 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2213 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2215 ## Creates a volume of many faces, giving the IDs of the existing faces.
2216 # @param IdsOfFaces the list of face IDs for volume creation.
2218 # Note: The created volume will refer only to the nodes
2219 # of the given faces, not to the faces themselves.
2220 # @return the Id of the new volumic element
2221 # @ingroup l2_modif_add
2222 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2223 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2226 ## @brief Binds a node to a vertex
2227 # @param NodeID a node ID
2228 # @param Vertex a vertex or vertex ID
2229 # @return True if succeed else raises an exception
2230 # @ingroup l2_modif_add
2231 def SetNodeOnVertex(self, NodeID, Vertex):
2232 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2233 VertexID = Vertex.GetSubShapeIndices()[0]
2237 self.editor.SetNodeOnVertex(NodeID, VertexID)
2238 except SALOME.SALOME_Exception, inst:
2239 raise ValueError, inst.details.text
2243 ## @brief Stores the node position on an edge
2244 # @param NodeID a node ID
2245 # @param Edge an edge or edge ID
2246 # @param paramOnEdge a parameter on the edge where the node is located
2247 # @return True if succeed else raises an exception
2248 # @ingroup l2_modif_add
2249 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2250 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2251 EdgeID = Edge.GetSubShapeIndices()[0]
2255 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2256 except SALOME.SALOME_Exception, inst:
2257 raise ValueError, inst.details.text
2260 ## @brief Stores node position on a face
2261 # @param NodeID a node ID
2262 # @param Face a face or face ID
2263 # @param u U parameter on the face where the node is located
2264 # @param v V parameter on the face where the node is located
2265 # @return True if succeed else raises an exception
2266 # @ingroup l2_modif_add
2267 def SetNodeOnFace(self, NodeID, Face, u, v):
2268 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2269 FaceID = Face.GetSubShapeIndices()[0]
2273 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2274 except SALOME.SALOME_Exception, inst:
2275 raise ValueError, inst.details.text
2278 ## @brief Binds a node to a solid
2279 # @param NodeID a node ID
2280 # @param Solid a solid or solid ID
2281 # @return True if succeed else raises an exception
2282 # @ingroup l2_modif_add
2283 def SetNodeInVolume(self, NodeID, Solid):
2284 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2285 SolidID = Solid.GetSubShapeIndices()[0]
2289 self.editor.SetNodeInVolume(NodeID, SolidID)
2290 except SALOME.SALOME_Exception, inst:
2291 raise ValueError, inst.details.text
2294 ## @brief Bind an element to a shape
2295 # @param ElementID an element ID
2296 # @param Shape a shape or shape ID
2297 # @return True if succeed else raises an exception
2298 # @ingroup l2_modif_add
2299 def SetMeshElementOnShape(self, ElementID, Shape):
2300 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2301 ShapeID = Shape.GetSubShapeIndices()[0]
2305 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2306 except SALOME.SALOME_Exception, inst:
2307 raise ValueError, inst.details.text
2311 ## Moves the node with the given id
2312 # @param NodeID the id of the node
2313 # @param x a new X coordinate
2314 # @param y a new Y coordinate
2315 # @param z a new Z coordinate
2316 # @return True if succeed else False
2317 # @ingroup l2_modif_movenode
2318 def MoveNode(self, NodeID, x, y, z):
2319 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2320 self.mesh.SetParameters(Parameters)
2321 return self.editor.MoveNode(NodeID, x, y, z)
2323 ## Finds the node closest to a point and moves it to a point location
2324 # @param x the X coordinate of a point
2325 # @param y the Y coordinate of a point
2326 # @param z the Z coordinate of a point
2327 # @param NodeID if specified (>0), the node with this ID is moved,
2328 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2329 # @return the ID of a node
2330 # @ingroup l2_modif_throughp
2331 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2332 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2333 self.mesh.SetParameters(Parameters)
2334 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2336 ## Finds the node closest to a point
2337 # @param x the X coordinate of a point
2338 # @param y the Y coordinate of a point
2339 # @param z the Z coordinate of a point
2340 # @return the ID of a node
2341 # @ingroup l2_modif_throughp
2342 def FindNodeClosestTo(self, x, y, z):
2343 #preview = self.mesh.GetMeshEditPreviewer()
2344 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2345 return self.editor.FindNodeClosestTo(x, y, z)
2347 ## Finds the elements where a point lays IN or ON
2348 # @param x the X coordinate of a point
2349 # @param y the Y coordinate of a point
2350 # @param z the Z coordinate of a point
2351 # @param elementType type of elements to find (SMESH.ALL type
2352 # means elements of any type excluding nodes and 0D elements)
2353 # @return list of IDs of found elements
2354 # @ingroup l2_modif_throughp
2355 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2356 return self.editor.FindElementsByPoint(x, y, z, elementType)
2358 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2359 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2361 def GetPointState(self, x, y, z):
2362 return self.editor.GetPointState(x, y, z)
2364 ## Finds the node closest to a point and moves it to a point location
2365 # @param x the X coordinate of a point
2366 # @param y the Y coordinate of a point
2367 # @param z the Z coordinate of a point
2368 # @return the ID of a moved node
2369 # @ingroup l2_modif_throughp
2370 def MeshToPassThroughAPoint(self, x, y, z):
2371 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2373 ## Replaces two neighbour triangles sharing Node1-Node2 link
2374 # with the triangles built on the same 4 nodes but having other common link.
2375 # @param NodeID1 the ID of the first node
2376 # @param NodeID2 the ID of the second node
2377 # @return false if proper faces were not found
2378 # @ingroup l2_modif_invdiag
2379 def InverseDiag(self, NodeID1, NodeID2):
2380 return self.editor.InverseDiag(NodeID1, NodeID2)
2382 ## Replaces two neighbour triangles sharing Node1-Node2 link
2383 # with a quadrangle built on the same 4 nodes.
2384 # @param NodeID1 the ID of the first node
2385 # @param NodeID2 the ID of the second node
2386 # @return false if proper faces were not found
2387 # @ingroup l2_modif_unitetri
2388 def DeleteDiag(self, NodeID1, NodeID2):
2389 return self.editor.DeleteDiag(NodeID1, NodeID2)
2391 ## Reorients elements by ids
2392 # @param IDsOfElements if undefined reorients all mesh elements
2393 # @return True if succeed else False
2394 # @ingroup l2_modif_changori
2395 def Reorient(self, IDsOfElements=None):
2396 if IDsOfElements == None:
2397 IDsOfElements = self.GetElementsId()
2398 return self.editor.Reorient(IDsOfElements)
2400 ## Reorients all elements of the object
2401 # @param theObject mesh, submesh or group
2402 # @return True if succeed else False
2403 # @ingroup l2_modif_changori
2404 def ReorientObject(self, theObject):
2405 if ( isinstance( theObject, Mesh )):
2406 theObject = theObject.GetMesh()
2407 return self.editor.ReorientObject(theObject)
2409 ## Fuses the neighbouring triangles into quadrangles.
2410 # @param IDsOfElements The triangles to be fused,
2411 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2412 # @param MaxAngle is the maximum angle between element normals at which the fusion
2413 # is still performed; theMaxAngle is mesured in radians.
2414 # Also it could be a name of variable which defines angle in degrees.
2415 # @return TRUE in case of success, FALSE otherwise.
2416 # @ingroup l2_modif_unitetri
2417 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2419 if isinstance(MaxAngle,str):
2421 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2423 MaxAngle = DegreesToRadians(MaxAngle)
2424 if IDsOfElements == []:
2425 IDsOfElements = self.GetElementsId()
2426 self.mesh.SetParameters(Parameters)
2428 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2429 Functor = theCriterion
2431 Functor = self.smeshpyD.GetFunctor(theCriterion)
2432 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2434 ## Fuses the neighbouring triangles of the object into quadrangles
2435 # @param theObject is mesh, submesh or group
2436 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2437 # @param MaxAngle a max angle between element normals at which the fusion
2438 # is still performed; theMaxAngle is mesured in radians.
2439 # @return TRUE in case of success, FALSE otherwise.
2440 # @ingroup l2_modif_unitetri
2441 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2442 if ( isinstance( theObject, Mesh )):
2443 theObject = theObject.GetMesh()
2444 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2446 ## Splits quadrangles into triangles.
2447 # @param IDsOfElements the faces to be splitted.
2448 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2449 # @return TRUE in case of success, FALSE otherwise.
2450 # @ingroup l2_modif_cutquadr
2451 def QuadToTri (self, IDsOfElements, theCriterion):
2452 if IDsOfElements == []:
2453 IDsOfElements = self.GetElementsId()
2454 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2456 ## Splits quadrangles into triangles.
2457 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2458 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2459 # @return TRUE in case of success, FALSE otherwise.
2460 # @ingroup l2_modif_cutquadr
2461 def QuadToTriObject (self, theObject, theCriterion):
2462 if ( isinstance( theObject, Mesh )):
2463 theObject = theObject.GetMesh()
2464 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2466 ## Splits quadrangles into triangles.
2467 # @param IDsOfElements the faces to be splitted
2468 # @param Diag13 is used to choose a diagonal for splitting.
2469 # @return TRUE in case of success, FALSE otherwise.
2470 # @ingroup l2_modif_cutquadr
2471 def SplitQuad (self, IDsOfElements, Diag13):
2472 if IDsOfElements == []:
2473 IDsOfElements = self.GetElementsId()
2474 return self.editor.SplitQuad(IDsOfElements, Diag13)
2476 ## Splits quadrangles into triangles.
2477 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2478 # @param Diag13 is used to choose a diagonal for splitting.
2479 # @return TRUE in case of success, FALSE otherwise.
2480 # @ingroup l2_modif_cutquadr
2481 def SplitQuadObject (self, theObject, Diag13):
2482 if ( isinstance( theObject, Mesh )):
2483 theObject = theObject.GetMesh()
2484 return self.editor.SplitQuadObject(theObject, Diag13)
2486 ## Finds a better splitting of the given quadrangle.
2487 # @param IDOfQuad the ID of the quadrangle to be splitted.
2488 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2489 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2490 # diagonal is better, 0 if error occurs.
2491 # @ingroup l2_modif_cutquadr
2492 def BestSplit (self, IDOfQuad, theCriterion):
2493 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2495 ## Splits volumic elements into tetrahedrons
2496 # @param elemIDs either list of elements or mesh or group or submesh
2497 # @param method flags passing splitting method:
2498 # 1 - split the hexahedron into 5 tetrahedrons
2499 # 2 - split the hexahedron into 6 tetrahedrons
2500 # @ingroup l2_modif_cutquadr
2501 def SplitVolumesIntoTetra(self, elemIDs, method=1 ):
2502 if isinstance( elemIDs, Mesh ):
2503 elemIDs = elemIDs.GetMesh()
2504 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2506 ## Splits quadrangle faces near triangular facets of volumes
2508 # @ingroup l1_auxiliary
2509 def SplitQuadsNearTriangularFacets(self):
2510 faces_array = self.GetElementsByType(SMESH.FACE)
2511 for face_id in faces_array:
2512 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2513 quad_nodes = self.mesh.GetElemNodes(face_id)
2514 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2515 isVolumeFound = False
2516 for node1_elem in node1_elems:
2517 if not isVolumeFound:
2518 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2519 nb_nodes = self.GetElemNbNodes(node1_elem)
2520 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2521 volume_elem = node1_elem
2522 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2523 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2524 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2525 isVolumeFound = True
2526 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2527 self.SplitQuad([face_id], False) # diagonal 2-4
2528 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2529 isVolumeFound = True
2530 self.SplitQuad([face_id], True) # diagonal 1-3
2531 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2532 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2533 isVolumeFound = True
2534 self.SplitQuad([face_id], True) # diagonal 1-3
2536 ## @brief Splits hexahedrons into tetrahedrons.
2538 # This operation uses pattern mapping functionality for splitting.
2539 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2540 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2541 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2542 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2543 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2544 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2545 # @return TRUE in case of success, FALSE otherwise.
2546 # @ingroup l1_auxiliary
2547 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2548 # Pattern: 5.---------.6
2553 # (0,0,1) 4.---------.7 * |
2560 # (0,0,0) 0.---------.3
2561 pattern_tetra = "!!! Nb of points: \n 8 \n\
2571 !!! Indices of points of 6 tetras: \n\
2579 pattern = self.smeshpyD.GetPattern()
2580 isDone = pattern.LoadFromFile(pattern_tetra)
2582 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2585 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2586 isDone = pattern.MakeMesh(self.mesh, False, False)
2587 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2589 # split quafrangle faces near triangular facets of volumes
2590 self.SplitQuadsNearTriangularFacets()
2594 ## @brief Split hexahedrons into prisms.
2596 # Uses the pattern mapping functionality for splitting.
2597 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2598 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2599 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2600 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2601 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2602 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2603 # @return TRUE in case of success, FALSE otherwise.
2604 # @ingroup l1_auxiliary
2605 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2606 # Pattern: 5.---------.6
2611 # (0,0,1) 4.---------.7 |
2618 # (0,0,0) 0.---------.3
2619 pattern_prism = "!!! Nb of points: \n 8 \n\
2629 !!! Indices of points of 2 prisms: \n\
2633 pattern = self.smeshpyD.GetPattern()
2634 isDone = pattern.LoadFromFile(pattern_prism)
2636 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2639 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2640 isDone = pattern.MakeMesh(self.mesh, False, False)
2641 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2643 # Splits quafrangle faces near triangular facets of volumes
2644 self.SplitQuadsNearTriangularFacets()
2648 ## Smoothes elements
2649 # @param IDsOfElements the list if ids of elements to smooth
2650 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2651 # Note that nodes built on edges and boundary nodes are always fixed.
2652 # @param MaxNbOfIterations the maximum number of iterations
2653 # @param MaxAspectRatio varies in range [1.0, inf]
2654 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2655 # @return TRUE in case of success, FALSE otherwise.
2656 # @ingroup l2_modif_smooth
2657 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2658 MaxNbOfIterations, MaxAspectRatio, Method):
2659 if IDsOfElements == []:
2660 IDsOfElements = self.GetElementsId()
2661 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2662 self.mesh.SetParameters(Parameters)
2663 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2664 MaxNbOfIterations, MaxAspectRatio, Method)
2666 ## Smoothes elements which belong to the given object
2667 # @param theObject the object to smooth
2668 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2669 # Note that nodes built on edges and boundary nodes are always fixed.
2670 # @param MaxNbOfIterations the maximum number of iterations
2671 # @param MaxAspectRatio varies in range [1.0, inf]
2672 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2673 # @return TRUE in case of success, FALSE otherwise.
2674 # @ingroup l2_modif_smooth
2675 def SmoothObject(self, theObject, IDsOfFixedNodes,
2676 MaxNbOfIterations, MaxAspectRatio, Method):
2677 if ( isinstance( theObject, Mesh )):
2678 theObject = theObject.GetMesh()
2679 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2680 MaxNbOfIterations, MaxAspectRatio, Method)
2682 ## Parametrically smoothes the given elements
2683 # @param IDsOfElements the list if ids of elements to smooth
2684 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2685 # Note that nodes built on edges and boundary nodes are always fixed.
2686 # @param MaxNbOfIterations the maximum number of iterations
2687 # @param MaxAspectRatio varies in range [1.0, inf]
2688 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2689 # @return TRUE in case of success, FALSE otherwise.
2690 # @ingroup l2_modif_smooth
2691 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2692 MaxNbOfIterations, MaxAspectRatio, Method):
2693 if IDsOfElements == []:
2694 IDsOfElements = self.GetElementsId()
2695 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2696 self.mesh.SetParameters(Parameters)
2697 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2698 MaxNbOfIterations, MaxAspectRatio, Method)
2700 ## Parametrically smoothes the elements which belong to the given object
2701 # @param theObject the object to smooth
2702 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2703 # Note that nodes built on edges and boundary nodes are always fixed.
2704 # @param MaxNbOfIterations the maximum number of iterations
2705 # @param MaxAspectRatio varies in range [1.0, inf]
2706 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2707 # @return TRUE in case of success, FALSE otherwise.
2708 # @ingroup l2_modif_smooth
2709 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2710 MaxNbOfIterations, MaxAspectRatio, Method):
2711 if ( isinstance( theObject, Mesh )):
2712 theObject = theObject.GetMesh()
2713 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2714 MaxNbOfIterations, MaxAspectRatio, Method)
2716 ## Converts the mesh to quadratic, deletes old elements, replacing
2717 # them with quadratic with the same id.
2718 # @ingroup l2_modif_tofromqu
2719 def ConvertToQuadratic(self, theForce3d):
2720 self.editor.ConvertToQuadratic(theForce3d)
2722 ## Converts the mesh from quadratic to ordinary,
2723 # deletes old quadratic elements, \n replacing
2724 # them with ordinary mesh elements with the same id.
2725 # @return TRUE in case of success, FALSE otherwise.
2726 # @ingroup l2_modif_tofromqu
2727 def ConvertFromQuadratic(self):
2728 return self.editor.ConvertFromQuadratic()
2730 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2731 # @return TRUE if operation has been completed successfully, FALSE otherwise
2732 # @ingroup l2_modif_edit
2733 def Make2DMeshFrom3D(self):
2734 return self.editor. Make2DMeshFrom3D()
2736 ## Renumber mesh nodes
2737 # @ingroup l2_modif_renumber
2738 def RenumberNodes(self):
2739 self.editor.RenumberNodes()
2741 ## Renumber mesh elements
2742 # @ingroup l2_modif_renumber
2743 def RenumberElements(self):
2744 self.editor.RenumberElements()
2746 ## Generates new elements by rotation of the elements around the axis
2747 # @param IDsOfElements the list of ids of elements to sweep
2748 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2749 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2750 # @param NbOfSteps the number of steps
2751 # @param Tolerance tolerance
2752 # @param MakeGroups forces the generation of new groups from existing ones
2753 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2754 # of all steps, else - size of each step
2755 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2756 # @ingroup l2_modif_extrurev
2757 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2758 MakeGroups=False, TotalAngle=False):
2760 if isinstance(AngleInRadians,str):
2762 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2764 AngleInRadians = DegreesToRadians(AngleInRadians)
2765 if IDsOfElements == []:
2766 IDsOfElements = self.GetElementsId()
2767 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2768 Axis = self.smeshpyD.GetAxisStruct(Axis)
2769 Axis,AxisParameters = ParseAxisStruct(Axis)
2770 if TotalAngle and NbOfSteps:
2771 AngleInRadians /= NbOfSteps
2772 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2773 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2774 self.mesh.SetParameters(Parameters)
2776 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2777 AngleInRadians, NbOfSteps, Tolerance)
2778 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2781 ## Generates new elements by rotation of the elements of object around the axis
2782 # @param theObject object which elements should be sweeped
2783 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2784 # @param AngleInRadians the angle of Rotation
2785 # @param NbOfSteps number of steps
2786 # @param Tolerance tolerance
2787 # @param MakeGroups forces the generation of new groups from existing ones
2788 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2789 # of all steps, else - size of each step
2790 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2791 # @ingroup l2_modif_extrurev
2792 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2793 MakeGroups=False, TotalAngle=False):
2795 if isinstance(AngleInRadians,str):
2797 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2799 AngleInRadians = DegreesToRadians(AngleInRadians)
2800 if ( isinstance( theObject, Mesh )):
2801 theObject = theObject.GetMesh()
2802 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2803 Axis = self.smeshpyD.GetAxisStruct(Axis)
2804 Axis,AxisParameters = ParseAxisStruct(Axis)
2805 if TotalAngle and NbOfSteps:
2806 AngleInRadians /= NbOfSteps
2807 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2808 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2809 self.mesh.SetParameters(Parameters)
2811 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2812 NbOfSteps, Tolerance)
2813 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2816 ## Generates new elements by rotation of the elements of object around the axis
2817 # @param theObject object which elements should be sweeped
2818 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2819 # @param AngleInRadians the angle of Rotation
2820 # @param NbOfSteps number of steps
2821 # @param Tolerance tolerance
2822 # @param MakeGroups forces the generation of new groups from existing ones
2823 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2824 # of all steps, else - size of each step
2825 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2826 # @ingroup l2_modif_extrurev
2827 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2828 MakeGroups=False, TotalAngle=False):
2830 if isinstance(AngleInRadians,str):
2832 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2834 AngleInRadians = DegreesToRadians(AngleInRadians)
2835 if ( isinstance( theObject, Mesh )):
2836 theObject = theObject.GetMesh()
2837 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2838 Axis = self.smeshpyD.GetAxisStruct(Axis)
2839 Axis,AxisParameters = ParseAxisStruct(Axis)
2840 if TotalAngle and NbOfSteps:
2841 AngleInRadians /= NbOfSteps
2842 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2843 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2844 self.mesh.SetParameters(Parameters)
2846 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2847 NbOfSteps, Tolerance)
2848 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2851 ## Generates new elements by rotation of the elements of object around the axis
2852 # @param theObject object which elements should be sweeped
2853 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2854 # @param AngleInRadians the angle of Rotation
2855 # @param NbOfSteps number of steps
2856 # @param Tolerance tolerance
2857 # @param MakeGroups forces the generation of new groups from existing ones
2858 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2859 # of all steps, else - size of each step
2860 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2861 # @ingroup l2_modif_extrurev
2862 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2863 MakeGroups=False, TotalAngle=False):
2865 if isinstance(AngleInRadians,str):
2867 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2869 AngleInRadians = DegreesToRadians(AngleInRadians)
2870 if ( isinstance( theObject, Mesh )):
2871 theObject = theObject.GetMesh()
2872 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2873 Axis = self.smeshpyD.GetAxisStruct(Axis)
2874 Axis,AxisParameters = ParseAxisStruct(Axis)
2875 if TotalAngle and NbOfSteps:
2876 AngleInRadians /= NbOfSteps
2877 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2878 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2879 self.mesh.SetParameters(Parameters)
2881 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2882 NbOfSteps, Tolerance)
2883 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2886 ## Generates new elements by extrusion of the elements with given ids
2887 # @param IDsOfElements the list of elements ids for extrusion
2888 # @param StepVector vector, defining the direction and value of extrusion
2889 # @param NbOfSteps the number of steps
2890 # @param MakeGroups forces the generation of new groups from existing ones
2891 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2892 # @ingroup l2_modif_extrurev
2893 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2894 if IDsOfElements == []:
2895 IDsOfElements = self.GetElementsId()
2896 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2897 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2898 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2899 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2900 Parameters = StepVectorParameters + var_separator + Parameters
2901 self.mesh.SetParameters(Parameters)
2903 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2904 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2907 ## Generates new elements by extrusion of the elements with given ids
2908 # @param IDsOfElements is ids of elements
2909 # @param StepVector vector, defining the direction and value of extrusion
2910 # @param NbOfSteps the number of steps
2911 # @param ExtrFlags sets flags for extrusion
2912 # @param SewTolerance uses for comparing locations of nodes if flag
2913 # EXTRUSION_FLAG_SEW is set
2914 # @param MakeGroups forces the generation of new groups from existing ones
2915 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2916 # @ingroup l2_modif_extrurev
2917 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2918 ExtrFlags, SewTolerance, MakeGroups=False):
2919 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2920 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2922 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2923 ExtrFlags, SewTolerance)
2924 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2925 ExtrFlags, SewTolerance)
2928 ## Generates new elements by extrusion of the elements which belong to the object
2929 # @param theObject the object which elements should be processed
2930 # @param StepVector vector, defining the direction and value of extrusion
2931 # @param NbOfSteps the number of steps
2932 # @param MakeGroups forces the generation of new groups from existing ones
2933 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2934 # @ingroup l2_modif_extrurev
2935 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2936 if ( isinstance( theObject, Mesh )):
2937 theObject = theObject.GetMesh()
2938 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2939 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2940 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2941 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2942 Parameters = StepVectorParameters + var_separator + Parameters
2943 self.mesh.SetParameters(Parameters)
2945 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2946 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2949 ## Generates new elements by extrusion of the elements which belong to the object
2950 # @param theObject object which elements should be processed
2951 # @param StepVector vector, defining the direction and value of extrusion
2952 # @param NbOfSteps the number of steps
2953 # @param MakeGroups to generate new groups from existing ones
2954 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2955 # @ingroup l2_modif_extrurev
2956 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2957 if ( isinstance( theObject, Mesh )):
2958 theObject = theObject.GetMesh()
2959 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2960 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2961 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2962 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2963 Parameters = StepVectorParameters + var_separator + Parameters
2964 self.mesh.SetParameters(Parameters)
2966 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2967 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2970 ## Generates new elements by extrusion of the elements which belong to the object
2971 # @param theObject object which elements should be processed
2972 # @param StepVector vector, defining the direction and value of extrusion
2973 # @param NbOfSteps the number of steps
2974 # @param MakeGroups forces the generation of new groups from existing ones
2975 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2976 # @ingroup l2_modif_extrurev
2977 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2978 if ( isinstance( theObject, Mesh )):
2979 theObject = theObject.GetMesh()
2980 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2981 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2982 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2983 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2984 Parameters = StepVectorParameters + var_separator + Parameters
2985 self.mesh.SetParameters(Parameters)
2987 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2988 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2993 ## Generates new elements by extrusion of the given elements
2994 # The path of extrusion must be a meshed edge.
2995 # @param Base mesh or list of ids of elements for extrusion
2996 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2997 # @param NodeStart the start node from Path. Defines the direction of extrusion
2998 # @param HasAngles allows the shape to be rotated around the path
2999 # to get the resulting mesh in a helical fashion
3000 # @param Angles list of angles in radians
3001 # @param LinearVariation forces the computation of rotation angles as linear
3002 # variation of the given Angles along path steps
3003 # @param HasRefPoint allows using the reference point
3004 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3005 # The User can specify any point as the Reference Point.
3006 # @param MakeGroups forces the generation of new groups from existing ones
3007 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3008 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3009 # only SMESH::Extrusion_Error otherwise
3010 # @ingroup l2_modif_extrurev
3011 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3012 HasAngles, Angles, LinearVariation,
3013 HasRefPoint, RefPoint, MakeGroups, ElemType):
3014 Angles,AnglesParameters = ParseAngles(Angles)
3015 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3016 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3017 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3019 Parameters = AnglesParameters + var_separator + RefPointParameters
3020 self.mesh.SetParameters(Parameters)
3022 if isinstance(Base,list):
3024 if Base == []: IDsOfElements = self.GetElementsId()
3025 else: IDsOfElements = Base
3026 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3027 HasAngles, Angles, LinearVariation,
3028 HasRefPoint, RefPoint, MakeGroups, ElemType)
3030 if isinstance(Base,Mesh):
3031 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3032 HasAngles, Angles, LinearVariation,
3033 HasRefPoint, RefPoint, MakeGroups, ElemType)
3035 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3038 ## Generates new elements by extrusion of the given elements
3039 # The path of extrusion must be a meshed edge.
3040 # @param IDsOfElements ids of elements
3041 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3042 # @param PathShape shape(edge) defines the sub-mesh for the path
3043 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3044 # @param HasAngles allows the shape to be rotated around the path
3045 # to get the resulting mesh in a helical fashion
3046 # @param Angles list of angles in radians
3047 # @param HasRefPoint allows using the reference point
3048 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3049 # The User can specify any point as the Reference Point.
3050 # @param MakeGroups forces the generation of new groups from existing ones
3051 # @param LinearVariation forces the computation of rotation angles as linear
3052 # variation of the given Angles along path steps
3053 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3054 # only SMESH::Extrusion_Error otherwise
3055 # @ingroup l2_modif_extrurev
3056 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3057 HasAngles, Angles, HasRefPoint, RefPoint,
3058 MakeGroups=False, LinearVariation=False):
3059 Angles,AnglesParameters = ParseAngles(Angles)
3060 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3061 if IDsOfElements == []:
3062 IDsOfElements = self.GetElementsId()
3063 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3064 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3066 if ( isinstance( PathMesh, Mesh )):
3067 PathMesh = PathMesh.GetMesh()
3068 if HasAngles and Angles and LinearVariation:
3069 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3071 Parameters = AnglesParameters + var_separator + RefPointParameters
3072 self.mesh.SetParameters(Parameters)
3074 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3075 PathShape, NodeStart, HasAngles,
3076 Angles, HasRefPoint, RefPoint)
3077 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3078 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3080 ## Generates new elements by extrusion of the elements which belong to the object
3081 # The path of extrusion must be a meshed edge.
3082 # @param theObject the object which elements should be processed
3083 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3084 # @param PathShape shape(edge) defines the sub-mesh for the path
3085 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3086 # @param HasAngles allows the shape to be rotated around the path
3087 # to get the resulting mesh in a helical fashion
3088 # @param Angles list of angles
3089 # @param HasRefPoint allows using the reference point
3090 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3091 # The User can specify any point as the Reference Point.
3092 # @param MakeGroups forces the generation of new groups from existing ones
3093 # @param LinearVariation forces the computation of rotation angles as linear
3094 # variation of the given Angles along path steps
3095 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3096 # only SMESH::Extrusion_Error otherwise
3097 # @ingroup l2_modif_extrurev
3098 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3099 HasAngles, Angles, HasRefPoint, RefPoint,
3100 MakeGroups=False, LinearVariation=False):
3101 Angles,AnglesParameters = ParseAngles(Angles)
3102 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3103 if ( isinstance( theObject, Mesh )):
3104 theObject = theObject.GetMesh()
3105 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3106 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3107 if ( isinstance( PathMesh, Mesh )):
3108 PathMesh = PathMesh.GetMesh()
3109 if HasAngles and Angles and LinearVariation:
3110 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3112 Parameters = AnglesParameters + var_separator + RefPointParameters
3113 self.mesh.SetParameters(Parameters)
3115 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3116 PathShape, NodeStart, HasAngles,
3117 Angles, HasRefPoint, RefPoint)
3118 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3119 NodeStart, HasAngles, Angles, HasRefPoint,
3122 ## Generates new elements by extrusion of the elements which belong to the object
3123 # The path of extrusion must be a meshed edge.
3124 # @param theObject the object which elements should be processed
3125 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3126 # @param PathShape shape(edge) defines the sub-mesh for the path
3127 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3128 # @param HasAngles allows the shape to be rotated around the path
3129 # to get the resulting mesh in a helical fashion
3130 # @param Angles list of angles
3131 # @param HasRefPoint allows using the reference point
3132 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3133 # The User can specify any point as the Reference Point.
3134 # @param MakeGroups forces the generation of new groups from existing ones
3135 # @param LinearVariation forces the computation of rotation angles as linear
3136 # variation of the given Angles along path steps
3137 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3138 # only SMESH::Extrusion_Error otherwise
3139 # @ingroup l2_modif_extrurev
3140 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3141 HasAngles, Angles, HasRefPoint, RefPoint,
3142 MakeGroups=False, LinearVariation=False):
3143 Angles,AnglesParameters = ParseAngles(Angles)
3144 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3145 if ( isinstance( theObject, Mesh )):
3146 theObject = theObject.GetMesh()
3147 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3148 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3149 if ( isinstance( PathMesh, Mesh )):
3150 PathMesh = PathMesh.GetMesh()
3151 if HasAngles and Angles and LinearVariation:
3152 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3154 Parameters = AnglesParameters + var_separator + RefPointParameters
3155 self.mesh.SetParameters(Parameters)
3157 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3158 PathShape, NodeStart, HasAngles,
3159 Angles, HasRefPoint, RefPoint)
3160 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3161 NodeStart, HasAngles, Angles, HasRefPoint,
3164 ## Generates new elements by extrusion of the elements which belong to the object
3165 # The path of extrusion must be a meshed edge.
3166 # @param theObject the object which elements should be processed
3167 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3168 # @param PathShape shape(edge) defines the sub-mesh for the path
3169 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3170 # @param HasAngles allows the shape to be rotated around the path
3171 # to get the resulting mesh in a helical fashion
3172 # @param Angles list of angles
3173 # @param HasRefPoint allows using the reference point
3174 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3175 # The User can specify any point as the Reference Point.
3176 # @param MakeGroups forces the generation of new groups from existing ones
3177 # @param LinearVariation forces the computation of rotation angles as linear
3178 # variation of the given Angles along path steps
3179 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3180 # only SMESH::Extrusion_Error otherwise
3181 # @ingroup l2_modif_extrurev
3182 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3183 HasAngles, Angles, HasRefPoint, RefPoint,
3184 MakeGroups=False, LinearVariation=False):
3185 Angles,AnglesParameters = ParseAngles(Angles)
3186 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3187 if ( isinstance( theObject, Mesh )):
3188 theObject = theObject.GetMesh()
3189 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3190 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3191 if ( isinstance( PathMesh, Mesh )):
3192 PathMesh = PathMesh.GetMesh()
3193 if HasAngles and Angles and LinearVariation:
3194 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3196 Parameters = AnglesParameters + var_separator + RefPointParameters
3197 self.mesh.SetParameters(Parameters)
3199 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3200 PathShape, NodeStart, HasAngles,
3201 Angles, HasRefPoint, RefPoint)
3202 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3203 NodeStart, HasAngles, Angles, HasRefPoint,
3206 ## Creates a symmetrical copy of mesh elements
3207 # @param IDsOfElements list of elements ids
3208 # @param Mirror is AxisStruct or geom object(point, line, plane)
3209 # @param theMirrorType is POINT, AXIS or PLANE
3210 # If the Mirror is a geom object this parameter is unnecessary
3211 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3212 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3213 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3214 # @ingroup l2_modif_trsf
3215 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3216 if IDsOfElements == []:
3217 IDsOfElements = self.GetElementsId()
3218 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3219 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3220 Mirror,Parameters = ParseAxisStruct(Mirror)
3221 self.mesh.SetParameters(Parameters)
3222 if Copy and MakeGroups:
3223 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3224 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3227 ## Creates a new mesh by a symmetrical copy of mesh elements
3228 # @param IDsOfElements the list of elements ids
3229 # @param Mirror is AxisStruct or geom object (point, line, plane)
3230 # @param theMirrorType is POINT, AXIS or PLANE
3231 # If the Mirror is a geom object this parameter is unnecessary
3232 # @param MakeGroups to generate new groups from existing ones
3233 # @param NewMeshName a name of the new mesh to create
3234 # @return instance of Mesh class
3235 # @ingroup l2_modif_trsf
3236 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3237 if IDsOfElements == []:
3238 IDsOfElements = self.GetElementsId()
3239 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3240 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3241 Mirror,Parameters = ParseAxisStruct(Mirror)
3242 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3243 MakeGroups, NewMeshName)
3244 mesh.SetParameters(Parameters)
3245 return Mesh(self.smeshpyD,self.geompyD,mesh)
3247 ## Creates a symmetrical copy of the object
3248 # @param theObject mesh, submesh or group
3249 # @param Mirror AxisStruct or geom object (point, line, plane)
3250 # @param theMirrorType is POINT, AXIS or PLANE
3251 # If the Mirror is a geom object this parameter is unnecessary
3252 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3253 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3254 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3255 # @ingroup l2_modif_trsf
3256 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3257 if ( isinstance( theObject, Mesh )):
3258 theObject = theObject.GetMesh()
3259 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3260 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3261 Mirror,Parameters = ParseAxisStruct(Mirror)
3262 self.mesh.SetParameters(Parameters)
3263 if Copy and MakeGroups:
3264 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3265 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3268 ## Creates a new mesh by a symmetrical copy of the object
3269 # @param theObject mesh, submesh or group
3270 # @param Mirror AxisStruct or geom object (point, line, plane)
3271 # @param theMirrorType POINT, AXIS or PLANE
3272 # If the Mirror is a geom object this parameter is unnecessary
3273 # @param MakeGroups forces the generation of new groups from existing ones
3274 # @param NewMeshName the name of the new mesh to create
3275 # @return instance of Mesh class
3276 # @ingroup l2_modif_trsf
3277 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3278 if ( isinstance( theObject, Mesh )):
3279 theObject = theObject.GetMesh()
3280 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3281 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3282 Mirror,Parameters = ParseAxisStruct(Mirror)
3283 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3284 MakeGroups, NewMeshName)
3285 mesh.SetParameters(Parameters)
3286 return Mesh( self.smeshpyD,self.geompyD,mesh )
3288 ## Translates the elements
3289 # @param IDsOfElements list of elements ids
3290 # @param Vector the direction of translation (DirStruct or vector)
3291 # @param Copy allows copying the translated elements
3292 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3293 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3294 # @ingroup l2_modif_trsf
3295 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3296 if IDsOfElements == []:
3297 IDsOfElements = self.GetElementsId()
3298 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3299 Vector = self.smeshpyD.GetDirStruct(Vector)
3300 Vector,Parameters = ParseDirStruct(Vector)
3301 self.mesh.SetParameters(Parameters)
3302 if Copy and MakeGroups:
3303 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3304 self.editor.Translate(IDsOfElements, Vector, Copy)
3307 ## Creates a new mesh of translated elements
3308 # @param IDsOfElements list of elements ids
3309 # @param Vector the direction of translation (DirStruct or vector)
3310 # @param MakeGroups forces the generation of new groups from existing ones
3311 # @param NewMeshName the name of the newly created mesh
3312 # @return instance of Mesh class
3313 # @ingroup l2_modif_trsf
3314 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3315 if IDsOfElements == []:
3316 IDsOfElements = self.GetElementsId()
3317 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3318 Vector = self.smeshpyD.GetDirStruct(Vector)
3319 Vector,Parameters = ParseDirStruct(Vector)
3320 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3321 mesh.SetParameters(Parameters)
3322 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3324 ## Translates the object
3325 # @param theObject the object to translate (mesh, submesh, or group)
3326 # @param Vector direction of translation (DirStruct or geom vector)
3327 # @param Copy allows copying the translated elements
3328 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3329 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3330 # @ingroup l2_modif_trsf
3331 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3332 if ( isinstance( theObject, Mesh )):
3333 theObject = theObject.GetMesh()
3334 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3335 Vector = self.smeshpyD.GetDirStruct(Vector)
3336 Vector,Parameters = ParseDirStruct(Vector)
3337 self.mesh.SetParameters(Parameters)
3338 if Copy and MakeGroups:
3339 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3340 self.editor.TranslateObject(theObject, Vector, Copy)
3343 ## Creates a new mesh from the translated object
3344 # @param theObject the object to translate (mesh, submesh, or group)
3345 # @param Vector the direction of translation (DirStruct or geom vector)
3346 # @param MakeGroups forces the generation of new groups from existing ones
3347 # @param NewMeshName the name of the newly created mesh
3348 # @return instance of Mesh class
3349 # @ingroup l2_modif_trsf
3350 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3351 if (isinstance(theObject, Mesh)):
3352 theObject = theObject.GetMesh()
3353 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3354 Vector = self.smeshpyD.GetDirStruct(Vector)
3355 Vector,Parameters = ParseDirStruct(Vector)
3356 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3357 mesh.SetParameters(Parameters)
3358 return Mesh( self.smeshpyD, self.geompyD, mesh )
3362 ## Scales the object
3363 # @param theObject - the object to translate (mesh, submesh, or group)
3364 # @param thePoint - base point for scale
3365 # @param theScaleFact - scale factors for axises
3366 # @param Copy - allows copying the translated elements
3367 # @param MakeGroups - forces the generation of new groups from existing
3369 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3370 # empty list otherwise
3371 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3372 if ( isinstance( theObject, Mesh )):
3373 theObject = theObject.GetMesh()
3374 if ( isinstance( theObject, list )):
3375 theObject = self.editor.MakeIDSource(theObject)
3377 thePoint, Parameters = ParsePointStruct(thePoint)
3378 self.mesh.SetParameters(Parameters)
3380 if Copy and MakeGroups:
3381 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3382 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3385 ## Creates a new mesh from the translated object
3386 # @param theObject - the object to translate (mesh, submesh, or group)
3387 # @param thePoint - base point for scale
3388 # @param theScaleFact - scale factors for axises
3389 # @param MakeGroups - forces the generation of new groups from existing ones
3390 # @param NewMeshName - the name of the newly created mesh
3391 # @return instance of Mesh class
3392 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3393 if (isinstance(theObject, Mesh)):
3394 theObject = theObject.GetMesh()
3395 if ( isinstance( theObject, list )):
3396 theObject = self.editor.MakeIDSource(theObject)
3398 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3399 MakeGroups, NewMeshName)
3400 #mesh.SetParameters(Parameters)
3401 return Mesh( self.smeshpyD, self.geompyD, mesh )
3405 ## Rotates the elements
3406 # @param IDsOfElements list of elements ids
3407 # @param Axis the axis of rotation (AxisStruct or geom line)
3408 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3409 # @param Copy allows copying the rotated elements
3410 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3411 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3412 # @ingroup l2_modif_trsf
3413 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3415 if isinstance(AngleInRadians,str):
3417 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3419 AngleInRadians = DegreesToRadians(AngleInRadians)
3420 if IDsOfElements == []:
3421 IDsOfElements = self.GetElementsId()
3422 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3423 Axis = self.smeshpyD.GetAxisStruct(Axis)
3424 Axis,AxisParameters = ParseAxisStruct(Axis)
3425 Parameters = AxisParameters + var_separator + Parameters
3426 self.mesh.SetParameters(Parameters)
3427 if Copy and MakeGroups:
3428 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3429 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3432 ## Creates a new mesh of rotated elements
3433 # @param IDsOfElements list of element ids
3434 # @param Axis the axis of rotation (AxisStruct or geom line)
3435 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3436 # @param MakeGroups forces the generation of new groups from existing ones
3437 # @param NewMeshName the name of the newly created mesh
3438 # @return instance of Mesh class
3439 # @ingroup l2_modif_trsf
3440 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3442 if isinstance(AngleInRadians,str):
3444 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3446 AngleInRadians = DegreesToRadians(AngleInRadians)
3447 if IDsOfElements == []:
3448 IDsOfElements = self.GetElementsId()
3449 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3450 Axis = self.smeshpyD.GetAxisStruct(Axis)
3451 Axis,AxisParameters = ParseAxisStruct(Axis)
3452 Parameters = AxisParameters + var_separator + Parameters
3453 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3454 MakeGroups, NewMeshName)
3455 mesh.SetParameters(Parameters)
3456 return Mesh( self.smeshpyD, self.geompyD, mesh )
3458 ## Rotates the object
3459 # @param theObject the object to rotate( mesh, submesh, or group)
3460 # @param Axis the axis of rotation (AxisStruct or geom line)
3461 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3462 # @param Copy allows copying the rotated elements
3463 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3464 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3465 # @ingroup l2_modif_trsf
3466 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3468 if isinstance(AngleInRadians,str):
3470 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3472 AngleInRadians = DegreesToRadians(AngleInRadians)
3473 if (isinstance(theObject, Mesh)):
3474 theObject = theObject.GetMesh()
3475 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3476 Axis = self.smeshpyD.GetAxisStruct(Axis)
3477 Axis,AxisParameters = ParseAxisStruct(Axis)
3478 Parameters = AxisParameters + ":" + Parameters
3479 self.mesh.SetParameters(Parameters)
3480 if Copy and MakeGroups:
3481 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3482 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3485 ## Creates a new mesh from the rotated object
3486 # @param theObject the object to rotate (mesh, submesh, or group)
3487 # @param Axis the axis of rotation (AxisStruct or geom line)
3488 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3489 # @param MakeGroups forces the generation of new groups from existing ones
3490 # @param NewMeshName the name of the newly created mesh
3491 # @return instance of Mesh class
3492 # @ingroup l2_modif_trsf
3493 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3495 if isinstance(AngleInRadians,str):
3497 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3499 AngleInRadians = DegreesToRadians(AngleInRadians)
3500 if (isinstance( theObject, Mesh )):
3501 theObject = theObject.GetMesh()
3502 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3503 Axis = self.smeshpyD.GetAxisStruct(Axis)
3504 Axis,AxisParameters = ParseAxisStruct(Axis)
3505 Parameters = AxisParameters + ":" + Parameters
3506 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3507 MakeGroups, NewMeshName)
3508 mesh.SetParameters(Parameters)
3509 return Mesh( self.smeshpyD, self.geompyD, mesh )
3511 ## Finds groups of ajacent nodes within Tolerance.
3512 # @param Tolerance the value of tolerance
3513 # @return the list of groups of nodes
3514 # @ingroup l2_modif_trsf
3515 def FindCoincidentNodes (self, Tolerance):
3516 return self.editor.FindCoincidentNodes(Tolerance)
3518 ## Finds groups of ajacent nodes within Tolerance.
3519 # @param Tolerance the value of tolerance
3520 # @param SubMeshOrGroup SubMesh or Group
3521 # @return the list of groups of nodes
3522 # @ingroup l2_modif_trsf
3523 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3524 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3527 # @param GroupsOfNodes the list of groups of nodes
3528 # @ingroup l2_modif_trsf
3529 def MergeNodes (self, GroupsOfNodes):
3530 self.editor.MergeNodes(GroupsOfNodes)
3532 ## Finds the elements built on the same nodes.
3533 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3534 # @return a list of groups of equal elements
3535 # @ingroup l2_modif_trsf
3536 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3537 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3538 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3539 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3541 ## Merges elements in each given group.
3542 # @param GroupsOfElementsID groups of elements for merging
3543 # @ingroup l2_modif_trsf
3544 def MergeElements(self, GroupsOfElementsID):
3545 self.editor.MergeElements(GroupsOfElementsID)
3547 ## Leaves one element and removes all other elements built on the same nodes.
3548 # @ingroup l2_modif_trsf
3549 def MergeEqualElements(self):
3550 self.editor.MergeEqualElements()
3552 ## Sews free borders
3553 # @return SMESH::Sew_Error
3554 # @ingroup l2_modif_trsf
3555 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3556 FirstNodeID2, SecondNodeID2, LastNodeID2,
3557 CreatePolygons, CreatePolyedrs):
3558 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3559 FirstNodeID2, SecondNodeID2, LastNodeID2,
3560 CreatePolygons, CreatePolyedrs)
3562 ## Sews conform free borders
3563 # @return SMESH::Sew_Error
3564 # @ingroup l2_modif_trsf
3565 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3566 FirstNodeID2, SecondNodeID2):
3567 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3568 FirstNodeID2, SecondNodeID2)
3570 ## Sews border to side
3571 # @return SMESH::Sew_Error
3572 # @ingroup l2_modif_trsf
3573 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3574 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3575 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3576 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3578 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3579 # merged with the nodes of elements of Side2.
3580 # The number of elements in theSide1 and in theSide2 must be
3581 # equal and they should have similar nodal connectivity.
3582 # The nodes to merge should belong to side borders and
3583 # the first node should be linked to the second.
3584 # @return SMESH::Sew_Error
3585 # @ingroup l2_modif_trsf
3586 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3587 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3588 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3589 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3590 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3591 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3593 ## Sets new nodes for the given element.
3594 # @param ide the element id
3595 # @param newIDs nodes ids
3596 # @return If the number of nodes does not correspond to the type of element - returns false
3597 # @ingroup l2_modif_edit
3598 def ChangeElemNodes(self, ide, newIDs):
3599 return self.editor.ChangeElemNodes(ide, newIDs)
3601 ## If during the last operation of MeshEditor some nodes were
3602 # created, this method returns the list of their IDs, \n
3603 # if new nodes were not created - returns empty list
3604 # @return the list of integer values (can be empty)
3605 # @ingroup l1_auxiliary
3606 def GetLastCreatedNodes(self):
3607 return self.editor.GetLastCreatedNodes()
3609 ## If during the last operation of MeshEditor some elements were
3610 # created this method returns the list of their IDs, \n
3611 # if new elements were not created - returns empty list
3612 # @return the list of integer values (can be empty)
3613 # @ingroup l1_auxiliary
3614 def GetLastCreatedElems(self):
3615 return self.editor.GetLastCreatedElems()
3617 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3618 # @param theNodes identifiers of nodes to be doubled
3619 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3620 # nodes. If list of element identifiers is empty then nodes are doubled but
3621 # they not assigned to elements
3622 # @return TRUE if operation has been completed successfully, FALSE otherwise
3623 # @ingroup l2_modif_edit
3624 def DoubleNodes(self, theNodes, theModifiedElems):
3625 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3627 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3628 # This method provided for convenience works as DoubleNodes() described above.
3629 # @param theNodeId identifiers of node to be doubled
3630 # @param theModifiedElems identifiers of elements to be updated
3631 # @return TRUE if operation has been completed successfully, FALSE otherwise
3632 # @ingroup l2_modif_edit
3633 def DoubleNode(self, theNodeId, theModifiedElems):
3634 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3636 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3637 # This method provided for convenience works as DoubleNodes() described above.
3638 # @param theNodes group of nodes to be doubled
3639 # @param theModifiedElems group of elements to be updated.
3640 # @return TRUE if operation has been completed successfully, FALSE otherwise
3641 # @ingroup l2_modif_edit
3642 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3643 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3645 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3646 # This method provided for convenience works as DoubleNodes() described above.
3647 # @param theNodes list of groups of nodes to be doubled
3648 # @param theModifiedElems list of groups of elements to be updated.
3649 # @return TRUE if operation has been completed successfully, FALSE otherwise
3650 # @ingroup l2_modif_edit
3651 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3652 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3654 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3655 # @param theElems - the list of elements (edges or faces) to be replicated
3656 # The nodes for duplication could be found from these elements
3657 # @param theNodesNot - list of nodes to NOT replicate
3658 # @param theAffectedElems - the list of elements (cells and edges) to which the
3659 # replicated nodes should be associated to.
3660 # @return TRUE if operation has been completed successfully, FALSE otherwise
3661 # @ingroup l2_modif_edit
3662 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3663 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3665 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3666 # @param theElems - the list of elements (edges or faces) to be replicated
3667 # The nodes for duplication could be found from these elements
3668 # @param theNodesNot - list of nodes to NOT replicate
3669 # @param theShape - shape to detect affected elements (element which geometric center
3670 # located on or inside shape).
3671 # The replicated nodes should be associated to affected elements.
3672 # @return TRUE if operation has been completed successfully, FALSE otherwise
3673 # @ingroup l2_modif_edit
3674 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3675 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3677 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3678 # This method provided for convenience works as DoubleNodes() described above.
3679 # @param theElems - group of of elements (edges or faces) to be replicated
3680 # @param theNodesNot - group of nodes not to replicated
3681 # @param theAffectedElems - group of elements to which the replicated nodes
3682 # should be associated to.
3683 # @ingroup l2_modif_edit
3684 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
3685 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3687 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3688 # This method provided for convenience works as DoubleNodes() described above.
3689 # @param theElems - group of of elements (edges or faces) to be replicated
3690 # @param theNodesNot - group of nodes not to replicated
3691 # @param theShape - shape to detect affected elements (element which geometric center
3692 # located on or inside shape).
3693 # The replicated nodes should be associated to affected elements.
3694 # @ingroup l2_modif_edit
3695 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3696 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3698 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3699 # This method provided for convenience works as DoubleNodes() described above.
3700 # @param theElems - list of groups of elements (edges or faces) to be replicated
3701 # @param theNodesNot - list of groups of nodes not to replicated
3702 # @param theAffectedElems - group of elements to which the replicated nodes
3703 # should be associated to.
3704 # @return TRUE if operation has been completed successfully, FALSE otherwise
3705 # @ingroup l2_modif_edit
3706 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3707 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3709 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3710 # This method provided for convenience works as DoubleNodes() described above.
3711 # @param theElems - list of groups of elements (edges or faces) to be replicated
3712 # @param theNodesNot - list of groups of nodes not to replicated
3713 # @param theShape - shape to detect affected elements (element which geometric center
3714 # located on or inside shape).
3715 # The replicated nodes should be associated to affected elements.
3716 # @return TRUE if operation has been completed successfully, FALSE otherwise
3717 # @ingroup l2_modif_edit
3718 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3719 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3721 ## The mother class to define algorithm, it is not recommended to use it directly.
3724 # @ingroup l2_algorithms
3725 class Mesh_Algorithm:
3726 # @class Mesh_Algorithm
3727 # @brief Class Mesh_Algorithm
3729 #def __init__(self,smesh):
3737 ## Finds a hypothesis in the study by its type name and parameters.
3738 # Finds only the hypotheses created in smeshpyD engine.
3739 # @return SMESH.SMESH_Hypothesis
3740 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3741 study = smeshpyD.GetCurrentStudy()
3742 #to do: find component by smeshpyD object, not by its data type
3743 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3744 if scomp is not None:
3745 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3746 # Check if the root label of the hypotheses exists
3747 if res and hypRoot is not None:
3748 iter = study.NewChildIterator(hypRoot)
3749 # Check all published hypotheses
3751 hypo_so_i = iter.Value()
3752 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3753 if attr is not None:
3754 anIOR = attr.Value()
3755 hypo_o_i = salome.orb.string_to_object(anIOR)
3756 if hypo_o_i is not None:
3757 # Check if this is a hypothesis
3758 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3759 if hypo_i is not None:
3760 # Check if the hypothesis belongs to current engine
3761 if smeshpyD.GetObjectId(hypo_i) > 0:
3762 # Check if this is the required hypothesis
3763 if hypo_i.GetName() == hypname:
3765 if CompareMethod(hypo_i, args):
3779 ## Finds the algorithm in the study by its type name.
3780 # Finds only the algorithms, which have been created in smeshpyD engine.
3781 # @return SMESH.SMESH_Algo
3782 def FindAlgorithm (self, algoname, smeshpyD):
3783 study = smeshpyD.GetCurrentStudy()
3784 #to do: find component by smeshpyD object, not by its data type
3785 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3786 if scomp is not None:
3787 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3788 # Check if the root label of the algorithms exists
3789 if res and hypRoot is not None:
3790 iter = study.NewChildIterator(hypRoot)
3791 # Check all published algorithms
3793 algo_so_i = iter.Value()
3794 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3795 if attr is not None:
3796 anIOR = attr.Value()
3797 algo_o_i = salome.orb.string_to_object(anIOR)
3798 if algo_o_i is not None:
3799 # Check if this is an algorithm
3800 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3801 if algo_i is not None:
3802 # Checks if the algorithm belongs to the current engine
3803 if smeshpyD.GetObjectId(algo_i) > 0:
3804 # Check if this is the required algorithm
3805 if algo_i.GetName() == algoname:
3818 ## If the algorithm is global, returns 0; \n
3819 # else returns the submesh associated to this algorithm.
3820 def GetSubMesh(self):
3823 ## Returns the wrapped mesher.
3824 def GetAlgorithm(self):
3827 ## Gets the list of hypothesis that can be used with this algorithm
3828 def GetCompatibleHypothesis(self):
3831 mylist = self.algo.GetCompatibleHypothesis()
3834 ## Gets the name of the algorithm
3838 ## Sets the name to the algorithm
3839 def SetName(self, name):
3840 self.mesh.smeshpyD.SetName(self.algo, name)
3842 ## Gets the id of the algorithm
3844 return self.algo.GetId()
3847 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3849 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3850 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3852 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3854 self.Assign(algo, mesh, geom)
3858 def Assign(self, algo, mesh, geom):
3860 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3869 name = GetName(geom)
3872 name = mesh.geompyD.SubShapeName(geom, piece)
3873 mesh.geompyD.addToStudyInFather(piece, geom, name)
3875 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3878 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3879 TreatHypoStatus( status, algo.GetName(), name, True )
3881 def CompareHyp (self, hyp, args):
3882 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3885 def CompareEqualHyp (self, hyp, args):
3889 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3890 UseExisting=0, CompareMethod=""):
3893 if CompareMethod == "": CompareMethod = self.CompareHyp
3894 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3897 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3903 a = a + s + str(args[i])
3907 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3909 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3910 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3913 ## Returns entry of the shape to mesh in the study
3914 def MainShapeEntry(self):
3916 if not self.mesh or not self.mesh.GetMesh(): return entry
3917 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3918 study = self.mesh.smeshpyD.GetCurrentStudy()
3919 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3920 sobj = study.FindObjectIOR(ior)
3921 if sobj: entry = sobj.GetID()
3922 if not entry: return ""
3925 # Public class: Mesh_Segment
3926 # --------------------------
3928 ## Class to define a segment 1D algorithm for discretization
3931 # @ingroup l3_algos_basic
3932 class Mesh_Segment(Mesh_Algorithm):
3934 ## Private constructor.
3935 def __init__(self, mesh, geom=0):
3936 Mesh_Algorithm.__init__(self)
3937 self.Create(mesh, geom, "Regular_1D")
3939 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3940 # @param l for the length of segments that cut an edge
3941 # @param UseExisting if ==true - searches for an existing hypothesis created with
3942 # the same parameters, else (default) - creates a new one
3943 # @param p precision, used for calculation of the number of segments.
3944 # The precision should be a positive, meaningful value within the range [0,1].
3945 # In general, the number of segments is calculated with the formula:
3946 # nb = ceil((edge_length / l) - p)
3947 # Function ceil rounds its argument to the higher integer.
3948 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3949 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3950 # p=1 means rounding of (edge_length / l) to the lower integer.
3951 # Default value is 1e-07.
3952 # @return an instance of StdMeshers_LocalLength hypothesis
3953 # @ingroup l3_hypos_1dhyps
3954 def LocalLength(self, l, UseExisting=0, p=1e-07):
3955 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3956 CompareMethod=self.CompareLocalLength)
3962 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3963 def CompareLocalLength(self, hyp, args):
3964 if IsEqual(hyp.GetLength(), args[0]):
3965 return IsEqual(hyp.GetPrecision(), args[1])
3968 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3969 # @param length is optional maximal allowed length of segment, if it is omitted
3970 # the preestimated length is used that depends on geometry size
3971 # @param UseExisting if ==true - searches for an existing hypothesis created with
3972 # the same parameters, else (default) - create a new one
3973 # @return an instance of StdMeshers_MaxLength hypothesis
3974 # @ingroup l3_hypos_1dhyps
3975 def MaxSize(self, length=0.0, UseExisting=0):
3976 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3979 hyp.SetLength(length)
3981 # set preestimated length
3982 gen = self.mesh.smeshpyD
3983 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3984 self.mesh.GetMesh(), self.mesh.GetShape(),
3986 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3988 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3991 hyp.SetUsePreestimatedLength( length == 0.0 )
3994 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3995 # @param n for the number of segments that cut an edge
3996 # @param s for the scale factor (optional)
3997 # @param reversedEdges is a list of edges to mesh using reversed orientation
3998 # @param UseExisting if ==true - searches for an existing hypothesis created with
3999 # the same parameters, else (default) - create a new one
4000 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4001 # @ingroup l3_hypos_1dhyps
4002 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4003 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4004 reversedEdges, UseExisting = [], reversedEdges
4005 entry = self.MainShapeEntry()
4007 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4008 UseExisting=UseExisting,
4009 CompareMethod=self.CompareNumberOfSegments)
4011 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4012 UseExisting=UseExisting,
4013 CompareMethod=self.CompareNumberOfSegments)
4014 hyp.SetDistrType( 1 )
4015 hyp.SetScaleFactor(s)
4016 hyp.SetNumberOfSegments(n)
4017 hyp.SetReversedEdges( reversedEdges )
4018 hyp.SetObjectEntry( entry )
4022 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4023 def CompareNumberOfSegments(self, hyp, args):
4024 if hyp.GetNumberOfSegments() == args[0]:
4026 if hyp.GetReversedEdges() == args[1]:
4027 if not args[1] or hyp.GetObjectEntry() == args[2]:
4030 if hyp.GetReversedEdges() == args[2]:
4031 if not args[2] or hyp.GetObjectEntry() == args[3]:
4032 if hyp.GetDistrType() == 1:
4033 if IsEqual(hyp.GetScaleFactor(), args[1]):
4037 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4038 # @param start defines the length of the first segment
4039 # @param end defines the length of the last segment
4040 # @param reversedEdges is a list of edges to mesh using reversed orientation
4041 # @param UseExisting if ==true - searches for an existing hypothesis created with
4042 # the same parameters, else (default) - creates a new one
4043 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4044 # @ingroup l3_hypos_1dhyps
4045 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4046 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4047 reversedEdges, UseExisting = [], reversedEdges
4048 entry = self.MainShapeEntry()
4049 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4050 UseExisting=UseExisting,
4051 CompareMethod=self.CompareArithmetic1D)
4052 hyp.SetStartLength(start)
4053 hyp.SetEndLength(end)
4054 hyp.SetReversedEdges( reversedEdges )
4055 hyp.SetObjectEntry( entry )
4059 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4060 def CompareArithmetic1D(self, hyp, args):
4061 if IsEqual(hyp.GetLength(1), args[0]):
4062 if IsEqual(hyp.GetLength(0), args[1]):
4063 if hyp.GetReversedEdges() == args[2]:
4064 if not args[2] or hyp.GetObjectEntry() == args[3]:
4069 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4070 # on curve from 0 to 1 (additionally it is neecessary to check
4071 # orientation of edges and create list of reversed edges if it is
4072 # needed) and sets numbers of segments between given points (default
4073 # values are equals 1
4074 # @param points defines the list of parameters on curve
4075 # @param nbSegs defines the list of numbers of segments
4076 # @param reversedEdges is a list of edges to mesh using reversed orientation
4077 # @param UseExisting if ==true - searches for an existing hypothesis created with
4078 # the same parameters, else (default) - creates a new one
4079 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4080 # @ingroup l3_hypos_1dhyps
4081 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4082 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4083 reversedEdges, UseExisting = [], reversedEdges
4084 if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4085 for i in range( len( reversedEdges )):
4086 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4087 entry = self.MainShapeEntry()
4088 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4089 UseExisting=UseExisting,
4090 CompareMethod=self.CompareFixedPoints1D)
4091 hyp.SetPoints(points)
4092 hyp.SetNbSegments(nbSegs)
4093 hyp.SetReversedEdges(reversedEdges)
4094 hyp.SetObjectEntry(entry)
4098 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4099 ## as the given arguments
4100 def CompareFixedPoints1D(self, hyp, args):
4101 if hyp.GetPoints() == args[0]:
4102 if hyp.GetNbSegments() == args[1]:
4103 if hyp.GetReversedEdges() == args[2]:
4104 if not args[2] or hyp.GetObjectEntry() == args[3]:
4110 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4111 # @param start defines the length of the first segment
4112 # @param end defines the length of the last segment
4113 # @param reversedEdges is a list of edges to mesh using reversed orientation
4114 # @param UseExisting if ==true - searches for an existing hypothesis created with
4115 # the same parameters, else (default) - creates a new one
4116 # @return an instance of StdMeshers_StartEndLength hypothesis
4117 # @ingroup l3_hypos_1dhyps
4118 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4119 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4120 reversedEdges, UseExisting = [], reversedEdges
4121 entry = self.MainShapeEntry()
4122 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4123 UseExisting=UseExisting,
4124 CompareMethod=self.CompareStartEndLength)
4125 hyp.SetStartLength(start)
4126 hyp.SetEndLength(end)
4127 hyp.SetReversedEdges( reversedEdges )
4128 hyp.SetObjectEntry( entry )
4131 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4132 def CompareStartEndLength(self, hyp, args):
4133 if IsEqual(hyp.GetLength(1), args[0]):
4134 if IsEqual(hyp.GetLength(0), args[1]):
4135 if hyp.GetReversedEdges() == args[2]:
4136 if not args[2] or hyp.GetObjectEntry() == args[3]:
4140 ## Defines "Deflection1D" hypothesis
4141 # @param d for the deflection
4142 # @param UseExisting if ==true - searches for an existing hypothesis created with
4143 # the same parameters, else (default) - create a new one
4144 # @ingroup l3_hypos_1dhyps
4145 def Deflection1D(self, d, UseExisting=0):
4146 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4147 CompareMethod=self.CompareDeflection1D)
4148 hyp.SetDeflection(d)
4151 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4152 def CompareDeflection1D(self, hyp, args):
4153 return IsEqual(hyp.GetDeflection(), args[0])
4155 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4156 # the opposite side in case of quadrangular faces
4157 # @ingroup l3_hypos_additi
4158 def Propagation(self):
4159 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4161 ## Defines "AutomaticLength" hypothesis
4162 # @param fineness for the fineness [0-1]
4163 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4164 # same parameters, else (default) - create a new one
4165 # @ingroup l3_hypos_1dhyps
4166 def AutomaticLength(self, fineness=0, UseExisting=0):
4167 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4168 CompareMethod=self.CompareAutomaticLength)
4169 hyp.SetFineness( fineness )
4172 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4173 def CompareAutomaticLength(self, hyp, args):
4174 return IsEqual(hyp.GetFineness(), args[0])
4176 ## Defines "SegmentLengthAroundVertex" hypothesis
4177 # @param length for the segment length
4178 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4179 # Any other integer value means that the hypothesis will be set on the
4180 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4181 # @param UseExisting if ==true - searches for an existing hypothesis created with
4182 # the same parameters, else (default) - creates a new one
4183 # @ingroup l3_algos_segmarv
4184 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4186 store_geom = self.geom
4187 if type(vertex) is types.IntType:
4188 if vertex == 0 or vertex == 1:
4189 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4197 if self.geom is None:
4198 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4200 name = GetName(self.geom)
4203 piece = self.mesh.geom
4204 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4205 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4207 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4209 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4211 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4212 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4214 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4215 CompareMethod=self.CompareLengthNearVertex)
4216 self.geom = store_geom
4217 hyp.SetLength( length )
4220 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4221 # @ingroup l3_algos_segmarv
4222 def CompareLengthNearVertex(self, hyp, args):
4223 return IsEqual(hyp.GetLength(), args[0])
4225 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4226 # If the 2D mesher sees that all boundary edges are quadratic,
4227 # it generates quadratic faces, else it generates linear faces using
4228 # medium nodes as if they are vertices.
4229 # The 3D mesher generates quadratic volumes only if all boundary faces
4230 # are quadratic, else it fails.
4232 # @ingroup l3_hypos_additi
4233 def QuadraticMesh(self):
4234 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4237 # Public class: Mesh_CompositeSegment
4238 # --------------------------
4240 ## Defines a segment 1D algorithm for discretization
4242 # @ingroup l3_algos_basic
4243 class Mesh_CompositeSegment(Mesh_Segment):
4245 ## Private constructor.
4246 def __init__(self, mesh, geom=0):
4247 self.Create(mesh, geom, "CompositeSegment_1D")
4250 # Public class: Mesh_Segment_Python
4251 # ---------------------------------
4253 ## Defines a segment 1D algorithm for discretization with python function
4255 # @ingroup l3_algos_basic
4256 class Mesh_Segment_Python(Mesh_Segment):
4258 ## Private constructor.
4259 def __init__(self, mesh, geom=0):
4260 import Python1dPlugin
4261 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4263 ## Defines "PythonSplit1D" hypothesis
4264 # @param n for the number of segments that cut an edge
4265 # @param func for the python function that calculates the length of all segments
4266 # @param UseExisting if ==true - searches for the existing hypothesis created with
4267 # the same parameters, else (default) - creates a new one
4268 # @ingroup l3_hypos_1dhyps
4269 def PythonSplit1D(self, n, func, UseExisting=0):
4270 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4271 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4272 hyp.SetNumberOfSegments(n)
4273 hyp.SetPythonLog10RatioFunction(func)
4276 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4277 def ComparePythonSplit1D(self, hyp, args):
4278 #if hyp.GetNumberOfSegments() == args[0]:
4279 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4283 # Public class: Mesh_Triangle
4284 # ---------------------------
4286 ## Defines a triangle 2D algorithm
4288 # @ingroup l3_algos_basic
4289 class Mesh_Triangle(Mesh_Algorithm):
4298 ## Private constructor.
4299 def __init__(self, mesh, algoType, geom=0):
4300 Mesh_Algorithm.__init__(self)
4302 self.algoType = algoType
4303 if algoType == MEFISTO:
4304 self.Create(mesh, geom, "MEFISTO_2D")
4306 elif algoType == BLSURF:
4308 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4309 #self.SetPhysicalMesh() - PAL19680
4310 elif algoType == NETGEN:
4312 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4314 elif algoType == NETGEN_2D:
4316 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4319 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4320 # @param area for the maximum area of each triangle
4321 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4322 # same parameters, else (default) - creates a new one
4324 # Only for algoType == MEFISTO || NETGEN_2D
4325 # @ingroup l3_hypos_2dhyps
4326 def MaxElementArea(self, area, UseExisting=0):
4327 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4328 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4329 CompareMethod=self.CompareMaxElementArea)
4330 elif self.algoType == NETGEN:
4331 hyp = self.Parameters(SIMPLE)
4332 hyp.SetMaxElementArea(area)
4335 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4336 def CompareMaxElementArea(self, hyp, args):
4337 return IsEqual(hyp.GetMaxElementArea(), args[0])
4339 ## Defines "LengthFromEdges" hypothesis to build triangles
4340 # based on the length of the edges taken from the wire
4342 # Only for algoType == MEFISTO || NETGEN_2D
4343 # @ingroup l3_hypos_2dhyps
4344 def LengthFromEdges(self):
4345 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4346 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4348 elif self.algoType == NETGEN:
4349 hyp = self.Parameters(SIMPLE)
4350 hyp.LengthFromEdges()
4353 ## Sets a way to define size of mesh elements to generate.
4354 # @param thePhysicalMesh is: DefaultSize or Custom.
4355 # @ingroup l3_hypos_blsurf
4356 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4357 # Parameter of BLSURF algo
4358 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4360 ## Sets size of mesh elements to generate.
4361 # @ingroup l3_hypos_blsurf
4362 def SetPhySize(self, theVal):
4363 # Parameter of BLSURF algo
4364 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4365 self.Parameters().SetPhySize(theVal)
4367 ## Sets lower boundary of mesh element size (PhySize).
4368 # @ingroup l3_hypos_blsurf
4369 def SetPhyMin(self, theVal=-1):
4370 # Parameter of BLSURF algo
4371 self.Parameters().SetPhyMin(theVal)
4373 ## Sets upper boundary of mesh element size (PhySize).
4374 # @ingroup l3_hypos_blsurf
4375 def SetPhyMax(self, theVal=-1):
4376 # Parameter of BLSURF algo
4377 self.Parameters().SetPhyMax(theVal)
4379 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4380 # @param theGeometricMesh is: DefaultGeom or Custom
4381 # @ingroup l3_hypos_blsurf
4382 def SetGeometricMesh(self, theGeometricMesh=0):
4383 # Parameter of BLSURF algo
4384 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4385 self.params.SetGeometricMesh(theGeometricMesh)
4387 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4388 # @ingroup l3_hypos_blsurf
4389 def SetAngleMeshS(self, theVal=_angleMeshS):
4390 # Parameter of BLSURF algo
4391 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4392 self.params.SetAngleMeshS(theVal)
4394 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4395 # @ingroup l3_hypos_blsurf
4396 def SetAngleMeshC(self, theVal=_angleMeshS):
4397 # Parameter of BLSURF algo
4398 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4399 self.params.SetAngleMeshC(theVal)
4401 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4402 # @ingroup l3_hypos_blsurf
4403 def SetGeoMin(self, theVal=-1):
4404 # Parameter of BLSURF algo
4405 self.Parameters().SetGeoMin(theVal)
4407 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4408 # @ingroup l3_hypos_blsurf
4409 def SetGeoMax(self, theVal=-1):
4410 # Parameter of BLSURF algo
4411 self.Parameters().SetGeoMax(theVal)
4413 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4414 # @ingroup l3_hypos_blsurf
4415 def SetGradation(self, theVal=_gradation):
4416 # Parameter of BLSURF algo
4417 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4418 self.params.SetGradation(theVal)
4420 ## Sets topology usage way.
4421 # @param way defines how mesh conformity is assured <ul>
4422 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4423 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4424 # @ingroup l3_hypos_blsurf
4425 def SetTopology(self, way):
4426 # Parameter of BLSURF algo
4427 self.Parameters().SetTopology(way)
4429 ## To respect geometrical edges or not.
4430 # @ingroup l3_hypos_blsurf
4431 def SetDecimesh(self, toIgnoreEdges=False):
4432 # Parameter of BLSURF algo
4433 self.Parameters().SetDecimesh(toIgnoreEdges)
4435 ## Sets verbosity level in the range 0 to 100.
4436 # @ingroup l3_hypos_blsurf
4437 def SetVerbosity(self, level):
4438 # Parameter of BLSURF algo
4439 self.Parameters().SetVerbosity(level)
4441 ## Sets advanced option value.
4442 # @ingroup l3_hypos_blsurf
4443 def SetOptionValue(self, optionName, level):
4444 # Parameter of BLSURF algo
4445 self.Parameters().SetOptionValue(optionName,level)
4447 ## Sets QuadAllowed flag.
4448 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4449 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4450 def SetQuadAllowed(self, toAllow=True):
4451 if self.algoType == NETGEN_2D:
4452 if toAllow: # add QuadranglePreference
4453 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4454 else: # remove QuadranglePreference
4455 for hyp in self.mesh.GetHypothesisList( self.geom ):
4456 if hyp.GetName() == "QuadranglePreference":
4457 self.mesh.RemoveHypothesis( self.geom, hyp )
4462 if self.Parameters():
4463 self.params.SetQuadAllowed(toAllow)
4466 ## Defines hypothesis having several parameters
4468 # @ingroup l3_hypos_netgen
4469 def Parameters(self, which=SOLE):
4472 if self.algoType == NETGEN:
4474 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4475 "libNETGENEngine.so", UseExisting=0)
4477 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4478 "libNETGENEngine.so", UseExisting=0)
4480 elif self.algoType == MEFISTO:
4481 print "Mefisto algo support no multi-parameter hypothesis"
4483 elif self.algoType == NETGEN_2D:
4484 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4485 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4487 elif self.algoType == BLSURF:
4488 self.params = self.Hypothesis("BLSURF_Parameters", [],
4489 "libBLSURFEngine.so", UseExisting=0)
4492 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4497 # Only for algoType == NETGEN
4498 # @ingroup l3_hypos_netgen
4499 def SetMaxSize(self, theSize):
4500 if self.Parameters():
4501 self.params.SetMaxSize(theSize)
4503 ## Sets SecondOrder flag
4505 # Only for algoType == NETGEN
4506 # @ingroup l3_hypos_netgen
4507 def SetSecondOrder(self, theVal):
4508 if self.Parameters():
4509 self.params.SetSecondOrder(theVal)
4511 ## Sets Optimize flag
4513 # Only for algoType == NETGEN
4514 # @ingroup l3_hypos_netgen
4515 def SetOptimize(self, theVal):
4516 if self.Parameters():
4517 self.params.SetOptimize(theVal)
4520 # @param theFineness is:
4521 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4523 # Only for algoType == NETGEN
4524 # @ingroup l3_hypos_netgen
4525 def SetFineness(self, theFineness):
4526 if self.Parameters():
4527 self.params.SetFineness(theFineness)
4531 # Only for algoType == NETGEN
4532 # @ingroup l3_hypos_netgen
4533 def SetGrowthRate(self, theRate):
4534 if self.Parameters():
4535 self.params.SetGrowthRate(theRate)
4537 ## Sets NbSegPerEdge
4539 # Only for algoType == NETGEN
4540 # @ingroup l3_hypos_netgen
4541 def SetNbSegPerEdge(self, theVal):
4542 if self.Parameters():
4543 self.params.SetNbSegPerEdge(theVal)
4545 ## Sets NbSegPerRadius
4547 # Only for algoType == NETGEN
4548 # @ingroup l3_hypos_netgen
4549 def SetNbSegPerRadius(self, theVal):
4550 if self.Parameters():
4551 self.params.SetNbSegPerRadius(theVal)
4553 ## Sets number of segments overriding value set by SetLocalLength()
4555 # Only for algoType == NETGEN
4556 # @ingroup l3_hypos_netgen
4557 def SetNumberOfSegments(self, theVal):
4558 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4560 ## Sets number of segments overriding value set by SetNumberOfSegments()
4562 # Only for algoType == NETGEN
4563 # @ingroup l3_hypos_netgen
4564 def SetLocalLength(self, theVal):
4565 self.Parameters(SIMPLE).SetLocalLength(theVal)
4570 # Public class: Mesh_Quadrangle
4571 # -----------------------------
4573 ## Defines a quadrangle 2D algorithm
4575 # @ingroup l3_algos_basic
4576 class Mesh_Quadrangle(Mesh_Algorithm):
4578 ## Private constructor.
4579 def __init__(self, mesh, geom=0):
4580 Mesh_Algorithm.__init__(self)
4581 self.Create(mesh, geom, "Quadrangle_2D")
4583 ## Defines "QuadranglePreference" hypothesis, forcing construction
4584 # of quadrangles if the number of nodes on the opposite edges is not the same
4585 # while the total number of nodes on edges is even
4587 # @ingroup l3_hypos_additi
4588 def QuadranglePreference(self):
4589 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4590 CompareMethod=self.CompareEqualHyp)
4593 ## Defines "TrianglePreference" hypothesis, forcing construction
4594 # of triangles in the refinement area if the number of nodes
4595 # on the opposite edges is not the same
4597 # @ingroup l3_hypos_additi
4598 def TrianglePreference(self):
4599 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4600 CompareMethod=self.CompareEqualHyp)
4603 ## Defines "QuadrangleParams" hypothesis
4604 # @param vertex: vertex of a trilateral geometrical face, around which triangles
4605 # will be created while other elements will be quadrangles.
4606 # Vertex can be either a GEOM_Object or a vertex ID within the
4608 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4609 # the same parameters, else (default) - creates a new one
4611 # @ingroup l3_hypos_additi
4612 def TriangleVertex(self, vertex, UseExisting=0):
4614 if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4615 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4616 hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4617 CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4618 hyp.SetTriaVertex( vertexID )
4622 # Public class: Mesh_Tetrahedron
4623 # ------------------------------
4625 ## Defines a tetrahedron 3D algorithm
4627 # @ingroup l3_algos_basic
4628 class Mesh_Tetrahedron(Mesh_Algorithm):
4633 ## Private constructor.
4634 def __init__(self, mesh, algoType, geom=0):
4635 Mesh_Algorithm.__init__(self)
4637 if algoType == NETGEN:
4639 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4642 elif algoType == FULL_NETGEN:
4644 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4647 elif algoType == GHS3D:
4649 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4652 elif algoType == GHS3DPRL:
4653 CheckPlugin(GHS3DPRL)
4654 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4657 self.algoType = algoType
4659 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4660 # @param vol for the maximum volume of each tetrahedron
4661 # @param UseExisting if ==true - searches for the existing hypothesis created with
4662 # the same parameters, else (default) - creates a new one
4663 # @ingroup l3_hypos_maxvol
4664 def MaxElementVolume(self, vol, UseExisting=0):
4665 if self.algoType == NETGEN:
4666 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4667 CompareMethod=self.CompareMaxElementVolume)
4668 hyp.SetMaxElementVolume(vol)
4670 elif self.algoType == FULL_NETGEN:
4671 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4674 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4675 def CompareMaxElementVolume(self, hyp, args):
4676 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4678 ## Defines hypothesis having several parameters
4680 # @ingroup l3_hypos_netgen
4681 def Parameters(self, which=SOLE):
4685 if self.algoType == FULL_NETGEN:
4687 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4688 "libNETGENEngine.so", UseExisting=0)
4690 self.params = self.Hypothesis("NETGEN_Parameters", [],
4691 "libNETGENEngine.so", UseExisting=0)
4694 if self.algoType == GHS3D:
4695 self.params = self.Hypothesis("GHS3D_Parameters", [],
4696 "libGHS3DEngine.so", UseExisting=0)
4699 if self.algoType == GHS3DPRL:
4700 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4701 "libGHS3DPRLEngine.so", UseExisting=0)
4704 print "Algo supports no multi-parameter hypothesis"
4708 # Parameter of FULL_NETGEN
4709 # @ingroup l3_hypos_netgen
4710 def SetMaxSize(self, theSize):
4711 self.Parameters().SetMaxSize(theSize)
4713 ## Sets SecondOrder flag
4714 # Parameter of FULL_NETGEN
4715 # @ingroup l3_hypos_netgen
4716 def SetSecondOrder(self, theVal):
4717 self.Parameters().SetSecondOrder(theVal)
4719 ## Sets Optimize flag
4720 # Parameter of FULL_NETGEN
4721 # @ingroup l3_hypos_netgen
4722 def SetOptimize(self, theVal):
4723 self.Parameters().SetOptimize(theVal)
4726 # @param theFineness is:
4727 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4728 # Parameter of FULL_NETGEN
4729 # @ingroup l3_hypos_netgen
4730 def SetFineness(self, theFineness):
4731 self.Parameters().SetFineness(theFineness)
4734 # Parameter of FULL_NETGEN
4735 # @ingroup l3_hypos_netgen
4736 def SetGrowthRate(self, theRate):
4737 self.Parameters().SetGrowthRate(theRate)
4739 ## Sets NbSegPerEdge
4740 # Parameter of FULL_NETGEN
4741 # @ingroup l3_hypos_netgen
4742 def SetNbSegPerEdge(self, theVal):
4743 self.Parameters().SetNbSegPerEdge(theVal)
4745 ## Sets NbSegPerRadius
4746 # Parameter of FULL_NETGEN
4747 # @ingroup l3_hypos_netgen
4748 def SetNbSegPerRadius(self, theVal):
4749 self.Parameters().SetNbSegPerRadius(theVal)
4751 ## Sets number of segments overriding value set by SetLocalLength()
4752 # Only for algoType == NETGEN_FULL
4753 # @ingroup l3_hypos_netgen
4754 def SetNumberOfSegments(self, theVal):
4755 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4757 ## Sets number of segments overriding value set by SetNumberOfSegments()
4758 # Only for algoType == NETGEN_FULL
4759 # @ingroup l3_hypos_netgen
4760 def SetLocalLength(self, theVal):
4761 self.Parameters(SIMPLE).SetLocalLength(theVal)
4763 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4764 # Overrides value set by LengthFromEdges()
4765 # Only for algoType == NETGEN_FULL
4766 # @ingroup l3_hypos_netgen
4767 def MaxElementArea(self, area):
4768 self.Parameters(SIMPLE).SetMaxElementArea(area)
4770 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4771 # Overrides value set by MaxElementArea()
4772 # Only for algoType == NETGEN_FULL
4773 # @ingroup l3_hypos_netgen
4774 def LengthFromEdges(self):
4775 self.Parameters(SIMPLE).LengthFromEdges()
4777 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4778 # Overrides value set by MaxElementVolume()
4779 # Only for algoType == NETGEN_FULL
4780 # @ingroup l3_hypos_netgen
4781 def LengthFromFaces(self):
4782 self.Parameters(SIMPLE).LengthFromFaces()
4784 ## To mesh "holes" in a solid or not. Default is to mesh.
4785 # @ingroup l3_hypos_ghs3dh
4786 def SetToMeshHoles(self, toMesh):
4787 # Parameter of GHS3D
4788 self.Parameters().SetToMeshHoles(toMesh)
4790 ## Set Optimization level:
4791 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4792 # Strong_Optimization.
4793 # Default is Standard_Optimization
4794 # @ingroup l3_hypos_ghs3dh
4795 def SetOptimizationLevel(self, level):
4796 # Parameter of GHS3D
4797 self.Parameters().SetOptimizationLevel(level)
4799 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4800 # @ingroup l3_hypos_ghs3dh
4801 def SetMaximumMemory(self, MB):
4802 # Advanced parameter of GHS3D
4803 self.Parameters().SetMaximumMemory(MB)
4805 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4806 # automatic memory adjustment mode.
4807 # @ingroup l3_hypos_ghs3dh
4808 def SetInitialMemory(self, MB):
4809 # Advanced parameter of GHS3D
4810 self.Parameters().SetInitialMemory(MB)
4812 ## Path to working directory.
4813 # @ingroup l3_hypos_ghs3dh
4814 def SetWorkingDirectory(self, path):
4815 # Advanced parameter of GHS3D
4816 self.Parameters().SetWorkingDirectory(path)
4818 ## To keep working files or remove them. Log file remains in case of errors anyway.
4819 # @ingroup l3_hypos_ghs3dh
4820 def SetKeepFiles(self, toKeep):
4821 # Advanced parameter of GHS3D and GHS3DPRL
4822 self.Parameters().SetKeepFiles(toKeep)
4824 ## To set verbose level [0-10]. <ul>
4825 #<li> 0 - no standard output,
4826 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4827 # indicates when the final mesh is being saved. In addition the software
4828 # gives indication regarding the CPU time.
4829 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4830 # histogram of the skin mesh, quality statistics histogram together with
4831 # the characteristics of the final mesh.</ul>
4832 # @ingroup l3_hypos_ghs3dh
4833 def SetVerboseLevel(self, level):
4834 # Advanced parameter of GHS3D
4835 self.Parameters().SetVerboseLevel(level)
4837 ## To create new nodes.
4838 # @ingroup l3_hypos_ghs3dh
4839 def SetToCreateNewNodes(self, toCreate):
4840 # Advanced parameter of GHS3D
4841 self.Parameters().SetToCreateNewNodes(toCreate)
4843 ## To use boundary recovery version which tries to create mesh on a very poor
4844 # quality surface mesh.
4845 # @ingroup l3_hypos_ghs3dh
4846 def SetToUseBoundaryRecoveryVersion(self, toUse):
4847 # Advanced parameter of GHS3D
4848 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4850 ## Sets command line option as text.
4851 # @ingroup l3_hypos_ghs3dh
4852 def SetTextOption(self, option):
4853 # Advanced parameter of GHS3D
4854 self.Parameters().SetTextOption(option)
4856 ## Sets MED files name and path.
4857 def SetMEDName(self, value):
4858 self.Parameters().SetMEDName(value)
4860 ## Sets the number of partition of the initial mesh
4861 def SetNbPart(self, value):
4862 self.Parameters().SetNbPart(value)
4864 ## When big mesh, start tepal in background
4865 def SetBackground(self, value):
4866 self.Parameters().SetBackground(value)
4868 # Public class: Mesh_Hexahedron
4869 # ------------------------------
4871 ## Defines a hexahedron 3D algorithm
4873 # @ingroup l3_algos_basic
4874 class Mesh_Hexahedron(Mesh_Algorithm):
4879 ## Private constructor.
4880 def __init__(self, mesh, algoType=Hexa, geom=0):
4881 Mesh_Algorithm.__init__(self)
4883 self.algoType = algoType
4885 if algoType == Hexa:
4886 self.Create(mesh, geom, "Hexa_3D")
4889 elif algoType == Hexotic:
4890 CheckPlugin(Hexotic)
4891 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4894 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4895 # @ingroup l3_hypos_hexotic
4896 def MinMaxQuad(self, min=3, max=8, quad=True):
4897 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4899 self.params.SetHexesMinLevel(min)
4900 self.params.SetHexesMaxLevel(max)
4901 self.params.SetHexoticQuadrangles(quad)
4904 # Deprecated, only for compatibility!
4905 # Public class: Mesh_Netgen
4906 # ------------------------------
4908 ## Defines a NETGEN-based 2D or 3D algorithm
4909 # that needs no discrete boundary (i.e. independent)
4911 # This class is deprecated, only for compatibility!
4914 # @ingroup l3_algos_basic
4915 class Mesh_Netgen(Mesh_Algorithm):
4919 ## Private constructor.
4920 def __init__(self, mesh, is3D, geom=0):
4921 Mesh_Algorithm.__init__(self)
4927 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4931 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4934 ## Defines the hypothesis containing parameters of the algorithm
4935 def Parameters(self):
4937 hyp = self.Hypothesis("NETGEN_Parameters", [],
4938 "libNETGENEngine.so", UseExisting=0)
4940 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4941 "libNETGENEngine.so", UseExisting=0)
4944 # Public class: Mesh_Projection1D
4945 # ------------------------------
4947 ## Defines a projection 1D algorithm
4948 # @ingroup l3_algos_proj
4950 class Mesh_Projection1D(Mesh_Algorithm):
4952 ## Private constructor.
4953 def __init__(self, mesh, geom=0):
4954 Mesh_Algorithm.__init__(self)
4955 self.Create(mesh, geom, "Projection_1D")
4957 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4958 # a mesh pattern is taken, and, optionally, the association of vertices
4959 # between the source edge and a target edge (to which a hypothesis is assigned)
4960 # @param edge from which nodes distribution is taken
4961 # @param mesh from which nodes distribution is taken (optional)
4962 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4963 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4964 # to associate with \a srcV (optional)
4965 # @param UseExisting if ==true - searches for the existing hypothesis created with
4966 # the same parameters, else (default) - creates a new one
4967 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4968 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4970 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4971 hyp.SetSourceEdge( edge )
4972 if not mesh is None and isinstance(mesh, Mesh):
4973 mesh = mesh.GetMesh()
4974 hyp.SetSourceMesh( mesh )
4975 hyp.SetVertexAssociation( srcV, tgtV )
4978 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4979 #def CompareSourceEdge(self, hyp, args):
4980 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4984 # Public class: Mesh_Projection2D
4985 # ------------------------------
4987 ## Defines a projection 2D algorithm
4988 # @ingroup l3_algos_proj
4990 class Mesh_Projection2D(Mesh_Algorithm):
4992 ## Private constructor.
4993 def __init__(self, mesh, geom=0):
4994 Mesh_Algorithm.__init__(self)
4995 self.Create(mesh, geom, "Projection_2D")
4997 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4998 # a mesh pattern is taken, and, optionally, the association of vertices
4999 # between the source face and the target face (to which a hypothesis is assigned)
5000 # @param face from which the mesh pattern is taken
5001 # @param mesh from which the mesh pattern is taken (optional)
5002 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5003 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5004 # to associate with \a srcV1 (optional)
5005 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5006 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5007 # to associate with \a srcV2 (optional)
5008 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5009 # the same parameters, else (default) - forces the creation a new one
5011 # Note: all association vertices must belong to one edge of a face
5012 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5013 srcV2=None, tgtV2=None, UseExisting=0):
5014 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5016 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5017 hyp.SetSourceFace( face )
5018 if not mesh is None and isinstance(mesh, Mesh):
5019 mesh = mesh.GetMesh()
5020 hyp.SetSourceMesh( mesh )
5021 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5024 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5025 #def CompareSourceFace(self, hyp, args):
5026 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5029 # Public class: Mesh_Projection3D
5030 # ------------------------------
5032 ## Defines a projection 3D algorithm
5033 # @ingroup l3_algos_proj
5035 class Mesh_Projection3D(Mesh_Algorithm):
5037 ## Private constructor.
5038 def __init__(self, mesh, geom=0):
5039 Mesh_Algorithm.__init__(self)
5040 self.Create(mesh, geom, "Projection_3D")
5042 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5043 # the mesh pattern is taken, and, optionally, the association of vertices
5044 # between the source and the target solid (to which a hipothesis is assigned)
5045 # @param solid from where the mesh pattern is taken
5046 # @param mesh from where the mesh pattern is taken (optional)
5047 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5048 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5049 # to associate with \a srcV1 (optional)
5050 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5051 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5052 # to associate with \a srcV2 (optional)
5053 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5054 # the same parameters, else (default) - creates a new one
5056 # Note: association vertices must belong to one edge of a solid
5057 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5058 srcV2=0, tgtV2=0, UseExisting=0):
5059 hyp = self.Hypothesis("ProjectionSource3D",
5060 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5062 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5063 hyp.SetSource3DShape( solid )
5064 if not mesh is None and isinstance(mesh, Mesh):
5065 mesh = mesh.GetMesh()
5066 hyp.SetSourceMesh( mesh )
5067 if srcV1 and srcV2 and tgtV1 and tgtV2:
5068 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5069 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5072 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5073 #def CompareSourceShape3D(self, hyp, args):
5074 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5078 # Public class: Mesh_Prism
5079 # ------------------------
5081 ## Defines a 3D extrusion algorithm
5082 # @ingroup l3_algos_3dextr
5084 class Mesh_Prism3D(Mesh_Algorithm):
5086 ## Private constructor.
5087 def __init__(self, mesh, geom=0):
5088 Mesh_Algorithm.__init__(self)
5089 self.Create(mesh, geom, "Prism_3D")
5091 # Public class: Mesh_RadialPrism
5092 # -------------------------------
5094 ## Defines a Radial Prism 3D algorithm
5095 # @ingroup l3_algos_radialp
5097 class Mesh_RadialPrism3D(Mesh_Algorithm):
5099 ## Private constructor.
5100 def __init__(self, mesh, geom=0):
5101 Mesh_Algorithm.__init__(self)
5102 self.Create(mesh, geom, "RadialPrism_3D")
5104 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5105 self.nbLayers = None
5107 ## Return 3D hypothesis holding the 1D one
5108 def Get3DHypothesis(self):
5109 return self.distribHyp
5111 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5112 # hypothesis. Returns the created hypothesis
5113 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5114 #print "OwnHypothesis",hypType
5115 if not self.nbLayers is None:
5116 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5117 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5118 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5119 self.mesh.smeshpyD.SetCurrentStudy( None )
5120 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5121 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5122 self.distribHyp.SetLayerDistribution( hyp )
5125 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5126 # prisms to build between the inner and outer shells
5127 # @param n number of layers
5128 # @param UseExisting if ==true - searches for the existing hypothesis created with
5129 # the same parameters, else (default) - creates a new one
5130 def NumberOfLayers(self, n, UseExisting=0):
5131 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5132 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5133 CompareMethod=self.CompareNumberOfLayers)
5134 self.nbLayers.SetNumberOfLayers( n )
5135 return self.nbLayers
5137 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5138 def CompareNumberOfLayers(self, hyp, args):
5139 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5141 ## Defines "LocalLength" hypothesis, specifying the segment length
5142 # to build between the inner and the outer shells
5143 # @param l the length of segments
5144 # @param p the precision of rounding
5145 def LocalLength(self, l, p=1e-07):
5146 hyp = self.OwnHypothesis("LocalLength", [l,p])
5151 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5152 # prisms to build between the inner and the outer shells.
5153 # @param n the number of layers
5154 # @param s the scale factor (optional)
5155 def NumberOfSegments(self, n, s=[]):
5157 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5159 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5160 hyp.SetDistrType( 1 )
5161 hyp.SetScaleFactor(s)
5162 hyp.SetNumberOfSegments(n)
5165 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5166 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5167 # @param start the length of the first segment
5168 # @param end the length of the last segment
5169 def Arithmetic1D(self, start, end ):
5170 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5171 hyp.SetLength(start, 1)
5172 hyp.SetLength(end , 0)
5175 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5176 # to build between the inner and the outer shells as geometric length increasing
5177 # @param start for the length of the first segment
5178 # @param end for the length of the last segment
5179 def StartEndLength(self, start, end):
5180 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5181 hyp.SetLength(start, 1)
5182 hyp.SetLength(end , 0)
5185 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5186 # to build between the inner and outer shells
5187 # @param fineness defines the quality of the mesh within the range [0-1]
5188 def AutomaticLength(self, fineness=0):
5189 hyp = self.OwnHypothesis("AutomaticLength")
5190 hyp.SetFineness( fineness )
5193 # Public class: Mesh_RadialQuadrangle1D2D
5194 # -------------------------------
5196 ## Defines a Radial Quadrangle 1D2D algorithm
5197 # @ingroup l2_algos_radialq
5199 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5201 ## Private constructor.
5202 def __init__(self, mesh, geom=0):
5203 Mesh_Algorithm.__init__(self)
5204 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5206 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5207 self.nbLayers = None
5209 ## Return 2D hypothesis holding the 1D one
5210 def Get2DHypothesis(self):
5211 return self.distribHyp
5213 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5214 # hypothesis. Returns the created hypothesis
5215 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5216 #print "OwnHypothesis",hypType
5218 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5219 if self.distribHyp is None:
5220 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5222 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5223 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5224 self.mesh.smeshpyD.SetCurrentStudy( None )
5225 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5226 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5227 self.distribHyp.SetLayerDistribution( hyp )
5230 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5231 # @param n number of layers
5232 # @param UseExisting if ==true - searches for the existing hypothesis created with
5233 # the same parameters, else (default) - creates a new one
5234 def NumberOfLayers(self, n, UseExisting=0):
5236 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5237 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5238 CompareMethod=self.CompareNumberOfLayers)
5239 self.nbLayers.SetNumberOfLayers( n )
5240 return self.nbLayers
5242 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5243 def CompareNumberOfLayers(self, hyp, args):
5244 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5246 ## Defines "LocalLength" hypothesis, specifying the segment length
5247 # @param l the length of segments
5248 # @param p the precision of rounding
5249 def LocalLength(self, l, p=1e-07):
5250 hyp = self.OwnHypothesis("LocalLength", [l,p])
5255 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5256 # @param n the number of layers
5257 # @param s the scale factor (optional)
5258 def NumberOfSegments(self, n, s=[]):
5260 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5262 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5263 hyp.SetDistrType( 1 )
5264 hyp.SetScaleFactor(s)
5265 hyp.SetNumberOfSegments(n)
5268 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5269 # with a length that changes in arithmetic progression
5270 # @param start the length of the first segment
5271 # @param end the length of the last segment
5272 def Arithmetic1D(self, start, end ):
5273 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5274 hyp.SetLength(start, 1)
5275 hyp.SetLength(end , 0)
5278 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5279 # as geometric length increasing
5280 # @param start for the length of the first segment
5281 # @param end for the length of the last segment
5282 def StartEndLength(self, start, end):
5283 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5284 hyp.SetLength(start, 1)
5285 hyp.SetLength(end , 0)
5288 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5289 # @param fineness defines the quality of the mesh within the range [0-1]
5290 def AutomaticLength(self, fineness=0):
5291 hyp = self.OwnHypothesis("AutomaticLength")
5292 hyp.SetFineness( fineness )
5296 # Private class: Mesh_UseExisting
5297 # -------------------------------
5298 class Mesh_UseExisting(Mesh_Algorithm):
5300 def __init__(self, dim, mesh, geom=0):
5302 self.Create(mesh, geom, "UseExisting_1D")
5304 self.Create(mesh, geom, "UseExisting_2D")
5307 import salome_notebook
5308 notebook = salome_notebook.notebook
5310 ##Return values of the notebook variables
5311 def ParseParameters(last, nbParams,nbParam, value):
5315 listSize = len(last)
5316 for n in range(0,nbParams):
5318 if counter < listSize:
5319 strResult = strResult + last[counter]
5321 strResult = strResult + ""
5323 if isinstance(value, str):
5324 if notebook.isVariable(value):
5325 result = notebook.get(value)
5326 strResult=strResult+value
5328 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5330 strResult=strResult+str(value)
5332 if nbParams - 1 != counter:
5333 strResult=strResult+var_separator #":"
5335 return result, strResult
5337 #Wrapper class for StdMeshers_LocalLength hypothesis
5338 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5340 ## Set Length parameter value
5341 # @param length numerical value or name of variable from notebook
5342 def SetLength(self, length):
5343 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5344 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5345 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5347 ## Set Precision parameter value
5348 # @param precision numerical value or name of variable from notebook
5349 def SetPrecision(self, precision):
5350 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5351 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5352 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5354 #Registering the new proxy for LocalLength
5355 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5358 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5359 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5361 def SetLayerDistribution(self, hypo):
5362 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5363 hypo.ClearParameters();
5364 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5366 #Registering the new proxy for LayerDistribution
5367 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5369 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5370 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5372 ## Set Length parameter value
5373 # @param length numerical value or name of variable from notebook
5374 def SetLength(self, length):
5375 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5376 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5377 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5379 #Registering the new proxy for SegmentLengthAroundVertex
5380 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5383 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5384 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5386 ## Set Length parameter value
5387 # @param length numerical value or name of variable from notebook
5388 # @param isStart true is length is Start Length, otherwise false
5389 def SetLength(self, length, isStart):
5393 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5394 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5395 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5397 #Registering the new proxy for Arithmetic1D
5398 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5400 #Wrapper class for StdMeshers_Deflection1D hypothesis
5401 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5403 ## Set Deflection parameter value
5404 # @param deflection numerical value or name of variable from notebook
5405 def SetDeflection(self, deflection):
5406 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5407 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5408 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5410 #Registering the new proxy for Deflection1D
5411 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5413 #Wrapper class for StdMeshers_StartEndLength hypothesis
5414 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5416 ## Set Length parameter value
5417 # @param length numerical value or name of variable from notebook
5418 # @param isStart true is length is Start Length, otherwise false
5419 def SetLength(self, length, isStart):
5423 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5424 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5425 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5427 #Registering the new proxy for StartEndLength
5428 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5430 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5431 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5433 ## Set Max Element Area parameter value
5434 # @param area numerical value or name of variable from notebook
5435 def SetMaxElementArea(self, area):
5436 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5437 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5438 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5440 #Registering the new proxy for MaxElementArea
5441 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5444 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5445 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5447 ## Set Max Element Volume parameter value
5448 # @param volume numerical value or name of variable from notebook
5449 def SetMaxElementVolume(self, volume):
5450 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5451 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5452 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5454 #Registering the new proxy for MaxElementVolume
5455 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5458 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5459 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5461 ## Set Number Of Layers parameter value
5462 # @param nbLayers numerical value or name of variable from notebook
5463 def SetNumberOfLayers(self, nbLayers):
5464 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5465 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5466 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5468 #Registering the new proxy for NumberOfLayers
5469 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5471 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5472 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5474 ## Set Number Of Segments parameter value
5475 # @param nbSeg numerical value or name of variable from notebook
5476 def SetNumberOfSegments(self, nbSeg):
5477 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5478 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5479 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5480 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5482 ## Set Scale Factor parameter value
5483 # @param factor numerical value or name of variable from notebook
5484 def SetScaleFactor(self, factor):
5485 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5486 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5487 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5489 #Registering the new proxy for NumberOfSegments
5490 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5492 if not noNETGENPlugin:
5493 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5494 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5496 ## Set Max Size parameter value
5497 # @param maxsize numerical value or name of variable from notebook
5498 def SetMaxSize(self, maxsize):
5499 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5500 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5501 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5502 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5504 ## Set Growth Rate parameter value
5505 # @param value numerical value or name of variable from notebook
5506 def SetGrowthRate(self, value):
5507 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5508 value, parameters = ParseParameters(lastParameters,4,2,value)
5509 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5510 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5512 ## Set Number of Segments per Edge parameter value
5513 # @param value numerical value or name of variable from notebook
5514 def SetNbSegPerEdge(self, value):
5515 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5516 value, parameters = ParseParameters(lastParameters,4,3,value)
5517 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5518 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5520 ## Set Number of Segments per Radius parameter value
5521 # @param value numerical value or name of variable from notebook
5522 def SetNbSegPerRadius(self, value):
5523 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5524 value, parameters = ParseParameters(lastParameters,4,4,value)
5525 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5526 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5528 #Registering the new proxy for NETGENPlugin_Hypothesis
5529 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5532 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5533 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5536 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5537 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5539 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5540 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5542 ## Set Number of Segments parameter value
5543 # @param nbSeg numerical value or name of variable from notebook
5544 def SetNumberOfSegments(self, nbSeg):
5545 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5546 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5547 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5548 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5550 ## Set Local Length parameter value
5551 # @param length numerical value or name of variable from notebook
5552 def SetLocalLength(self, length):
5553 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5554 length, parameters = ParseParameters(lastParameters,2,1,length)
5555 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5556 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5558 ## Set Max Element Area parameter value
5559 # @param area numerical value or name of variable from notebook
5560 def SetMaxElementArea(self, area):
5561 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5562 area, parameters = ParseParameters(lastParameters,2,2,area)
5563 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5564 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5566 def LengthFromEdges(self):
5567 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5569 value, parameters = ParseParameters(lastParameters,2,2,value)
5570 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5571 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5573 #Registering the new proxy for NETGEN_SimpleParameters_2D
5574 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5577 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5578 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5579 ## Set Max Element Volume parameter value
5580 # @param volume numerical value or name of variable from notebook
5581 def SetMaxElementVolume(self, volume):
5582 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5583 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5584 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5585 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5587 def LengthFromFaces(self):
5588 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5590 value, parameters = ParseParameters(lastParameters,3,3,value)
5591 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5592 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5594 #Registering the new proxy for NETGEN_SimpleParameters_3D
5595 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5597 pass # if not noNETGENPlugin:
5599 class Pattern(SMESH._objref_SMESH_Pattern):
5601 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5603 if isinstance(theNodeIndexOnKeyPoint1,str):
5605 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5607 theNodeIndexOnKeyPoint1 -= 1
5608 theMesh.SetParameters(Parameters)
5609 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5611 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5614 if isinstance(theNode000Index,str):
5616 if isinstance(theNode001Index,str):
5618 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5620 theNode000Index -= 1
5622 theNode001Index -= 1
5623 theMesh.SetParameters(Parameters)
5624 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5626 #Registering the new proxy for Pattern
5627 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)