1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 # Author : Francis KLOSS, OCC
31 ## @defgroup l1_auxiliary Auxiliary methods and structures
32 ## @defgroup l1_creating Creating meshes
34 ## @defgroup l2_impexp Importing and exporting meshes
35 ## @defgroup l2_construct Constructing meshes
36 ## @defgroup l2_algorithms Defining Algorithms
38 ## @defgroup l3_algos_basic Basic meshing algorithms
39 ## @defgroup l3_algos_proj Projection Algorithms
40 ## @defgroup l3_algos_radialp Radial Prism
41 ## @defgroup l3_algos_segmarv Segments around Vertex
42 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
45 ## @defgroup l2_hypotheses Defining hypotheses
47 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
48 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
49 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
50 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
51 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
52 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
53 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
54 ## @defgroup l3_hypos_additi Additional Hypotheses
57 ## @defgroup l2_submeshes Constructing submeshes
58 ## @defgroup l2_compounds Building Compounds
59 ## @defgroup l2_editing Editing Meshes
62 ## @defgroup l1_meshinfo Mesh Information
63 ## @defgroup l1_controls Quality controls and Filtering
64 ## @defgroup l1_grouping Grouping elements
66 ## @defgroup l2_grps_create Creating groups
67 ## @defgroup l2_grps_edit Editing groups
68 ## @defgroup l2_grps_operon Using operations on groups
69 ## @defgroup l2_grps_delete Deleting Groups
72 ## @defgroup l1_modifying Modifying meshes
74 ## @defgroup l2_modif_add Adding nodes and elements
75 ## @defgroup l2_modif_del Removing nodes and elements
76 ## @defgroup l2_modif_edit Modifying nodes and elements
77 ## @defgroup l2_modif_renumber Renumbering nodes and elements
78 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
79 ## @defgroup l2_modif_movenode Moving nodes
80 ## @defgroup l2_modif_throughp Mesh through point
81 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
82 ## @defgroup l2_modif_unitetri Uniting triangles
83 ## @defgroup l2_modif_changori Changing orientation of elements
84 ## @defgroup l2_modif_cutquadr Cutting quadrangles
85 ## @defgroup l2_modif_smooth Smoothing
86 ## @defgroup l2_modif_extrurev Extrusion and Revolution
87 ## @defgroup l2_modif_patterns Pattern mapping
88 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
95 import SMESH # This is necessary for back compatibility
102 # import NETGENPlugin module if possible
110 ## @addtogroup l1_auxiliary
113 # Types of algorithms
126 NETGEN_1D2D3D = FULL_NETGEN
127 NETGEN_FULL = FULL_NETGEN
133 # MirrorType enumeration
134 POINT = SMESH_MeshEditor.POINT
135 AXIS = SMESH_MeshEditor.AXIS
136 PLANE = SMESH_MeshEditor.PLANE
138 # Smooth_Method enumeration
139 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
140 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
142 # Fineness enumeration (for NETGEN)
150 # Optimization level of GHS3D
151 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
153 # Topology treatment way of BLSURF
154 FromCAD, PreProcess, PreProcessPlus = 0,1,2
156 # Element size flag of BLSURF
157 DefaultSize, DefaultGeom, Custom = 0,0,1
159 PrecisionConfusion = 1e-07
161 ## Converts an angle from degrees to radians
162 def DegreesToRadians(AngleInDegrees):
164 return AngleInDegrees * pi / 180.0
166 # Salome notebook variable separator
169 # Parametrized substitute for PointStruct
170 class PointStructStr:
179 def __init__(self, xStr, yStr, zStr):
183 if isinstance(xStr, str) and notebook.isVariable(xStr):
184 self.x = notebook.get(xStr)
187 if isinstance(yStr, str) and notebook.isVariable(yStr):
188 self.y = notebook.get(yStr)
191 if isinstance(zStr, str) and notebook.isVariable(zStr):
192 self.z = notebook.get(zStr)
196 # Parametrized substitute for PointStruct (with 6 parameters)
197 class PointStructStr6:
212 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
219 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
220 self.x1 = notebook.get(x1Str)
223 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
224 self.x2 = notebook.get(x2Str)
227 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
228 self.y1 = notebook.get(y1Str)
231 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
232 self.y2 = notebook.get(y2Str)
235 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
236 self.z1 = notebook.get(z1Str)
239 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
240 self.z2 = notebook.get(z2Str)
244 # Parametrized substitute for AxisStruct
260 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
267 if isinstance(xStr, str) and notebook.isVariable(xStr):
268 self.x = notebook.get(xStr)
271 if isinstance(yStr, str) and notebook.isVariable(yStr):
272 self.y = notebook.get(yStr)
275 if isinstance(zStr, str) and notebook.isVariable(zStr):
276 self.z = notebook.get(zStr)
279 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
280 self.dx = notebook.get(dxStr)
283 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
284 self.dy = notebook.get(dyStr)
287 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
288 self.dz = notebook.get(dzStr)
292 # Parametrized substitute for DirStruct
295 def __init__(self, pointStruct):
296 self.pointStruct = pointStruct
298 # Returns list of variable values from salome notebook
299 def ParsePointStruct(Point):
300 Parameters = 2*var_separator
301 if isinstance(Point, PointStructStr):
302 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
303 Point = PointStruct(Point.x, Point.y, Point.z)
304 return Point, Parameters
306 # Returns list of variable values from salome notebook
307 def ParseDirStruct(Dir):
308 Parameters = 2*var_separator
309 if isinstance(Dir, DirStructStr):
310 pntStr = Dir.pointStruct
311 if isinstance(pntStr, PointStructStr6):
312 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
313 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
314 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
315 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
317 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
318 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
319 Dir = DirStruct(Point)
320 return Dir, Parameters
322 # Returns list of variable values from salome notebook
323 def ParseAxisStruct(Axis):
324 Parameters = 5*var_separator
325 if isinstance(Axis, AxisStructStr):
326 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
327 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
328 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
329 return Axis, Parameters
331 ## Return list of variable values from salome notebook
332 def ParseAngles(list):
335 for parameter in list:
336 if isinstance(parameter,str) and notebook.isVariable(parameter):
337 Result.append(DegreesToRadians(notebook.get(parameter)))
340 Result.append(parameter)
343 Parameters = Parameters + str(parameter)
344 Parameters = Parameters + var_separator
346 Parameters = Parameters[:len(Parameters)-1]
347 return Result, Parameters
349 def IsEqual(val1, val2, tol=PrecisionConfusion):
350 if abs(val1 - val2) < tol:
358 ior = salome.orb.object_to_string(obj)
359 sobj = salome.myStudy.FindObjectIOR(ior)
363 attr = sobj.FindAttribute("AttributeName")[1]
366 ## Prints error message if a hypothesis was not assigned.
367 def TreatHypoStatus(status, hypName, geomName, isAlgo):
369 hypType = "algorithm"
371 hypType = "hypothesis"
373 if status == HYP_UNKNOWN_FATAL :
374 reason = "for unknown reason"
375 elif status == HYP_INCOMPATIBLE :
376 reason = "this hypothesis mismatches the algorithm"
377 elif status == HYP_NOTCONFORM :
378 reason = "a non-conform mesh would be built"
379 elif status == HYP_ALREADY_EXIST :
380 reason = hypType + " of the same dimension is already assigned to this shape"
381 elif status == HYP_BAD_DIM :
382 reason = hypType + " mismatches the shape"
383 elif status == HYP_CONCURENT :
384 reason = "there are concurrent hypotheses on sub-shapes"
385 elif status == HYP_BAD_SUBSHAPE :
386 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
387 elif status == HYP_BAD_GEOMETRY:
388 reason = "geometry mismatches the expectation of the algorithm"
389 elif status == HYP_HIDDEN_ALGO:
390 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
391 elif status == HYP_HIDING_ALGO:
392 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
393 elif status == HYP_NEED_SHAPE:
394 reason = "Algorithm can't work without shape"
397 hypName = '"' + hypName + '"'
398 geomName= '"' + geomName+ '"'
399 if status < HYP_UNKNOWN_FATAL:
400 print hypName, "was assigned to", geomName,"but", reason
402 print hypName, "was not assigned to",geomName,":", reason
405 # end of l1_auxiliary
408 # All methods of this class are accessible directly from the smesh.py package.
409 class smeshDC(SMESH._objref_SMESH_Gen):
411 ## Sets the current study and Geometry component
412 # @ingroup l1_auxiliary
413 def init_smesh(self,theStudy,geompyD):
414 self.SetCurrentStudy(theStudy,geompyD)
416 ## Creates an empty Mesh. This mesh can have an underlying geometry.
417 # @param obj the Geometrical object on which the mesh is built. If not defined,
418 # the mesh will have no underlying geometry.
419 # @param name the name for the new mesh.
420 # @return an instance of Mesh class.
421 # @ingroup l2_construct
422 def Mesh(self, obj=0, name=0):
423 return Mesh(self,self.geompyD,obj,name)
425 ## Returns a long value from enumeration
426 # Should be used for SMESH.FunctorType enumeration
427 # @ingroup l1_controls
428 def EnumToLong(self,theItem):
431 ## Gets PointStruct from vertex
432 # @param theVertex a GEOM object(vertex)
433 # @return SMESH.PointStruct
434 # @ingroup l1_auxiliary
435 def GetPointStruct(self,theVertex):
436 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
437 return PointStruct(x,y,z)
439 ## Gets DirStruct from vector
440 # @param theVector a GEOM object(vector)
441 # @return SMESH.DirStruct
442 # @ingroup l1_auxiliary
443 def GetDirStruct(self,theVector):
444 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
445 if(len(vertices) != 2):
446 print "Error: vector object is incorrect."
448 p1 = self.geompyD.PointCoordinates(vertices[0])
449 p2 = self.geompyD.PointCoordinates(vertices[1])
450 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
451 dirst = DirStruct(pnt)
454 ## Makes DirStruct from a triplet
455 # @param x,y,z vector components
456 # @return SMESH.DirStruct
457 # @ingroup l1_auxiliary
458 def MakeDirStruct(self,x,y,z):
459 pnt = PointStruct(x,y,z)
460 return DirStruct(pnt)
462 ## Get AxisStruct from object
463 # @param theObj a GEOM object (line or plane)
464 # @return SMESH.AxisStruct
465 # @ingroup l1_auxiliary
466 def GetAxisStruct(self,theObj):
467 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
469 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
470 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
471 vertex1 = self.geompyD.PointCoordinates(vertex1)
472 vertex2 = self.geompyD.PointCoordinates(vertex2)
473 vertex3 = self.geompyD.PointCoordinates(vertex3)
474 vertex4 = self.geompyD.PointCoordinates(vertex4)
475 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
476 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
477 normal = [ v1[1]*v2[2]-v2[1]*v1[2], v1[2]*v2[0]-v2[2]*v1[0], v1[0]*v2[1]-v2[0]*v1[1] ]
478 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
480 elif len(edges) == 1:
481 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
482 p1 = self.geompyD.PointCoordinates( vertex1 )
483 p2 = self.geompyD.PointCoordinates( vertex2 )
484 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
488 # From SMESH_Gen interface:
489 # ------------------------
491 ## Sets the given name to the object
492 # @param obj the object to rename
493 # @param name a new object name
494 # @ingroup l1_auxiliary
495 def SetName(self, obj, name):
496 if isinstance( obj, Mesh ):
498 elif isinstance( obj, Mesh_Algorithm ):
499 obj = obj.GetAlgorithm()
500 ior = salome.orb.object_to_string(obj)
501 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
503 ## Sets the current mode
504 # @ingroup l1_auxiliary
505 def SetEmbeddedMode( self,theMode ):
506 #self.SetEmbeddedMode(theMode)
507 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
509 ## Gets the current mode
510 # @ingroup l1_auxiliary
511 def IsEmbeddedMode(self):
512 #return self.IsEmbeddedMode()
513 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
515 ## Sets the current study
516 # @ingroup l1_auxiliary
517 def SetCurrentStudy( self, theStudy, geompyD = None ):
518 #self.SetCurrentStudy(theStudy)
521 geompyD = geompy.geom
524 self.SetGeomEngine(geompyD)
525 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
527 ## Gets the current study
528 # @ingroup l1_auxiliary
529 def GetCurrentStudy(self):
530 #return self.GetCurrentStudy()
531 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
533 ## Creates a Mesh object importing data from the given UNV file
534 # @return an instance of Mesh class
536 def CreateMeshesFromUNV( self,theFileName ):
537 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
538 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
541 ## Creates a Mesh object(s) importing data from the given MED file
542 # @return a list of Mesh class instances
544 def CreateMeshesFromMED( self,theFileName ):
545 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
547 for iMesh in range(len(aSmeshMeshes)) :
548 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
549 aMeshes.append(aMesh)
550 return aMeshes, aStatus
552 ## Creates a Mesh object importing data from the given STL file
553 # @return an instance of Mesh class
555 def CreateMeshesFromSTL( self, theFileName ):
556 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
557 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
560 ## From SMESH_Gen interface
561 # @return the list of integer values
562 # @ingroup l1_auxiliary
563 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
564 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
566 ## From SMESH_Gen interface. Creates a pattern
567 # @return an instance of SMESH_Pattern
569 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
570 # @ingroup l2_modif_patterns
571 def GetPattern(self):
572 return SMESH._objref_SMESH_Gen.GetPattern(self)
574 ## Sets number of segments per diagonal of boundary box of geometry by which
575 # default segment length of appropriate 1D hypotheses is defined.
576 # Default value is 10
577 # @ingroup l1_auxiliary
578 def SetBoundaryBoxSegmentation(self, nbSegments):
579 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
581 ## Concatenate the given meshes into one mesh.
582 # @return an instance of Mesh class
583 # @param meshes the meshes to combine into one mesh
584 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
585 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
586 # @param mergeTolerance tolerance for merging nodes
587 # @param allGroups forces creation of groups of all elements
588 def Concatenate( self, meshes, uniteIdenticalGroups,
589 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
590 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
592 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
593 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
595 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
596 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
597 aSmeshMesh.SetParameters(Parameters)
598 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
601 # Filtering. Auxiliary functions:
602 # ------------------------------
604 ## Creates an empty criterion
605 # @return SMESH.Filter.Criterion
606 # @ingroup l1_controls
607 def GetEmptyCriterion(self):
608 Type = self.EnumToLong(FT_Undefined)
609 Compare = self.EnumToLong(FT_Undefined)
613 UnaryOp = self.EnumToLong(FT_Undefined)
614 BinaryOp = self.EnumToLong(FT_Undefined)
617 Precision = -1 ##@1e-07
618 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
619 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
621 ## Creates a criterion by the given parameters
622 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
623 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
624 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
625 # @param Treshold the threshold value (range of ids as string, shape, numeric)
626 # @param UnaryOp FT_LogicalNOT or FT_Undefined
627 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
628 # FT_Undefined (must be for the last criterion of all criteria)
629 # @return SMESH.Filter.Criterion
630 # @ingroup l1_controls
631 def GetCriterion(self,elementType,
633 Compare = FT_EqualTo,
635 UnaryOp=FT_Undefined,
636 BinaryOp=FT_Undefined):
637 aCriterion = self.GetEmptyCriterion()
638 aCriterion.TypeOfElement = elementType
639 aCriterion.Type = self.EnumToLong(CritType)
643 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
644 aCriterion.Compare = self.EnumToLong(Compare)
645 elif Compare == "=" or Compare == "==":
646 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
648 aCriterion.Compare = self.EnumToLong(FT_LessThan)
650 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
652 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
655 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
656 FT_BelongToCylinder, FT_LyingOnGeom]:
657 # Checks the treshold
658 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
659 aCriterion.ThresholdStr = GetName(aTreshold)
660 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
662 print "Error: The treshold should be a shape."
664 elif CritType == FT_RangeOfIds:
665 # Checks the treshold
666 if isinstance(aTreshold, str):
667 aCriterion.ThresholdStr = aTreshold
669 print "Error: The treshold should be a string."
671 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
672 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
673 # At this point the treshold is unnecessary
674 if aTreshold == FT_LogicalNOT:
675 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
676 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
677 aCriterion.BinaryOp = aTreshold
681 aTreshold = float(aTreshold)
682 aCriterion.Threshold = aTreshold
684 print "Error: The treshold should be a number."
687 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
688 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
690 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
691 aCriterion.BinaryOp = self.EnumToLong(Treshold)
693 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
694 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
696 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
697 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
701 ## Creates a filter with the given parameters
702 # @param elementType the type of elements in the group
703 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
704 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
705 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
706 # @param UnaryOp FT_LogicalNOT or FT_Undefined
707 # @return SMESH_Filter
708 # @ingroup l1_controls
709 def GetFilter(self,elementType,
710 CritType=FT_Undefined,
713 UnaryOp=FT_Undefined):
714 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
715 aFilterMgr = self.CreateFilterManager()
716 aFilter = aFilterMgr.CreateFilter()
718 aCriteria.append(aCriterion)
719 aFilter.SetCriteria(aCriteria)
722 ## Creates a numerical functor by its type
723 # @param theCriterion FT_...; functor type
724 # @return SMESH_NumericalFunctor
725 # @ingroup l1_controls
726 def GetFunctor(self,theCriterion):
727 aFilterMgr = self.CreateFilterManager()
728 if theCriterion == FT_AspectRatio:
729 return aFilterMgr.CreateAspectRatio()
730 elif theCriterion == FT_AspectRatio3D:
731 return aFilterMgr.CreateAspectRatio3D()
732 elif theCriterion == FT_Warping:
733 return aFilterMgr.CreateWarping()
734 elif theCriterion == FT_MinimumAngle:
735 return aFilterMgr.CreateMinimumAngle()
736 elif theCriterion == FT_Taper:
737 return aFilterMgr.CreateTaper()
738 elif theCriterion == FT_Skew:
739 return aFilterMgr.CreateSkew()
740 elif theCriterion == FT_Area:
741 return aFilterMgr.CreateArea()
742 elif theCriterion == FT_Volume3D:
743 return aFilterMgr.CreateVolume3D()
744 elif theCriterion == FT_MultiConnection:
745 return aFilterMgr.CreateMultiConnection()
746 elif theCriterion == FT_MultiConnection2D:
747 return aFilterMgr.CreateMultiConnection2D()
748 elif theCriterion == FT_Length:
749 return aFilterMgr.CreateLength()
750 elif theCriterion == FT_Length2D:
751 return aFilterMgr.CreateLength2D()
753 print "Error: given parameter is not numerucal functor type."
755 ## Creates hypothesis
758 # @return created hypothesis instance
759 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
760 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
763 #Registering the new proxy for SMESH_Gen
764 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
770 ## This class allows defining and managing a mesh.
771 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
772 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
773 # new nodes and elements and by changing the existing entities), to get information
774 # about a mesh and to export a mesh into different formats.
783 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
784 # sets the GUI name of this mesh to \a name.
785 # @param smeshpyD an instance of smeshDC class
786 # @param geompyD an instance of geompyDC class
787 # @param obj Shape to be meshed or SMESH_Mesh object
788 # @param name Study name of the mesh
789 # @ingroup l2_construct
790 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
791 self.smeshpyD=smeshpyD
796 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
798 self.mesh = self.smeshpyD.CreateMesh(self.geom)
799 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
802 self.mesh = self.smeshpyD.CreateEmptyMesh()
804 self.smeshpyD.SetName(self.mesh, name)
806 self.smeshpyD.SetName(self.mesh, GetName(obj))
809 self.geom = self.mesh.GetShapeToMesh()
811 self.editor = self.mesh.GetMeshEditor()
813 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
814 # @param theMesh a SMESH_Mesh object
815 # @ingroup l2_construct
816 def SetMesh(self, theMesh):
818 self.geom = self.mesh.GetShapeToMesh()
820 ## Returns the mesh, that is an instance of SMESH_Mesh interface
821 # @return a SMESH_Mesh object
822 # @ingroup l2_construct
826 ## Gets the name of the mesh
827 # @return the name of the mesh as a string
828 # @ingroup l2_construct
830 name = GetName(self.GetMesh())
833 ## Sets a name to the mesh
834 # @param name a new name of the mesh
835 # @ingroup l2_construct
836 def SetName(self, name):
837 self.smeshpyD.SetName(self.GetMesh(), name)
839 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
840 # The subMesh object gives access to the IDs of nodes and elements.
841 # @param theSubObject a geometrical object (shape)
842 # @param theName a name for the submesh
843 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
844 # @ingroup l2_submeshes
845 def GetSubMesh(self, theSubObject, theName):
846 submesh = self.mesh.GetSubMesh(theSubObject, theName)
849 ## Returns the shape associated to the mesh
850 # @return a GEOM_Object
851 # @ingroup l2_construct
855 ## Associates the given shape to the mesh (entails the recreation of the mesh)
856 # @param geom the shape to be meshed (GEOM_Object)
857 # @ingroup l2_construct
858 def SetShape(self, geom):
859 self.mesh = self.smeshpyD.CreateMesh(geom)
861 ## Returns true if the hypotheses are defined well
862 # @param theSubObject a subshape of a mesh shape
863 # @return True or False
864 # @ingroup l2_construct
865 def IsReadyToCompute(self, theSubObject):
866 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
868 ## Returns errors of hypotheses definition.
869 # The list of errors is empty if everything is OK.
870 # @param theSubObject a subshape of a mesh shape
871 # @return a list of errors
872 # @ingroup l2_construct
873 def GetAlgoState(self, theSubObject):
874 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
876 ## Returns a geometrical object on which the given element was built.
877 # The returned geometrical object, if not nil, is either found in the
878 # study or published by this method with the given name
879 # @param theElementID the id of the mesh element
880 # @param theGeomName the user-defined name of the geometrical object
881 # @return GEOM::GEOM_Object instance
882 # @ingroup l2_construct
883 def GetGeometryByMeshElement(self, theElementID, theGeomName):
884 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
886 ## Returns the mesh dimension depending on the dimension of the underlying shape
887 # @return mesh dimension as an integer value [0,3]
888 # @ingroup l1_auxiliary
889 def MeshDimension(self):
890 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
891 if len( shells ) > 0 :
893 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
895 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
901 ## Creates a segment discretization 1D algorithm.
902 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
903 # \n If the optional \a geom parameter is not set, this algorithm is global.
904 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
905 # @param algo the type of the required algorithm. Possible values are:
907 # - smesh.PYTHON for discretization via a python function,
908 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
909 # @param geom If defined is the subshape to be meshed
910 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
911 # @ingroup l3_algos_basic
912 def Segment(self, algo=REGULAR, geom=0):
913 ## if Segment(geom) is called by mistake
914 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
915 algo, geom = geom, algo
916 if not algo: algo = REGULAR
919 return Mesh_Segment(self, geom)
921 return Mesh_Segment_Python(self, geom)
922 elif algo == COMPOSITE:
923 return Mesh_CompositeSegment(self, geom)
925 return Mesh_Segment(self, geom)
927 ## Enables creation of nodes and segments usable by 2D algoritms.
928 # The added nodes and segments must be bound to edges and vertices by
929 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
930 # If the optional \a geom parameter is not set, this algorithm is global.
931 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
932 # @param geom the subshape to be manually meshed
933 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
934 # @ingroup l3_algos_basic
935 def UseExistingSegments(self, geom=0):
936 algo = Mesh_UseExisting(1,self,geom)
937 return algo.GetAlgorithm()
939 ## Enables creation of nodes and faces usable by 3D algoritms.
940 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
941 # and SetMeshElementOnShape()
942 # If the optional \a geom parameter is not set, this algorithm is global.
943 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
944 # @param geom the subshape to be manually meshed
945 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
946 # @ingroup l3_algos_basic
947 def UseExistingFaces(self, geom=0):
948 algo = Mesh_UseExisting(2,self,geom)
949 return algo.GetAlgorithm()
951 ## Creates a triangle 2D algorithm for faces.
952 # If the optional \a geom parameter is not set, this algorithm is global.
953 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
954 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
955 # @param geom If defined, the subshape to be meshed (GEOM_Object)
956 # @return an instance of Mesh_Triangle algorithm
957 # @ingroup l3_algos_basic
958 def Triangle(self, algo=MEFISTO, geom=0):
959 ## if Triangle(geom) is called by mistake
960 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
964 return Mesh_Triangle(self, algo, geom)
966 ## Creates a quadrangle 2D algorithm for faces.
967 # If the optional \a geom parameter is not set, this algorithm is global.
968 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
969 # @param geom If defined, the subshape to be meshed (GEOM_Object)
970 # @return an instance of Mesh_Quadrangle algorithm
971 # @ingroup l3_algos_basic
972 def Quadrangle(self, geom=0):
973 return Mesh_Quadrangle(self, geom)
975 ## Creates a tetrahedron 3D algorithm for solids.
976 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
977 # If the optional \a geom parameter is not set, this algorithm is global.
978 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
979 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
980 # @param geom If defined, the subshape to be meshed (GEOM_Object)
981 # @return an instance of Mesh_Tetrahedron algorithm
982 # @ingroup l3_algos_basic
983 def Tetrahedron(self, algo=NETGEN, geom=0):
984 ## if Tetrahedron(geom) is called by mistake
985 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
986 algo, geom = geom, algo
987 if not algo: algo = NETGEN
989 return Mesh_Tetrahedron(self, algo, geom)
991 ## Creates a hexahedron 3D algorithm for solids.
992 # If the optional \a geom parameter is not set, this algorithm is global.
993 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
994 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
995 # @param geom If defined, the subshape to be meshed (GEOM_Object)
996 # @return an instance of Mesh_Hexahedron algorithm
997 # @ingroup l3_algos_basic
998 def Hexahedron(self, algo=Hexa, geom=0):
999 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1000 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1001 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1002 elif geom == 0: algo, geom = Hexa, algo
1003 return Mesh_Hexahedron(self, algo, geom)
1005 ## Deprecated, used only for compatibility!
1006 # @return an instance of Mesh_Netgen algorithm
1007 # @ingroup l3_algos_basic
1008 def Netgen(self, is3D, geom=0):
1009 return Mesh_Netgen(self, is3D, geom)
1011 ## Creates a projection 1D algorithm for edges.
1012 # If the optional \a geom parameter is not set, this algorithm is global.
1013 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1014 # @param geom If defined, the subshape to be meshed
1015 # @return an instance of Mesh_Projection1D algorithm
1016 # @ingroup l3_algos_proj
1017 def Projection1D(self, geom=0):
1018 return Mesh_Projection1D(self, geom)
1020 ## Creates a projection 2D algorithm for faces.
1021 # If the optional \a geom parameter is not set, this algorithm is global.
1022 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1023 # @param geom If defined, the subshape to be meshed
1024 # @return an instance of Mesh_Projection2D algorithm
1025 # @ingroup l3_algos_proj
1026 def Projection2D(self, geom=0):
1027 return Mesh_Projection2D(self, geom)
1029 ## Creates a projection 3D algorithm for solids.
1030 # If the optional \a geom parameter is not set, this algorithm is global.
1031 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1032 # @param geom If defined, the subshape to be meshed
1033 # @return an instance of Mesh_Projection3D algorithm
1034 # @ingroup l3_algos_proj
1035 def Projection3D(self, geom=0):
1036 return Mesh_Projection3D(self, geom)
1038 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1039 # If the optional \a geom parameter is not set, this algorithm is global.
1040 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1041 # @param geom If defined, the subshape to be meshed
1042 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1043 # @ingroup l3_algos_radialp l3_algos_3dextr
1044 def Prism(self, geom=0):
1048 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1049 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1050 if nbSolids == 0 or nbSolids == nbShells:
1051 return Mesh_Prism3D(self, geom)
1052 return Mesh_RadialPrism3D(self, geom)
1054 ## Computes the mesh and returns the status of the computation
1055 # @return True or False
1056 # @ingroup l2_construct
1057 def Compute(self, geom=0):
1058 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1060 geom = self.mesh.GetShapeToMesh()
1065 ok = self.smeshpyD.Compute(self.mesh, geom)
1066 except SALOME.SALOME_Exception, ex:
1067 print "Mesh computation failed, exception caught:"
1068 print " ", ex.details.text
1071 print "Mesh computation failed, exception caught:"
1072 traceback.print_exc()
1074 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1077 if err.isGlobalAlgo:
1085 reason = '%s %sD algorithm is missing' % (glob, dim)
1086 elif err.state == HYP_MISSING:
1087 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1088 % (glob, dim, name, dim))
1089 elif err.state == HYP_NOTCONFORM:
1090 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1091 elif err.state == HYP_BAD_PARAMETER:
1092 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1093 % ( glob, dim, name ))
1094 elif err.state == HYP_BAD_GEOMETRY:
1095 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1096 'geometry' % ( glob, dim, name ))
1098 reason = "For unknown reason."+\
1099 " Revise Mesh.Compute() implementation in smeshDC.py!"
1101 if allReasons != "":
1104 allReasons += reason
1106 if allReasons != "":
1107 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1111 print '"' + GetName(self.mesh) + '"',"has not been computed."
1114 if salome.sg.hasDesktop():
1115 smeshgui = salome.ImportComponentGUI("SMESH")
1116 smeshgui.Init(self.mesh.GetStudyId())
1117 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1118 salome.sg.updateObjBrowser(1)
1122 ## Removes all nodes and elements
1123 # @ingroup l2_construct
1126 if salome.sg.hasDesktop():
1127 smeshgui = salome.ImportComponentGUI("SMESH")
1128 smeshgui.Init(self.mesh.GetStudyId())
1129 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1130 salome.sg.updateObjBrowser(1)
1132 ## Removes all nodes and elements of indicated shape
1133 # @ingroup l2_construct
1134 def ClearSubMesh(self, geomId):
1135 self.mesh.ClearSubMesh(geomId)
1136 if salome.sg.hasDesktop():
1137 smeshgui = salome.ImportComponentGUI("SMESH")
1138 smeshgui.Init(self.mesh.GetStudyId())
1139 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1140 salome.sg.updateObjBrowser(1)
1142 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1143 # @param fineness [0,-1] defines mesh fineness
1144 # @return True or False
1145 # @ingroup l3_algos_basic
1146 def AutomaticTetrahedralization(self, fineness=0):
1147 dim = self.MeshDimension()
1149 self.RemoveGlobalHypotheses()
1150 self.Segment().AutomaticLength(fineness)
1152 self.Triangle().LengthFromEdges()
1155 self.Tetrahedron(NETGEN)
1157 return self.Compute()
1159 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1160 # @param fineness [0,-1] defines mesh fineness
1161 # @return True or False
1162 # @ingroup l3_algos_basic
1163 def AutomaticHexahedralization(self, fineness=0):
1164 dim = self.MeshDimension()
1165 # assign the hypotheses
1166 self.RemoveGlobalHypotheses()
1167 self.Segment().AutomaticLength(fineness)
1174 return self.Compute()
1176 ## Assigns a hypothesis
1177 # @param hyp a hypothesis to assign
1178 # @param geom a subhape of mesh geometry
1179 # @return SMESH.Hypothesis_Status
1180 # @ingroup l2_hypotheses
1181 def AddHypothesis(self, hyp, geom=0):
1182 if isinstance( hyp, Mesh_Algorithm ):
1183 hyp = hyp.GetAlgorithm()
1188 geom = self.mesh.GetShapeToMesh()
1190 status = self.mesh.AddHypothesis(geom, hyp)
1191 isAlgo = hyp._narrow( SMESH_Algo )
1192 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1195 ## Unassigns a hypothesis
1196 # @param hyp a hypothesis to unassign
1197 # @param geom a subshape of mesh geometry
1198 # @return SMESH.Hypothesis_Status
1199 # @ingroup l2_hypotheses
1200 def RemoveHypothesis(self, hyp, geom=0):
1201 if isinstance( hyp, Mesh_Algorithm ):
1202 hyp = hyp.GetAlgorithm()
1207 status = self.mesh.RemoveHypothesis(geom, hyp)
1210 ## Gets the list of hypotheses added on a geometry
1211 # @param geom a subshape of mesh geometry
1212 # @return the sequence of SMESH_Hypothesis
1213 # @ingroup l2_hypotheses
1214 def GetHypothesisList(self, geom):
1215 return self.mesh.GetHypothesisList( geom )
1217 ## Removes all global hypotheses
1218 # @ingroup l2_hypotheses
1219 def RemoveGlobalHypotheses(self):
1220 current_hyps = self.mesh.GetHypothesisList( self.geom )
1221 for hyp in current_hyps:
1222 self.mesh.RemoveHypothesis( self.geom, hyp )
1226 ## Creates a mesh group based on the geometric object \a grp
1227 # and gives a \a name, \n if this parameter is not defined
1228 # the name is the same as the geometric group name \n
1229 # Note: Works like GroupOnGeom().
1230 # @param grp a geometric group, a vertex, an edge, a face or a solid
1231 # @param name the name of the mesh group
1232 # @return SMESH_GroupOnGeom
1233 # @ingroup l2_grps_create
1234 def Group(self, grp, name=""):
1235 return self.GroupOnGeom(grp, name)
1237 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1238 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1239 # @param f the file name
1240 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1241 # @ingroup l2_impexp
1242 def ExportToMED(self, f, version, opt=0):
1243 self.mesh.ExportToMED(f, opt, version)
1245 ## Exports the mesh in a file in MED format
1246 # @param f is the file name
1247 # @param auto_groups boolean parameter for creating/not creating
1248 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1249 # the typical use is auto_groups=false.
1250 # @param version MED format version(MED_V2_1 or MED_V2_2)
1251 # @ingroup l2_impexp
1252 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1253 self.mesh.ExportToMED(f, auto_groups, version)
1255 ## Exports the mesh in a file in DAT format
1256 # @param f the file name
1257 # @ingroup l2_impexp
1258 def ExportDAT(self, f):
1259 self.mesh.ExportDAT(f)
1261 ## Exports the mesh in a file in UNV format
1262 # @param f the file name
1263 # @ingroup l2_impexp
1264 def ExportUNV(self, f):
1265 self.mesh.ExportUNV(f)
1267 ## Export the mesh in a file in STL format
1268 # @param f the file name
1269 # @param ascii defines the file encoding
1270 # @ingroup l2_impexp
1271 def ExportSTL(self, f, ascii=1):
1272 self.mesh.ExportSTL(f, ascii)
1275 # Operations with groups:
1276 # ----------------------
1278 ## Creates an empty mesh group
1279 # @param elementType the type of elements in the group
1280 # @param name the name of the mesh group
1281 # @return SMESH_Group
1282 # @ingroup l2_grps_create
1283 def CreateEmptyGroup(self, elementType, name):
1284 return self.mesh.CreateGroup(elementType, name)
1286 ## Creates a mesh group based on the geometrical object \a grp
1287 # and gives a \a name, \n if this parameter is not defined
1288 # the name is the same as the geometrical group name
1289 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1290 # @param name the name of the mesh group
1291 # @param typ the type of elements in the group. If not set, it is
1292 # automatically detected by the type of the geometry
1293 # @return SMESH_GroupOnGeom
1294 # @ingroup l2_grps_create
1295 def GroupOnGeom(self, grp, name="", typ=None):
1297 name = grp.GetName()
1300 tgeo = str(grp.GetShapeType())
1301 if tgeo == "VERTEX":
1303 elif tgeo == "EDGE":
1305 elif tgeo == "FACE":
1307 elif tgeo == "SOLID":
1309 elif tgeo == "SHELL":
1311 elif tgeo == "COMPOUND":
1312 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1313 print "Mesh.Group: empty geometric group", GetName( grp )
1315 tgeo = self.geompyD.GetType(grp)
1316 if tgeo == geompyDC.ShapeType["VERTEX"]:
1318 elif tgeo == geompyDC.ShapeType["EDGE"]:
1320 elif tgeo == geompyDC.ShapeType["FACE"]:
1322 elif tgeo == geompyDC.ShapeType["SOLID"]:
1326 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1329 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1331 ## Creates a mesh group by the given ids of elements
1332 # @param groupName the name of the mesh group
1333 # @param elementType the type of elements in the group
1334 # @param elemIDs the list of ids
1335 # @return SMESH_Group
1336 # @ingroup l2_grps_create
1337 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1338 group = self.mesh.CreateGroup(elementType, groupName)
1342 ## Creates a mesh group by the given conditions
1343 # @param groupName the name of the mesh group
1344 # @param elementType the type of elements in the group
1345 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1346 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1347 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1348 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1349 # @return SMESH_Group
1350 # @ingroup l2_grps_create
1354 CritType=FT_Undefined,
1357 UnaryOp=FT_Undefined):
1358 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1359 group = self.MakeGroupByCriterion(groupName, aCriterion)
1362 ## Creates a mesh group by the given criterion
1363 # @param groupName the name of the mesh group
1364 # @param Criterion the instance of Criterion class
1365 # @return SMESH_Group
1366 # @ingroup l2_grps_create
1367 def MakeGroupByCriterion(self, groupName, Criterion):
1368 aFilterMgr = self.smeshpyD.CreateFilterManager()
1369 aFilter = aFilterMgr.CreateFilter()
1371 aCriteria.append(Criterion)
1372 aFilter.SetCriteria(aCriteria)
1373 group = self.MakeGroupByFilter(groupName, aFilter)
1376 ## Creates a mesh group by the given criteria (list of criteria)
1377 # @param groupName the name of the mesh group
1378 # @param theCriteria the list of criteria
1379 # @return SMESH_Group
1380 # @ingroup l2_grps_create
1381 def MakeGroupByCriteria(self, groupName, theCriteria):
1382 aFilterMgr = self.smeshpyD.CreateFilterManager()
1383 aFilter = aFilterMgr.CreateFilter()
1384 aFilter.SetCriteria(theCriteria)
1385 group = self.MakeGroupByFilter(groupName, aFilter)
1388 ## Creates a mesh group by the given filter
1389 # @param groupName the name of the mesh group
1390 # @param theFilter the instance of Filter class
1391 # @return SMESH_Group
1392 # @ingroup l2_grps_create
1393 def MakeGroupByFilter(self, groupName, theFilter):
1394 anIds = theFilter.GetElementsId(self.mesh)
1395 anElemType = theFilter.GetElementType()
1396 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1399 ## Passes mesh elements through the given filter and return IDs of fitting elements
1400 # @param theFilter SMESH_Filter
1401 # @return a list of ids
1402 # @ingroup l1_controls
1403 def GetIdsFromFilter(self, theFilter):
1404 return theFilter.GetElementsId(self.mesh)
1406 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1407 # Returns a list of special structures (borders).
1408 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1409 # @ingroup l1_controls
1410 def GetFreeBorders(self):
1411 aFilterMgr = self.smeshpyD.CreateFilterManager()
1412 aPredicate = aFilterMgr.CreateFreeEdges()
1413 aPredicate.SetMesh(self.mesh)
1414 aBorders = aPredicate.GetBorders()
1418 # @ingroup l2_grps_delete
1419 def RemoveGroup(self, group):
1420 self.mesh.RemoveGroup(group)
1422 ## Removes a group with its contents
1423 # @ingroup l2_grps_delete
1424 def RemoveGroupWithContents(self, group):
1425 self.mesh.RemoveGroupWithContents(group)
1427 ## Gets the list of groups existing in the mesh
1428 # @return a sequence of SMESH_GroupBase
1429 # @ingroup l2_grps_create
1430 def GetGroups(self):
1431 return self.mesh.GetGroups()
1433 ## Gets the number of groups existing in the mesh
1434 # @return the quantity of groups as an integer value
1435 # @ingroup l2_grps_create
1437 return self.mesh.NbGroups()
1439 ## Gets the list of names of groups existing in the mesh
1440 # @return list of strings
1441 # @ingroup l2_grps_create
1442 def GetGroupNames(self):
1443 groups = self.GetGroups()
1445 for group in groups:
1446 names.append(group.GetName())
1449 ## Produces a union of two groups
1450 # A new group is created. All mesh elements that are
1451 # present in the initial groups are added to the new one
1452 # @return an instance of SMESH_Group
1453 # @ingroup l2_grps_operon
1454 def UnionGroups(self, group1, group2, name):
1455 return self.mesh.UnionGroups(group1, group2, name)
1457 ## Produces a union list of groups
1458 # New group is created. All mesh elements that are present in
1459 # initial groups are added to the new one
1460 # @return an instance of SMESH_Group
1461 # @ingroup l2_grps_operon
1462 def UnionListOfGroups(self, groups, name):
1463 return self.mesh.UnionListOfGroups(groups, name)
1465 ## Prodices an intersection of two groups
1466 # A new group is created. All mesh elements that are common
1467 # for the two initial groups are added to the new one.
1468 # @return an instance of SMESH_Group
1469 # @ingroup l2_grps_operon
1470 def IntersectGroups(self, group1, group2, name):
1471 return self.mesh.IntersectGroups(group1, group2, name)
1473 ## Produces an intersection of groups
1474 # New group is created. All mesh elements that are present in all
1475 # initial groups simultaneously are added to the new one
1476 # @return an instance of SMESH_Group
1477 # @ingroup l2_grps_operon
1478 def IntersectListOfGroups(self, groups, name):
1479 return self.mesh.IntersectListOfGroups(groups, name)
1481 ## Produces a cut of two groups
1482 # A new group is created. All mesh elements that are present in
1483 # the main group but are not present in the tool group are added to the new one
1484 # @return an instance of SMESH_Group
1485 # @ingroup l2_grps_operon
1486 def CutGroups(self, main_group, tool_group, name):
1487 return self.mesh.CutGroups(main_group, tool_group, name)
1489 ## Produces a cut of groups
1490 # A new group is created. All mesh elements that are present in main groups
1491 # but do not present in tool groups are added to the new one
1492 # @return an instance of SMESH_Group
1493 # @ingroup l2_grps_operon
1494 def CutListOfGroups(self, main_groups, tool_groups, name):
1495 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1497 ## Produces a group of elements with specified element type using list of existing groups
1498 # A new group is created. System
1499 # 1) extract all nodes on which groups elements are built
1500 # 2) combine all elements of specified dimension laying on these nodes
1501 # @return an instance of SMESH_Group
1502 # @ingroup l2_grps_operon
1503 def CreateDimGroup(self, groups, elem_type, name):
1504 return self.mesh.CreateDimGroup(groups, elem_type, name)
1507 ## Convert group on geom into standalone group
1508 # @ingroup l2_grps_delete
1509 def ConvertToStandalone(self, group):
1510 return self.mesh.ConvertToStandalone(group)
1512 # Get some info about mesh:
1513 # ------------------------
1515 ## Returns the log of nodes and elements added or removed
1516 # since the previous clear of the log.
1517 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1518 # @return list of log_block structures:
1523 # @ingroup l1_auxiliary
1524 def GetLog(self, clearAfterGet):
1525 return self.mesh.GetLog(clearAfterGet)
1527 ## Clears the log of nodes and elements added or removed since the previous
1528 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1529 # @ingroup l1_auxiliary
1531 self.mesh.ClearLog()
1533 ## Toggles auto color mode on the object.
1534 # @param theAutoColor the flag which toggles auto color mode.
1535 # @ingroup l1_auxiliary
1536 def SetAutoColor(self, theAutoColor):
1537 self.mesh.SetAutoColor(theAutoColor)
1539 ## Gets flag of object auto color mode.
1540 # @return True or False
1541 # @ingroup l1_auxiliary
1542 def GetAutoColor(self):
1543 return self.mesh.GetAutoColor()
1545 ## Gets the internal ID
1546 # @return integer value, which is the internal Id of the mesh
1547 # @ingroup l1_auxiliary
1549 return self.mesh.GetId()
1552 # @return integer value, which is the study Id of the mesh
1553 # @ingroup l1_auxiliary
1554 def GetStudyId(self):
1555 return self.mesh.GetStudyId()
1557 ## Checks the group names for duplications.
1558 # Consider the maximum group name length stored in MED file.
1559 # @return True or False
1560 # @ingroup l1_auxiliary
1561 def HasDuplicatedGroupNamesMED(self):
1562 return self.mesh.HasDuplicatedGroupNamesMED()
1564 ## Obtains the mesh editor tool
1565 # @return an instance of SMESH_MeshEditor
1566 # @ingroup l1_modifying
1567 def GetMeshEditor(self):
1568 return self.mesh.GetMeshEditor()
1571 # @return an instance of SALOME_MED::MESH
1572 # @ingroup l1_auxiliary
1573 def GetMEDMesh(self):
1574 return self.mesh.GetMEDMesh()
1577 # Get informations about mesh contents:
1578 # ------------------------------------
1580 ## Returns the number of nodes in the mesh
1581 # @return an integer value
1582 # @ingroup l1_meshinfo
1584 return self.mesh.NbNodes()
1586 ## Returns the number of elements in the mesh
1587 # @return an integer value
1588 # @ingroup l1_meshinfo
1589 def NbElements(self):
1590 return self.mesh.NbElements()
1592 ## Returns the number of edges in the mesh
1593 # @return an integer value
1594 # @ingroup l1_meshinfo
1596 return self.mesh.NbEdges()
1598 ## Returns the number of edges with the given order in the mesh
1599 # @param elementOrder the order of elements:
1600 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1601 # @return an integer value
1602 # @ingroup l1_meshinfo
1603 def NbEdgesOfOrder(self, elementOrder):
1604 return self.mesh.NbEdgesOfOrder(elementOrder)
1606 ## Returns the number of faces in the mesh
1607 # @return an integer value
1608 # @ingroup l1_meshinfo
1610 return self.mesh.NbFaces()
1612 ## Returns the number of faces with the given order in the mesh
1613 # @param elementOrder the order of elements:
1614 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1615 # @return an integer value
1616 # @ingroup l1_meshinfo
1617 def NbFacesOfOrder(self, elementOrder):
1618 return self.mesh.NbFacesOfOrder(elementOrder)
1620 ## Returns the number of triangles in the mesh
1621 # @return an integer value
1622 # @ingroup l1_meshinfo
1623 def NbTriangles(self):
1624 return self.mesh.NbTriangles()
1626 ## Returns the number of triangles with the given order in the mesh
1627 # @param elementOrder is the order of elements:
1628 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1629 # @return an integer value
1630 # @ingroup l1_meshinfo
1631 def NbTrianglesOfOrder(self, elementOrder):
1632 return self.mesh.NbTrianglesOfOrder(elementOrder)
1634 ## Returns the number of quadrangles in the mesh
1635 # @return an integer value
1636 # @ingroup l1_meshinfo
1637 def NbQuadrangles(self):
1638 return self.mesh.NbQuadrangles()
1640 ## Returns the number of quadrangles with the given order in the mesh
1641 # @param elementOrder the order of elements:
1642 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1643 # @return an integer value
1644 # @ingroup l1_meshinfo
1645 def NbQuadranglesOfOrder(self, elementOrder):
1646 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1648 ## Returns the number of polygons in the mesh
1649 # @return an integer value
1650 # @ingroup l1_meshinfo
1651 def NbPolygons(self):
1652 return self.mesh.NbPolygons()
1654 ## Returns the number of volumes in the mesh
1655 # @return an integer value
1656 # @ingroup l1_meshinfo
1657 def NbVolumes(self):
1658 return self.mesh.NbVolumes()
1660 ## Returns the number of volumes with the given order in the mesh
1661 # @param elementOrder the order of elements:
1662 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1663 # @return an integer value
1664 # @ingroup l1_meshinfo
1665 def NbVolumesOfOrder(self, elementOrder):
1666 return self.mesh.NbVolumesOfOrder(elementOrder)
1668 ## Returns the number of tetrahedrons in the mesh
1669 # @return an integer value
1670 # @ingroup l1_meshinfo
1672 return self.mesh.NbTetras()
1674 ## Returns the number of tetrahedrons with the given order in the mesh
1675 # @param elementOrder the order of elements:
1676 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1677 # @return an integer value
1678 # @ingroup l1_meshinfo
1679 def NbTetrasOfOrder(self, elementOrder):
1680 return self.mesh.NbTetrasOfOrder(elementOrder)
1682 ## Returns the number of hexahedrons in the mesh
1683 # @return an integer value
1684 # @ingroup l1_meshinfo
1686 return self.mesh.NbHexas()
1688 ## Returns the number of hexahedrons with the given order in the mesh
1689 # @param elementOrder the order of elements:
1690 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1691 # @return an integer value
1692 # @ingroup l1_meshinfo
1693 def NbHexasOfOrder(self, elementOrder):
1694 return self.mesh.NbHexasOfOrder(elementOrder)
1696 ## Returns the number of pyramids in the mesh
1697 # @return an integer value
1698 # @ingroup l1_meshinfo
1699 def NbPyramids(self):
1700 return self.mesh.NbPyramids()
1702 ## Returns the number of pyramids with the given order in the mesh
1703 # @param elementOrder the order of elements:
1704 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1705 # @return an integer value
1706 # @ingroup l1_meshinfo
1707 def NbPyramidsOfOrder(self, elementOrder):
1708 return self.mesh.NbPyramidsOfOrder(elementOrder)
1710 ## Returns the number of prisms in the mesh
1711 # @return an integer value
1712 # @ingroup l1_meshinfo
1714 return self.mesh.NbPrisms()
1716 ## Returns the number of prisms with the given order in the mesh
1717 # @param elementOrder the order of elements:
1718 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1719 # @return an integer value
1720 # @ingroup l1_meshinfo
1721 def NbPrismsOfOrder(self, elementOrder):
1722 return self.mesh.NbPrismsOfOrder(elementOrder)
1724 ## Returns the number of polyhedrons in the mesh
1725 # @return an integer value
1726 # @ingroup l1_meshinfo
1727 def NbPolyhedrons(self):
1728 return self.mesh.NbPolyhedrons()
1730 ## Returns the number of submeshes in the mesh
1731 # @return an integer value
1732 # @ingroup l1_meshinfo
1733 def NbSubMesh(self):
1734 return self.mesh.NbSubMesh()
1736 ## Returns the list of mesh elements IDs
1737 # @return the list of integer values
1738 # @ingroup l1_meshinfo
1739 def GetElementsId(self):
1740 return self.mesh.GetElementsId()
1742 ## Returns the list of IDs of mesh elements with the given type
1743 # @param elementType the required type of elements
1744 # @return list of integer values
1745 # @ingroup l1_meshinfo
1746 def GetElementsByType(self, elementType):
1747 return self.mesh.GetElementsByType(elementType)
1749 ## Returns the list of mesh nodes IDs
1750 # @return the list of integer values
1751 # @ingroup l1_meshinfo
1752 def GetNodesId(self):
1753 return self.mesh.GetNodesId()
1755 # Get the information about mesh elements:
1756 # ------------------------------------
1758 ## Returns the type of mesh element
1759 # @return the value from SMESH::ElementType enumeration
1760 # @ingroup l1_meshinfo
1761 def GetElementType(self, id, iselem):
1762 return self.mesh.GetElementType(id, iselem)
1764 ## Returns the list of submesh elements IDs
1765 # @param Shape a geom object(subshape) IOR
1766 # Shape must be the subshape of a ShapeToMesh()
1767 # @return the list of integer values
1768 # @ingroup l1_meshinfo
1769 def GetSubMeshElementsId(self, Shape):
1770 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1771 ShapeID = Shape.GetSubShapeIndices()[0]
1774 return self.mesh.GetSubMeshElementsId(ShapeID)
1776 ## Returns the list of submesh nodes IDs
1777 # @param Shape a geom object(subshape) IOR
1778 # Shape must be the subshape of a ShapeToMesh()
1779 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1780 # @return the list of integer values
1781 # @ingroup l1_meshinfo
1782 def GetSubMeshNodesId(self, Shape, all):
1783 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1784 ShapeID = Shape.GetSubShapeIndices()[0]
1787 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1789 ## Returns the list of IDs of submesh elements with the given type
1790 # @param Shape a geom object(subshape) IOR
1791 # Shape must be a subshape of a ShapeToMesh()
1792 # @return the list of integer values
1793 # @ingroup l1_meshinfo
1794 def GetSubMeshElementType(self, Shape):
1795 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1796 ShapeID = Shape.GetSubShapeIndices()[0]
1799 return self.mesh.GetSubMeshElementType(ShapeID)
1801 ## Gets the mesh description
1802 # @return string value
1803 # @ingroup l1_meshinfo
1805 return self.mesh.Dump()
1808 # Get the information about nodes and elements of a mesh by its IDs:
1809 # -----------------------------------------------------------
1811 ## Gets XYZ coordinates of a node
1812 # \n If there is no nodes for the given ID - returns an empty list
1813 # @return a list of double precision values
1814 # @ingroup l1_meshinfo
1815 def GetNodeXYZ(self, id):
1816 return self.mesh.GetNodeXYZ(id)
1818 ## Returns list of IDs of inverse elements for the given node
1819 # \n If there is no node for the given ID - returns an empty list
1820 # @return a list of integer values
1821 # @ingroup l1_meshinfo
1822 def GetNodeInverseElements(self, id):
1823 return self.mesh.GetNodeInverseElements(id)
1825 ## @brief Returns the position of a node on the shape
1826 # @return SMESH::NodePosition
1827 # @ingroup l1_meshinfo
1828 def GetNodePosition(self,NodeID):
1829 return self.mesh.GetNodePosition(NodeID)
1831 ## If the given element is a node, returns the ID of shape
1832 # \n If there is no node for the given ID - returns -1
1833 # @return an integer value
1834 # @ingroup l1_meshinfo
1835 def GetShapeID(self, id):
1836 return self.mesh.GetShapeID(id)
1838 ## Returns the ID of the result shape after
1839 # FindShape() from SMESH_MeshEditor for the given element
1840 # \n If there is no element for the given ID - returns -1
1841 # @return an integer value
1842 # @ingroup l1_meshinfo
1843 def GetShapeIDForElem(self,id):
1844 return self.mesh.GetShapeIDForElem(id)
1846 ## Returns the number of nodes for the given element
1847 # \n If there is no element for the given ID - returns -1
1848 # @return an integer value
1849 # @ingroup l1_meshinfo
1850 def GetElemNbNodes(self, id):
1851 return self.mesh.GetElemNbNodes(id)
1853 ## Returns the node ID the given index for the given element
1854 # \n If there is no element for the given ID - returns -1
1855 # \n If there is no node for the given index - returns -2
1856 # @return an integer value
1857 # @ingroup l1_meshinfo
1858 def GetElemNode(self, id, index):
1859 return self.mesh.GetElemNode(id, index)
1861 ## Returns the IDs of nodes of the given element
1862 # @return a list of integer values
1863 # @ingroup l1_meshinfo
1864 def GetElemNodes(self, id):
1865 return self.mesh.GetElemNodes(id)
1867 ## Returns true if the given node is the medium node in the given quadratic element
1868 # @ingroup l1_meshinfo
1869 def IsMediumNode(self, elementID, nodeID):
1870 return self.mesh.IsMediumNode(elementID, nodeID)
1872 ## Returns true if the given node is the medium node in one of quadratic elements
1873 # @ingroup l1_meshinfo
1874 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1875 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1877 ## Returns the number of edges for the given element
1878 # @ingroup l1_meshinfo
1879 def ElemNbEdges(self, id):
1880 return self.mesh.ElemNbEdges(id)
1882 ## Returns the number of faces for the given element
1883 # @ingroup l1_meshinfo
1884 def ElemNbFaces(self, id):
1885 return self.mesh.ElemNbFaces(id)
1887 ## Returns true if the given element is a polygon
1888 # @ingroup l1_meshinfo
1889 def IsPoly(self, id):
1890 return self.mesh.IsPoly(id)
1892 ## Returns true if the given element is quadratic
1893 # @ingroup l1_meshinfo
1894 def IsQuadratic(self, id):
1895 return self.mesh.IsQuadratic(id)
1897 ## Returns XYZ coordinates of the barycenter of the given element
1898 # \n If there is no element for the given ID - returns an empty list
1899 # @return a list of three double values
1900 # @ingroup l1_meshinfo
1901 def BaryCenter(self, id):
1902 return self.mesh.BaryCenter(id)
1905 # Mesh edition (SMESH_MeshEditor functionality):
1906 # ---------------------------------------------
1908 ## Removes the elements from the mesh by ids
1909 # @param IDsOfElements is a list of ids of elements to remove
1910 # @return True or False
1911 # @ingroup l2_modif_del
1912 def RemoveElements(self, IDsOfElements):
1913 return self.editor.RemoveElements(IDsOfElements)
1915 ## Removes nodes from mesh by ids
1916 # @param IDsOfNodes is a list of ids of nodes to remove
1917 # @return True or False
1918 # @ingroup l2_modif_del
1919 def RemoveNodes(self, IDsOfNodes):
1920 return self.editor.RemoveNodes(IDsOfNodes)
1922 ## Add a node to the mesh by coordinates
1923 # @return Id of the new node
1924 # @ingroup l2_modif_add
1925 def AddNode(self, x, y, z):
1926 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
1927 self.mesh.SetParameters(Parameters)
1928 return self.editor.AddNode( x, y, z)
1930 ## Creates a linear or quadratic edge (this is determined
1931 # by the number of given nodes).
1932 # @param IDsOfNodes the list of node IDs for creation of the element.
1933 # The order of nodes in this list should correspond to the description
1934 # of MED. \n This description is located by the following link:
1935 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1936 # @return the Id of the new edge
1937 # @ingroup l2_modif_add
1938 def AddEdge(self, IDsOfNodes):
1939 return self.editor.AddEdge(IDsOfNodes)
1941 ## Creates a linear or quadratic face (this is determined
1942 # by the number of given nodes).
1943 # @param IDsOfNodes the list of node IDs for creation of the element.
1944 # The order of nodes in this list should correspond to the description
1945 # of MED. \n This description is located by the following link:
1946 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1947 # @return the Id of the new face
1948 # @ingroup l2_modif_add
1949 def AddFace(self, IDsOfNodes):
1950 return self.editor.AddFace(IDsOfNodes)
1952 ## Adds a polygonal face to the mesh by the list of node IDs
1953 # @param IdsOfNodes the list of node IDs for creation of the element.
1954 # @return the Id of the new face
1955 # @ingroup l2_modif_add
1956 def AddPolygonalFace(self, IdsOfNodes):
1957 return self.editor.AddPolygonalFace(IdsOfNodes)
1959 ## Creates both simple and quadratic volume (this is determined
1960 # by the number of given nodes).
1961 # @param IDsOfNodes the list of node IDs for creation of the element.
1962 # The order of nodes in this list should correspond to the description
1963 # of MED. \n This description is located by the following link:
1964 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1965 # @return the Id of the new volumic element
1966 # @ingroup l2_modif_add
1967 def AddVolume(self, IDsOfNodes):
1968 return self.editor.AddVolume(IDsOfNodes)
1970 ## Creates a volume of many faces, giving nodes for each face.
1971 # @param IdsOfNodes the list of node IDs for volume creation face by face.
1972 # @param Quantities the list of integer values, Quantities[i]
1973 # gives the quantity of nodes in face number i.
1974 # @return the Id of the new volumic element
1975 # @ingroup l2_modif_add
1976 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1977 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1979 ## Creates a volume of many faces, giving the IDs of the existing faces.
1980 # @param IdsOfFaces the list of face IDs for volume creation.
1982 # Note: The created volume will refer only to the nodes
1983 # of the given faces, not to the faces themselves.
1984 # @return the Id of the new volumic element
1985 # @ingroup l2_modif_add
1986 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1987 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1990 ## @brief Binds a node to a vertex
1991 # @param NodeID a node ID
1992 # @param Vertex a vertex or vertex ID
1993 # @return True if succeed else raises an exception
1994 # @ingroup l2_modif_add
1995 def SetNodeOnVertex(self, NodeID, Vertex):
1996 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
1997 VertexID = Vertex.GetSubShapeIndices()[0]
2001 self.editor.SetNodeOnVertex(NodeID, VertexID)
2002 except SALOME.SALOME_Exception, inst:
2003 raise ValueError, inst.details.text
2007 ## @brief Stores the node position on an edge
2008 # @param NodeID a node ID
2009 # @param Edge an edge or edge ID
2010 # @param paramOnEdge a parameter on the edge where the node is located
2011 # @return True if succeed else raises an exception
2012 # @ingroup l2_modif_add
2013 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2014 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2015 EdgeID = Edge.GetSubShapeIndices()[0]
2019 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2020 except SALOME.SALOME_Exception, inst:
2021 raise ValueError, inst.details.text
2024 ## @brief Stores node position on a face
2025 # @param NodeID a node ID
2026 # @param Face a face or face ID
2027 # @param u U parameter on the face where the node is located
2028 # @param v V parameter on the face where the node is located
2029 # @return True if succeed else raises an exception
2030 # @ingroup l2_modif_add
2031 def SetNodeOnFace(self, NodeID, Face, u, v):
2032 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2033 FaceID = Face.GetSubShapeIndices()[0]
2037 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2038 except SALOME.SALOME_Exception, inst:
2039 raise ValueError, inst.details.text
2042 ## @brief Binds a node to a solid
2043 # @param NodeID a node ID
2044 # @param Solid a solid or solid ID
2045 # @return True if succeed else raises an exception
2046 # @ingroup l2_modif_add
2047 def SetNodeInVolume(self, NodeID, Solid):
2048 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2049 SolidID = Solid.GetSubShapeIndices()[0]
2053 self.editor.SetNodeInVolume(NodeID, SolidID)
2054 except SALOME.SALOME_Exception, inst:
2055 raise ValueError, inst.details.text
2058 ## @brief Bind an element to a shape
2059 # @param ElementID an element ID
2060 # @param Shape a shape or shape ID
2061 # @return True if succeed else raises an exception
2062 # @ingroup l2_modif_add
2063 def SetMeshElementOnShape(self, ElementID, Shape):
2064 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2065 ShapeID = Shape.GetSubShapeIndices()[0]
2069 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2070 except SALOME.SALOME_Exception, inst:
2071 raise ValueError, inst.details.text
2075 ## Moves the node with the given id
2076 # @param NodeID the id of the node
2077 # @param x a new X coordinate
2078 # @param y a new Y coordinate
2079 # @param z a new Z coordinate
2080 # @return True if succeed else False
2081 # @ingroup l2_modif_movenode
2082 def MoveNode(self, NodeID, x, y, z):
2083 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2084 self.mesh.SetParameters(Parameters)
2085 return self.editor.MoveNode(NodeID, x, y, z)
2087 ## Finds the node closest to a point and moves it to a point location
2088 # @param x the X coordinate of a point
2089 # @param y the Y coordinate of a point
2090 # @param z the Z coordinate of a point
2091 # @return the ID of a node
2092 # @ingroup l2_modif_throughp
2093 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2094 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2095 self.mesh.SetParameters(Parameters)
2096 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2098 ## Finds the node closest to a point
2099 # @param x the X coordinate of a point
2100 # @param y the Y coordinate of a point
2101 # @param z the Z coordinate of a point
2102 # @return the ID of a node
2103 # @ingroup l2_modif_throughp
2104 def FindNodeClosestTo(self, x, y, z):
2105 preview = self.mesh.GetMeshEditPreviewer()
2106 return preview.MoveClosestNodeToPoint(x, y, z, -1)
2108 ## Finds the node closest to a point and moves it to a point location
2109 # @param x the X coordinate of a point
2110 # @param y the Y coordinate of a point
2111 # @param z the Z coordinate of a point
2112 # @return the ID of a moved node
2113 # @ingroup l2_modif_throughp
2114 def MeshToPassThroughAPoint(self, x, y, z):
2115 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2117 ## Replaces two neighbour triangles sharing Node1-Node2 link
2118 # with the triangles built on the same 4 nodes but having other common link.
2119 # @param NodeID1 the ID of the first node
2120 # @param NodeID2 the ID of the second node
2121 # @return false if proper faces were not found
2122 # @ingroup l2_modif_invdiag
2123 def InverseDiag(self, NodeID1, NodeID2):
2124 return self.editor.InverseDiag(NodeID1, NodeID2)
2126 ## Replaces two neighbour triangles sharing Node1-Node2 link
2127 # with a quadrangle built on the same 4 nodes.
2128 # @param NodeID1 the ID of the first node
2129 # @param NodeID2 the ID of the second node
2130 # @return false if proper faces were not found
2131 # @ingroup l2_modif_unitetri
2132 def DeleteDiag(self, NodeID1, NodeID2):
2133 return self.editor.DeleteDiag(NodeID1, NodeID2)
2135 ## Reorients elements by ids
2136 # @param IDsOfElements if undefined reorients all mesh elements
2137 # @return True if succeed else False
2138 # @ingroup l2_modif_changori
2139 def Reorient(self, IDsOfElements=None):
2140 if IDsOfElements == None:
2141 IDsOfElements = self.GetElementsId()
2142 return self.editor.Reorient(IDsOfElements)
2144 ## Reorients all elements of the object
2145 # @param theObject mesh, submesh or group
2146 # @return True if succeed else False
2147 # @ingroup l2_modif_changori
2148 def ReorientObject(self, theObject):
2149 if ( isinstance( theObject, Mesh )):
2150 theObject = theObject.GetMesh()
2151 return self.editor.ReorientObject(theObject)
2153 ## Fuses the neighbouring triangles into quadrangles.
2154 # @param IDsOfElements The triangles to be fused,
2155 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2156 # @param MaxAngle is the maximum angle between element normals at which the fusion
2157 # is still performed; theMaxAngle is mesured in radians.
2158 # Also it could be a name of variable which defines angle in degrees.
2159 # @return TRUE in case of success, FALSE otherwise.
2160 # @ingroup l2_modif_unitetri
2161 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2163 if isinstance(MaxAngle,str):
2165 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2167 MaxAngle = DegreesToRadians(MaxAngle)
2168 if IDsOfElements == []:
2169 IDsOfElements = self.GetElementsId()
2170 self.mesh.SetParameters(Parameters)
2172 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2173 Functor = theCriterion
2175 Functor = self.smeshpyD.GetFunctor(theCriterion)
2176 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2178 ## Fuses the neighbouring triangles of the object into quadrangles
2179 # @param theObject is mesh, submesh or group
2180 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2181 # @param MaxAngle a max angle between element normals at which the fusion
2182 # is still performed; theMaxAngle is mesured in radians.
2183 # @return TRUE in case of success, FALSE otherwise.
2184 # @ingroup l2_modif_unitetri
2185 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2186 if ( isinstance( theObject, Mesh )):
2187 theObject = theObject.GetMesh()
2188 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2190 ## Splits quadrangles into triangles.
2191 # @param IDsOfElements the faces to be splitted.
2192 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2193 # @return TRUE in case of success, FALSE otherwise.
2194 # @ingroup l2_modif_cutquadr
2195 def QuadToTri (self, IDsOfElements, theCriterion):
2196 if IDsOfElements == []:
2197 IDsOfElements = self.GetElementsId()
2198 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2200 ## Splits quadrangles into triangles.
2201 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2202 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2203 # @return TRUE in case of success, FALSE otherwise.
2204 # @ingroup l2_modif_cutquadr
2205 def QuadToTriObject (self, theObject, theCriterion):
2206 if ( isinstance( theObject, Mesh )):
2207 theObject = theObject.GetMesh()
2208 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2210 ## Splits quadrangles into triangles.
2211 # @param IDsOfElements the faces to be splitted
2212 # @param Diag13 is used to choose a diagonal for splitting.
2213 # @return TRUE in case of success, FALSE otherwise.
2214 # @ingroup l2_modif_cutquadr
2215 def SplitQuad (self, IDsOfElements, Diag13):
2216 if IDsOfElements == []:
2217 IDsOfElements = self.GetElementsId()
2218 return self.editor.SplitQuad(IDsOfElements, Diag13)
2220 ## Splits quadrangles into triangles.
2221 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2222 # @param Diag13 is used to choose a diagonal for splitting.
2223 # @return TRUE in case of success, FALSE otherwise.
2224 # @ingroup l2_modif_cutquadr
2225 def SplitQuadObject (self, theObject, Diag13):
2226 if ( isinstance( theObject, Mesh )):
2227 theObject = theObject.GetMesh()
2228 return self.editor.SplitQuadObject(theObject, Diag13)
2230 ## Finds a better splitting of the given quadrangle.
2231 # @param IDOfQuad the ID of the quadrangle to be splitted.
2232 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2233 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2234 # diagonal is better, 0 if error occurs.
2235 # @ingroup l2_modif_cutquadr
2236 def BestSplit (self, IDOfQuad, theCriterion):
2237 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2239 ## Splits quadrangle faces near triangular facets of volumes
2241 # @ingroup l1_auxiliary
2242 def SplitQuadsNearTriangularFacets(self):
2243 faces_array = self.GetElementsByType(SMESH.FACE)
2244 for face_id in faces_array:
2245 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2246 quad_nodes = self.mesh.GetElemNodes(face_id)
2247 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2248 isVolumeFound = False
2249 for node1_elem in node1_elems:
2250 if not isVolumeFound:
2251 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2252 nb_nodes = self.GetElemNbNodes(node1_elem)
2253 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2254 volume_elem = node1_elem
2255 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2256 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2257 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2258 isVolumeFound = True
2259 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2260 self.SplitQuad([face_id], False) # diagonal 2-4
2261 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2262 isVolumeFound = True
2263 self.SplitQuad([face_id], True) # diagonal 1-3
2264 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2265 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2266 isVolumeFound = True
2267 self.SplitQuad([face_id], True) # diagonal 1-3
2269 ## @brief Splits hexahedrons into tetrahedrons.
2271 # This operation uses pattern mapping functionality for splitting.
2272 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2273 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2274 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2275 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2276 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2277 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2278 # @return TRUE in case of success, FALSE otherwise.
2279 # @ingroup l1_auxiliary
2280 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2281 # Pattern: 5.---------.6
2286 # (0,0,1) 4.---------.7 * |
2293 # (0,0,0) 0.---------.3
2294 pattern_tetra = "!!! Nb of points: \n 8 \n\
2304 !!! Indices of points of 6 tetras: \n\
2312 pattern = self.smeshpyD.GetPattern()
2313 isDone = pattern.LoadFromFile(pattern_tetra)
2315 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2318 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2319 isDone = pattern.MakeMesh(self.mesh, False, False)
2320 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2322 # split quafrangle faces near triangular facets of volumes
2323 self.SplitQuadsNearTriangularFacets()
2327 ## @brief Split hexahedrons into prisms.
2329 # Uses the pattern mapping functionality for splitting.
2330 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2331 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2332 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2333 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2334 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2335 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2336 # @return TRUE in case of success, FALSE otherwise.
2337 # @ingroup l1_auxiliary
2338 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2339 # Pattern: 5.---------.6
2344 # (0,0,1) 4.---------.7 |
2351 # (0,0,0) 0.---------.3
2352 pattern_prism = "!!! Nb of points: \n 8 \n\
2362 !!! Indices of points of 2 prisms: \n\
2366 pattern = self.smeshpyD.GetPattern()
2367 isDone = pattern.LoadFromFile(pattern_prism)
2369 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2372 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2373 isDone = pattern.MakeMesh(self.mesh, False, False)
2374 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2376 # Splits quafrangle faces near triangular facets of volumes
2377 self.SplitQuadsNearTriangularFacets()
2381 ## Smoothes elements
2382 # @param IDsOfElements the list if ids of elements to smooth
2383 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2384 # Note that nodes built on edges and boundary nodes are always fixed.
2385 # @param MaxNbOfIterations the maximum number of iterations
2386 # @param MaxAspectRatio varies in range [1.0, inf]
2387 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2388 # @return TRUE in case of success, FALSE otherwise.
2389 # @ingroup l2_modif_smooth
2390 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2391 MaxNbOfIterations, MaxAspectRatio, Method):
2392 if IDsOfElements == []:
2393 IDsOfElements = self.GetElementsId()
2394 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2395 self.mesh.SetParameters(Parameters)
2396 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2397 MaxNbOfIterations, MaxAspectRatio, Method)
2399 ## Smoothes elements which belong to the given object
2400 # @param theObject the object to smooth
2401 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2402 # Note that nodes built on edges and boundary nodes are always fixed.
2403 # @param MaxNbOfIterations the maximum number of iterations
2404 # @param MaxAspectRatio varies in range [1.0, inf]
2405 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2406 # @return TRUE in case of success, FALSE otherwise.
2407 # @ingroup l2_modif_smooth
2408 def SmoothObject(self, theObject, IDsOfFixedNodes,
2409 MaxNbOfIterations, MaxAspectRatio, Method):
2410 if ( isinstance( theObject, Mesh )):
2411 theObject = theObject.GetMesh()
2412 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2413 MaxNbOfIterations, MaxAspectRatio, Method)
2415 ## Parametrically smoothes the given elements
2416 # @param IDsOfElements the list if ids of elements to smooth
2417 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2418 # Note that nodes built on edges and boundary nodes are always fixed.
2419 # @param MaxNbOfIterations the maximum number of iterations
2420 # @param MaxAspectRatio varies in range [1.0, inf]
2421 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2422 # @return TRUE in case of success, FALSE otherwise.
2423 # @ingroup l2_modif_smooth
2424 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2425 MaxNbOfIterations, MaxAspectRatio, Method):
2426 if IDsOfElements == []:
2427 IDsOfElements = self.GetElementsId()
2428 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2429 self.mesh.SetParameters(Parameters)
2430 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2431 MaxNbOfIterations, MaxAspectRatio, Method)
2433 ## Parametrically smoothes the elements which belong to the given object
2434 # @param theObject the object to smooth
2435 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2436 # Note that nodes built on edges and boundary nodes are always fixed.
2437 # @param MaxNbOfIterations the maximum number of iterations
2438 # @param MaxAspectRatio varies in range [1.0, inf]
2439 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2440 # @return TRUE in case of success, FALSE otherwise.
2441 # @ingroup l2_modif_smooth
2442 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2443 MaxNbOfIterations, MaxAspectRatio, Method):
2444 if ( isinstance( theObject, Mesh )):
2445 theObject = theObject.GetMesh()
2446 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2447 MaxNbOfIterations, MaxAspectRatio, Method)
2449 ## Converts the mesh to quadratic, deletes old elements, replacing
2450 # them with quadratic with the same id.
2451 # @ingroup l2_modif_tofromqu
2452 def ConvertToQuadratic(self, theForce3d):
2453 self.editor.ConvertToQuadratic(theForce3d)
2455 ## Converts the mesh from quadratic to ordinary,
2456 # deletes old quadratic elements, \n replacing
2457 # them with ordinary mesh elements with the same id.
2458 # @return TRUE in case of success, FALSE otherwise.
2459 # @ingroup l2_modif_tofromqu
2460 def ConvertFromQuadratic(self):
2461 return self.editor.ConvertFromQuadratic()
2463 ## Renumber mesh nodes
2464 # @ingroup l2_modif_renumber
2465 def RenumberNodes(self):
2466 self.editor.RenumberNodes()
2468 ## Renumber mesh elements
2469 # @ingroup l2_modif_renumber
2470 def RenumberElements(self):
2471 self.editor.RenumberElements()
2473 ## Generates new elements by rotation of the elements around the axis
2474 # @param IDsOfElements the list of ids of elements to sweep
2475 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2476 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2477 # @param NbOfSteps the number of steps
2478 # @param Tolerance tolerance
2479 # @param MakeGroups forces the generation of new groups from existing ones
2480 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2481 # of all steps, else - size of each step
2482 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2483 # @ingroup l2_modif_extrurev
2484 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2485 MakeGroups=False, TotalAngle=False):
2487 if isinstance(AngleInRadians,str):
2489 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2491 AngleInRadians = DegreesToRadians(AngleInRadians)
2492 if IDsOfElements == []:
2493 IDsOfElements = self.GetElementsId()
2494 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2495 Axis = self.smeshpyD.GetAxisStruct(Axis)
2496 Axis,AxisParameters = ParseAxisStruct(Axis)
2497 if TotalAngle and NbOfSteps:
2498 AngleInRadians /= NbOfSteps
2499 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2500 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2501 self.mesh.SetParameters(Parameters)
2503 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2504 AngleInRadians, NbOfSteps, Tolerance)
2505 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2508 ## Generates new elements by rotation of the elements of object around the axis
2509 # @param theObject object which elements should be sweeped
2510 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2511 # @param AngleInRadians the angle of Rotation
2512 # @param NbOfSteps number of steps
2513 # @param Tolerance tolerance
2514 # @param MakeGroups forces the generation of new groups from existing ones
2515 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2516 # of all steps, else - size of each step
2517 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2518 # @ingroup l2_modif_extrurev
2519 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2520 MakeGroups=False, TotalAngle=False):
2522 if isinstance(AngleInRadians,str):
2524 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2526 AngleInRadians = DegreesToRadians(AngleInRadians)
2527 if ( isinstance( theObject, Mesh )):
2528 theObject = theObject.GetMesh()
2529 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2530 Axis = self.smeshpyD.GetAxisStruct(Axis)
2531 Axis,AxisParameters = ParseAxisStruct(Axis)
2532 if TotalAngle and NbOfSteps:
2533 AngleInRadians /= NbOfSteps
2534 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2535 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2536 self.mesh.SetParameters(Parameters)
2538 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2539 NbOfSteps, Tolerance)
2540 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2543 ## Generates new elements by rotation of the elements of object around the axis
2544 # @param theObject object which elements should be sweeped
2545 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2546 # @param AngleInRadians the angle of Rotation
2547 # @param NbOfSteps number of steps
2548 # @param Tolerance tolerance
2549 # @param MakeGroups forces the generation of new groups from existing ones
2550 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2551 # of all steps, else - size of each step
2552 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2553 # @ingroup l2_modif_extrurev
2554 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2555 MakeGroups=False, TotalAngle=False):
2557 if isinstance(AngleInRadians,str):
2559 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2561 AngleInRadians = DegreesToRadians(AngleInRadians)
2562 if ( isinstance( theObject, Mesh )):
2563 theObject = theObject.GetMesh()
2564 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2565 Axis = self.smeshpyD.GetAxisStruct(Axis)
2566 Axis,AxisParameters = ParseAxisStruct(Axis)
2567 if TotalAngle and NbOfSteps:
2568 AngleInRadians /= NbOfSteps
2569 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2570 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2571 self.mesh.SetParameters(Parameters)
2573 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2574 NbOfSteps, Tolerance)
2575 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2578 ## Generates new elements by rotation of the elements of object around the axis
2579 # @param theObject object which elements should be sweeped
2580 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2581 # @param AngleInRadians the angle of Rotation
2582 # @param NbOfSteps number of steps
2583 # @param Tolerance tolerance
2584 # @param MakeGroups forces the generation of new groups from existing ones
2585 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2586 # of all steps, else - size of each step
2587 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2588 # @ingroup l2_modif_extrurev
2589 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2590 MakeGroups=False, TotalAngle=False):
2592 if isinstance(AngleInRadians,str):
2594 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2596 AngleInRadians = DegreesToRadians(AngleInRadians)
2597 if ( isinstance( theObject, Mesh )):
2598 theObject = theObject.GetMesh()
2599 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2600 Axis = self.smeshpyD.GetAxisStruct(Axis)
2601 Axis,AxisParameters = ParseAxisStruct(Axis)
2602 if TotalAngle and NbOfSteps:
2603 AngleInRadians /= NbOfSteps
2604 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2605 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2606 self.mesh.SetParameters(Parameters)
2608 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2609 NbOfSteps, Tolerance)
2610 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2613 ## Generates new elements by extrusion of the elements with given ids
2614 # @param IDsOfElements the list of elements ids for extrusion
2615 # @param StepVector vector, defining the direction and value of extrusion
2616 # @param NbOfSteps the number of steps
2617 # @param MakeGroups forces the generation of new groups from existing ones
2618 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2619 # @ingroup l2_modif_extrurev
2620 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2621 if IDsOfElements == []:
2622 IDsOfElements = self.GetElementsId()
2623 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2624 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2625 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2626 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2627 Parameters = StepVectorParameters + var_separator + Parameters
2628 self.mesh.SetParameters(Parameters)
2630 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2631 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2634 ## Generates new elements by extrusion of the elements with given ids
2635 # @param IDsOfElements is ids of elements
2636 # @param StepVector vector, defining the direction and value of extrusion
2637 # @param NbOfSteps the number of steps
2638 # @param ExtrFlags sets flags for extrusion
2639 # @param SewTolerance uses for comparing locations of nodes if flag
2640 # EXTRUSION_FLAG_SEW is set
2641 # @param MakeGroups forces the generation of new groups from existing ones
2642 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2643 # @ingroup l2_modif_extrurev
2644 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2645 ExtrFlags, SewTolerance, MakeGroups=False):
2646 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2647 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2649 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2650 ExtrFlags, SewTolerance)
2651 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2652 ExtrFlags, SewTolerance)
2655 ## Generates new elements by extrusion of the elements which belong to the object
2656 # @param theObject the object which elements should be processed
2657 # @param StepVector vector, defining the direction and value of extrusion
2658 # @param NbOfSteps the number of steps
2659 # @param MakeGroups forces the generation of new groups from existing ones
2660 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2661 # @ingroup l2_modif_extrurev
2662 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2663 if ( isinstance( theObject, Mesh )):
2664 theObject = theObject.GetMesh()
2665 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2666 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2667 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2668 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2669 Parameters = StepVectorParameters + var_separator + Parameters
2670 self.mesh.SetParameters(Parameters)
2672 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2673 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2676 ## Generates new elements by extrusion of the elements which belong to the object
2677 # @param theObject object which elements should be processed
2678 # @param StepVector vector, defining the direction and value of extrusion
2679 # @param NbOfSteps the number of steps
2680 # @param MakeGroups to generate new groups from existing ones
2681 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2682 # @ingroup l2_modif_extrurev
2683 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2684 if ( isinstance( theObject, Mesh )):
2685 theObject = theObject.GetMesh()
2686 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2687 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2688 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2689 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2690 Parameters = StepVectorParameters + var_separator + Parameters
2691 self.mesh.SetParameters(Parameters)
2693 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2694 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2697 ## Generates new elements by extrusion of the elements which belong to the object
2698 # @param theObject object which elements should be processed
2699 # @param StepVector vector, defining the direction and value of extrusion
2700 # @param NbOfSteps the number of steps
2701 # @param MakeGroups forces the generation of new groups from existing ones
2702 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2703 # @ingroup l2_modif_extrurev
2704 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2705 if ( isinstance( theObject, Mesh )):
2706 theObject = theObject.GetMesh()
2707 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2708 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2709 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2710 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2711 Parameters = StepVectorParameters + var_separator + Parameters
2712 self.mesh.SetParameters(Parameters)
2714 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2715 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2718 ## Generates new elements by extrusion of the given elements
2719 # The path of extrusion must be a meshed edge.
2720 # @param IDsOfElements ids of elements
2721 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2722 # @param PathShape shape(edge) defines the sub-mesh for the path
2723 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2724 # @param HasAngles allows the shape to be rotated around the path
2725 # to get the resulting mesh in a helical fashion
2726 # @param Angles list of angles
2727 # @param HasRefPoint allows using the reference point
2728 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2729 # The User can specify any point as the Reference Point.
2730 # @param MakeGroups forces the generation of new groups from existing ones
2731 # @param LinearVariation forces the computation of rotation angles as linear
2732 # variation of the given Angles along path steps
2733 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2734 # only SMESH::Extrusion_Error otherwise
2735 # @ingroup l2_modif_extrurev
2736 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2737 HasAngles, Angles, HasRefPoint, RefPoint,
2738 MakeGroups=False, LinearVariation=False):
2739 Angles,AnglesParameters = ParseAngles(Angles)
2740 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2741 if IDsOfElements == []:
2742 IDsOfElements = self.GetElementsId()
2743 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2744 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2746 if ( isinstance( PathMesh, Mesh )):
2747 PathMesh = PathMesh.GetMesh()
2748 if HasAngles and Angles and LinearVariation:
2749 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2751 Parameters = AnglesParameters + var_separator + RefPointParameters
2752 self.mesh.SetParameters(Parameters)
2754 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2755 PathShape, NodeStart, HasAngles,
2756 Angles, HasRefPoint, RefPoint)
2757 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2758 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2760 ## Generates new elements by extrusion of the elements which belong to the object
2761 # The path of extrusion must be a meshed edge.
2762 # @param theObject the object which elements should be processed
2763 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2764 # @param PathShape shape(edge) defines the sub-mesh for the path
2765 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2766 # @param HasAngles allows the shape to be rotated around the path
2767 # to get the resulting mesh in a helical fashion
2768 # @param Angles list of angles
2769 # @param HasRefPoint allows using the reference point
2770 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2771 # The User can specify any point as the Reference Point.
2772 # @param MakeGroups forces the generation of new groups from existing ones
2773 # @param LinearVariation forces the computation of rotation angles as linear
2774 # variation of the given Angles along path steps
2775 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2776 # only SMESH::Extrusion_Error otherwise
2777 # @ingroup l2_modif_extrurev
2778 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2779 HasAngles, Angles, HasRefPoint, RefPoint,
2780 MakeGroups=False, LinearVariation=False):
2781 Angles,AnglesParameters = ParseAngles(Angles)
2782 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2783 if ( isinstance( theObject, Mesh )):
2784 theObject = theObject.GetMesh()
2785 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2786 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2787 if ( isinstance( PathMesh, Mesh )):
2788 PathMesh = PathMesh.GetMesh()
2789 if HasAngles and Angles and LinearVariation:
2790 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2792 Parameters = AnglesParameters + var_separator + RefPointParameters
2793 self.mesh.SetParameters(Parameters)
2795 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2796 PathShape, NodeStart, HasAngles,
2797 Angles, HasRefPoint, RefPoint)
2798 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2799 NodeStart, HasAngles, Angles, HasRefPoint,
2802 ## Generates new elements by extrusion of the elements which belong to the object
2803 # The path of extrusion must be a meshed edge.
2804 # @param theObject the object which elements should be processed
2805 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2806 # @param PathShape shape(edge) defines the sub-mesh for the path
2807 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2808 # @param HasAngles allows the shape to be rotated around the path
2809 # to get the resulting mesh in a helical fashion
2810 # @param Angles list of angles
2811 # @param HasRefPoint allows using the reference point
2812 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2813 # The User can specify any point as the Reference Point.
2814 # @param MakeGroups forces the generation of new groups from existing ones
2815 # @param LinearVariation forces the computation of rotation angles as linear
2816 # variation of the given Angles along path steps
2817 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2818 # only SMESH::Extrusion_Error otherwise
2819 # @ingroup l2_modif_extrurev
2820 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
2821 HasAngles, Angles, HasRefPoint, RefPoint,
2822 MakeGroups=False, LinearVariation=False):
2823 Angles,AnglesParameters = ParseAngles(Angles)
2824 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2825 if ( isinstance( theObject, Mesh )):
2826 theObject = theObject.GetMesh()
2827 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2828 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2829 if ( isinstance( PathMesh, Mesh )):
2830 PathMesh = PathMesh.GetMesh()
2831 if HasAngles and Angles and LinearVariation:
2832 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2834 Parameters = AnglesParameters + var_separator + RefPointParameters
2835 self.mesh.SetParameters(Parameters)
2837 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
2838 PathShape, NodeStart, HasAngles,
2839 Angles, HasRefPoint, RefPoint)
2840 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
2841 NodeStart, HasAngles, Angles, HasRefPoint,
2844 ## Generates new elements by extrusion of the elements which belong to the object
2845 # The path of extrusion must be a meshed edge.
2846 # @param theObject the object which elements should be processed
2847 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2848 # @param PathShape shape(edge) defines the sub-mesh for the path
2849 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2850 # @param HasAngles allows the shape to be rotated around the path
2851 # to get the resulting mesh in a helical fashion
2852 # @param Angles list of angles
2853 # @param HasRefPoint allows using the reference point
2854 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2855 # The User can specify any point as the Reference Point.
2856 # @param MakeGroups forces the generation of new groups from existing ones
2857 # @param LinearVariation forces the computation of rotation angles as linear
2858 # variation of the given Angles along path steps
2859 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2860 # only SMESH::Extrusion_Error otherwise
2861 # @ingroup l2_modif_extrurev
2862 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
2863 HasAngles, Angles, HasRefPoint, RefPoint,
2864 MakeGroups=False, LinearVariation=False):
2865 Angles,AnglesParameters = ParseAngles(Angles)
2866 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2867 if ( isinstance( theObject, Mesh )):
2868 theObject = theObject.GetMesh()
2869 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2870 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2871 if ( isinstance( PathMesh, Mesh )):
2872 PathMesh = PathMesh.GetMesh()
2873 if HasAngles and Angles and LinearVariation:
2874 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2876 Parameters = AnglesParameters + var_separator + RefPointParameters
2877 self.mesh.SetParameters(Parameters)
2879 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
2880 PathShape, NodeStart, HasAngles,
2881 Angles, HasRefPoint, RefPoint)
2882 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
2883 NodeStart, HasAngles, Angles, HasRefPoint,
2886 ## Creates a symmetrical copy of mesh elements
2887 # @param IDsOfElements list of elements ids
2888 # @param Mirror is AxisStruct or geom object(point, line, plane)
2889 # @param theMirrorType is POINT, AXIS or PLANE
2890 # If the Mirror is a geom object this parameter is unnecessary
2891 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2892 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2893 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2894 # @ingroup l2_modif_trsf
2895 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2896 if IDsOfElements == []:
2897 IDsOfElements = self.GetElementsId()
2898 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2899 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2900 Mirror,Parameters = ParseAxisStruct(Mirror)
2901 self.mesh.SetParameters(Parameters)
2902 if Copy and MakeGroups:
2903 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2904 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2907 ## Creates a new mesh by a symmetrical copy of mesh elements
2908 # @param IDsOfElements the list of elements ids
2909 # @param Mirror is AxisStruct or geom object (point, line, plane)
2910 # @param theMirrorType is POINT, AXIS or PLANE
2911 # If the Mirror is a geom object this parameter is unnecessary
2912 # @param MakeGroups to generate new groups from existing ones
2913 # @param NewMeshName a name of the new mesh to create
2914 # @return instance of Mesh class
2915 # @ingroup l2_modif_trsf
2916 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2917 if IDsOfElements == []:
2918 IDsOfElements = self.GetElementsId()
2919 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2920 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2921 Mirror,Parameters = ParseAxisStruct(Mirror)
2922 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2923 MakeGroups, NewMeshName)
2924 mesh.SetParameters(Parameters)
2925 return Mesh(self.smeshpyD,self.geompyD,mesh)
2927 ## Creates a symmetrical copy of the object
2928 # @param theObject mesh, submesh or group
2929 # @param Mirror AxisStruct or geom object (point, line, plane)
2930 # @param theMirrorType is POINT, AXIS or PLANE
2931 # If the Mirror is a geom object this parameter is unnecessary
2932 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2933 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2934 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2935 # @ingroup l2_modif_trsf
2936 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2937 if ( isinstance( theObject, Mesh )):
2938 theObject = theObject.GetMesh()
2939 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2940 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2941 Mirror,Parameters = ParseAxisStruct(Mirror)
2942 self.mesh.SetParameters(Parameters)
2943 if Copy and MakeGroups:
2944 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2945 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2948 ## Creates a new mesh by a symmetrical copy of the object
2949 # @param theObject mesh, submesh or group
2950 # @param Mirror AxisStruct or geom object (point, line, plane)
2951 # @param theMirrorType POINT, AXIS or PLANE
2952 # If the Mirror is a geom object this parameter is unnecessary
2953 # @param MakeGroups forces the generation of new groups from existing ones
2954 # @param NewMeshName the name of the new mesh to create
2955 # @return instance of Mesh class
2956 # @ingroup l2_modif_trsf
2957 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2958 if ( isinstance( theObject, Mesh )):
2959 theObject = theObject.GetMesh()
2960 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2961 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2962 Mirror,Parameters = ParseAxisStruct(Mirror)
2963 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2964 MakeGroups, NewMeshName)
2965 mesh.SetParameters(Parameters)
2966 return Mesh( self.smeshpyD,self.geompyD,mesh )
2968 ## Translates the elements
2969 # @param IDsOfElements list of elements ids
2970 # @param Vector the direction of translation (DirStruct or vector)
2971 # @param Copy allows copying the translated elements
2972 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2973 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2974 # @ingroup l2_modif_trsf
2975 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2976 if IDsOfElements == []:
2977 IDsOfElements = self.GetElementsId()
2978 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2979 Vector = self.smeshpyD.GetDirStruct(Vector)
2980 Vector,Parameters = ParseDirStruct(Vector)
2981 self.mesh.SetParameters(Parameters)
2982 if Copy and MakeGroups:
2983 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
2984 self.editor.Translate(IDsOfElements, Vector, Copy)
2987 ## Creates a new mesh of translated elements
2988 # @param IDsOfElements list of elements ids
2989 # @param Vector the direction of translation (DirStruct or vector)
2990 # @param MakeGroups forces the generation of new groups from existing ones
2991 # @param NewMeshName the name of the newly created mesh
2992 # @return instance of Mesh class
2993 # @ingroup l2_modif_trsf
2994 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
2995 if IDsOfElements == []:
2996 IDsOfElements = self.GetElementsId()
2997 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2998 Vector = self.smeshpyD.GetDirStruct(Vector)
2999 Vector,Parameters = ParseDirStruct(Vector)
3000 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3001 mesh.SetParameters(Parameters)
3002 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3004 ## Translates the object
3005 # @param theObject the object to translate (mesh, submesh, or group)
3006 # @param Vector direction of translation (DirStruct or geom vector)
3007 # @param Copy allows copying the translated elements
3008 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3009 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3010 # @ingroup l2_modif_trsf
3011 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3012 if ( isinstance( theObject, Mesh )):
3013 theObject = theObject.GetMesh()
3014 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3015 Vector = self.smeshpyD.GetDirStruct(Vector)
3016 Vector,Parameters = ParseDirStruct(Vector)
3017 self.mesh.SetParameters(Parameters)
3018 if Copy and MakeGroups:
3019 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3020 self.editor.TranslateObject(theObject, Vector, Copy)
3023 ## Creates a new mesh from the translated object
3024 # @param theObject the object to translate (mesh, submesh, or group)
3025 # @param Vector the direction of translation (DirStruct or geom vector)
3026 # @param MakeGroups forces the generation of new groups from existing ones
3027 # @param NewMeshName the name of the newly created mesh
3028 # @return instance of Mesh class
3029 # @ingroup l2_modif_trsf
3030 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3031 if (isinstance(theObject, Mesh)):
3032 theObject = theObject.GetMesh()
3033 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3034 Vector = self.smeshpyD.GetDirStruct(Vector)
3035 Vector,Parameters = ParseDirStruct(Vector)
3036 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3037 mesh.SetParameters(Parameters)
3038 return Mesh( self.smeshpyD, self.geompyD, mesh )
3040 ## Rotates the elements
3041 # @param IDsOfElements list of elements ids
3042 # @param Axis the axis of rotation (AxisStruct or geom line)
3043 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3044 # @param Copy allows copying the rotated elements
3045 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3046 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3047 # @ingroup l2_modif_trsf
3048 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3050 if isinstance(AngleInRadians,str):
3052 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3054 AngleInRadians = DegreesToRadians(AngleInRadians)
3055 if IDsOfElements == []:
3056 IDsOfElements = self.GetElementsId()
3057 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3058 Axis = self.smeshpyD.GetAxisStruct(Axis)
3059 Axis,AxisParameters = ParseAxisStruct(Axis)
3060 Parameters = AxisParameters + var_separator + Parameters
3061 self.mesh.SetParameters(Parameters)
3062 if Copy and MakeGroups:
3063 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3064 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3067 ## Creates a new mesh of rotated elements
3068 # @param IDsOfElements list of element ids
3069 # @param Axis the axis of rotation (AxisStruct or geom line)
3070 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3071 # @param MakeGroups forces the generation of new groups from existing ones
3072 # @param NewMeshName the name of the newly created mesh
3073 # @return instance of Mesh class
3074 # @ingroup l2_modif_trsf
3075 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3077 if isinstance(AngleInRadians,str):
3079 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3081 AngleInRadians = DegreesToRadians(AngleInRadians)
3082 if IDsOfElements == []:
3083 IDsOfElements = self.GetElementsId()
3084 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3085 Axis = self.smeshpyD.GetAxisStruct(Axis)
3086 Axis,AxisParameters = ParseAxisStruct(Axis)
3087 Parameters = AxisParameters + var_separator + Parameters
3088 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3089 MakeGroups, NewMeshName)
3090 mesh.SetParameters(Parameters)
3091 return Mesh( self.smeshpyD, self.geompyD, mesh )
3093 ## Rotates the object
3094 # @param theObject the object to rotate( mesh, submesh, or group)
3095 # @param Axis the axis of rotation (AxisStruct or geom line)
3096 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3097 # @param Copy allows copying the rotated elements
3098 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3099 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3100 # @ingroup l2_modif_trsf
3101 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3103 if isinstance(AngleInRadians,str):
3105 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3107 AngleInRadians = DegreesToRadians(AngleInRadians)
3108 if (isinstance(theObject, Mesh)):
3109 theObject = theObject.GetMesh()
3110 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3111 Axis = self.smeshpyD.GetAxisStruct(Axis)
3112 Axis,AxisParameters = ParseAxisStruct(Axis)
3113 Parameters = AxisParameters + ":" + Parameters
3114 self.mesh.SetParameters(Parameters)
3115 if Copy and MakeGroups:
3116 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3117 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3120 ## Creates a new mesh from the rotated object
3121 # @param theObject the object to rotate (mesh, submesh, or group)
3122 # @param Axis the axis of rotation (AxisStruct or geom line)
3123 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3124 # @param MakeGroups forces the generation of new groups from existing ones
3125 # @param NewMeshName the name of the newly created mesh
3126 # @return instance of Mesh class
3127 # @ingroup l2_modif_trsf
3128 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3130 if isinstance(AngleInRadians,str):
3132 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3134 AngleInRadians = DegreesToRadians(AngleInRadians)
3135 if (isinstance( theObject, Mesh )):
3136 theObject = theObject.GetMesh()
3137 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3138 Axis = self.smeshpyD.GetAxisStruct(Axis)
3139 Axis,AxisParameters = ParseAxisStruct(Axis)
3140 Parameters = AxisParameters + ":" + Parameters
3141 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3142 MakeGroups, NewMeshName)
3143 mesh.SetParameters(Parameters)
3144 return Mesh( self.smeshpyD, self.geompyD, mesh )
3146 ## Finds groups of ajacent nodes within Tolerance.
3147 # @param Tolerance the value of tolerance
3148 # @return the list of groups of nodes
3149 # @ingroup l2_modif_trsf
3150 def FindCoincidentNodes (self, Tolerance):
3151 return self.editor.FindCoincidentNodes(Tolerance)
3153 ## Finds groups of ajacent nodes within Tolerance.
3154 # @param Tolerance the value of tolerance
3155 # @param SubMeshOrGroup SubMesh or Group
3156 # @return the list of groups of nodes
3157 # @ingroup l2_modif_trsf
3158 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3159 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3162 # @param GroupsOfNodes the list of groups of nodes
3163 # @ingroup l2_modif_trsf
3164 def MergeNodes (self, GroupsOfNodes):
3165 self.editor.MergeNodes(GroupsOfNodes)
3167 ## Finds the elements built on the same nodes.
3168 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3169 # @return a list of groups of equal elements
3170 # @ingroup l2_modif_trsf
3171 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3172 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3174 ## Merges elements in each given group.
3175 # @param GroupsOfElementsID groups of elements for merging
3176 # @ingroup l2_modif_trsf
3177 def MergeElements(self, GroupsOfElementsID):
3178 self.editor.MergeElements(GroupsOfElementsID)
3180 ## Leaves one element and removes all other elements built on the same nodes.
3181 # @ingroup l2_modif_trsf
3182 def MergeEqualElements(self):
3183 self.editor.MergeEqualElements()
3185 ## Sews free borders
3186 # @return SMESH::Sew_Error
3187 # @ingroup l2_modif_trsf
3188 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3189 FirstNodeID2, SecondNodeID2, LastNodeID2,
3190 CreatePolygons, CreatePolyedrs):
3191 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3192 FirstNodeID2, SecondNodeID2, LastNodeID2,
3193 CreatePolygons, CreatePolyedrs)
3195 ## Sews conform free borders
3196 # @return SMESH::Sew_Error
3197 # @ingroup l2_modif_trsf
3198 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3199 FirstNodeID2, SecondNodeID2):
3200 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3201 FirstNodeID2, SecondNodeID2)
3203 ## Sews border to side
3204 # @return SMESH::Sew_Error
3205 # @ingroup l2_modif_trsf
3206 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3207 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3208 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3209 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3211 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3212 # merged with the nodes of elements of Side2.
3213 # The number of elements in theSide1 and in theSide2 must be
3214 # equal and they should have similar nodal connectivity.
3215 # The nodes to merge should belong to side borders and
3216 # the first node should be linked to the second.
3217 # @return SMESH::Sew_Error
3218 # @ingroup l2_modif_trsf
3219 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3220 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3221 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3222 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3223 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3224 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3226 ## Sets new nodes for the given element.
3227 # @param ide the element id
3228 # @param newIDs nodes ids
3229 # @return If the number of nodes does not correspond to the type of element - returns false
3230 # @ingroup l2_modif_edit
3231 def ChangeElemNodes(self, ide, newIDs):
3232 return self.editor.ChangeElemNodes(ide, newIDs)
3234 ## If during the last operation of MeshEditor some nodes were
3235 # created, this method returns the list of their IDs, \n
3236 # if new nodes were not created - returns empty list
3237 # @return the list of integer values (can be empty)
3238 # @ingroup l1_auxiliary
3239 def GetLastCreatedNodes(self):
3240 return self.editor.GetLastCreatedNodes()
3242 ## If during the last operation of MeshEditor some elements were
3243 # created this method returns the list of their IDs, \n
3244 # if new elements were not created - returns empty list
3245 # @return the list of integer values (can be empty)
3246 # @ingroup l1_auxiliary
3247 def GetLastCreatedElems(self):
3248 return self.editor.GetLastCreatedElems()
3250 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3251 # @param theNodes identifiers of nodes to be doubled
3252 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3253 # nodes. If list of element identifiers is empty then nodes are doubled but
3254 # they not assigned to elements
3255 # @return TRUE if operation has been completed successfully, FALSE otherwise
3256 # @ingroup l2_modif_edit
3257 def DoubleNodes(self, theNodes, theModifiedElems):
3258 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3260 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3261 # This method provided for convenience works as DoubleNodes() described above.
3262 # @param theNodes identifiers of node to be doubled
3263 # @param theModifiedElems identifiers of elements to be updated
3264 # @return TRUE if operation has been completed successfully, FALSE otherwise
3265 # @ingroup l2_modif_edit
3266 def DoubleNode(self, theNodeId, theModifiedElems):
3267 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3269 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3270 # This method provided for convenience works as DoubleNodes() described above.
3271 # @param theNodes group of nodes to be doubled
3272 # @param theModifiedElems group of elements to be updated.
3273 # @return TRUE if operation has been completed successfully, FALSE otherwise
3274 # @ingroup l2_modif_edit
3275 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3276 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3278 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3279 # This method provided for convenience works as DoubleNodes() described above.
3280 # @param theNodes list of groups of nodes to be doubled
3281 # @param theModifiedElems list of groups of elements to be updated.
3282 # @return TRUE if operation has been completed successfully, FALSE otherwise
3283 # @ingroup l2_modif_edit
3284 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3285 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3287 ## The mother class to define algorithm, it is not recommended to use it directly.
3290 # @ingroup l2_algorithms
3291 class Mesh_Algorithm:
3292 # @class Mesh_Algorithm
3293 # @brief Class Mesh_Algorithm
3295 #def __init__(self,smesh):
3303 ## Finds a hypothesis in the study by its type name and parameters.
3304 # Finds only the hypotheses created in smeshpyD engine.
3305 # @return SMESH.SMESH_Hypothesis
3306 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3307 study = smeshpyD.GetCurrentStudy()
3308 #to do: find component by smeshpyD object, not by its data type
3309 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3310 if scomp is not None:
3311 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3312 # Check if the root label of the hypotheses exists
3313 if res and hypRoot is not None:
3314 iter = study.NewChildIterator(hypRoot)
3315 # Check all published hypotheses
3317 hypo_so_i = iter.Value()
3318 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3319 if attr is not None:
3320 anIOR = attr.Value()
3321 hypo_o_i = salome.orb.string_to_object(anIOR)
3322 if hypo_o_i is not None:
3323 # Check if this is a hypothesis
3324 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3325 if hypo_i is not None:
3326 # Check if the hypothesis belongs to current engine
3327 if smeshpyD.GetObjectId(hypo_i) > 0:
3328 # Check if this is the required hypothesis
3329 if hypo_i.GetName() == hypname:
3331 if CompareMethod(hypo_i, args):
3345 ## Finds the algorithm in the study by its type name.
3346 # Finds only the algorithms, which have been created in smeshpyD engine.
3347 # @return SMESH.SMESH_Algo
3348 def FindAlgorithm (self, algoname, smeshpyD):
3349 study = smeshpyD.GetCurrentStudy()
3350 #to do: find component by smeshpyD object, not by its data type
3351 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3352 if scomp is not None:
3353 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3354 # Check if the root label of the algorithms exists
3355 if res and hypRoot is not None:
3356 iter = study.NewChildIterator(hypRoot)
3357 # Check all published algorithms
3359 algo_so_i = iter.Value()
3360 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3361 if attr is not None:
3362 anIOR = attr.Value()
3363 algo_o_i = salome.orb.string_to_object(anIOR)
3364 if algo_o_i is not None:
3365 # Check if this is an algorithm
3366 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3367 if algo_i is not None:
3368 # Checks if the algorithm belongs to the current engine
3369 if smeshpyD.GetObjectId(algo_i) > 0:
3370 # Check if this is the required algorithm
3371 if algo_i.GetName() == algoname:
3384 ## If the algorithm is global, returns 0; \n
3385 # else returns the submesh associated to this algorithm.
3386 def GetSubMesh(self):
3389 ## Returns the wrapped mesher.
3390 def GetAlgorithm(self):
3393 ## Gets the list of hypothesis that can be used with this algorithm
3394 def GetCompatibleHypothesis(self):
3397 mylist = self.algo.GetCompatibleHypothesis()
3400 ## Gets the name of the algorithm
3404 ## Sets the name to the algorithm
3405 def SetName(self, name):
3406 self.mesh.smeshpyD.SetName(self.algo, name)
3408 ## Gets the id of the algorithm
3410 return self.algo.GetId()
3413 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3415 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3416 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3418 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3420 self.Assign(algo, mesh, geom)
3424 def Assign(self, algo, mesh, geom):
3426 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3433 name = GetName(geom)
3435 name = mesh.geompyD.SubShapeName(geom, piece)
3436 mesh.geompyD.addToStudyInFather(piece, geom, name)
3437 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3440 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3441 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3443 def CompareHyp (self, hyp, args):
3444 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3447 def CompareEqualHyp (self, hyp, args):
3451 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3452 UseExisting=0, CompareMethod=""):
3455 if CompareMethod == "": CompareMethod = self.CompareHyp
3456 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3459 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3465 a = a + s + str(args[i])
3469 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3471 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3472 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3476 # Public class: Mesh_Segment
3477 # --------------------------
3479 ## Class to define a segment 1D algorithm for discretization
3482 # @ingroup l3_algos_basic
3483 class Mesh_Segment(Mesh_Algorithm):
3485 ## Private constructor.
3486 def __init__(self, mesh, geom=0):
3487 Mesh_Algorithm.__init__(self)
3488 self.Create(mesh, geom, "Regular_1D")
3490 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3491 # @param l for the length of segments that cut an edge
3492 # @param UseExisting if ==true - searches for an existing hypothesis created with
3493 # the same parameters, else (default) - creates a new one
3494 # @param p precision, used for calculation of the number of segments.
3495 # The precision should be a positive, meaningful value within the range [0,1].
3496 # In general, the number of segments is calculated with the formula:
3497 # nb = ceil((edge_length / l) - p)
3498 # Function ceil rounds its argument to the higher integer.
3499 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3500 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3501 # p=1 means rounding of (edge_length / l) to the lower integer.
3502 # Default value is 1e-07.
3503 # @return an instance of StdMeshers_LocalLength hypothesis
3504 # @ingroup l3_hypos_1dhyps
3505 def LocalLength(self, l, UseExisting=0, p=1e-07):
3506 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3507 CompareMethod=self.CompareLocalLength)
3513 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3514 def CompareLocalLength(self, hyp, args):
3515 if IsEqual(hyp.GetLength(), args[0]):
3516 return IsEqual(hyp.GetPrecision(), args[1])
3519 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3520 # @param length is optional maximal allowed length of segment, if it is omitted
3521 # the preestimated length is used that depends on geometry size
3522 # @param UseExisting if ==true - searches for an existing hypothesis created with
3523 # the same parameters, else (default) - create a new one
3524 # @return an instance of StdMeshers_MaxLength hypothesis
3525 # @ingroup l3_hypos_1dhyps
3526 def MaxSize(self, length=0.0, UseExisting=0):
3527 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3530 hyp.SetLength(length)
3532 # set preestimated length
3533 gen = self.mesh.smeshpyD
3534 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3535 self.mesh.GetMesh(), self.mesh.GetShape(),
3537 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3539 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3542 hyp.SetUsePreestimatedLength( length == 0.0 )
3545 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3546 # @param n for the number of segments that cut an edge
3547 # @param s for the scale factor (optional)
3548 # @param UseExisting if ==true - searches for an existing hypothesis created with
3549 # the same parameters, else (default) - create a new one
3550 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3551 # @ingroup l3_hypos_1dhyps
3552 def NumberOfSegments(self, n, s=[], UseExisting=0):
3554 hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
3555 CompareMethod=self.CompareNumberOfSegments)
3557 hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
3558 CompareMethod=self.CompareNumberOfSegments)
3559 hyp.SetDistrType( 1 )
3560 hyp.SetScaleFactor(s)
3561 hyp.SetNumberOfSegments(n)
3565 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3566 def CompareNumberOfSegments(self, hyp, args):
3567 if hyp.GetNumberOfSegments() == args[0]:
3571 if hyp.GetDistrType() == 1:
3572 if IsEqual(hyp.GetScaleFactor(), args[1]):
3576 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3577 # @param start defines the length of the first segment
3578 # @param end defines the length of the last segment
3579 # @param UseExisting if ==true - searches for an existing hypothesis created with
3580 # the same parameters, else (default) - creates a new one
3581 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3582 # @ingroup l3_hypos_1dhyps
3583 def Arithmetic1D(self, start, end, UseExisting=0):
3584 hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
3585 CompareMethod=self.CompareArithmetic1D)
3586 hyp.SetLength(start, 1)
3587 hyp.SetLength(end , 0)
3591 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3592 def CompareArithmetic1D(self, hyp, args):
3593 if IsEqual(hyp.GetLength(1), args[0]):
3594 if IsEqual(hyp.GetLength(0), args[1]):
3598 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3599 # @param start defines the length of the first segment
3600 # @param end defines the length of the last segment
3601 # @param UseExisting if ==true - searches for an existing hypothesis created with
3602 # the same parameters, else (default) - creates a new one
3603 # @return an instance of StdMeshers_StartEndLength hypothesis
3604 # @ingroup l3_hypos_1dhyps
3605 def StartEndLength(self, start, end, UseExisting=0):
3606 hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
3607 CompareMethod=self.CompareStartEndLength)
3608 hyp.SetLength(start, 1)
3609 hyp.SetLength(end , 0)
3612 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3613 def CompareStartEndLength(self, hyp, args):
3614 if IsEqual(hyp.GetLength(1), args[0]):
3615 if IsEqual(hyp.GetLength(0), args[1]):
3619 ## Defines "Deflection1D" hypothesis
3620 # @param d for the deflection
3621 # @param UseExisting if ==true - searches for an existing hypothesis created with
3622 # the same parameters, else (default) - create a new one
3623 # @ingroup l3_hypos_1dhyps
3624 def Deflection1D(self, d, UseExisting=0):
3625 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3626 CompareMethod=self.CompareDeflection1D)
3627 hyp.SetDeflection(d)
3630 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3631 def CompareDeflection1D(self, hyp, args):
3632 return IsEqual(hyp.GetDeflection(), args[0])
3634 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3635 # the opposite side in case of quadrangular faces
3636 # @ingroup l3_hypos_additi
3637 def Propagation(self):
3638 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3640 ## Defines "AutomaticLength" hypothesis
3641 # @param fineness for the fineness [0-1]
3642 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3643 # same parameters, else (default) - create a new one
3644 # @ingroup l3_hypos_1dhyps
3645 def AutomaticLength(self, fineness=0, UseExisting=0):
3646 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3647 CompareMethod=self.CompareAutomaticLength)
3648 hyp.SetFineness( fineness )
3651 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3652 def CompareAutomaticLength(self, hyp, args):
3653 return IsEqual(hyp.GetFineness(), args[0])
3655 ## Defines "SegmentLengthAroundVertex" hypothesis
3656 # @param length for the segment length
3657 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3658 # Any other integer value means that the hypothesis will be set on the
3659 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3660 # @param UseExisting if ==true - searches for an existing hypothesis created with
3661 # the same parameters, else (default) - creates a new one
3662 # @ingroup l3_algos_segmarv
3663 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3665 store_geom = self.geom
3666 if type(vertex) is types.IntType:
3667 if vertex == 0 or vertex == 1:
3668 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3676 if self.geom is None:
3677 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3678 name = GetName(self.geom)
3680 piece = self.mesh.geom
3681 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3682 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3683 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3685 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3687 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3688 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3690 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3691 CompareMethod=self.CompareLengthNearVertex)
3692 self.geom = store_geom
3693 hyp.SetLength( length )
3696 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3697 # @ingroup l3_algos_segmarv
3698 def CompareLengthNearVertex(self, hyp, args):
3699 return IsEqual(hyp.GetLength(), args[0])
3701 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3702 # If the 2D mesher sees that all boundary edges are quadratic,
3703 # it generates quadratic faces, else it generates linear faces using
3704 # medium nodes as if they are vertices.
3705 # The 3D mesher generates quadratic volumes only if all boundary faces
3706 # are quadratic, else it fails.
3708 # @ingroup l3_hypos_additi
3709 def QuadraticMesh(self):
3710 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3713 # Public class: Mesh_CompositeSegment
3714 # --------------------------
3716 ## Defines a segment 1D algorithm for discretization
3718 # @ingroup l3_algos_basic
3719 class Mesh_CompositeSegment(Mesh_Segment):
3721 ## Private constructor.
3722 def __init__(self, mesh, geom=0):
3723 self.Create(mesh, geom, "CompositeSegment_1D")
3726 # Public class: Mesh_Segment_Python
3727 # ---------------------------------
3729 ## Defines a segment 1D algorithm for discretization with python function
3731 # @ingroup l3_algos_basic
3732 class Mesh_Segment_Python(Mesh_Segment):
3734 ## Private constructor.
3735 def __init__(self, mesh, geom=0):
3736 import Python1dPlugin
3737 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3739 ## Defines "PythonSplit1D" hypothesis
3740 # @param n for the number of segments that cut an edge
3741 # @param func for the python function that calculates the length of all segments
3742 # @param UseExisting if ==true - searches for the existing hypothesis created with
3743 # the same parameters, else (default) - creates a new one
3744 # @ingroup l3_hypos_1dhyps
3745 def PythonSplit1D(self, n, func, UseExisting=0):
3746 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3747 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3748 hyp.SetNumberOfSegments(n)
3749 hyp.SetPythonLog10RatioFunction(func)
3752 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3753 def ComparePythonSplit1D(self, hyp, args):
3754 #if hyp.GetNumberOfSegments() == args[0]:
3755 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3759 # Public class: Mesh_Triangle
3760 # ---------------------------
3762 ## Defines a triangle 2D algorithm
3764 # @ingroup l3_algos_basic
3765 class Mesh_Triangle(Mesh_Algorithm):
3774 ## Private constructor.
3775 def __init__(self, mesh, algoType, geom=0):
3776 Mesh_Algorithm.__init__(self)
3778 self.algoType = algoType
3779 if algoType == MEFISTO:
3780 self.Create(mesh, geom, "MEFISTO_2D")
3782 elif algoType == BLSURF:
3784 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3785 #self.SetPhysicalMesh() - PAL19680
3786 elif algoType == NETGEN:
3788 print "Warning: NETGENPlugin module unavailable"
3790 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3792 elif algoType == NETGEN_2D:
3794 print "Warning: NETGENPlugin module unavailable"
3796 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3799 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3800 # @param area for the maximum area of each triangle
3801 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3802 # same parameters, else (default) - creates a new one
3804 # Only for algoType == MEFISTO || NETGEN_2D
3805 # @ingroup l3_hypos_2dhyps
3806 def MaxElementArea(self, area, UseExisting=0):
3807 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3808 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3809 CompareMethod=self.CompareMaxElementArea)
3810 elif self.algoType == NETGEN:
3811 hyp = self.Parameters(SIMPLE)
3812 hyp.SetMaxElementArea(area)
3815 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3816 def CompareMaxElementArea(self, hyp, args):
3817 return IsEqual(hyp.GetMaxElementArea(), args[0])
3819 ## Defines "LengthFromEdges" hypothesis to build triangles
3820 # based on the length of the edges taken from the wire
3822 # Only for algoType == MEFISTO || NETGEN_2D
3823 # @ingroup l3_hypos_2dhyps
3824 def LengthFromEdges(self):
3825 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3826 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3828 elif self.algoType == NETGEN:
3829 hyp = self.Parameters(SIMPLE)
3830 hyp.LengthFromEdges()
3833 ## Sets a way to define size of mesh elements to generate.
3834 # @param thePhysicalMesh is: DefaultSize or Custom.
3835 # @ingroup l3_hypos_blsurf
3836 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3837 # Parameter of BLSURF algo
3838 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3840 ## Sets size of mesh elements to generate.
3841 # @ingroup l3_hypos_blsurf
3842 def SetPhySize(self, theVal):
3843 # Parameter of BLSURF algo
3844 self.Parameters().SetPhySize(theVal)
3846 ## Sets lower boundary of mesh element size (PhySize).
3847 # @ingroup l3_hypos_blsurf
3848 def SetPhyMin(self, theVal=-1):
3849 # Parameter of BLSURF algo
3850 self.Parameters().SetPhyMin(theVal)
3852 ## Sets upper boundary of mesh element size (PhySize).
3853 # @ingroup l3_hypos_blsurf
3854 def SetPhyMax(self, theVal=-1):
3855 # Parameter of BLSURF algo
3856 self.Parameters().SetPhyMax(theVal)
3858 ## Sets a way to define maximum angular deflection of mesh from CAD model.
3859 # @param theGeometricMesh is: DefaultGeom or Custom
3860 # @ingroup l3_hypos_blsurf
3861 def SetGeometricMesh(self, theGeometricMesh=0):
3862 # Parameter of BLSURF algo
3863 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3864 self.params.SetGeometricMesh(theGeometricMesh)
3866 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3867 # @ingroup l3_hypos_blsurf
3868 def SetAngleMeshS(self, theVal=_angleMeshS):
3869 # Parameter of BLSURF algo
3870 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3871 self.params.SetAngleMeshS(theVal)
3873 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3874 # @ingroup l3_hypos_blsurf
3875 def SetAngleMeshC(self, theVal=_angleMeshS):
3876 # Parameter of BLSURF algo
3877 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3878 self.params.SetAngleMeshC(theVal)
3880 ## Sets lower boundary of mesh element size computed to respect angular deflection.
3881 # @ingroup l3_hypos_blsurf
3882 def SetGeoMin(self, theVal=-1):
3883 # Parameter of BLSURF algo
3884 self.Parameters().SetGeoMin(theVal)
3886 ## Sets upper boundary of mesh element size computed to respect angular deflection.
3887 # @ingroup l3_hypos_blsurf
3888 def SetGeoMax(self, theVal=-1):
3889 # Parameter of BLSURF algo
3890 self.Parameters().SetGeoMax(theVal)
3892 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3893 # @ingroup l3_hypos_blsurf
3894 def SetGradation(self, theVal=_gradation):
3895 # Parameter of BLSURF algo
3896 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3897 self.params.SetGradation(theVal)
3899 ## Sets topology usage way.
3900 # @param way defines how mesh conformity is assured <ul>
3901 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
3902 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
3903 # @ingroup l3_hypos_blsurf
3904 def SetTopology(self, way):
3905 # Parameter of BLSURF algo
3906 self.Parameters().SetTopology(way)
3908 ## To respect geometrical edges or not.
3909 # @ingroup l3_hypos_blsurf
3910 def SetDecimesh(self, toIgnoreEdges=False):
3911 # Parameter of BLSURF algo
3912 self.Parameters().SetDecimesh(toIgnoreEdges)
3914 ## Sets verbosity level in the range 0 to 100.
3915 # @ingroup l3_hypos_blsurf
3916 def SetVerbosity(self, level):
3917 # Parameter of BLSURF algo
3918 self.Parameters().SetVerbosity(level)
3920 ## Sets advanced option value.
3921 # @ingroup l3_hypos_blsurf
3922 def SetOptionValue(self, optionName, level):
3923 # Parameter of BLSURF algo
3924 self.Parameters().SetOptionValue(optionName,level)
3926 ## Sets QuadAllowed flag.
3927 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
3928 # @ingroup l3_hypos_netgen l3_hypos_blsurf
3929 def SetQuadAllowed(self, toAllow=True):
3930 if self.algoType == NETGEN_2D:
3931 if toAllow: # add QuadranglePreference
3932 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3933 else: # remove QuadranglePreference
3934 for hyp in self.mesh.GetHypothesisList( self.geom ):
3935 if hyp.GetName() == "QuadranglePreference":
3936 self.mesh.RemoveHypothesis( self.geom, hyp )
3941 if self.Parameters():
3942 self.params.SetQuadAllowed(toAllow)
3945 ## Defines hypothesis having several parameters
3947 # @ingroup l3_hypos_netgen
3948 def Parameters(self, which=SOLE):
3951 if self.algoType == NETGEN:
3953 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
3954 "libNETGENEngine.so", UseExisting=0)
3956 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
3957 "libNETGENEngine.so", UseExisting=0)
3959 elif self.algoType == MEFISTO:
3960 print "Mefisto algo support no multi-parameter hypothesis"
3962 elif self.algoType == NETGEN_2D:
3963 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
3964 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3966 elif self.algoType == BLSURF:
3967 self.params = self.Hypothesis("BLSURF_Parameters", [],
3968 "libBLSURFEngine.so", UseExisting=0)
3971 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
3976 # Only for algoType == NETGEN
3977 # @ingroup l3_hypos_netgen
3978 def SetMaxSize(self, theSize):
3979 if self.Parameters():
3980 self.params.SetMaxSize(theSize)
3982 ## Sets SecondOrder flag
3984 # Only for algoType == NETGEN
3985 # @ingroup l3_hypos_netgen
3986 def SetSecondOrder(self, theVal):
3987 if self.Parameters():
3988 self.params.SetSecondOrder(theVal)
3990 ## Sets Optimize flag
3992 # Only for algoType == NETGEN
3993 # @ingroup l3_hypos_netgen
3994 def SetOptimize(self, theVal):
3995 if self.Parameters():
3996 self.params.SetOptimize(theVal)
3999 # @param theFineness is:
4000 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4002 # Only for algoType == NETGEN
4003 # @ingroup l3_hypos_netgen
4004 def SetFineness(self, theFineness):
4005 if self.Parameters():
4006 self.params.SetFineness(theFineness)
4010 # Only for algoType == NETGEN
4011 # @ingroup l3_hypos_netgen
4012 def SetGrowthRate(self, theRate):
4013 if self.Parameters():
4014 self.params.SetGrowthRate(theRate)
4016 ## Sets NbSegPerEdge
4018 # Only for algoType == NETGEN
4019 # @ingroup l3_hypos_netgen
4020 def SetNbSegPerEdge(self, theVal):
4021 if self.Parameters():
4022 self.params.SetNbSegPerEdge(theVal)
4024 ## Sets NbSegPerRadius
4026 # Only for algoType == NETGEN
4027 # @ingroup l3_hypos_netgen
4028 def SetNbSegPerRadius(self, theVal):
4029 if self.Parameters():
4030 self.params.SetNbSegPerRadius(theVal)
4032 ## Sets number of segments overriding value set by SetLocalLength()
4034 # Only for algoType == NETGEN
4035 # @ingroup l3_hypos_netgen
4036 def SetNumberOfSegments(self, theVal):
4037 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4039 ## Sets number of segments overriding value set by SetNumberOfSegments()
4041 # Only for algoType == NETGEN
4042 # @ingroup l3_hypos_netgen
4043 def SetLocalLength(self, theVal):
4044 self.Parameters(SIMPLE).SetLocalLength(theVal)
4049 # Public class: Mesh_Quadrangle
4050 # -----------------------------
4052 ## Defines a quadrangle 2D algorithm
4054 # @ingroup l3_algos_basic
4055 class Mesh_Quadrangle(Mesh_Algorithm):
4057 ## Private constructor.
4058 def __init__(self, mesh, geom=0):
4059 Mesh_Algorithm.__init__(self)
4060 self.Create(mesh, geom, "Quadrangle_2D")
4062 ## Defines "QuadranglePreference" hypothesis, forcing construction
4063 # of quadrangles if the number of nodes on the opposite edges is not the same
4064 # while the total number of nodes on edges is even
4066 # @ingroup l3_hypos_additi
4067 def QuadranglePreference(self):
4068 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4069 CompareMethod=self.CompareEqualHyp)
4072 ## Defines "TrianglePreference" hypothesis, forcing construction
4073 # of triangles in the refinement area if the number of nodes
4074 # on the opposite edges is not the same
4076 # @ingroup l3_hypos_additi
4077 def TrianglePreference(self):
4078 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4079 CompareMethod=self.CompareEqualHyp)
4082 # Public class: Mesh_Tetrahedron
4083 # ------------------------------
4085 ## Defines a tetrahedron 3D algorithm
4087 # @ingroup l3_algos_basic
4088 class Mesh_Tetrahedron(Mesh_Algorithm):
4093 ## Private constructor.
4094 def __init__(self, mesh, algoType, geom=0):
4095 Mesh_Algorithm.__init__(self)
4097 if algoType == NETGEN:
4098 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4101 elif algoType == FULL_NETGEN:
4103 print "Warning: NETGENPlugin module has not been imported."
4104 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4107 elif algoType == GHS3D:
4109 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4112 elif algoType == GHS3DPRL:
4113 import GHS3DPRLPlugin
4114 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4117 self.algoType = algoType
4119 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4120 # @param vol for the maximum volume of each tetrahedron
4121 # @param UseExisting if ==true - searches for the existing hypothesis created with
4122 # the same parameters, else (default) - creates a new one
4123 # @ingroup l3_hypos_maxvol
4124 def MaxElementVolume(self, vol, UseExisting=0):
4125 if self.algoType == NETGEN:
4126 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4127 CompareMethod=self.CompareMaxElementVolume)
4128 hyp.SetMaxElementVolume(vol)
4130 elif self.algoType == FULL_NETGEN:
4131 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4134 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4135 def CompareMaxElementVolume(self, hyp, args):
4136 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4138 ## Defines hypothesis having several parameters
4140 # @ingroup l3_hypos_netgen
4141 def Parameters(self, which=SOLE):
4145 if self.algoType == FULL_NETGEN:
4147 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4148 "libNETGENEngine.so", UseExisting=0)
4150 self.params = self.Hypothesis("NETGEN_Parameters", [],
4151 "libNETGENEngine.so", UseExisting=0)
4154 if self.algoType == GHS3D:
4155 self.params = self.Hypothesis("GHS3D_Parameters", [],
4156 "libGHS3DEngine.so", UseExisting=0)
4159 if self.algoType == GHS3DPRL:
4160 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4161 "libGHS3DPRLEngine.so", UseExisting=0)
4164 print "Algo supports no multi-parameter hypothesis"
4168 # Parameter of FULL_NETGEN
4169 # @ingroup l3_hypos_netgen
4170 def SetMaxSize(self, theSize):
4171 self.Parameters().SetMaxSize(theSize)
4173 ## Sets SecondOrder flag
4174 # Parameter of FULL_NETGEN
4175 # @ingroup l3_hypos_netgen
4176 def SetSecondOrder(self, theVal):
4177 self.Parameters().SetSecondOrder(theVal)
4179 ## Sets Optimize flag
4180 # Parameter of FULL_NETGEN
4181 # @ingroup l3_hypos_netgen
4182 def SetOptimize(self, theVal):
4183 self.Parameters().SetOptimize(theVal)
4186 # @param theFineness is:
4187 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4188 # Parameter of FULL_NETGEN
4189 # @ingroup l3_hypos_netgen
4190 def SetFineness(self, theFineness):
4191 self.Parameters().SetFineness(theFineness)
4194 # Parameter of FULL_NETGEN
4195 # @ingroup l3_hypos_netgen
4196 def SetGrowthRate(self, theRate):
4197 self.Parameters().SetGrowthRate(theRate)
4199 ## Sets NbSegPerEdge
4200 # Parameter of FULL_NETGEN
4201 # @ingroup l3_hypos_netgen
4202 def SetNbSegPerEdge(self, theVal):
4203 self.Parameters().SetNbSegPerEdge(theVal)
4205 ## Sets NbSegPerRadius
4206 # Parameter of FULL_NETGEN
4207 # @ingroup l3_hypos_netgen
4208 def SetNbSegPerRadius(self, theVal):
4209 self.Parameters().SetNbSegPerRadius(theVal)
4211 ## Sets number of segments overriding value set by SetLocalLength()
4212 # Only for algoType == NETGEN_FULL
4213 # @ingroup l3_hypos_netgen
4214 def SetNumberOfSegments(self, theVal):
4215 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4217 ## Sets number of segments overriding value set by SetNumberOfSegments()
4218 # Only for algoType == NETGEN_FULL
4219 # @ingroup l3_hypos_netgen
4220 def SetLocalLength(self, theVal):
4221 self.Parameters(SIMPLE).SetLocalLength(theVal)
4223 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4224 # Overrides value set by LengthFromEdges()
4225 # Only for algoType == NETGEN_FULL
4226 # @ingroup l3_hypos_netgen
4227 def MaxElementArea(self, area):
4228 self.Parameters(SIMPLE).SetMaxElementArea(area)
4230 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4231 # Overrides value set by MaxElementArea()
4232 # Only for algoType == NETGEN_FULL
4233 # @ingroup l3_hypos_netgen
4234 def LengthFromEdges(self):
4235 self.Parameters(SIMPLE).LengthFromEdges()
4237 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4238 # Overrides value set by MaxElementVolume()
4239 # Only for algoType == NETGEN_FULL
4240 # @ingroup l3_hypos_netgen
4241 def LengthFromFaces(self):
4242 self.Parameters(SIMPLE).LengthFromFaces()
4244 ## To mesh "holes" in a solid or not. Default is to mesh.
4245 # @ingroup l3_hypos_ghs3dh
4246 def SetToMeshHoles(self, toMesh):
4247 # Parameter of GHS3D
4248 self.Parameters().SetToMeshHoles(toMesh)
4250 ## Set Optimization level:
4251 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
4252 # Default is Medium_Optimization
4253 # @ingroup l3_hypos_ghs3dh
4254 def SetOptimizationLevel(self, level):
4255 # Parameter of GHS3D
4256 self.Parameters().SetOptimizationLevel(level)
4258 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4259 # @ingroup l3_hypos_ghs3dh
4260 def SetMaximumMemory(self, MB):
4261 # Advanced parameter of GHS3D
4262 self.Parameters().SetMaximumMemory(MB)
4264 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4265 # automatic memory adjustment mode.
4266 # @ingroup l3_hypos_ghs3dh
4267 def SetInitialMemory(self, MB):
4268 # Advanced parameter of GHS3D
4269 self.Parameters().SetInitialMemory(MB)
4271 ## Path to working directory.
4272 # @ingroup l3_hypos_ghs3dh
4273 def SetWorkingDirectory(self, path):
4274 # Advanced parameter of GHS3D
4275 self.Parameters().SetWorkingDirectory(path)
4277 ## To keep working files or remove them. Log file remains in case of errors anyway.
4278 # @ingroup l3_hypos_ghs3dh
4279 def SetKeepFiles(self, toKeep):
4280 # Advanced parameter of GHS3D and GHS3DPRL
4281 self.Parameters().SetKeepFiles(toKeep)
4283 ## To set verbose level [0-10]. <ul>
4284 #<li> 0 - no standard output,
4285 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4286 # indicates when the final mesh is being saved. In addition the software
4287 # gives indication regarding the CPU time.
4288 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4289 # histogram of the skin mesh, quality statistics histogram together with
4290 # the characteristics of the final mesh.</ul>
4291 # @ingroup l3_hypos_ghs3dh
4292 def SetVerboseLevel(self, level):
4293 # Advanced parameter of GHS3D
4294 self.Parameters().SetVerboseLevel(level)
4296 ## To create new nodes.
4297 # @ingroup l3_hypos_ghs3dh
4298 def SetToCreateNewNodes(self, toCreate):
4299 # Advanced parameter of GHS3D
4300 self.Parameters().SetToCreateNewNodes(toCreate)
4302 ## To use boundary recovery version which tries to create mesh on a very poor
4303 # quality surface mesh.
4304 # @ingroup l3_hypos_ghs3dh
4305 def SetToUseBoundaryRecoveryVersion(self, toUse):
4306 # Advanced parameter of GHS3D
4307 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4309 ## Sets command line option as text.
4310 # @ingroup l3_hypos_ghs3dh
4311 def SetTextOption(self, option):
4312 # Advanced parameter of GHS3D
4313 self.Parameters().SetTextOption(option)
4315 ## Sets MED files name and path.
4316 def SetMEDName(self, value):
4317 self.Parameters().SetMEDName(value)
4319 ## Sets the number of partition of the initial mesh
4320 def SetNbPart(self, value):
4321 self.Parameters().SetNbPart(value)
4323 ## When big mesh, start tepal in background
4324 def SetBackground(self, value):
4325 self.Parameters().SetBackground(value)
4327 # Public class: Mesh_Hexahedron
4328 # ------------------------------
4330 ## Defines a hexahedron 3D algorithm
4332 # @ingroup l3_algos_basic
4333 class Mesh_Hexahedron(Mesh_Algorithm):
4338 ## Private constructor.
4339 def __init__(self, mesh, algoType=Hexa, geom=0):
4340 Mesh_Algorithm.__init__(self)
4342 self.algoType = algoType
4344 if algoType == Hexa:
4345 self.Create(mesh, geom, "Hexa_3D")
4348 elif algoType == Hexotic:
4349 import HexoticPlugin
4350 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4353 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4354 # @ingroup l3_hypos_hexotic
4355 def MinMaxQuad(self, min=3, max=8, quad=True):
4356 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4358 self.params.SetHexesMinLevel(min)
4359 self.params.SetHexesMaxLevel(max)
4360 self.params.SetHexoticQuadrangles(quad)
4363 # Deprecated, only for compatibility!
4364 # Public class: Mesh_Netgen
4365 # ------------------------------
4367 ## Defines a NETGEN-based 2D or 3D algorithm
4368 # that needs no discrete boundary (i.e. independent)
4370 # This class is deprecated, only for compatibility!
4373 # @ingroup l3_algos_basic
4374 class Mesh_Netgen(Mesh_Algorithm):
4378 ## Private constructor.
4379 def __init__(self, mesh, is3D, geom=0):
4380 Mesh_Algorithm.__init__(self)
4383 print "Warning: NETGENPlugin module has not been imported."
4387 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4391 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4394 ## Defines the hypothesis containing parameters of the algorithm
4395 def Parameters(self):
4397 hyp = self.Hypothesis("NETGEN_Parameters", [],
4398 "libNETGENEngine.so", UseExisting=0)
4400 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4401 "libNETGENEngine.so", UseExisting=0)
4404 # Public class: Mesh_Projection1D
4405 # ------------------------------
4407 ## Defines a projection 1D algorithm
4408 # @ingroup l3_algos_proj
4410 class Mesh_Projection1D(Mesh_Algorithm):
4412 ## Private constructor.
4413 def __init__(self, mesh, geom=0):
4414 Mesh_Algorithm.__init__(self)
4415 self.Create(mesh, geom, "Projection_1D")
4417 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4418 # a mesh pattern is taken, and, optionally, the association of vertices
4419 # between the source edge and a target edge (to which a hypothesis is assigned)
4420 # @param edge from which nodes distribution is taken
4421 # @param mesh from which nodes distribution is taken (optional)
4422 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4423 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4424 # to associate with \a srcV (optional)
4425 # @param UseExisting if ==true - searches for the existing hypothesis created with
4426 # the same parameters, else (default) - creates a new one
4427 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4428 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4430 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4431 hyp.SetSourceEdge( edge )
4432 if not mesh is None and isinstance(mesh, Mesh):
4433 mesh = mesh.GetMesh()
4434 hyp.SetSourceMesh( mesh )
4435 hyp.SetVertexAssociation( srcV, tgtV )
4438 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4439 #def CompareSourceEdge(self, hyp, args):
4440 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4444 # Public class: Mesh_Projection2D
4445 # ------------------------------
4447 ## Defines a projection 2D algorithm
4448 # @ingroup l3_algos_proj
4450 class Mesh_Projection2D(Mesh_Algorithm):
4452 ## Private constructor.
4453 def __init__(self, mesh, geom=0):
4454 Mesh_Algorithm.__init__(self)
4455 self.Create(mesh, geom, "Projection_2D")
4457 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4458 # a mesh pattern is taken, and, optionally, the association of vertices
4459 # between the source face and the target face (to which a hypothesis is assigned)
4460 # @param face from which the mesh pattern is taken
4461 # @param mesh from which the mesh pattern is taken (optional)
4462 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4463 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4464 # to associate with \a srcV1 (optional)
4465 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4466 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4467 # to associate with \a srcV2 (optional)
4468 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4469 # the same parameters, else (default) - forces the creation a new one
4471 # Note: all association vertices must belong to one edge of a face
4472 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4473 srcV2=None, tgtV2=None, UseExisting=0):
4474 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4476 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4477 hyp.SetSourceFace( face )
4478 if not mesh is None and isinstance(mesh, Mesh):
4479 mesh = mesh.GetMesh()
4480 hyp.SetSourceMesh( mesh )
4481 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4484 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4485 #def CompareSourceFace(self, hyp, args):
4486 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4489 # Public class: Mesh_Projection3D
4490 # ------------------------------
4492 ## Defines a projection 3D algorithm
4493 # @ingroup l3_algos_proj
4495 class Mesh_Projection3D(Mesh_Algorithm):
4497 ## Private constructor.
4498 def __init__(self, mesh, geom=0):
4499 Mesh_Algorithm.__init__(self)
4500 self.Create(mesh, geom, "Projection_3D")
4502 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4503 # the mesh pattern is taken, and, optionally, the association of vertices
4504 # between the source and the target solid (to which a hipothesis is assigned)
4505 # @param solid from where the mesh pattern is taken
4506 # @param mesh from where the mesh pattern is taken (optional)
4507 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4508 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4509 # to associate with \a srcV1 (optional)
4510 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4511 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4512 # to associate with \a srcV2 (optional)
4513 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4514 # the same parameters, else (default) - creates a new one
4516 # Note: association vertices must belong to one edge of a solid
4517 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4518 srcV2=0, tgtV2=0, UseExisting=0):
4519 hyp = self.Hypothesis("ProjectionSource3D",
4520 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4522 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4523 hyp.SetSource3DShape( solid )
4524 if not mesh is None and isinstance(mesh, Mesh):
4525 mesh = mesh.GetMesh()
4526 hyp.SetSourceMesh( mesh )
4527 if srcV1 and srcV2 and tgtV1 and tgtV2:
4528 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4529 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4532 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4533 #def CompareSourceShape3D(self, hyp, args):
4534 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4538 # Public class: Mesh_Prism
4539 # ------------------------
4541 ## Defines a 3D extrusion algorithm
4542 # @ingroup l3_algos_3dextr
4544 class Mesh_Prism3D(Mesh_Algorithm):
4546 ## Private constructor.
4547 def __init__(self, mesh, geom=0):
4548 Mesh_Algorithm.__init__(self)
4549 self.Create(mesh, geom, "Prism_3D")
4551 # Public class: Mesh_RadialPrism
4552 # -------------------------------
4554 ## Defines a Radial Prism 3D algorithm
4555 # @ingroup l3_algos_radialp
4557 class Mesh_RadialPrism3D(Mesh_Algorithm):
4559 ## Private constructor.
4560 def __init__(self, mesh, geom=0):
4561 Mesh_Algorithm.__init__(self)
4562 self.Create(mesh, geom, "RadialPrism_3D")
4564 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4565 self.nbLayers = None
4567 ## Return 3D hypothesis holding the 1D one
4568 def Get3DHypothesis(self):
4569 return self.distribHyp
4571 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4572 # hypothesis. Returns the created hypothesis
4573 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4574 #print "OwnHypothesis",hypType
4575 if not self.nbLayers is None:
4576 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4577 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4578 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4579 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4580 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4581 self.distribHyp.SetLayerDistribution( hyp )
4584 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4585 # prisms to build between the inner and outer shells
4586 # @param n number of layers
4587 # @param UseExisting if ==true - searches for the existing hypothesis created with
4588 # the same parameters, else (default) - creates a new one
4589 def NumberOfLayers(self, n, UseExisting=0):
4590 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4591 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4592 CompareMethod=self.CompareNumberOfLayers)
4593 self.nbLayers.SetNumberOfLayers( n )
4594 return self.nbLayers
4596 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4597 def CompareNumberOfLayers(self, hyp, args):
4598 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4600 ## Defines "LocalLength" hypothesis, specifying the segment length
4601 # to build between the inner and the outer shells
4602 # @param l the length of segments
4603 # @param p the precision of rounding
4604 def LocalLength(self, l, p=1e-07):
4605 hyp = self.OwnHypothesis("LocalLength", [l,p])
4610 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4611 # prisms to build between the inner and the outer shells.
4612 # @param n the number of layers
4613 # @param s the scale factor (optional)
4614 def NumberOfSegments(self, n, s=[]):
4616 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4618 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4619 hyp.SetDistrType( 1 )
4620 hyp.SetScaleFactor(s)
4621 hyp.SetNumberOfSegments(n)
4624 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4625 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4626 # @param start the length of the first segment
4627 # @param end the length of the last segment
4628 def Arithmetic1D(self, start, end ):
4629 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4630 hyp.SetLength(start, 1)
4631 hyp.SetLength(end , 0)
4634 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4635 # to build between the inner and the outer shells as geometric length increasing
4636 # @param start for the length of the first segment
4637 # @param end for the length of the last segment
4638 def StartEndLength(self, start, end):
4639 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4640 hyp.SetLength(start, 1)
4641 hyp.SetLength(end , 0)
4644 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4645 # to build between the inner and outer shells
4646 # @param fineness defines the quality of the mesh within the range [0-1]
4647 def AutomaticLength(self, fineness=0):
4648 hyp = self.OwnHypothesis("AutomaticLength")
4649 hyp.SetFineness( fineness )
4652 # Private class: Mesh_UseExisting
4653 # -------------------------------
4654 class Mesh_UseExisting(Mesh_Algorithm):
4656 def __init__(self, dim, mesh, geom=0):
4658 self.Create(mesh, geom, "UseExisting_1D")
4660 self.Create(mesh, geom, "UseExisting_2D")
4663 import salome_notebook
4664 notebook = salome_notebook.notebook
4666 ##Return values of the notebook variables
4667 def ParseParameters(last, nbParams,nbParam, value):
4671 listSize = len(last)
4672 for n in range(0,nbParams):
4674 if counter < listSize:
4675 strResult = strResult + last[counter]
4677 strResult = strResult + ""
4679 if isinstance(value, str):
4680 if notebook.isVariable(value):
4681 result = notebook.get(value)
4682 strResult=strResult+value
4684 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
4686 strResult=strResult+str(value)
4688 if nbParams - 1 != counter:
4689 strResult=strResult+var_separator #":"
4691 return result, strResult
4693 #Wrapper class for StdMeshers_LocalLength hypothesis
4694 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
4696 ## Set Length parameter value
4697 # @param length numerical value or name of variable from notebook
4698 def SetLength(self, length):
4699 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
4700 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4701 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
4703 ## Set Precision parameter value
4704 # @param precision numerical value or name of variable from notebook
4705 def SetPrecision(self, precision):
4706 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
4707 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4708 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
4710 #Registering the new proxy for LocalLength
4711 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
4714 #Wrapper class for StdMeshers_LayerDistribution hypothesis
4715 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
4717 def SetLayerDistribution(self, hypo):
4718 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
4719 hypo.ClearParameters();
4720 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
4722 #Registering the new proxy for LayerDistribution
4723 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
4725 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
4726 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
4728 ## Set Length parameter value
4729 # @param length numerical value or name of variable from notebook
4730 def SetLength(self, length):
4731 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
4732 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
4733 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
4735 #Registering the new proxy for SegmentLengthAroundVertex
4736 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
4739 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
4740 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
4742 ## Set Length parameter value
4743 # @param length numerical value or name of variable from notebook
4744 # @param isStart true is length is Start Length, otherwise false
4745 def SetLength(self, length, isStart):
4749 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
4750 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
4751 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
4753 #Registering the new proxy for Arithmetic1D
4754 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
4756 #Wrapper class for StdMeshers_Deflection1D hypothesis
4757 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
4759 ## Set Deflection parameter value
4760 # @param deflection numerical value or name of variable from notebook
4761 def SetDeflection(self, deflection):
4762 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
4763 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
4764 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
4766 #Registering the new proxy for Deflection1D
4767 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
4769 #Wrapper class for StdMeshers_StartEndLength hypothesis
4770 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
4772 ## Set Length parameter value
4773 # @param length numerical value or name of variable from notebook
4774 # @param isStart true is length is Start Length, otherwise false
4775 def SetLength(self, length, isStart):
4779 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
4780 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
4781 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
4783 #Registering the new proxy for StartEndLength
4784 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
4786 #Wrapper class for StdMeshers_MaxElementArea hypothesis
4787 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
4789 ## Set Max Element Area parameter value
4790 # @param area numerical value or name of variable from notebook
4791 def SetMaxElementArea(self, area):
4792 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
4793 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
4794 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
4796 #Registering the new proxy for MaxElementArea
4797 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
4800 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
4801 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
4803 ## Set Max Element Volume parameter value
4804 # @param area numerical value or name of variable from notebook
4805 def SetMaxElementVolume(self, volume):
4806 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
4807 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
4808 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
4810 #Registering the new proxy for MaxElementVolume
4811 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
4814 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
4815 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
4817 ## Set Number Of Layers parameter value
4818 # @param nbLayers numerical value or name of variable from notebook
4819 def SetNumberOfLayers(self, nbLayers):
4820 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
4821 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
4822 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
4824 #Registering the new proxy for NumberOfLayers
4825 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
4827 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
4828 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
4830 ## Set Number Of Segments parameter value
4831 # @param nbSeg numerical value or name of variable from notebook
4832 def SetNumberOfSegments(self, nbSeg):
4833 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
4834 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
4835 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4836 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
4838 ## Set Scale Factor parameter value
4839 # @param factor numerical value or name of variable from notebook
4840 def SetScaleFactor(self, factor):
4841 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
4842 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4843 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
4845 #Registering the new proxy for NumberOfSegments
4846 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
4849 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
4850 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
4852 ## Set Max Size parameter value
4853 # @param maxsize numerical value or name of variable from notebook
4854 def SetMaxSize(self, maxsize):
4855 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4856 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
4857 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4858 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
4860 ## Set Growth Rate parameter value
4861 # @param value numerical value or name of variable from notebook
4862 def SetGrowthRate(self, value):
4863 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4864 value, parameters = ParseParameters(lastParameters,4,2,value)
4865 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4866 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
4868 ## Set Number of Segments per Edge parameter value
4869 # @param value numerical value or name of variable from notebook
4870 def SetNbSegPerEdge(self, value):
4871 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4872 value, parameters = ParseParameters(lastParameters,4,3,value)
4873 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4874 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
4876 ## Set Number of Segments per Radius parameter value
4877 # @param value numerical value or name of variable from notebook
4878 def SetNbSegPerRadius(self, value):
4879 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
4880 value, parameters = ParseParameters(lastParameters,4,4,value)
4881 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
4882 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
4884 #Registering the new proxy for NETGENPlugin_Hypothesis
4885 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
4888 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
4889 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
4892 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
4893 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
4895 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
4896 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
4898 ## Set Number of Segments parameter value
4899 # @param nbSeg numerical value or name of variable from notebook
4900 def SetNumberOfSegments(self, nbSeg):
4901 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4902 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
4903 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4904 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
4906 ## Set Local Length parameter value
4907 # @param length numerical value or name of variable from notebook
4908 def SetLocalLength(self, length):
4909 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4910 length, parameters = ParseParameters(lastParameters,2,1,length)
4911 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4912 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
4914 ## Set Max Element Area parameter value
4915 # @param area numerical value or name of variable from notebook
4916 def SetMaxElementArea(self, area):
4917 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4918 area, parameters = ParseParameters(lastParameters,2,2,area)
4919 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4920 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
4922 def LengthFromEdges(self):
4923 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
4925 value, parameters = ParseParameters(lastParameters,2,2,value)
4926 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
4927 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
4929 #Registering the new proxy for NETGEN_SimpleParameters_2D
4930 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
4933 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
4934 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
4935 ## Set Max Element Volume parameter value
4936 # @param volume numerical value or name of variable from notebook
4937 def SetMaxElementVolume(self, volume):
4938 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
4939 volume, parameters = ParseParameters(lastParameters,3,3,volume)
4940 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
4941 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
4943 def LengthFromFaces(self):
4944 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
4946 value, parameters = ParseParameters(lastParameters,3,3,value)
4947 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
4948 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
4950 #Registering the new proxy for NETGEN_SimpleParameters_3D
4951 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
4953 class Pattern(SMESH._objref_SMESH_Pattern):
4955 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
4957 if isinstance(theNodeIndexOnKeyPoint1,str):
4959 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
4961 theNodeIndexOnKeyPoint1 -= 1
4962 theMesh.SetParameters(Parameters)
4963 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
4965 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
4968 if isinstance(theNode000Index,str):
4970 if isinstance(theNode001Index,str):
4972 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
4974 theNode000Index -= 1
4976 theNode001Index -= 1
4977 theMesh.SetParameters(Parameters)
4978 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
4980 #Registering the new proxy for Pattern
4981 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)