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 if isinstance(obj,str):
425 return Mesh(self,self.geompyD,obj,name)
427 ## Returns a long value from enumeration
428 # Should be used for SMESH.FunctorType enumeration
429 # @ingroup l1_controls
430 def EnumToLong(self,theItem):
433 ## Gets PointStruct from vertex
434 # @param theVertex a GEOM object(vertex)
435 # @return SMESH.PointStruct
436 # @ingroup l1_auxiliary
437 def GetPointStruct(self,theVertex):
438 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
439 return PointStruct(x,y,z)
441 ## Gets DirStruct from vector
442 # @param theVector a GEOM object(vector)
443 # @return SMESH.DirStruct
444 # @ingroup l1_auxiliary
445 def GetDirStruct(self,theVector):
446 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
447 if(len(vertices) != 2):
448 print "Error: vector object is incorrect."
450 p1 = self.geompyD.PointCoordinates(vertices[0])
451 p2 = self.geompyD.PointCoordinates(vertices[1])
452 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
453 dirst = DirStruct(pnt)
456 ## Makes DirStruct from a triplet
457 # @param x,y,z vector components
458 # @return SMESH.DirStruct
459 # @ingroup l1_auxiliary
460 def MakeDirStruct(self,x,y,z):
461 pnt = PointStruct(x,y,z)
462 return DirStruct(pnt)
464 ## Get AxisStruct from object
465 # @param theObj a GEOM object (line or plane)
466 # @return SMESH.AxisStruct
467 # @ingroup l1_auxiliary
468 def GetAxisStruct(self,theObj):
469 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
471 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
472 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
473 vertex1 = self.geompyD.PointCoordinates(vertex1)
474 vertex2 = self.geompyD.PointCoordinates(vertex2)
475 vertex3 = self.geompyD.PointCoordinates(vertex3)
476 vertex4 = self.geompyD.PointCoordinates(vertex4)
477 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
478 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
479 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] ]
480 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
482 elif len(edges) == 1:
483 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
484 p1 = self.geompyD.PointCoordinates( vertex1 )
485 p2 = self.geompyD.PointCoordinates( vertex2 )
486 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
490 # From SMESH_Gen interface:
491 # ------------------------
493 ## Sets the given name to the object
494 # @param obj the object to rename
495 # @param name a new object name
496 # @ingroup l1_auxiliary
497 def SetName(self, obj, name):
498 if isinstance( obj, Mesh ):
500 elif isinstance( obj, Mesh_Algorithm ):
501 obj = obj.GetAlgorithm()
502 ior = salome.orb.object_to_string(obj)
503 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
505 ## Sets the current mode
506 # @ingroup l1_auxiliary
507 def SetEmbeddedMode( self,theMode ):
508 #self.SetEmbeddedMode(theMode)
509 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
511 ## Gets the current mode
512 # @ingroup l1_auxiliary
513 def IsEmbeddedMode(self):
514 #return self.IsEmbeddedMode()
515 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
517 ## Sets the current study
518 # @ingroup l1_auxiliary
519 def SetCurrentStudy( self, theStudy, geompyD = None ):
520 #self.SetCurrentStudy(theStudy)
523 geompyD = geompy.geom
526 self.SetGeomEngine(geompyD)
527 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
529 ## Gets the current study
530 # @ingroup l1_auxiliary
531 def GetCurrentStudy(self):
532 #return self.GetCurrentStudy()
533 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
535 ## Creates a Mesh object importing data from the given UNV file
536 # @return an instance of Mesh class
538 def CreateMeshesFromUNV( self,theFileName ):
539 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
540 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
543 ## Creates a Mesh object(s) importing data from the given MED file
544 # @return a list of Mesh class instances
546 def CreateMeshesFromMED( self,theFileName ):
547 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
549 for iMesh in range(len(aSmeshMeshes)) :
550 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
551 aMeshes.append(aMesh)
552 return aMeshes, aStatus
554 ## Creates a Mesh object importing data from the given STL file
555 # @return an instance of Mesh class
557 def CreateMeshesFromSTL( self, theFileName ):
558 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
559 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
562 ## From SMESH_Gen interface
563 # @return the list of integer values
564 # @ingroup l1_auxiliary
565 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
566 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
568 ## From SMESH_Gen interface. Creates a pattern
569 # @return an instance of SMESH_Pattern
571 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
572 # @ingroup l2_modif_patterns
573 def GetPattern(self):
574 return SMESH._objref_SMESH_Gen.GetPattern(self)
576 ## Sets number of segments per diagonal of boundary box of geometry by which
577 # default segment length of appropriate 1D hypotheses is defined.
578 # Default value is 10
579 # @ingroup l1_auxiliary
580 def SetBoundaryBoxSegmentation(self, nbSegments):
581 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
583 ## Concatenate the given meshes into one mesh.
584 # @return an instance of Mesh class
585 # @param meshes the meshes to combine into one mesh
586 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
587 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
588 # @param mergeTolerance tolerance for merging nodes
589 # @param allGroups forces creation of groups of all elements
590 def Concatenate( self, meshes, uniteIdenticalGroups,
591 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
592 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
594 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
595 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
597 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
598 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
599 aSmeshMesh.SetParameters(Parameters)
600 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
603 # Filtering. Auxiliary functions:
604 # ------------------------------
606 ## Creates an empty criterion
607 # @return SMESH.Filter.Criterion
608 # @ingroup l1_controls
609 def GetEmptyCriterion(self):
610 Type = self.EnumToLong(FT_Undefined)
611 Compare = self.EnumToLong(FT_Undefined)
615 UnaryOp = self.EnumToLong(FT_Undefined)
616 BinaryOp = self.EnumToLong(FT_Undefined)
619 Precision = -1 ##@1e-07
620 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
621 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
623 ## Creates a criterion by the given parameters
624 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
625 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
626 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
627 # @param Treshold the threshold value (range of ids as string, shape, numeric)
628 # @param UnaryOp FT_LogicalNOT or FT_Undefined
629 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
630 # FT_Undefined (must be for the last criterion of all criteria)
631 # @return SMESH.Filter.Criterion
632 # @ingroup l1_controls
633 def GetCriterion(self,elementType,
635 Compare = FT_EqualTo,
637 UnaryOp=FT_Undefined,
638 BinaryOp=FT_Undefined):
639 aCriterion = self.GetEmptyCriterion()
640 aCriterion.TypeOfElement = elementType
641 aCriterion.Type = self.EnumToLong(CritType)
645 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
646 aCriterion.Compare = self.EnumToLong(Compare)
647 elif Compare == "=" or Compare == "==":
648 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
650 aCriterion.Compare = self.EnumToLong(FT_LessThan)
652 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
654 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
657 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
658 FT_BelongToCylinder, FT_LyingOnGeom]:
659 # Checks the treshold
660 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
661 aCriterion.ThresholdStr = GetName(aTreshold)
662 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
664 print "Error: The treshold should be a shape."
666 elif CritType == FT_RangeOfIds:
667 # Checks the treshold
668 if isinstance(aTreshold, str):
669 aCriterion.ThresholdStr = aTreshold
671 print "Error: The treshold should be a string."
673 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
674 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
675 # At this point the treshold is unnecessary
676 if aTreshold == FT_LogicalNOT:
677 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
678 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
679 aCriterion.BinaryOp = aTreshold
683 aTreshold = float(aTreshold)
684 aCriterion.Threshold = aTreshold
686 print "Error: The treshold should be a number."
689 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
690 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
692 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
693 aCriterion.BinaryOp = self.EnumToLong(Treshold)
695 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
696 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
698 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
699 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
703 ## Creates a filter with the given parameters
704 # @param elementType the type of elements in the group
705 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
706 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
707 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
708 # @param UnaryOp FT_LogicalNOT or FT_Undefined
709 # @return SMESH_Filter
710 # @ingroup l1_controls
711 def GetFilter(self,elementType,
712 CritType=FT_Undefined,
715 UnaryOp=FT_Undefined):
716 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
717 aFilterMgr = self.CreateFilterManager()
718 aFilter = aFilterMgr.CreateFilter()
720 aCriteria.append(aCriterion)
721 aFilter.SetCriteria(aCriteria)
724 ## Creates a numerical functor by its type
725 # @param theCriterion FT_...; functor type
726 # @return SMESH_NumericalFunctor
727 # @ingroup l1_controls
728 def GetFunctor(self,theCriterion):
729 aFilterMgr = self.CreateFilterManager()
730 if theCriterion == FT_AspectRatio:
731 return aFilterMgr.CreateAspectRatio()
732 elif theCriterion == FT_AspectRatio3D:
733 return aFilterMgr.CreateAspectRatio3D()
734 elif theCriterion == FT_Warping:
735 return aFilterMgr.CreateWarping()
736 elif theCriterion == FT_MinimumAngle:
737 return aFilterMgr.CreateMinimumAngle()
738 elif theCriterion == FT_Taper:
739 return aFilterMgr.CreateTaper()
740 elif theCriterion == FT_Skew:
741 return aFilterMgr.CreateSkew()
742 elif theCriterion == FT_Area:
743 return aFilterMgr.CreateArea()
744 elif theCriterion == FT_Volume3D:
745 return aFilterMgr.CreateVolume3D()
746 elif theCriterion == FT_MultiConnection:
747 return aFilterMgr.CreateMultiConnection()
748 elif theCriterion == FT_MultiConnection2D:
749 return aFilterMgr.CreateMultiConnection2D()
750 elif theCriterion == FT_Length:
751 return aFilterMgr.CreateLength()
752 elif theCriterion == FT_Length2D:
753 return aFilterMgr.CreateLength2D()
755 print "Error: given parameter is not numerucal functor type."
757 ## Creates hypothesis
760 # @return created hypothesis instance
761 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
762 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
765 #Registering the new proxy for SMESH_Gen
766 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
772 ## This class allows defining and managing a mesh.
773 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
774 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
775 # new nodes and elements and by changing the existing entities), to get information
776 # about a mesh and to export a mesh into different formats.
785 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
786 # sets the GUI name of this mesh to \a name.
787 # @param smeshpyD an instance of smeshDC class
788 # @param geompyD an instance of geompyDC class
789 # @param obj Shape to be meshed or SMESH_Mesh object
790 # @param name Study name of the mesh
791 # @ingroup l2_construct
792 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
793 self.smeshpyD=smeshpyD
798 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
800 self.mesh = self.smeshpyD.CreateMesh(self.geom)
801 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
804 self.mesh = self.smeshpyD.CreateEmptyMesh()
806 self.smeshpyD.SetName(self.mesh, name)
808 self.smeshpyD.SetName(self.mesh, GetName(obj))
811 self.geom = self.mesh.GetShapeToMesh()
813 self.editor = self.mesh.GetMeshEditor()
815 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
816 # @param theMesh a SMESH_Mesh object
817 # @ingroup l2_construct
818 def SetMesh(self, theMesh):
820 self.geom = self.mesh.GetShapeToMesh()
822 ## Returns the mesh, that is an instance of SMESH_Mesh interface
823 # @return a SMESH_Mesh object
824 # @ingroup l2_construct
828 ## Gets the name of the mesh
829 # @return the name of the mesh as a string
830 # @ingroup l2_construct
832 name = GetName(self.GetMesh())
835 ## Sets a name to the mesh
836 # @param name a new name of the mesh
837 # @ingroup l2_construct
838 def SetName(self, name):
839 self.smeshpyD.SetName(self.GetMesh(), name)
841 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
842 # The subMesh object gives access to the IDs of nodes and elements.
843 # @param theSubObject a geometrical object (shape)
844 # @param theName a name for the submesh
845 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
846 # @ingroup l2_submeshes
847 def GetSubMesh(self, theSubObject, theName):
848 submesh = self.mesh.GetSubMesh(theSubObject, theName)
851 ## Returns the shape associated to the mesh
852 # @return a GEOM_Object
853 # @ingroup l2_construct
857 ## Associates the given shape to the mesh (entails the recreation of the mesh)
858 # @param geom the shape to be meshed (GEOM_Object)
859 # @ingroup l2_construct
860 def SetShape(self, geom):
861 self.mesh = self.smeshpyD.CreateMesh(geom)
863 ## Returns true if the hypotheses are defined well
864 # @param theSubObject a subshape of a mesh shape
865 # @return True or False
866 # @ingroup l2_construct
867 def IsReadyToCompute(self, theSubObject):
868 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
870 ## Returns errors of hypotheses definition.
871 # The list of errors is empty if everything is OK.
872 # @param theSubObject a subshape of a mesh shape
873 # @return a list of errors
874 # @ingroup l2_construct
875 def GetAlgoState(self, theSubObject):
876 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
878 ## Returns a geometrical object on which the given element was built.
879 # The returned geometrical object, if not nil, is either found in the
880 # study or published by this method with the given name
881 # @param theElementID the id of the mesh element
882 # @param theGeomName the user-defined name of the geometrical object
883 # @return GEOM::GEOM_Object instance
884 # @ingroup l2_construct
885 def GetGeometryByMeshElement(self, theElementID, theGeomName):
886 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
888 ## Returns the mesh dimension depending on the dimension of the underlying shape
889 # @return mesh dimension as an integer value [0,3]
890 # @ingroup l1_auxiliary
891 def MeshDimension(self):
892 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
893 if len( shells ) > 0 :
895 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
897 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
903 ## Creates a segment discretization 1D algorithm.
904 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
905 # \n If the optional \a geom parameter is not set, this algorithm is global.
906 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
907 # @param algo the type of the required algorithm. Possible values are:
909 # - smesh.PYTHON for discretization via a python function,
910 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
911 # @param geom If defined is the subshape to be meshed
912 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
913 # @ingroup l3_algos_basic
914 def Segment(self, algo=REGULAR, geom=0):
915 ## if Segment(geom) is called by mistake
916 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
917 algo, geom = geom, algo
918 if not algo: algo = REGULAR
921 return Mesh_Segment(self, geom)
923 return Mesh_Segment_Python(self, geom)
924 elif algo == COMPOSITE:
925 return Mesh_CompositeSegment(self, geom)
927 return Mesh_Segment(self, geom)
929 ## Enables creation of nodes and segments usable by 2D algoritms.
930 # The added nodes and segments must be bound to edges and vertices by
931 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
932 # If the optional \a geom parameter is not set, this algorithm is global.
933 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
934 # @param geom the subshape to be manually meshed
935 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
936 # @ingroup l3_algos_basic
937 def UseExistingSegments(self, geom=0):
938 algo = Mesh_UseExisting(1,self,geom)
939 return algo.GetAlgorithm()
941 ## Enables creation of nodes and faces usable by 3D algoritms.
942 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
943 # and SetMeshElementOnShape()
944 # If the optional \a geom parameter is not set, this algorithm is global.
945 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
946 # @param geom the subshape to be manually meshed
947 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
948 # @ingroup l3_algos_basic
949 def UseExistingFaces(self, geom=0):
950 algo = Mesh_UseExisting(2,self,geom)
951 return algo.GetAlgorithm()
953 ## Creates a triangle 2D algorithm for faces.
954 # If the optional \a geom parameter is not set, this algorithm is global.
955 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
956 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
957 # @param geom If defined, the subshape to be meshed (GEOM_Object)
958 # @return an instance of Mesh_Triangle algorithm
959 # @ingroup l3_algos_basic
960 def Triangle(self, algo=MEFISTO, geom=0):
961 ## if Triangle(geom) is called by mistake
962 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
966 return Mesh_Triangle(self, algo, geom)
968 ## Creates a quadrangle 2D algorithm for faces.
969 # If the optional \a geom parameter is not set, this algorithm is global.
970 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
971 # @param geom If defined, the subshape to be meshed (GEOM_Object)
972 # @return an instance of Mesh_Quadrangle algorithm
973 # @ingroup l3_algos_basic
974 def Quadrangle(self, geom=0):
975 return Mesh_Quadrangle(self, geom)
977 ## Creates a tetrahedron 3D algorithm for solids.
978 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
979 # If the optional \a geom parameter is not set, this algorithm is global.
980 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
981 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
982 # @param geom If defined, the subshape to be meshed (GEOM_Object)
983 # @return an instance of Mesh_Tetrahedron algorithm
984 # @ingroup l3_algos_basic
985 def Tetrahedron(self, algo=NETGEN, geom=0):
986 ## if Tetrahedron(geom) is called by mistake
987 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
988 algo, geom = geom, algo
989 if not algo: algo = NETGEN
991 return Mesh_Tetrahedron(self, algo, geom)
993 ## Creates a hexahedron 3D algorithm for solids.
994 # If the optional \a geom parameter is not set, this algorithm is global.
995 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
996 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
997 # @param geom If defined, the subshape to be meshed (GEOM_Object)
998 # @return an instance of Mesh_Hexahedron algorithm
999 # @ingroup l3_algos_basic
1000 def Hexahedron(self, algo=Hexa, geom=0):
1001 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1002 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1003 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1004 elif geom == 0: algo, geom = Hexa, algo
1005 return Mesh_Hexahedron(self, algo, geom)
1007 ## Deprecated, used only for compatibility!
1008 # @return an instance of Mesh_Netgen algorithm
1009 # @ingroup l3_algos_basic
1010 def Netgen(self, is3D, geom=0):
1011 return Mesh_Netgen(self, is3D, geom)
1013 ## Creates a projection 1D algorithm for edges.
1014 # If the optional \a geom parameter is not set, this algorithm is global.
1015 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1016 # @param geom If defined, the subshape to be meshed
1017 # @return an instance of Mesh_Projection1D algorithm
1018 # @ingroup l3_algos_proj
1019 def Projection1D(self, geom=0):
1020 return Mesh_Projection1D(self, geom)
1022 ## Creates a projection 2D algorithm for faces.
1023 # If the optional \a geom parameter is not set, this algorithm is global.
1024 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1025 # @param geom If defined, the subshape to be meshed
1026 # @return an instance of Mesh_Projection2D algorithm
1027 # @ingroup l3_algos_proj
1028 def Projection2D(self, geom=0):
1029 return Mesh_Projection2D(self, geom)
1031 ## Creates a projection 3D algorithm for solids.
1032 # If the optional \a geom parameter is not set, this algorithm is global.
1033 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1034 # @param geom If defined, the subshape to be meshed
1035 # @return an instance of Mesh_Projection3D algorithm
1036 # @ingroup l3_algos_proj
1037 def Projection3D(self, geom=0):
1038 return Mesh_Projection3D(self, geom)
1040 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1041 # If the optional \a geom parameter is not set, this algorithm is global.
1042 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1043 # @param geom If defined, the subshape to be meshed
1044 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1045 # @ingroup l3_algos_radialp l3_algos_3dextr
1046 def Prism(self, geom=0):
1050 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1051 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1052 if nbSolids == 0 or nbSolids == nbShells:
1053 return Mesh_Prism3D(self, geom)
1054 return Mesh_RadialPrism3D(self, geom)
1056 ## Evaluates size of prospective mesh on a shape
1057 # @return True or False
1058 def Evaluate(self, geom=0):
1059 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1061 geom = self.mesh.GetShapeToMesh()
1064 return self.smeshpyD.Evaluate(self.mesh, geom)
1067 ## Computes the mesh and returns the status of the computation
1068 # @return True or False
1069 # @ingroup l2_construct
1070 def Compute(self, geom=0):
1071 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1073 geom = self.mesh.GetShapeToMesh()
1078 ok = self.smeshpyD.Compute(self.mesh, geom)
1079 except SALOME.SALOME_Exception, ex:
1080 print "Mesh computation failed, exception caught:"
1081 print " ", ex.details.text
1084 print "Mesh computation failed, exception caught:"
1085 traceback.print_exc()
1087 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1090 if err.isGlobalAlgo:
1098 reason = '%s %sD algorithm is missing' % (glob, dim)
1099 elif err.state == HYP_MISSING:
1100 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1101 % (glob, dim, name, dim))
1102 elif err.state == HYP_NOTCONFORM:
1103 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1104 elif err.state == HYP_BAD_PARAMETER:
1105 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1106 % ( glob, dim, name ))
1107 elif err.state == HYP_BAD_GEOMETRY:
1108 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1109 'geometry' % ( glob, dim, name ))
1111 reason = "For unknown reason."+\
1112 " Revise Mesh.Compute() implementation in smeshDC.py!"
1114 if allReasons != "":
1117 allReasons += reason
1119 if allReasons != "":
1120 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1124 print '"' + GetName(self.mesh) + '"',"has not been computed."
1127 if salome.sg.hasDesktop():
1128 smeshgui = salome.ImportComponentGUI("SMESH")
1129 smeshgui.Init(self.mesh.GetStudyId())
1130 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1131 salome.sg.updateObjBrowser(1)
1135 ## Removes all nodes and elements
1136 # @ingroup l2_construct
1139 if salome.sg.hasDesktop():
1140 smeshgui = salome.ImportComponentGUI("SMESH")
1141 smeshgui.Init(self.mesh.GetStudyId())
1142 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1143 salome.sg.updateObjBrowser(1)
1145 ## Removes all nodes and elements of indicated shape
1146 # @ingroup l2_construct
1147 def ClearSubMesh(self, geomId):
1148 self.mesh.ClearSubMesh(geomId)
1149 if salome.sg.hasDesktop():
1150 smeshgui = salome.ImportComponentGUI("SMESH")
1151 smeshgui.Init(self.mesh.GetStudyId())
1152 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1153 salome.sg.updateObjBrowser(1)
1155 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1156 # @param fineness [0,-1] defines mesh fineness
1157 # @return True or False
1158 # @ingroup l3_algos_basic
1159 def AutomaticTetrahedralization(self, fineness=0):
1160 dim = self.MeshDimension()
1162 self.RemoveGlobalHypotheses()
1163 self.Segment().AutomaticLength(fineness)
1165 self.Triangle().LengthFromEdges()
1168 self.Tetrahedron(NETGEN)
1170 return self.Compute()
1172 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1173 # @param fineness [0,-1] defines mesh fineness
1174 # @return True or False
1175 # @ingroup l3_algos_basic
1176 def AutomaticHexahedralization(self, fineness=0):
1177 dim = self.MeshDimension()
1178 # assign the hypotheses
1179 self.RemoveGlobalHypotheses()
1180 self.Segment().AutomaticLength(fineness)
1187 return self.Compute()
1189 ## Assigns a hypothesis
1190 # @param hyp a hypothesis to assign
1191 # @param geom a subhape of mesh geometry
1192 # @return SMESH.Hypothesis_Status
1193 # @ingroup l2_hypotheses
1194 def AddHypothesis(self, hyp, geom=0):
1195 if isinstance( hyp, Mesh_Algorithm ):
1196 hyp = hyp.GetAlgorithm()
1201 geom = self.mesh.GetShapeToMesh()
1203 status = self.mesh.AddHypothesis(geom, hyp)
1204 isAlgo = hyp._narrow( SMESH_Algo )
1205 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1208 ## Unassigns a hypothesis
1209 # @param hyp a hypothesis to unassign
1210 # @param geom a subshape of mesh geometry
1211 # @return SMESH.Hypothesis_Status
1212 # @ingroup l2_hypotheses
1213 def RemoveHypothesis(self, hyp, geom=0):
1214 if isinstance( hyp, Mesh_Algorithm ):
1215 hyp = hyp.GetAlgorithm()
1220 status = self.mesh.RemoveHypothesis(geom, hyp)
1223 ## Gets the list of hypotheses added on a geometry
1224 # @param geom a subshape of mesh geometry
1225 # @return the sequence of SMESH_Hypothesis
1226 # @ingroup l2_hypotheses
1227 def GetHypothesisList(self, geom):
1228 return self.mesh.GetHypothesisList( geom )
1230 ## Removes all global hypotheses
1231 # @ingroup l2_hypotheses
1232 def RemoveGlobalHypotheses(self):
1233 current_hyps = self.mesh.GetHypothesisList( self.geom )
1234 for hyp in current_hyps:
1235 self.mesh.RemoveHypothesis( self.geom, hyp )
1239 ## Creates a mesh group based on the geometric object \a grp
1240 # and gives a \a name, \n if this parameter is not defined
1241 # the name is the same as the geometric group name \n
1242 # Note: Works like GroupOnGeom().
1243 # @param grp a geometric group, a vertex, an edge, a face or a solid
1244 # @param name the name of the mesh group
1245 # @return SMESH_GroupOnGeom
1246 # @ingroup l2_grps_create
1247 def Group(self, grp, name=""):
1248 return self.GroupOnGeom(grp, name)
1250 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1251 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1252 # @param f the file name
1253 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1254 # @ingroup l2_impexp
1255 def ExportToMED(self, f, version, opt=0):
1256 self.mesh.ExportToMED(f, opt, version)
1258 ## Exports the mesh in a file in MED format
1259 # @param f is the file name
1260 # @param auto_groups boolean parameter for creating/not creating
1261 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1262 # the typical use is auto_groups=false.
1263 # @param version MED format version(MED_V2_1 or MED_V2_2)
1264 # @ingroup l2_impexp
1265 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1266 self.mesh.ExportToMED(f, auto_groups, version)
1268 ## Exports the mesh in a file in DAT format
1269 # @param f the file name
1270 # @ingroup l2_impexp
1271 def ExportDAT(self, f):
1272 self.mesh.ExportDAT(f)
1274 ## Exports the mesh in a file in UNV format
1275 # @param f the file name
1276 # @ingroup l2_impexp
1277 def ExportUNV(self, f):
1278 self.mesh.ExportUNV(f)
1280 ## Export the mesh in a file in STL format
1281 # @param f the file name
1282 # @param ascii defines the file encoding
1283 # @ingroup l2_impexp
1284 def ExportSTL(self, f, ascii=1):
1285 self.mesh.ExportSTL(f, ascii)
1288 # Operations with groups:
1289 # ----------------------
1291 ## Creates an empty mesh group
1292 # @param elementType the type of elements in the group
1293 # @param name the name of the mesh group
1294 # @return SMESH_Group
1295 # @ingroup l2_grps_create
1296 def CreateEmptyGroup(self, elementType, name):
1297 return self.mesh.CreateGroup(elementType, name)
1299 ## Creates a mesh group based on the geometrical object \a grp
1300 # and gives a \a name, \n if this parameter is not defined
1301 # the name is the same as the geometrical group name
1302 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1303 # @param name the name of the mesh group
1304 # @param typ the type of elements in the group. If not set, it is
1305 # automatically detected by the type of the geometry
1306 # @return SMESH_GroupOnGeom
1307 # @ingroup l2_grps_create
1308 def GroupOnGeom(self, grp, name="", typ=None):
1310 name = grp.GetName()
1313 tgeo = str(grp.GetShapeType())
1314 if tgeo == "VERTEX":
1316 elif tgeo == "EDGE":
1318 elif tgeo == "FACE":
1320 elif tgeo == "SOLID":
1322 elif tgeo == "SHELL":
1324 elif tgeo == "COMPOUND":
1325 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1326 print "Mesh.Group: empty geometric group", GetName( grp )
1328 tgeo = self.geompyD.GetType(grp)
1329 if tgeo == geompyDC.ShapeType["VERTEX"]:
1331 elif tgeo == geompyDC.ShapeType["EDGE"]:
1333 elif tgeo == geompyDC.ShapeType["FACE"]:
1335 elif tgeo == geompyDC.ShapeType["SOLID"]:
1339 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1342 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1344 ## Creates a mesh group by the given ids of elements
1345 # @param groupName the name of the mesh group
1346 # @param elementType the type of elements in the group
1347 # @param elemIDs the list of ids
1348 # @return SMESH_Group
1349 # @ingroup l2_grps_create
1350 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1351 group = self.mesh.CreateGroup(elementType, groupName)
1355 ## Creates a mesh group by the given conditions
1356 # @param groupName the name of the mesh group
1357 # @param elementType the type of elements in the group
1358 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1359 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1360 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1361 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1362 # @return SMESH_Group
1363 # @ingroup l2_grps_create
1367 CritType=FT_Undefined,
1370 UnaryOp=FT_Undefined):
1371 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1372 group = self.MakeGroupByCriterion(groupName, aCriterion)
1375 ## Creates a mesh group by the given criterion
1376 # @param groupName the name of the mesh group
1377 # @param Criterion the instance of Criterion class
1378 # @return SMESH_Group
1379 # @ingroup l2_grps_create
1380 def MakeGroupByCriterion(self, groupName, Criterion):
1381 aFilterMgr = self.smeshpyD.CreateFilterManager()
1382 aFilter = aFilterMgr.CreateFilter()
1384 aCriteria.append(Criterion)
1385 aFilter.SetCriteria(aCriteria)
1386 group = self.MakeGroupByFilter(groupName, aFilter)
1389 ## Creates a mesh group by the given criteria (list of criteria)
1390 # @param groupName the name of the mesh group
1391 # @param theCriteria the list of criteria
1392 # @return SMESH_Group
1393 # @ingroup l2_grps_create
1394 def MakeGroupByCriteria(self, groupName, theCriteria):
1395 aFilterMgr = self.smeshpyD.CreateFilterManager()
1396 aFilter = aFilterMgr.CreateFilter()
1397 aFilter.SetCriteria(theCriteria)
1398 group = self.MakeGroupByFilter(groupName, aFilter)
1401 ## Creates a mesh group by the given filter
1402 # @param groupName the name of the mesh group
1403 # @param theFilter the instance of Filter class
1404 # @return SMESH_Group
1405 # @ingroup l2_grps_create
1406 def MakeGroupByFilter(self, groupName, theFilter):
1407 anIds = theFilter.GetElementsId(self.mesh)
1408 anElemType = theFilter.GetElementType()
1409 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1412 ## Passes mesh elements through the given filter and return IDs of fitting elements
1413 # @param theFilter SMESH_Filter
1414 # @return a list of ids
1415 # @ingroup l1_controls
1416 def GetIdsFromFilter(self, theFilter):
1417 return theFilter.GetElementsId(self.mesh)
1419 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1420 # Returns a list of special structures (borders).
1421 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1422 # @ingroup l1_controls
1423 def GetFreeBorders(self):
1424 aFilterMgr = self.smeshpyD.CreateFilterManager()
1425 aPredicate = aFilterMgr.CreateFreeEdges()
1426 aPredicate.SetMesh(self.mesh)
1427 aBorders = aPredicate.GetBorders()
1431 # @ingroup l2_grps_delete
1432 def RemoveGroup(self, group):
1433 self.mesh.RemoveGroup(group)
1435 ## Removes a group with its contents
1436 # @ingroup l2_grps_delete
1437 def RemoveGroupWithContents(self, group):
1438 self.mesh.RemoveGroupWithContents(group)
1440 ## Gets the list of groups existing in the mesh
1441 # @return a sequence of SMESH_GroupBase
1442 # @ingroup l2_grps_create
1443 def GetGroups(self):
1444 return self.mesh.GetGroups()
1446 ## Gets the number of groups existing in the mesh
1447 # @return the quantity of groups as an integer value
1448 # @ingroup l2_grps_create
1450 return self.mesh.NbGroups()
1452 ## Gets the list of names of groups existing in the mesh
1453 # @return list of strings
1454 # @ingroup l2_grps_create
1455 def GetGroupNames(self):
1456 groups = self.GetGroups()
1458 for group in groups:
1459 names.append(group.GetName())
1462 ## Produces a union of two groups
1463 # A new group is created. All mesh elements that are
1464 # present in the initial groups are added to the new one
1465 # @return an instance of SMESH_Group
1466 # @ingroup l2_grps_operon
1467 def UnionGroups(self, group1, group2, name):
1468 return self.mesh.UnionGroups(group1, group2, name)
1470 ## Produces a union list of groups
1471 # New group is created. All mesh elements that are present in
1472 # initial groups are added to the new one
1473 # @return an instance of SMESH_Group
1474 # @ingroup l2_grps_operon
1475 def UnionListOfGroups(self, groups, name):
1476 return self.mesh.UnionListOfGroups(groups, name)
1478 ## Prodices an intersection of two groups
1479 # A new group is created. All mesh elements that are common
1480 # for the two initial groups are added to the new one.
1481 # @return an instance of SMESH_Group
1482 # @ingroup l2_grps_operon
1483 def IntersectGroups(self, group1, group2, name):
1484 return self.mesh.IntersectGroups(group1, group2, name)
1486 ## Produces an intersection of groups
1487 # New group is created. All mesh elements that are present in all
1488 # initial groups simultaneously are added to the new one
1489 # @return an instance of SMESH_Group
1490 # @ingroup l2_grps_operon
1491 def IntersectListOfGroups(self, groups, name):
1492 return self.mesh.IntersectListOfGroups(groups, name)
1494 ## Produces a cut of two groups
1495 # A new group is created. All mesh elements that are present in
1496 # the main group but are not present in the tool group are added to the new one
1497 # @return an instance of SMESH_Group
1498 # @ingroup l2_grps_operon
1499 def CutGroups(self, main_group, tool_group, name):
1500 return self.mesh.CutGroups(main_group, tool_group, name)
1502 ## Produces a cut of groups
1503 # A new group is created. All mesh elements that are present in main groups
1504 # but do not present in tool groups are added to the new one
1505 # @return an instance of SMESH_Group
1506 # @ingroup l2_grps_operon
1507 def CutListOfGroups(self, main_groups, tool_groups, name):
1508 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1510 ## Produces a group of elements with specified element type using list of existing groups
1511 # A new group is created. System
1512 # 1) extract all nodes on which groups elements are built
1513 # 2) combine all elements of specified dimension laying on these nodes
1514 # @return an instance of SMESH_Group
1515 # @ingroup l2_grps_operon
1516 def CreateDimGroup(self, groups, elem_type, name):
1517 return self.mesh.CreateDimGroup(groups, elem_type, name)
1520 ## Convert group on geom into standalone group
1521 # @ingroup l2_grps_delete
1522 def ConvertToStandalone(self, group):
1523 return self.mesh.ConvertToStandalone(group)
1525 # Get some info about mesh:
1526 # ------------------------
1528 ## Returns the log of nodes and elements added or removed
1529 # since the previous clear of the log.
1530 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1531 # @return list of log_block structures:
1536 # @ingroup l1_auxiliary
1537 def GetLog(self, clearAfterGet):
1538 return self.mesh.GetLog(clearAfterGet)
1540 ## Clears the log of nodes and elements added or removed since the previous
1541 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1542 # @ingroup l1_auxiliary
1544 self.mesh.ClearLog()
1546 ## Toggles auto color mode on the object.
1547 # @param theAutoColor the flag which toggles auto color mode.
1548 # @ingroup l1_auxiliary
1549 def SetAutoColor(self, theAutoColor):
1550 self.mesh.SetAutoColor(theAutoColor)
1552 ## Gets flag of object auto color mode.
1553 # @return True or False
1554 # @ingroup l1_auxiliary
1555 def GetAutoColor(self):
1556 return self.mesh.GetAutoColor()
1558 ## Gets the internal ID
1559 # @return integer value, which is the internal Id of the mesh
1560 # @ingroup l1_auxiliary
1562 return self.mesh.GetId()
1565 # @return integer value, which is the study Id of the mesh
1566 # @ingroup l1_auxiliary
1567 def GetStudyId(self):
1568 return self.mesh.GetStudyId()
1570 ## Checks the group names for duplications.
1571 # Consider the maximum group name length stored in MED file.
1572 # @return True or False
1573 # @ingroup l1_auxiliary
1574 def HasDuplicatedGroupNamesMED(self):
1575 return self.mesh.HasDuplicatedGroupNamesMED()
1577 ## Obtains the mesh editor tool
1578 # @return an instance of SMESH_MeshEditor
1579 # @ingroup l1_modifying
1580 def GetMeshEditor(self):
1581 return self.mesh.GetMeshEditor()
1584 # @return an instance of SALOME_MED::MESH
1585 # @ingroup l1_auxiliary
1586 def GetMEDMesh(self):
1587 return self.mesh.GetMEDMesh()
1590 # Get informations about mesh contents:
1591 # ------------------------------------
1593 ## Gets the mesh stattistic
1594 # @return dictionary type element - count of elements
1595 # @ingroup l1_meshinfo
1596 def GetMeshInfo(self, obj = None):
1597 if not obj: obj = self.mesh
1599 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
1600 values = obj.GetMeshInfo()
1601 for i in range(SMESH.Entity_Last._v):
1602 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
1606 ## Returns the number of nodes in the mesh
1607 # @return an integer value
1608 # @ingroup l1_meshinfo
1610 return self.mesh.NbNodes()
1612 ## Returns the number of elements in the mesh
1613 # @return an integer value
1614 # @ingroup l1_meshinfo
1615 def NbElements(self):
1616 return self.mesh.NbElements()
1618 ## Returns the number of 0d elements in the mesh
1619 # @return an integer value
1620 # @ingroup l1_meshinfo
1621 def Nb0DElements(self):
1622 return self.mesh.Nb0DElements()
1624 ## Returns the number of edges in the mesh
1625 # @return an integer value
1626 # @ingroup l1_meshinfo
1628 return self.mesh.NbEdges()
1630 ## Returns the number of edges with the given order in the mesh
1631 # @param elementOrder the order of elements:
1632 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1633 # @return an integer value
1634 # @ingroup l1_meshinfo
1635 def NbEdgesOfOrder(self, elementOrder):
1636 return self.mesh.NbEdgesOfOrder(elementOrder)
1638 ## Returns the number of faces in the mesh
1639 # @return an integer value
1640 # @ingroup l1_meshinfo
1642 return self.mesh.NbFaces()
1644 ## Returns the number of faces with the given order in the mesh
1645 # @param elementOrder the order of elements:
1646 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1647 # @return an integer value
1648 # @ingroup l1_meshinfo
1649 def NbFacesOfOrder(self, elementOrder):
1650 return self.mesh.NbFacesOfOrder(elementOrder)
1652 ## Returns the number of triangles in the mesh
1653 # @return an integer value
1654 # @ingroup l1_meshinfo
1655 def NbTriangles(self):
1656 return self.mesh.NbTriangles()
1658 ## Returns the number of triangles with the given order in the mesh
1659 # @param elementOrder is the order of elements:
1660 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1661 # @return an integer value
1662 # @ingroup l1_meshinfo
1663 def NbTrianglesOfOrder(self, elementOrder):
1664 return self.mesh.NbTrianglesOfOrder(elementOrder)
1666 ## Returns the number of quadrangles in the mesh
1667 # @return an integer value
1668 # @ingroup l1_meshinfo
1669 def NbQuadrangles(self):
1670 return self.mesh.NbQuadrangles()
1672 ## Returns the number of quadrangles with the given order in the mesh
1673 # @param elementOrder the order of elements:
1674 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1675 # @return an integer value
1676 # @ingroup l1_meshinfo
1677 def NbQuadranglesOfOrder(self, elementOrder):
1678 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1680 ## Returns the number of polygons in the mesh
1681 # @return an integer value
1682 # @ingroup l1_meshinfo
1683 def NbPolygons(self):
1684 return self.mesh.NbPolygons()
1686 ## Returns the number of volumes in the mesh
1687 # @return an integer value
1688 # @ingroup l1_meshinfo
1689 def NbVolumes(self):
1690 return self.mesh.NbVolumes()
1692 ## Returns the number of volumes with the given order in the mesh
1693 # @param elementOrder the order of elements:
1694 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1695 # @return an integer value
1696 # @ingroup l1_meshinfo
1697 def NbVolumesOfOrder(self, elementOrder):
1698 return self.mesh.NbVolumesOfOrder(elementOrder)
1700 ## Returns the number of tetrahedrons in the mesh
1701 # @return an integer value
1702 # @ingroup l1_meshinfo
1704 return self.mesh.NbTetras()
1706 ## Returns the number of tetrahedrons with the given order in the mesh
1707 # @param elementOrder the order of elements:
1708 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1709 # @return an integer value
1710 # @ingroup l1_meshinfo
1711 def NbTetrasOfOrder(self, elementOrder):
1712 return self.mesh.NbTetrasOfOrder(elementOrder)
1714 ## Returns the number of hexahedrons in the mesh
1715 # @return an integer value
1716 # @ingroup l1_meshinfo
1718 return self.mesh.NbHexas()
1720 ## Returns the number of hexahedrons with the given order in the mesh
1721 # @param elementOrder the order of elements:
1722 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1723 # @return an integer value
1724 # @ingroup l1_meshinfo
1725 def NbHexasOfOrder(self, elementOrder):
1726 return self.mesh.NbHexasOfOrder(elementOrder)
1728 ## Returns the number of pyramids in the mesh
1729 # @return an integer value
1730 # @ingroup l1_meshinfo
1731 def NbPyramids(self):
1732 return self.mesh.NbPyramids()
1734 ## Returns the number of pyramids with the given order in the mesh
1735 # @param elementOrder the order of elements:
1736 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1737 # @return an integer value
1738 # @ingroup l1_meshinfo
1739 def NbPyramidsOfOrder(self, elementOrder):
1740 return self.mesh.NbPyramidsOfOrder(elementOrder)
1742 ## Returns the number of prisms in the mesh
1743 # @return an integer value
1744 # @ingroup l1_meshinfo
1746 return self.mesh.NbPrisms()
1748 ## Returns the number of prisms with the given order in the mesh
1749 # @param elementOrder the order of elements:
1750 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1751 # @return an integer value
1752 # @ingroup l1_meshinfo
1753 def NbPrismsOfOrder(self, elementOrder):
1754 return self.mesh.NbPrismsOfOrder(elementOrder)
1756 ## Returns the number of polyhedrons in the mesh
1757 # @return an integer value
1758 # @ingroup l1_meshinfo
1759 def NbPolyhedrons(self):
1760 return self.mesh.NbPolyhedrons()
1762 ## Returns the number of submeshes in the mesh
1763 # @return an integer value
1764 # @ingroup l1_meshinfo
1765 def NbSubMesh(self):
1766 return self.mesh.NbSubMesh()
1768 ## Returns the list of mesh elements IDs
1769 # @return the list of integer values
1770 # @ingroup l1_meshinfo
1771 def GetElementsId(self):
1772 return self.mesh.GetElementsId()
1774 ## Returns the list of IDs of mesh elements with the given type
1775 # @param elementType the required type of elements
1776 # @return list of integer values
1777 # @ingroup l1_meshinfo
1778 def GetElementsByType(self, elementType):
1779 return self.mesh.GetElementsByType(elementType)
1781 ## Returns the list of mesh nodes IDs
1782 # @return the list of integer values
1783 # @ingroup l1_meshinfo
1784 def GetNodesId(self):
1785 return self.mesh.GetNodesId()
1787 # Get the information about mesh elements:
1788 # ------------------------------------
1790 ## Returns the type of mesh element
1791 # @return the value from SMESH::ElementType enumeration
1792 # @ingroup l1_meshinfo
1793 def GetElementType(self, id, iselem):
1794 return self.mesh.GetElementType(id, iselem)
1796 ## Returns the list of submesh elements IDs
1797 # @param Shape a geom object(subshape) IOR
1798 # Shape must be the subshape of a ShapeToMesh()
1799 # @return the list of integer values
1800 # @ingroup l1_meshinfo
1801 def GetSubMeshElementsId(self, Shape):
1802 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1803 ShapeID = Shape.GetSubShapeIndices()[0]
1806 return self.mesh.GetSubMeshElementsId(ShapeID)
1808 ## Returns the list of submesh nodes IDs
1809 # @param Shape a geom object(subshape) IOR
1810 # Shape must be the subshape of a ShapeToMesh()
1811 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1812 # @return the list of integer values
1813 # @ingroup l1_meshinfo
1814 def GetSubMeshNodesId(self, Shape, all):
1815 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1816 ShapeID = Shape.GetSubShapeIndices()[0]
1819 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1821 ## Returns type of elements on given shape
1822 # @param Shape a geom object(subshape) IOR
1823 # Shape must be a subshape of a ShapeToMesh()
1824 # @return element type
1825 # @ingroup l1_meshinfo
1826 def GetSubMeshElementType(self, Shape):
1827 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1828 ShapeID = Shape.GetSubShapeIndices()[0]
1831 return self.mesh.GetSubMeshElementType(ShapeID)
1833 ## Gets the mesh description
1834 # @return string value
1835 # @ingroup l1_meshinfo
1837 return self.mesh.Dump()
1840 # Get the information about nodes and elements of a mesh by its IDs:
1841 # -----------------------------------------------------------
1843 ## Gets XYZ coordinates of a node
1844 # \n If there is no nodes for the given ID - returns an empty list
1845 # @return a list of double precision values
1846 # @ingroup l1_meshinfo
1847 def GetNodeXYZ(self, id):
1848 return self.mesh.GetNodeXYZ(id)
1850 ## Returns list of IDs of inverse elements for the given node
1851 # \n If there is no node for the given ID - returns an empty list
1852 # @return a list of integer values
1853 # @ingroup l1_meshinfo
1854 def GetNodeInverseElements(self, id):
1855 return self.mesh.GetNodeInverseElements(id)
1857 ## @brief Returns the position of a node on the shape
1858 # @return SMESH::NodePosition
1859 # @ingroup l1_meshinfo
1860 def GetNodePosition(self,NodeID):
1861 return self.mesh.GetNodePosition(NodeID)
1863 ## If the given element is a node, returns the ID of shape
1864 # \n If there is no node for the given ID - returns -1
1865 # @return an integer value
1866 # @ingroup l1_meshinfo
1867 def GetShapeID(self, id):
1868 return self.mesh.GetShapeID(id)
1870 ## Returns the ID of the result shape after
1871 # FindShape() from SMESH_MeshEditor for the given element
1872 # \n If there is no element for the given ID - returns -1
1873 # @return an integer value
1874 # @ingroup l1_meshinfo
1875 def GetShapeIDForElem(self,id):
1876 return self.mesh.GetShapeIDForElem(id)
1878 ## Returns the number of nodes for the given element
1879 # \n If there is no element for the given ID - returns -1
1880 # @return an integer value
1881 # @ingroup l1_meshinfo
1882 def GetElemNbNodes(self, id):
1883 return self.mesh.GetElemNbNodes(id)
1885 ## Returns the node ID the given index for the given element
1886 # \n If there is no element for the given ID - returns -1
1887 # \n If there is no node for the given index - returns -2
1888 # @return an integer value
1889 # @ingroup l1_meshinfo
1890 def GetElemNode(self, id, index):
1891 return self.mesh.GetElemNode(id, index)
1893 ## Returns the IDs of nodes of the given element
1894 # @return a list of integer values
1895 # @ingroup l1_meshinfo
1896 def GetElemNodes(self, id):
1897 return self.mesh.GetElemNodes(id)
1899 ## Returns true if the given node is the medium node in the given quadratic element
1900 # @ingroup l1_meshinfo
1901 def IsMediumNode(self, elementID, nodeID):
1902 return self.mesh.IsMediumNode(elementID, nodeID)
1904 ## Returns true if the given node is the medium node in one of quadratic elements
1905 # @ingroup l1_meshinfo
1906 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1907 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1909 ## Returns the number of edges for the given element
1910 # @ingroup l1_meshinfo
1911 def ElemNbEdges(self, id):
1912 return self.mesh.ElemNbEdges(id)
1914 ## Returns the number of faces for the given element
1915 # @ingroup l1_meshinfo
1916 def ElemNbFaces(self, id):
1917 return self.mesh.ElemNbFaces(id)
1919 ## Returns true if the given element is a polygon
1920 # @ingroup l1_meshinfo
1921 def IsPoly(self, id):
1922 return self.mesh.IsPoly(id)
1924 ## Returns true if the given element is quadratic
1925 # @ingroup l1_meshinfo
1926 def IsQuadratic(self, id):
1927 return self.mesh.IsQuadratic(id)
1929 ## Returns XYZ coordinates of the barycenter of the given element
1930 # \n If there is no element for the given ID - returns an empty list
1931 # @return a list of three double values
1932 # @ingroup l1_meshinfo
1933 def BaryCenter(self, id):
1934 return self.mesh.BaryCenter(id)
1937 # Mesh edition (SMESH_MeshEditor functionality):
1938 # ---------------------------------------------
1940 ## Removes the elements from the mesh by ids
1941 # @param IDsOfElements is a list of ids of elements to remove
1942 # @return True or False
1943 # @ingroup l2_modif_del
1944 def RemoveElements(self, IDsOfElements):
1945 return self.editor.RemoveElements(IDsOfElements)
1947 ## Removes nodes from mesh by ids
1948 # @param IDsOfNodes is a list of ids of nodes to remove
1949 # @return True or False
1950 # @ingroup l2_modif_del
1951 def RemoveNodes(self, IDsOfNodes):
1952 return self.editor.RemoveNodes(IDsOfNodes)
1954 ## Add a node to the mesh by coordinates
1955 # @return Id of the new node
1956 # @ingroup l2_modif_add
1957 def AddNode(self, x, y, z):
1958 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
1959 self.mesh.SetParameters(Parameters)
1960 return self.editor.AddNode( x, y, z)
1962 ## Creates a 0D element on a node with given number.
1963 # @param IDOfNode the ID of node for creation of the element.
1964 # @return the Id of the new 0D element
1965 # @ingroup l2_modif_add
1966 def Add0DElement(self, IDOfNode):
1967 return self.editor.Add0DElement(IDOfNode)
1969 ## Creates a linear or quadratic edge (this is determined
1970 # by the number of given nodes).
1971 # @param IDsOfNodes the list of node IDs for creation of the element.
1972 # The order of nodes in this list should correspond to the description
1973 # of MED. \n This description is located by the following link:
1974 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1975 # @return the Id of the new edge
1976 # @ingroup l2_modif_add
1977 def AddEdge(self, IDsOfNodes):
1978 return self.editor.AddEdge(IDsOfNodes)
1980 ## Creates a linear or quadratic face (this is determined
1981 # by the number of given nodes).
1982 # @param IDsOfNodes the list of node IDs for creation of the element.
1983 # The order of nodes in this list should correspond to the description
1984 # of MED. \n This description is located by the following link:
1985 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1986 # @return the Id of the new face
1987 # @ingroup l2_modif_add
1988 def AddFace(self, IDsOfNodes):
1989 return self.editor.AddFace(IDsOfNodes)
1991 ## Adds a polygonal face to the mesh by the list of node IDs
1992 # @param IdsOfNodes the list of node IDs for creation of the element.
1993 # @return the Id of the new face
1994 # @ingroup l2_modif_add
1995 def AddPolygonalFace(self, IdsOfNodes):
1996 return self.editor.AddPolygonalFace(IdsOfNodes)
1998 ## Creates both simple and quadratic volume (this is determined
1999 # by the number of given nodes).
2000 # @param IDsOfNodes the list of node IDs for creation of the element.
2001 # The order of nodes in this list should correspond to the description
2002 # of MED. \n This description is located by the following link:
2003 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2004 # @return the Id of the new volumic element
2005 # @ingroup l2_modif_add
2006 def AddVolume(self, IDsOfNodes):
2007 return self.editor.AddVolume(IDsOfNodes)
2009 ## Creates a volume of many faces, giving nodes for each face.
2010 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2011 # @param Quantities the list of integer values, Quantities[i]
2012 # gives the quantity of nodes in face number i.
2013 # @return the Id of the new volumic element
2014 # @ingroup l2_modif_add
2015 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2016 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2018 ## Creates a volume of many faces, giving the IDs of the existing faces.
2019 # @param IdsOfFaces the list of face IDs for volume creation.
2021 # Note: The created volume will refer only to the nodes
2022 # of the given faces, not to the faces themselves.
2023 # @return the Id of the new volumic element
2024 # @ingroup l2_modif_add
2025 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2026 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2029 ## @brief Binds a node to a vertex
2030 # @param NodeID a node ID
2031 # @param Vertex a vertex or vertex ID
2032 # @return True if succeed else raises an exception
2033 # @ingroup l2_modif_add
2034 def SetNodeOnVertex(self, NodeID, Vertex):
2035 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2036 VertexID = Vertex.GetSubShapeIndices()[0]
2040 self.editor.SetNodeOnVertex(NodeID, VertexID)
2041 except SALOME.SALOME_Exception, inst:
2042 raise ValueError, inst.details.text
2046 ## @brief Stores the node position on an edge
2047 # @param NodeID a node ID
2048 # @param Edge an edge or edge ID
2049 # @param paramOnEdge a parameter on the edge where the node is located
2050 # @return True if succeed else raises an exception
2051 # @ingroup l2_modif_add
2052 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2053 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2054 EdgeID = Edge.GetSubShapeIndices()[0]
2058 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2059 except SALOME.SALOME_Exception, inst:
2060 raise ValueError, inst.details.text
2063 ## @brief Stores node position on a face
2064 # @param NodeID a node ID
2065 # @param Face a face or face ID
2066 # @param u U parameter on the face where the node is located
2067 # @param v V parameter on the face where the node is located
2068 # @return True if succeed else raises an exception
2069 # @ingroup l2_modif_add
2070 def SetNodeOnFace(self, NodeID, Face, u, v):
2071 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2072 FaceID = Face.GetSubShapeIndices()[0]
2076 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2077 except SALOME.SALOME_Exception, inst:
2078 raise ValueError, inst.details.text
2081 ## @brief Binds a node to a solid
2082 # @param NodeID a node ID
2083 # @param Solid a solid or solid ID
2084 # @return True if succeed else raises an exception
2085 # @ingroup l2_modif_add
2086 def SetNodeInVolume(self, NodeID, Solid):
2087 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2088 SolidID = Solid.GetSubShapeIndices()[0]
2092 self.editor.SetNodeInVolume(NodeID, SolidID)
2093 except SALOME.SALOME_Exception, inst:
2094 raise ValueError, inst.details.text
2097 ## @brief Bind an element to a shape
2098 # @param ElementID an element ID
2099 # @param Shape a shape or shape ID
2100 # @return True if succeed else raises an exception
2101 # @ingroup l2_modif_add
2102 def SetMeshElementOnShape(self, ElementID, Shape):
2103 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2104 ShapeID = Shape.GetSubShapeIndices()[0]
2108 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2109 except SALOME.SALOME_Exception, inst:
2110 raise ValueError, inst.details.text
2114 ## Moves the node with the given id
2115 # @param NodeID the id of the node
2116 # @param x a new X coordinate
2117 # @param y a new Y coordinate
2118 # @param z a new Z coordinate
2119 # @return True if succeed else False
2120 # @ingroup l2_modif_movenode
2121 def MoveNode(self, NodeID, x, y, z):
2122 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2123 self.mesh.SetParameters(Parameters)
2124 return self.editor.MoveNode(NodeID, x, y, z)
2126 ## Finds the node closest to a point and moves it to a point location
2127 # @param x the X coordinate of a point
2128 # @param y the Y coordinate of a point
2129 # @param z the Z coordinate of a point
2130 # @return the ID of a node
2131 # @ingroup l2_modif_throughp
2132 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2133 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2134 self.mesh.SetParameters(Parameters)
2135 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2137 ## Finds the node closest to a point
2138 # @param x the X coordinate of a point
2139 # @param y the Y coordinate of a point
2140 # @param z the Z coordinate of a point
2141 # @return the ID of a node
2142 # @ingroup l2_modif_throughp
2143 def FindNodeClosestTo(self, x, y, z):
2144 #preview = self.mesh.GetMeshEditPreviewer()
2145 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2146 return self.editor.FindNodeClosestTo(x, y, z)
2148 ## Finds the elements where a point lays IN or ON
2149 # @param x the X coordinate of a point
2150 # @param y the Y coordinate of a point
2151 # @param z the Z coordinate of a point
2152 # @param elementType type of elements to find (SMESH.ALL type
2153 # means elements of any type excluding nodes and 0D elements)
2154 # @return list of IDs of found elements
2155 # @ingroup l2_modif_throughp
2156 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2157 return self.editor.FindElementsByPoint(x, y, z, elementType)
2160 ## Finds the node closest to a point and moves it to a point location
2161 # @param x the X coordinate of a point
2162 # @param y the Y coordinate of a point
2163 # @param z the Z coordinate of a point
2164 # @return the ID of a moved node
2165 # @ingroup l2_modif_throughp
2166 def MeshToPassThroughAPoint(self, x, y, z):
2167 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2169 ## Replaces two neighbour triangles sharing Node1-Node2 link
2170 # with the triangles built on the same 4 nodes but having other common link.
2171 # @param NodeID1 the ID of the first node
2172 # @param NodeID2 the ID of the second node
2173 # @return false if proper faces were not found
2174 # @ingroup l2_modif_invdiag
2175 def InverseDiag(self, NodeID1, NodeID2):
2176 return self.editor.InverseDiag(NodeID1, NodeID2)
2178 ## Replaces two neighbour triangles sharing Node1-Node2 link
2179 # with a quadrangle built on the same 4 nodes.
2180 # @param NodeID1 the ID of the first node
2181 # @param NodeID2 the ID of the second node
2182 # @return false if proper faces were not found
2183 # @ingroup l2_modif_unitetri
2184 def DeleteDiag(self, NodeID1, NodeID2):
2185 return self.editor.DeleteDiag(NodeID1, NodeID2)
2187 ## Reorients elements by ids
2188 # @param IDsOfElements if undefined reorients all mesh elements
2189 # @return True if succeed else False
2190 # @ingroup l2_modif_changori
2191 def Reorient(self, IDsOfElements=None):
2192 if IDsOfElements == None:
2193 IDsOfElements = self.GetElementsId()
2194 return self.editor.Reorient(IDsOfElements)
2196 ## Reorients all elements of the object
2197 # @param theObject mesh, submesh or group
2198 # @return True if succeed else False
2199 # @ingroup l2_modif_changori
2200 def ReorientObject(self, theObject):
2201 if ( isinstance( theObject, Mesh )):
2202 theObject = theObject.GetMesh()
2203 return self.editor.ReorientObject(theObject)
2205 ## Fuses the neighbouring triangles into quadrangles.
2206 # @param IDsOfElements The triangles to be fused,
2207 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2208 # @param MaxAngle is the maximum angle between element normals at which the fusion
2209 # is still performed; theMaxAngle is mesured in radians.
2210 # Also it could be a name of variable which defines angle in degrees.
2211 # @return TRUE in case of success, FALSE otherwise.
2212 # @ingroup l2_modif_unitetri
2213 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2215 if isinstance(MaxAngle,str):
2217 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2219 MaxAngle = DegreesToRadians(MaxAngle)
2220 if IDsOfElements == []:
2221 IDsOfElements = self.GetElementsId()
2222 self.mesh.SetParameters(Parameters)
2224 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2225 Functor = theCriterion
2227 Functor = self.smeshpyD.GetFunctor(theCriterion)
2228 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2230 ## Fuses the neighbouring triangles of the object into quadrangles
2231 # @param theObject is mesh, submesh or group
2232 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2233 # @param MaxAngle a max angle between element normals at which the fusion
2234 # is still performed; theMaxAngle is mesured in radians.
2235 # @return TRUE in case of success, FALSE otherwise.
2236 # @ingroup l2_modif_unitetri
2237 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2238 if ( isinstance( theObject, Mesh )):
2239 theObject = theObject.GetMesh()
2240 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2242 ## Splits quadrangles into triangles.
2243 # @param IDsOfElements the faces to be splitted.
2244 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2245 # @return TRUE in case of success, FALSE otherwise.
2246 # @ingroup l2_modif_cutquadr
2247 def QuadToTri (self, IDsOfElements, theCriterion):
2248 if IDsOfElements == []:
2249 IDsOfElements = self.GetElementsId()
2250 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2252 ## Splits quadrangles into triangles.
2253 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2254 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2255 # @return TRUE in case of success, FALSE otherwise.
2256 # @ingroup l2_modif_cutquadr
2257 def QuadToTriObject (self, theObject, theCriterion):
2258 if ( isinstance( theObject, Mesh )):
2259 theObject = theObject.GetMesh()
2260 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2262 ## Splits quadrangles into triangles.
2263 # @param IDsOfElements the faces to be splitted
2264 # @param Diag13 is used to choose a diagonal for splitting.
2265 # @return TRUE in case of success, FALSE otherwise.
2266 # @ingroup l2_modif_cutquadr
2267 def SplitQuad (self, IDsOfElements, Diag13):
2268 if IDsOfElements == []:
2269 IDsOfElements = self.GetElementsId()
2270 return self.editor.SplitQuad(IDsOfElements, Diag13)
2272 ## Splits quadrangles into triangles.
2273 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2274 # @param Diag13 is used to choose a diagonal for splitting.
2275 # @return TRUE in case of success, FALSE otherwise.
2276 # @ingroup l2_modif_cutquadr
2277 def SplitQuadObject (self, theObject, Diag13):
2278 if ( isinstance( theObject, Mesh )):
2279 theObject = theObject.GetMesh()
2280 return self.editor.SplitQuadObject(theObject, Diag13)
2282 ## Finds a better splitting of the given quadrangle.
2283 # @param IDOfQuad the ID of the quadrangle to be splitted.
2284 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2285 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2286 # diagonal is better, 0 if error occurs.
2287 # @ingroup l2_modif_cutquadr
2288 def BestSplit (self, IDOfQuad, theCriterion):
2289 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2291 ## Splits quadrangle faces near triangular facets of volumes
2293 # @ingroup l1_auxiliary
2294 def SplitQuadsNearTriangularFacets(self):
2295 faces_array = self.GetElementsByType(SMESH.FACE)
2296 for face_id in faces_array:
2297 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2298 quad_nodes = self.mesh.GetElemNodes(face_id)
2299 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2300 isVolumeFound = False
2301 for node1_elem in node1_elems:
2302 if not isVolumeFound:
2303 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2304 nb_nodes = self.GetElemNbNodes(node1_elem)
2305 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2306 volume_elem = node1_elem
2307 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2308 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2309 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2310 isVolumeFound = True
2311 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2312 self.SplitQuad([face_id], False) # diagonal 2-4
2313 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2314 isVolumeFound = True
2315 self.SplitQuad([face_id], True) # diagonal 1-3
2316 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2317 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2318 isVolumeFound = True
2319 self.SplitQuad([face_id], True) # diagonal 1-3
2321 ## @brief Splits hexahedrons into tetrahedrons.
2323 # This operation uses pattern mapping functionality for splitting.
2324 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2325 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2326 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2327 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2328 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2329 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2330 # @return TRUE in case of success, FALSE otherwise.
2331 # @ingroup l1_auxiliary
2332 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2333 # Pattern: 5.---------.6
2338 # (0,0,1) 4.---------.7 * |
2345 # (0,0,0) 0.---------.3
2346 pattern_tetra = "!!! Nb of points: \n 8 \n\
2356 !!! Indices of points of 6 tetras: \n\
2364 pattern = self.smeshpyD.GetPattern()
2365 isDone = pattern.LoadFromFile(pattern_tetra)
2367 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2370 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2371 isDone = pattern.MakeMesh(self.mesh, False, False)
2372 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2374 # split quafrangle faces near triangular facets of volumes
2375 self.SplitQuadsNearTriangularFacets()
2379 ## @brief Split hexahedrons into prisms.
2381 # Uses the pattern mapping functionality for splitting.
2382 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2383 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2384 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2385 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2386 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2387 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2388 # @return TRUE in case of success, FALSE otherwise.
2389 # @ingroup l1_auxiliary
2390 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2391 # Pattern: 5.---------.6
2396 # (0,0,1) 4.---------.7 |
2403 # (0,0,0) 0.---------.3
2404 pattern_prism = "!!! Nb of points: \n 8 \n\
2414 !!! Indices of points of 2 prisms: \n\
2418 pattern = self.smeshpyD.GetPattern()
2419 isDone = pattern.LoadFromFile(pattern_prism)
2421 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2424 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2425 isDone = pattern.MakeMesh(self.mesh, False, False)
2426 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2428 # Splits quafrangle faces near triangular facets of volumes
2429 self.SplitQuadsNearTriangularFacets()
2433 ## Smoothes elements
2434 # @param IDsOfElements the list if ids of elements 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 is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2440 # @return TRUE in case of success, FALSE otherwise.
2441 # @ingroup l2_modif_smooth
2442 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2443 MaxNbOfIterations, MaxAspectRatio, Method):
2444 if IDsOfElements == []:
2445 IDsOfElements = self.GetElementsId()
2446 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2447 self.mesh.SetParameters(Parameters)
2448 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2449 MaxNbOfIterations, MaxAspectRatio, Method)
2451 ## Smoothes elements which belong to the given object
2452 # @param theObject the object to smooth
2453 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2454 # Note that nodes built on edges and boundary nodes are always fixed.
2455 # @param MaxNbOfIterations the maximum number of iterations
2456 # @param MaxAspectRatio varies in range [1.0, inf]
2457 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2458 # @return TRUE in case of success, FALSE otherwise.
2459 # @ingroup l2_modif_smooth
2460 def SmoothObject(self, theObject, IDsOfFixedNodes,
2461 MaxNbOfIterations, MaxAspectRatio, Method):
2462 if ( isinstance( theObject, Mesh )):
2463 theObject = theObject.GetMesh()
2464 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2465 MaxNbOfIterations, MaxAspectRatio, Method)
2467 ## Parametrically smoothes the given elements
2468 # @param IDsOfElements the list if ids of elements to smooth
2469 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2470 # Note that nodes built on edges and boundary nodes are always fixed.
2471 # @param MaxNbOfIterations the maximum number of iterations
2472 # @param MaxAspectRatio varies in range [1.0, inf]
2473 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2474 # @return TRUE in case of success, FALSE otherwise.
2475 # @ingroup l2_modif_smooth
2476 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2477 MaxNbOfIterations, MaxAspectRatio, Method):
2478 if IDsOfElements == []:
2479 IDsOfElements = self.GetElementsId()
2480 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2481 self.mesh.SetParameters(Parameters)
2482 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2483 MaxNbOfIterations, MaxAspectRatio, Method)
2485 ## Parametrically smoothes the elements which belong to the given object
2486 # @param theObject the object to smooth
2487 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2488 # Note that nodes built on edges and boundary nodes are always fixed.
2489 # @param MaxNbOfIterations the maximum number of iterations
2490 # @param MaxAspectRatio varies in range [1.0, inf]
2491 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2492 # @return TRUE in case of success, FALSE otherwise.
2493 # @ingroup l2_modif_smooth
2494 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2495 MaxNbOfIterations, MaxAspectRatio, Method):
2496 if ( isinstance( theObject, Mesh )):
2497 theObject = theObject.GetMesh()
2498 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2499 MaxNbOfIterations, MaxAspectRatio, Method)
2501 ## Converts the mesh to quadratic, deletes old elements, replacing
2502 # them with quadratic with the same id.
2503 # @ingroup l2_modif_tofromqu
2504 def ConvertToQuadratic(self, theForce3d):
2505 self.editor.ConvertToQuadratic(theForce3d)
2507 ## Converts the mesh from quadratic to ordinary,
2508 # deletes old quadratic elements, \n replacing
2509 # them with ordinary mesh elements with the same id.
2510 # @return TRUE in case of success, FALSE otherwise.
2511 # @ingroup l2_modif_tofromqu
2512 def ConvertFromQuadratic(self):
2513 return self.editor.ConvertFromQuadratic()
2515 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2516 # @return TRUE if operation has been completed successfully, FALSE otherwise
2517 # @ingroup l2_modif_edit
2518 def Make2DMeshFrom3D(self):
2519 return self.editor. Make2DMeshFrom3D()
2521 ## Renumber mesh nodes
2522 # @ingroup l2_modif_renumber
2523 def RenumberNodes(self):
2524 self.editor.RenumberNodes()
2526 ## Renumber mesh elements
2527 # @ingroup l2_modif_renumber
2528 def RenumberElements(self):
2529 self.editor.RenumberElements()
2531 ## Generates new elements by rotation of the elements around the axis
2532 # @param IDsOfElements the list of ids of elements to sweep
2533 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2534 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2535 # @param NbOfSteps the number of steps
2536 # @param Tolerance tolerance
2537 # @param MakeGroups forces the generation of new groups from existing ones
2538 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2539 # of all steps, else - size of each step
2540 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2541 # @ingroup l2_modif_extrurev
2542 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2543 MakeGroups=False, TotalAngle=False):
2545 if isinstance(AngleInRadians,str):
2547 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2549 AngleInRadians = DegreesToRadians(AngleInRadians)
2550 if IDsOfElements == []:
2551 IDsOfElements = self.GetElementsId()
2552 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2553 Axis = self.smeshpyD.GetAxisStruct(Axis)
2554 Axis,AxisParameters = ParseAxisStruct(Axis)
2555 if TotalAngle and NbOfSteps:
2556 AngleInRadians /= NbOfSteps
2557 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2558 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2559 self.mesh.SetParameters(Parameters)
2561 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2562 AngleInRadians, NbOfSteps, Tolerance)
2563 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2566 ## Generates new elements by rotation of the elements of object around the axis
2567 # @param theObject object which elements should be sweeped
2568 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2569 # @param AngleInRadians the angle of Rotation
2570 # @param NbOfSteps number of steps
2571 # @param Tolerance tolerance
2572 # @param MakeGroups forces the generation of new groups from existing ones
2573 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2574 # of all steps, else - size of each step
2575 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2576 # @ingroup l2_modif_extrurev
2577 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2578 MakeGroups=False, TotalAngle=False):
2580 if isinstance(AngleInRadians,str):
2582 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2584 AngleInRadians = DegreesToRadians(AngleInRadians)
2585 if ( isinstance( theObject, Mesh )):
2586 theObject = theObject.GetMesh()
2587 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2588 Axis = self.smeshpyD.GetAxisStruct(Axis)
2589 Axis,AxisParameters = ParseAxisStruct(Axis)
2590 if TotalAngle and NbOfSteps:
2591 AngleInRadians /= NbOfSteps
2592 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2593 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2594 self.mesh.SetParameters(Parameters)
2596 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2597 NbOfSteps, Tolerance)
2598 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2601 ## Generates new elements by rotation of the elements of object around the axis
2602 # @param theObject object which elements should be sweeped
2603 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2604 # @param AngleInRadians the angle of Rotation
2605 # @param NbOfSteps number of steps
2606 # @param Tolerance tolerance
2607 # @param MakeGroups forces the generation of new groups from existing ones
2608 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2609 # of all steps, else - size of each step
2610 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2611 # @ingroup l2_modif_extrurev
2612 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2613 MakeGroups=False, TotalAngle=False):
2615 if isinstance(AngleInRadians,str):
2617 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2619 AngleInRadians = DegreesToRadians(AngleInRadians)
2620 if ( isinstance( theObject, Mesh )):
2621 theObject = theObject.GetMesh()
2622 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2623 Axis = self.smeshpyD.GetAxisStruct(Axis)
2624 Axis,AxisParameters = ParseAxisStruct(Axis)
2625 if TotalAngle and NbOfSteps:
2626 AngleInRadians /= NbOfSteps
2627 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2628 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2629 self.mesh.SetParameters(Parameters)
2631 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2632 NbOfSteps, Tolerance)
2633 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2636 ## Generates new elements by rotation of the elements of object around the axis
2637 # @param theObject object which elements should be sweeped
2638 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2639 # @param AngleInRadians the angle of Rotation
2640 # @param NbOfSteps number of steps
2641 # @param Tolerance tolerance
2642 # @param MakeGroups forces the generation of new groups from existing ones
2643 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2644 # of all steps, else - size of each step
2645 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2646 # @ingroup l2_modif_extrurev
2647 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2648 MakeGroups=False, TotalAngle=False):
2650 if isinstance(AngleInRadians,str):
2652 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2654 AngleInRadians = DegreesToRadians(AngleInRadians)
2655 if ( isinstance( theObject, Mesh )):
2656 theObject = theObject.GetMesh()
2657 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2658 Axis = self.smeshpyD.GetAxisStruct(Axis)
2659 Axis,AxisParameters = ParseAxisStruct(Axis)
2660 if TotalAngle and NbOfSteps:
2661 AngleInRadians /= NbOfSteps
2662 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2663 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2664 self.mesh.SetParameters(Parameters)
2666 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2667 NbOfSteps, Tolerance)
2668 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2671 ## Generates new elements by extrusion of the elements with given ids
2672 # @param IDsOfElements the list of elements ids for extrusion
2673 # @param StepVector vector, defining the direction and value of extrusion
2674 # @param NbOfSteps the number of steps
2675 # @param MakeGroups forces the generation of new groups from existing ones
2676 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2677 # @ingroup l2_modif_extrurev
2678 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2679 if IDsOfElements == []:
2680 IDsOfElements = self.GetElementsId()
2681 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2682 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2683 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2684 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2685 Parameters = StepVectorParameters + var_separator + Parameters
2686 self.mesh.SetParameters(Parameters)
2688 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2689 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2692 ## Generates new elements by extrusion of the elements with given ids
2693 # @param IDsOfElements is ids of elements
2694 # @param StepVector vector, defining the direction and value of extrusion
2695 # @param NbOfSteps the number of steps
2696 # @param ExtrFlags sets flags for extrusion
2697 # @param SewTolerance uses for comparing locations of nodes if flag
2698 # EXTRUSION_FLAG_SEW is set
2699 # @param MakeGroups forces the generation of new groups from existing ones
2700 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2701 # @ingroup l2_modif_extrurev
2702 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2703 ExtrFlags, SewTolerance, MakeGroups=False):
2704 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2705 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2707 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2708 ExtrFlags, SewTolerance)
2709 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2710 ExtrFlags, SewTolerance)
2713 ## Generates new elements by extrusion of the elements which belong to the object
2714 # @param theObject the object which elements should be processed
2715 # @param StepVector vector, defining the direction and value of extrusion
2716 # @param NbOfSteps the number of steps
2717 # @param MakeGroups forces the generation of new groups from existing ones
2718 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2719 # @ingroup l2_modif_extrurev
2720 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2721 if ( isinstance( theObject, Mesh )):
2722 theObject = theObject.GetMesh()
2723 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2724 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2725 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2726 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2727 Parameters = StepVectorParameters + var_separator + Parameters
2728 self.mesh.SetParameters(Parameters)
2730 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2731 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2734 ## Generates new elements by extrusion of the elements which belong to the object
2735 # @param theObject object which elements should be processed
2736 # @param StepVector vector, defining the direction and value of extrusion
2737 # @param NbOfSteps the number of steps
2738 # @param MakeGroups to generate new groups from existing ones
2739 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2740 # @ingroup l2_modif_extrurev
2741 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2742 if ( isinstance( theObject, Mesh )):
2743 theObject = theObject.GetMesh()
2744 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2745 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2746 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2747 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2748 Parameters = StepVectorParameters + var_separator + Parameters
2749 self.mesh.SetParameters(Parameters)
2751 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2752 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2755 ## Generates new elements by extrusion of the elements which belong to the object
2756 # @param theObject object which elements should be processed
2757 # @param StepVector vector, defining the direction and value of extrusion
2758 # @param NbOfSteps the number of steps
2759 # @param MakeGroups forces the generation of new groups from existing ones
2760 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2761 # @ingroup l2_modif_extrurev
2762 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2763 if ( isinstance( theObject, Mesh )):
2764 theObject = theObject.GetMesh()
2765 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2766 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2767 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2768 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2769 Parameters = StepVectorParameters + var_separator + Parameters
2770 self.mesh.SetParameters(Parameters)
2772 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2773 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2778 ## Generates new elements by extrusion of the given elements
2779 # The path of extrusion must be a meshed edge.
2780 # @param Base mesh or list of ids of elements for extrusion
2781 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2782 # @param NodeStart the start node from Path. Defines the direction of extrusion
2783 # @param HasAngles allows the shape to be rotated around the path
2784 # to get the resulting mesh in a helical fashion
2785 # @param Angles list of angles in radians
2786 # @param LinearVariation forces the computation of rotation angles as linear
2787 # variation of the given Angles along path steps
2788 # @param HasRefPoint allows using the reference point
2789 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2790 # The User can specify any point as the Reference Point.
2791 # @param MakeGroups forces the generation of new groups from existing ones
2792 # @param ElemType type of elements for extrusion (if param Base is a mesh)
2793 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2794 # only SMESH::Extrusion_Error otherwise
2795 # @ingroup l2_modif_extrurev
2796 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2797 HasAngles, Angles, LinearVariation,
2798 HasRefPoint, RefPoint, MakeGroups, ElemType):
2799 Angles,AnglesParameters = ParseAngles(Angles)
2800 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2801 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2802 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2804 Parameters = AnglesParameters + var_separator + RefPointParameters
2805 self.mesh.SetParameters(Parameters)
2807 if isinstance(Base,list):
2809 if Base == []: IDsOfElements = self.GetElementsId()
2810 else: IDsOfElements = Base
2811 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2812 HasAngles, Angles, LinearVariation,
2813 HasRefPoint, RefPoint, MakeGroups, ElemType)
2815 if isinstance(Base,Mesh):
2816 return self.editor.ExtrusionAlongPathObjX(Base.GetMesh(), Path, NodeStart,
2817 HasAngles, Angles, LinearVariation,
2818 HasRefPoint, RefPoint, MakeGroups, ElemType)
2820 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2823 ## Generates new elements by extrusion of the given elements
2824 # The path of extrusion must be a meshed edge.
2825 # @param IDsOfElements ids of elements
2826 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2827 # @param PathShape shape(edge) defines the sub-mesh for the path
2828 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2829 # @param HasAngles allows the shape to be rotated around the path
2830 # to get the resulting mesh in a helical fashion
2831 # @param Angles list of angles in radians
2832 # @param HasRefPoint allows using the reference point
2833 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2834 # The User can specify any point as the Reference Point.
2835 # @param MakeGroups forces the generation of new groups from existing ones
2836 # @param LinearVariation forces the computation of rotation angles as linear
2837 # variation of the given Angles along path steps
2838 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2839 # only SMESH::Extrusion_Error otherwise
2840 # @ingroup l2_modif_extrurev
2841 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2842 HasAngles, Angles, HasRefPoint, RefPoint,
2843 MakeGroups=False, LinearVariation=False):
2844 Angles,AnglesParameters = ParseAngles(Angles)
2845 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2846 if IDsOfElements == []:
2847 IDsOfElements = self.GetElementsId()
2848 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2849 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2851 if ( isinstance( PathMesh, Mesh )):
2852 PathMesh = PathMesh.GetMesh()
2853 if HasAngles and Angles and LinearVariation:
2854 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2856 Parameters = AnglesParameters + var_separator + RefPointParameters
2857 self.mesh.SetParameters(Parameters)
2859 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2860 PathShape, NodeStart, HasAngles,
2861 Angles, HasRefPoint, RefPoint)
2862 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2863 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2865 ## Generates new elements by extrusion of the elements which belong to the object
2866 # The path of extrusion must be a meshed edge.
2867 # @param theObject the object which elements should be processed
2868 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2869 # @param PathShape shape(edge) defines the sub-mesh for the path
2870 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2871 # @param HasAngles allows the shape to be rotated around the path
2872 # to get the resulting mesh in a helical fashion
2873 # @param Angles list of angles
2874 # @param HasRefPoint allows using the reference point
2875 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2876 # The User can specify any point as the Reference Point.
2877 # @param MakeGroups forces the generation of new groups from existing ones
2878 # @param LinearVariation forces the computation of rotation angles as linear
2879 # variation of the given Angles along path steps
2880 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2881 # only SMESH::Extrusion_Error otherwise
2882 # @ingroup l2_modif_extrurev
2883 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2884 HasAngles, Angles, HasRefPoint, RefPoint,
2885 MakeGroups=False, LinearVariation=False):
2886 Angles,AnglesParameters = ParseAngles(Angles)
2887 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2888 if ( isinstance( theObject, Mesh )):
2889 theObject = theObject.GetMesh()
2890 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2891 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2892 if ( isinstance( PathMesh, Mesh )):
2893 PathMesh = PathMesh.GetMesh()
2894 if HasAngles and Angles and LinearVariation:
2895 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2897 Parameters = AnglesParameters + var_separator + RefPointParameters
2898 self.mesh.SetParameters(Parameters)
2900 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2901 PathShape, NodeStart, HasAngles,
2902 Angles, HasRefPoint, RefPoint)
2903 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2904 NodeStart, HasAngles, Angles, HasRefPoint,
2907 ## Generates new elements by extrusion of the elements which belong to the object
2908 # The path of extrusion must be a meshed edge.
2909 # @param theObject the object which elements should be processed
2910 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2911 # @param PathShape shape(edge) defines the sub-mesh for the path
2912 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2913 # @param HasAngles allows the shape to be rotated around the path
2914 # to get the resulting mesh in a helical fashion
2915 # @param Angles list of angles
2916 # @param HasRefPoint allows using the reference point
2917 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2918 # The User can specify any point as the Reference Point.
2919 # @param MakeGroups forces the generation of new groups from existing ones
2920 # @param LinearVariation forces the computation of rotation angles as linear
2921 # variation of the given Angles along path steps
2922 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2923 # only SMESH::Extrusion_Error otherwise
2924 # @ingroup l2_modif_extrurev
2925 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
2926 HasAngles, Angles, HasRefPoint, RefPoint,
2927 MakeGroups=False, LinearVariation=False):
2928 Angles,AnglesParameters = ParseAngles(Angles)
2929 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2930 if ( isinstance( theObject, Mesh )):
2931 theObject = theObject.GetMesh()
2932 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2933 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2934 if ( isinstance( PathMesh, Mesh )):
2935 PathMesh = PathMesh.GetMesh()
2936 if HasAngles and Angles and LinearVariation:
2937 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2939 Parameters = AnglesParameters + var_separator + RefPointParameters
2940 self.mesh.SetParameters(Parameters)
2942 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
2943 PathShape, NodeStart, HasAngles,
2944 Angles, HasRefPoint, RefPoint)
2945 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
2946 NodeStart, HasAngles, Angles, HasRefPoint,
2949 ## Generates new elements by extrusion of the elements which belong to the object
2950 # The path of extrusion must be a meshed edge.
2951 # @param theObject the object which elements should be processed
2952 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2953 # @param PathShape shape(edge) defines the sub-mesh for the path
2954 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2955 # @param HasAngles allows the shape to be rotated around the path
2956 # to get the resulting mesh in a helical fashion
2957 # @param Angles list of angles
2958 # @param HasRefPoint allows using the reference point
2959 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2960 # The User can specify any point as the Reference Point.
2961 # @param MakeGroups forces the generation of new groups from existing ones
2962 # @param LinearVariation forces the computation of rotation angles as linear
2963 # variation of the given Angles along path steps
2964 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2965 # only SMESH::Extrusion_Error otherwise
2966 # @ingroup l2_modif_extrurev
2967 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
2968 HasAngles, Angles, HasRefPoint, RefPoint,
2969 MakeGroups=False, LinearVariation=False):
2970 Angles,AnglesParameters = ParseAngles(Angles)
2971 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2972 if ( isinstance( theObject, Mesh )):
2973 theObject = theObject.GetMesh()
2974 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2975 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2976 if ( isinstance( PathMesh, Mesh )):
2977 PathMesh = PathMesh.GetMesh()
2978 if HasAngles and Angles and LinearVariation:
2979 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2981 Parameters = AnglesParameters + var_separator + RefPointParameters
2982 self.mesh.SetParameters(Parameters)
2984 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
2985 PathShape, NodeStart, HasAngles,
2986 Angles, HasRefPoint, RefPoint)
2987 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
2988 NodeStart, HasAngles, Angles, HasRefPoint,
2991 ## Creates a symmetrical copy of mesh elements
2992 # @param IDsOfElements list of elements ids
2993 # @param Mirror is AxisStruct or geom object(point, line, plane)
2994 # @param theMirrorType is POINT, AXIS or PLANE
2995 # If the Mirror is a geom object this parameter is unnecessary
2996 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2997 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2998 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2999 # @ingroup l2_modif_trsf
3000 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3001 if IDsOfElements == []:
3002 IDsOfElements = self.GetElementsId()
3003 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3004 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3005 Mirror,Parameters = ParseAxisStruct(Mirror)
3006 self.mesh.SetParameters(Parameters)
3007 if Copy and MakeGroups:
3008 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3009 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3012 ## Creates a new mesh by a symmetrical copy of mesh elements
3013 # @param IDsOfElements the list of elements ids
3014 # @param Mirror is AxisStruct or geom object (point, line, plane)
3015 # @param theMirrorType is POINT, AXIS or PLANE
3016 # If the Mirror is a geom object this parameter is unnecessary
3017 # @param MakeGroups to generate new groups from existing ones
3018 # @param NewMeshName a name of the new mesh to create
3019 # @return instance of Mesh class
3020 # @ingroup l2_modif_trsf
3021 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3022 if IDsOfElements == []:
3023 IDsOfElements = self.GetElementsId()
3024 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3025 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3026 Mirror,Parameters = ParseAxisStruct(Mirror)
3027 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3028 MakeGroups, NewMeshName)
3029 mesh.SetParameters(Parameters)
3030 return Mesh(self.smeshpyD,self.geompyD,mesh)
3032 ## Creates a symmetrical copy of the object
3033 # @param theObject mesh, submesh or group
3034 # @param Mirror AxisStruct or geom object (point, line, plane)
3035 # @param theMirrorType is POINT, AXIS or PLANE
3036 # If the Mirror is a geom object this parameter is unnecessary
3037 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3038 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3039 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3040 # @ingroup l2_modif_trsf
3041 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3042 if ( isinstance( theObject, Mesh )):
3043 theObject = theObject.GetMesh()
3044 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3045 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3046 Mirror,Parameters = ParseAxisStruct(Mirror)
3047 self.mesh.SetParameters(Parameters)
3048 if Copy and MakeGroups:
3049 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3050 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3053 ## Creates a new mesh by a symmetrical copy of the object
3054 # @param theObject mesh, submesh or group
3055 # @param Mirror AxisStruct or geom object (point, line, plane)
3056 # @param theMirrorType POINT, AXIS or PLANE
3057 # If the Mirror is a geom object this parameter is unnecessary
3058 # @param MakeGroups forces the generation of new groups from existing ones
3059 # @param NewMeshName the name of the new mesh to create
3060 # @return instance of Mesh class
3061 # @ingroup l2_modif_trsf
3062 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3063 if ( isinstance( theObject, Mesh )):
3064 theObject = theObject.GetMesh()
3065 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3066 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3067 Mirror,Parameters = ParseAxisStruct(Mirror)
3068 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3069 MakeGroups, NewMeshName)
3070 mesh.SetParameters(Parameters)
3071 return Mesh( self.smeshpyD,self.geompyD,mesh )
3073 ## Translates the elements
3074 # @param IDsOfElements list of elements ids
3075 # @param Vector the direction of translation (DirStruct or vector)
3076 # @param Copy allows copying the translated elements
3077 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3078 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3079 # @ingroup l2_modif_trsf
3080 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3081 if IDsOfElements == []:
3082 IDsOfElements = self.GetElementsId()
3083 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3084 Vector = self.smeshpyD.GetDirStruct(Vector)
3085 Vector,Parameters = ParseDirStruct(Vector)
3086 self.mesh.SetParameters(Parameters)
3087 if Copy and MakeGroups:
3088 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3089 self.editor.Translate(IDsOfElements, Vector, Copy)
3092 ## Creates a new mesh of translated elements
3093 # @param IDsOfElements list of elements ids
3094 # @param Vector the direction of translation (DirStruct or vector)
3095 # @param MakeGroups forces the generation of new groups from existing ones
3096 # @param NewMeshName the name of the newly created mesh
3097 # @return instance of Mesh class
3098 # @ingroup l2_modif_trsf
3099 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3100 if IDsOfElements == []:
3101 IDsOfElements = self.GetElementsId()
3102 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3103 Vector = self.smeshpyD.GetDirStruct(Vector)
3104 Vector,Parameters = ParseDirStruct(Vector)
3105 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3106 mesh.SetParameters(Parameters)
3107 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3109 ## Translates the object
3110 # @param theObject the object to translate (mesh, submesh, or group)
3111 # @param Vector direction of translation (DirStruct or geom vector)
3112 # @param Copy allows copying the translated elements
3113 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3114 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3115 # @ingroup l2_modif_trsf
3116 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3117 if ( isinstance( theObject, Mesh )):
3118 theObject = theObject.GetMesh()
3119 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3120 Vector = self.smeshpyD.GetDirStruct(Vector)
3121 Vector,Parameters = ParseDirStruct(Vector)
3122 self.mesh.SetParameters(Parameters)
3123 if Copy and MakeGroups:
3124 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3125 self.editor.TranslateObject(theObject, Vector, Copy)
3128 ## Creates a new mesh from the translated object
3129 # @param theObject the object to translate (mesh, submesh, or group)
3130 # @param Vector the direction of translation (DirStruct or geom vector)
3131 # @param MakeGroups forces the generation of new groups from existing ones
3132 # @param NewMeshName the name of the newly created mesh
3133 # @return instance of Mesh class
3134 # @ingroup l2_modif_trsf
3135 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3136 if (isinstance(theObject, Mesh)):
3137 theObject = theObject.GetMesh()
3138 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3139 Vector = self.smeshpyD.GetDirStruct(Vector)
3140 Vector,Parameters = ParseDirStruct(Vector)
3141 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3142 mesh.SetParameters(Parameters)
3143 return Mesh( self.smeshpyD, self.geompyD, mesh )
3145 ## Rotates the elements
3146 # @param IDsOfElements list of elements ids
3147 # @param Axis the axis of rotation (AxisStruct or geom line)
3148 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3149 # @param Copy allows copying the rotated elements
3150 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3151 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3152 # @ingroup l2_modif_trsf
3153 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3155 if isinstance(AngleInRadians,str):
3157 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3159 AngleInRadians = DegreesToRadians(AngleInRadians)
3160 if IDsOfElements == []:
3161 IDsOfElements = self.GetElementsId()
3162 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3163 Axis = self.smeshpyD.GetAxisStruct(Axis)
3164 Axis,AxisParameters = ParseAxisStruct(Axis)
3165 Parameters = AxisParameters + var_separator + Parameters
3166 self.mesh.SetParameters(Parameters)
3167 if Copy and MakeGroups:
3168 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3169 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3172 ## Creates a new mesh of rotated elements
3173 # @param IDsOfElements list of element ids
3174 # @param Axis the axis of rotation (AxisStruct or geom line)
3175 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3176 # @param MakeGroups forces the generation of new groups from existing ones
3177 # @param NewMeshName the name of the newly created mesh
3178 # @return instance of Mesh class
3179 # @ingroup l2_modif_trsf
3180 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3182 if isinstance(AngleInRadians,str):
3184 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3186 AngleInRadians = DegreesToRadians(AngleInRadians)
3187 if IDsOfElements == []:
3188 IDsOfElements = self.GetElementsId()
3189 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3190 Axis = self.smeshpyD.GetAxisStruct(Axis)
3191 Axis,AxisParameters = ParseAxisStruct(Axis)
3192 Parameters = AxisParameters + var_separator + Parameters
3193 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3194 MakeGroups, NewMeshName)
3195 mesh.SetParameters(Parameters)
3196 return Mesh( self.smeshpyD, self.geompyD, mesh )
3198 ## Rotates the object
3199 # @param theObject the object to rotate( mesh, submesh, or group)
3200 # @param Axis the axis of rotation (AxisStruct or geom line)
3201 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3202 # @param Copy allows copying the rotated elements
3203 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3204 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3205 # @ingroup l2_modif_trsf
3206 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3208 if isinstance(AngleInRadians,str):
3210 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3212 AngleInRadians = DegreesToRadians(AngleInRadians)
3213 if (isinstance(theObject, Mesh)):
3214 theObject = theObject.GetMesh()
3215 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3216 Axis = self.smeshpyD.GetAxisStruct(Axis)
3217 Axis,AxisParameters = ParseAxisStruct(Axis)
3218 Parameters = AxisParameters + ":" + Parameters
3219 self.mesh.SetParameters(Parameters)
3220 if Copy and MakeGroups:
3221 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3222 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3225 ## Creates a new mesh from the rotated object
3226 # @param theObject the object to rotate (mesh, submesh, or group)
3227 # @param Axis the axis of rotation (AxisStruct or geom line)
3228 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3229 # @param MakeGroups forces the generation of new groups from existing ones
3230 # @param NewMeshName the name of the newly created mesh
3231 # @return instance of Mesh class
3232 # @ingroup l2_modif_trsf
3233 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3235 if isinstance(AngleInRadians,str):
3237 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3239 AngleInRadians = DegreesToRadians(AngleInRadians)
3240 if (isinstance( theObject, Mesh )):
3241 theObject = theObject.GetMesh()
3242 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3243 Axis = self.smeshpyD.GetAxisStruct(Axis)
3244 Axis,AxisParameters = ParseAxisStruct(Axis)
3245 Parameters = AxisParameters + ":" + Parameters
3246 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3247 MakeGroups, NewMeshName)
3248 mesh.SetParameters(Parameters)
3249 return Mesh( self.smeshpyD, self.geompyD, mesh )
3251 ## Finds groups of ajacent nodes within Tolerance.
3252 # @param Tolerance the value of tolerance
3253 # @return the list of groups of nodes
3254 # @ingroup l2_modif_trsf
3255 def FindCoincidentNodes (self, Tolerance):
3256 return self.editor.FindCoincidentNodes(Tolerance)
3258 ## Finds groups of ajacent nodes within Tolerance.
3259 # @param Tolerance the value of tolerance
3260 # @param SubMeshOrGroup SubMesh or Group
3261 # @return the list of groups of nodes
3262 # @ingroup l2_modif_trsf
3263 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3264 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3267 # @param GroupsOfNodes the list of groups of nodes
3268 # @ingroup l2_modif_trsf
3269 def MergeNodes (self, GroupsOfNodes):
3270 self.editor.MergeNodes(GroupsOfNodes)
3272 ## Finds the elements built on the same nodes.
3273 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3274 # @return a list of groups of equal elements
3275 # @ingroup l2_modif_trsf
3276 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3277 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3279 ## Merges elements in each given group.
3280 # @param GroupsOfElementsID groups of elements for merging
3281 # @ingroup l2_modif_trsf
3282 def MergeElements(self, GroupsOfElementsID):
3283 self.editor.MergeElements(GroupsOfElementsID)
3285 ## Leaves one element and removes all other elements built on the same nodes.
3286 # @ingroup l2_modif_trsf
3287 def MergeEqualElements(self):
3288 self.editor.MergeEqualElements()
3290 ## Sews free borders
3291 # @return SMESH::Sew_Error
3292 # @ingroup l2_modif_trsf
3293 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3294 FirstNodeID2, SecondNodeID2, LastNodeID2,
3295 CreatePolygons, CreatePolyedrs):
3296 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3297 FirstNodeID2, SecondNodeID2, LastNodeID2,
3298 CreatePolygons, CreatePolyedrs)
3300 ## Sews conform free borders
3301 # @return SMESH::Sew_Error
3302 # @ingroup l2_modif_trsf
3303 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3304 FirstNodeID2, SecondNodeID2):
3305 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3306 FirstNodeID2, SecondNodeID2)
3308 ## Sews border to side
3309 # @return SMESH::Sew_Error
3310 # @ingroup l2_modif_trsf
3311 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3312 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3313 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3314 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3316 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3317 # merged with the nodes of elements of Side2.
3318 # The number of elements in theSide1 and in theSide2 must be
3319 # equal and they should have similar nodal connectivity.
3320 # The nodes to merge should belong to side borders and
3321 # the first node should be linked to the second.
3322 # @return SMESH::Sew_Error
3323 # @ingroup l2_modif_trsf
3324 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3325 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3326 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3327 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3328 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3329 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3331 ## Sets new nodes for the given element.
3332 # @param ide the element id
3333 # @param newIDs nodes ids
3334 # @return If the number of nodes does not correspond to the type of element - returns false
3335 # @ingroup l2_modif_edit
3336 def ChangeElemNodes(self, ide, newIDs):
3337 return self.editor.ChangeElemNodes(ide, newIDs)
3339 ## If during the last operation of MeshEditor some nodes were
3340 # created, this method returns the list of their IDs, \n
3341 # if new nodes were not created - returns empty list
3342 # @return the list of integer values (can be empty)
3343 # @ingroup l1_auxiliary
3344 def GetLastCreatedNodes(self):
3345 return self.editor.GetLastCreatedNodes()
3347 ## If during the last operation of MeshEditor some elements were
3348 # created this method returns the list of their IDs, \n
3349 # if new elements were not created - returns empty list
3350 # @return the list of integer values (can be empty)
3351 # @ingroup l1_auxiliary
3352 def GetLastCreatedElems(self):
3353 return self.editor.GetLastCreatedElems()
3355 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3356 # @param theElems - the list of elements (edges or faces) to be replicated
3357 # The nodes for duplication could be found from these elements
3358 # @param theNodesNot - list of nodes to NOT replicate
3359 # @param theAffectedElems - the list of elements (cells and edges) to which the
3360 # replicated nodes should be associated to.
3361 # @return TRUE if operation has been completed successfully, FALSE otherwise
3362 # @ingroup l2_modif_edit
3363 def DoubleNodes(self, theElems, theNodesNot, theAffectedElems):
3364 return self.editor.DoubleNodes(theElems, theNodesNot, theAffectedElems)
3366 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3367 # @param theElems - the list of elements (edges or faces) to be replicated
3368 # The nodes for duplication could be found from these elements
3369 # @param theNodesNot - list of nodes to NOT replicate
3370 # @param theShape - shape to detect affected elements (element which geometric center
3371 # located on or inside shape).
3372 # The replicated nodes should be associated to affected elements.
3373 # @return TRUE if operation has been completed successfully, FALSE otherwise
3374 # @ingroup l2_modif_edit
3375 def DoubleNodesInRegion(self, theElems, theNodesNot, theShape):
3376 return self.editor.DoubleNodesInRegion(theElems, theNodesNot, theShape)
3378 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3379 # This method provided for convenience works as DoubleNodes() described above.
3380 # @param theElems - group of of elements (edges or faces) to be replicated
3381 # @param theNodesNot - group of nodes not to replicated
3382 # @param theAffectedElems - group of elements to which the replicated nodes
3383 # should be associated to.
3384 # @ingroup l2_modif_edit
3385 def DoubleNodeGroup(self, theElems, theNodesNot, theAffectedElems):
3386 return self.editor.DoubleNodeGroup(theElems, theNodesNot, theAffectedElems)
3388 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3389 # This method provided for convenience works as DoubleNodes() described above.
3390 # @param theElems - group of of elements (edges or faces) to be replicated
3391 # @param theNodesNot - group of nodes not to replicated
3392 # @param theShape - shape to detect affected elements (element which geometric center
3393 # located on or inside shape).
3394 # The replicated nodes should be associated to affected elements.
3395 # @ingroup l2_modif_edit
3396 def DoubleNodeGroupInRegion(self, theElems, theNodesNot, theShape):
3397 return self.editor.DoubleNodeGroup(theElems, theNodesNot, theShape)
3399 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3400 # This method provided for convenience works as DoubleNodes() described above.
3401 # @param theElems - list of groups of elements (edges or faces) to be replicated
3402 # @param theNodesNot - list of groups of nodes not to replicated
3403 # @param theAffectedElems - group of elements to which the replicated nodes
3404 # should be associated to.
3405 # @return TRUE if operation has been completed successfully, FALSE otherwise
3406 # @ingroup l2_modif_edit
3407 def DoubleNodeGroups(self, theElems, theNodesNot, theAffectedElems):
3408 return self.editor.DoubleNodeGroups(theElems, theNodesNot, theAffectedElems)
3410 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3411 # This method provided for convenience works as DoubleNodes() described above.
3412 # @param theElems - list of groups of elements (edges or faces) to be replicated
3413 # @param theNodesNot - list of groups of nodes not to replicated
3414 # @param theShape - shape to detect affected elements (element which geometric center
3415 # located on or inside shape).
3416 # The replicated nodes should be associated to affected elements.
3417 # @return TRUE if operation has been completed successfully, FALSE otherwise
3418 # @ingroup l2_modif_edit
3419 def DoubleNodeGroupsInRegion(self, theElems, theNodesNot, theShape):
3420 return self.editor.DoubleNodeGroupsInRegion(theElems, theNodesNot, theShape)
3422 ## The mother class to define algorithm, it is not recommended to use it directly.
3425 # @ingroup l2_algorithms
3426 class Mesh_Algorithm:
3427 # @class Mesh_Algorithm
3428 # @brief Class Mesh_Algorithm
3430 #def __init__(self,smesh):
3438 ## Finds a hypothesis in the study by its type name and parameters.
3439 # Finds only the hypotheses created in smeshpyD engine.
3440 # @return SMESH.SMESH_Hypothesis
3441 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3442 study = smeshpyD.GetCurrentStudy()
3443 #to do: find component by smeshpyD object, not by its data type
3444 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3445 if scomp is not None:
3446 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3447 # Check if the root label of the hypotheses exists
3448 if res and hypRoot is not None:
3449 iter = study.NewChildIterator(hypRoot)
3450 # Check all published hypotheses
3452 hypo_so_i = iter.Value()
3453 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3454 if attr is not None:
3455 anIOR = attr.Value()
3456 hypo_o_i = salome.orb.string_to_object(anIOR)
3457 if hypo_o_i is not None:
3458 # Check if this is a hypothesis
3459 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3460 if hypo_i is not None:
3461 # Check if the hypothesis belongs to current engine
3462 if smeshpyD.GetObjectId(hypo_i) > 0:
3463 # Check if this is the required hypothesis
3464 if hypo_i.GetName() == hypname:
3466 if CompareMethod(hypo_i, args):
3480 ## Finds the algorithm in the study by its type name.
3481 # Finds only the algorithms, which have been created in smeshpyD engine.
3482 # @return SMESH.SMESH_Algo
3483 def FindAlgorithm (self, algoname, smeshpyD):
3484 study = smeshpyD.GetCurrentStudy()
3485 #to do: find component by smeshpyD object, not by its data type
3486 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3487 if scomp is not None:
3488 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3489 # Check if the root label of the algorithms exists
3490 if res and hypRoot is not None:
3491 iter = study.NewChildIterator(hypRoot)
3492 # Check all published algorithms
3494 algo_so_i = iter.Value()
3495 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3496 if attr is not None:
3497 anIOR = attr.Value()
3498 algo_o_i = salome.orb.string_to_object(anIOR)
3499 if algo_o_i is not None:
3500 # Check if this is an algorithm
3501 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3502 if algo_i is not None:
3503 # Checks if the algorithm belongs to the current engine
3504 if smeshpyD.GetObjectId(algo_i) > 0:
3505 # Check if this is the required algorithm
3506 if algo_i.GetName() == algoname:
3519 ## If the algorithm is global, returns 0; \n
3520 # else returns the submesh associated to this algorithm.
3521 def GetSubMesh(self):
3524 ## Returns the wrapped mesher.
3525 def GetAlgorithm(self):
3528 ## Gets the list of hypothesis that can be used with this algorithm
3529 def GetCompatibleHypothesis(self):
3532 mylist = self.algo.GetCompatibleHypothesis()
3535 ## Gets the name of the algorithm
3539 ## Sets the name to the algorithm
3540 def SetName(self, name):
3541 self.mesh.smeshpyD.SetName(self.algo, name)
3543 ## Gets the id of the algorithm
3545 return self.algo.GetId()
3548 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3550 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3551 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3553 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3555 self.Assign(algo, mesh, geom)
3559 def Assign(self, algo, mesh, geom):
3561 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3568 name = GetName(geom)
3570 name = mesh.geompyD.SubShapeName(geom, piece)
3571 mesh.geompyD.addToStudyInFather(piece, geom, name)
3572 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3575 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3576 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3578 def CompareHyp (self, hyp, args):
3579 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3582 def CompareEqualHyp (self, hyp, args):
3586 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3587 UseExisting=0, CompareMethod=""):
3590 if CompareMethod == "": CompareMethod = self.CompareHyp
3591 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3594 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3600 a = a + s + str(args[i])
3604 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3606 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3607 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3610 ## Returns entry of the shape to mesh in the study
3611 def MainShapeEntry(self):
3613 if not self.mesh or not self.mesh.GetMesh(): return entry
3614 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3615 study = self.mesh.smeshpyD.GetCurrentStudy()
3616 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3617 sobj = study.FindObjectIOR(ior)
3618 if sobj: entry = sobj.GetID()
3619 if not entry: return ""
3622 # Public class: Mesh_Segment
3623 # --------------------------
3625 ## Class to define a segment 1D algorithm for discretization
3628 # @ingroup l3_algos_basic
3629 class Mesh_Segment(Mesh_Algorithm):
3631 ## Private constructor.
3632 def __init__(self, mesh, geom=0):
3633 Mesh_Algorithm.__init__(self)
3634 self.Create(mesh, geom, "Regular_1D")
3636 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3637 # @param l for the length of segments that cut an edge
3638 # @param UseExisting if ==true - searches for an existing hypothesis created with
3639 # the same parameters, else (default) - creates a new one
3640 # @param p precision, used for calculation of the number of segments.
3641 # The precision should be a positive, meaningful value within the range [0,1].
3642 # In general, the number of segments is calculated with the formula:
3643 # nb = ceil((edge_length / l) - p)
3644 # Function ceil rounds its argument to the higher integer.
3645 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3646 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3647 # p=1 means rounding of (edge_length / l) to the lower integer.
3648 # Default value is 1e-07.
3649 # @return an instance of StdMeshers_LocalLength hypothesis
3650 # @ingroup l3_hypos_1dhyps
3651 def LocalLength(self, l, UseExisting=0, p=1e-07):
3652 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3653 CompareMethod=self.CompareLocalLength)
3659 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3660 def CompareLocalLength(self, hyp, args):
3661 if IsEqual(hyp.GetLength(), args[0]):
3662 return IsEqual(hyp.GetPrecision(), args[1])
3665 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3666 # @param length is optional maximal allowed length of segment, if it is omitted
3667 # the preestimated length is used that depends on geometry size
3668 # @param UseExisting if ==true - searches for an existing hypothesis created with
3669 # the same parameters, else (default) - create a new one
3670 # @return an instance of StdMeshers_MaxLength hypothesis
3671 # @ingroup l3_hypos_1dhyps
3672 def MaxSize(self, length=0.0, UseExisting=0):
3673 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3676 hyp.SetLength(length)
3678 # set preestimated length
3679 gen = self.mesh.smeshpyD
3680 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3681 self.mesh.GetMesh(), self.mesh.GetShape(),
3683 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3685 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3688 hyp.SetUsePreestimatedLength( length == 0.0 )
3691 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3692 # @param n for the number of segments that cut an edge
3693 # @param s for the scale factor (optional)
3694 # @param reversedEdges is a list of edges to mesh using reversed orientation
3695 # @param UseExisting if ==true - searches for an existing hypothesis created with
3696 # the same parameters, else (default) - create a new one
3697 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3698 # @ingroup l3_hypos_1dhyps
3699 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3700 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3701 reversedEdges, UseExisting = [], reversedEdges
3702 entry = self.MainShapeEntry()
3704 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3705 UseExisting=UseExisting,
3706 CompareMethod=self.CompareNumberOfSegments)
3708 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3709 UseExisting=UseExisting,
3710 CompareMethod=self.CompareNumberOfSegments)
3711 hyp.SetDistrType( 1 )
3712 hyp.SetScaleFactor(s)
3713 hyp.SetNumberOfSegments(n)
3714 hyp.SetReversedEdges( reversedEdges )
3715 hyp.SetObjectEntry( entry )
3719 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3720 def CompareNumberOfSegments(self, hyp, args):
3721 if hyp.GetNumberOfSegments() == args[0]:
3723 if hyp.GetReversedEdges() == args[1]:
3724 if not args[1] or hyp.GetObjectEntry() == args[2]:
3727 if hyp.GetReversedEdges() == args[2]:
3728 if not args[2] or hyp.GetObjectEntry() == args[3]:
3729 if hyp.GetDistrType() == 1:
3730 if IsEqual(hyp.GetScaleFactor(), args[1]):
3734 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3735 # @param start defines the length of the first segment
3736 # @param end defines the length of the last segment
3737 # @param reversedEdges is a list of edges to mesh using reversed orientation
3738 # @param UseExisting if ==true - searches for an existing hypothesis created with
3739 # the same parameters, else (default) - creates a new one
3740 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3741 # @ingroup l3_hypos_1dhyps
3742 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3743 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3744 reversedEdges, UseExisting = [], reversedEdges
3745 entry = self.MainShapeEntry()
3746 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
3747 UseExisting=UseExisting,
3748 CompareMethod=self.CompareArithmetic1D)
3749 hyp.SetStartLength(start)
3750 hyp.SetEndLength(end)
3751 hyp.SetReversedEdges( reversedEdges )
3752 hyp.SetObjectEntry( entry )
3756 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3757 def CompareArithmetic1D(self, hyp, args):
3758 if IsEqual(hyp.GetLength(1), args[0]):
3759 if IsEqual(hyp.GetLength(0), args[1]):
3760 if hyp.GetReversedEdges() == args[2]:
3761 if not args[2] or hyp.GetObjectEntry() == args[3]:
3766 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
3767 # on curve from 0 to 1 (additionally it is neecessary to check
3768 # orientation of edges and create list of reversed edges if it is
3769 # needed) and sets numbers of segments between given points (default
3770 # values are equals 1
3771 # @param points defines the list of parameters on curve
3772 # @param nbSegs defines the list of numbers of segments
3773 # @param reversedEdges is a list of edges to mesh using reversed orientation
3774 # @param UseExisting if ==true - searches for an existing hypothesis created with
3775 # the same parameters, else (default) - creates a new one
3776 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3777 # @ingroup l3_hypos_1dhyps
3778 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
3779 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3780 reversedEdges, UseExisting = [], reversedEdges
3781 entry = self.MainShapeEntry()
3782 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
3783 UseExisting=UseExisting,
3784 CompareMethod=self.CompareArithmetic1D)
3785 hyp.SetPoints(points)
3786 hyp.SetNbSegments(nbSegs)
3787 hyp.SetReversedEdges(reversedEdges)
3788 hyp.SetObjectEntry(entry)
3792 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
3793 ## as the given arguments
3794 def CompareFixedPoints1D(self, hyp, args):
3795 if hyp.GetPoints() == args[0]:
3796 if hyp.GetNbSegments() == args[1]:
3797 if hyp.GetReversedEdges() == args[2]:
3798 if not args[2] or hyp.GetObjectEntry() == args[3]:
3804 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3805 # @param start defines the length of the first segment
3806 # @param end defines the length of the last segment
3807 # @param reversedEdges is a list of edges to mesh using reversed orientation
3808 # @param UseExisting if ==true - searches for an existing hypothesis created with
3809 # the same parameters, else (default) - creates a new one
3810 # @return an instance of StdMeshers_StartEndLength hypothesis
3811 # @ingroup l3_hypos_1dhyps
3812 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3813 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3814 reversedEdges, UseExisting = [], reversedEdges
3815 entry = self.MainShapeEntry()
3816 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3817 UseExisting=UseExisting,
3818 CompareMethod=self.CompareStartEndLength)
3819 hyp.SetStartLength(start)
3820 hyp.SetEndLength(end)
3821 hyp.SetReversedEdges( reversedEdges )
3822 hyp.SetObjectEntry( entry )
3825 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3826 def CompareStartEndLength(self, hyp, args):
3827 if IsEqual(hyp.GetLength(1), args[0]):
3828 if IsEqual(hyp.GetLength(0), args[1]):
3829 if hyp.GetReversedEdges() == args[2]:
3830 if not args[2] or hyp.GetObjectEntry() == args[3]:
3834 ## Defines "Deflection1D" hypothesis
3835 # @param d for the deflection
3836 # @param UseExisting if ==true - searches for an existing hypothesis created with
3837 # the same parameters, else (default) - create a new one
3838 # @ingroup l3_hypos_1dhyps
3839 def Deflection1D(self, d, UseExisting=0):
3840 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3841 CompareMethod=self.CompareDeflection1D)
3842 hyp.SetDeflection(d)
3845 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3846 def CompareDeflection1D(self, hyp, args):
3847 return IsEqual(hyp.GetDeflection(), args[0])
3849 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3850 # the opposite side in case of quadrangular faces
3851 # @ingroup l3_hypos_additi
3852 def Propagation(self):
3853 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3855 ## Defines "AutomaticLength" hypothesis
3856 # @param fineness for the fineness [0-1]
3857 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3858 # same parameters, else (default) - create a new one
3859 # @ingroup l3_hypos_1dhyps
3860 def AutomaticLength(self, fineness=0, UseExisting=0):
3861 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3862 CompareMethod=self.CompareAutomaticLength)
3863 hyp.SetFineness( fineness )
3866 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3867 def CompareAutomaticLength(self, hyp, args):
3868 return IsEqual(hyp.GetFineness(), args[0])
3870 ## Defines "SegmentLengthAroundVertex" hypothesis
3871 # @param length for the segment length
3872 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3873 # Any other integer value means that the hypothesis will be set on the
3874 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3875 # @param UseExisting if ==true - searches for an existing hypothesis created with
3876 # the same parameters, else (default) - creates a new one
3877 # @ingroup l3_algos_segmarv
3878 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3880 store_geom = self.geom
3881 if type(vertex) is types.IntType:
3882 if vertex == 0 or vertex == 1:
3883 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3891 if self.geom is None:
3892 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3893 name = GetName(self.geom)
3895 piece = self.mesh.geom
3896 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3897 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3898 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3900 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3902 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3903 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3905 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3906 CompareMethod=self.CompareLengthNearVertex)
3907 self.geom = store_geom
3908 hyp.SetLength( length )
3911 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3912 # @ingroup l3_algos_segmarv
3913 def CompareLengthNearVertex(self, hyp, args):
3914 return IsEqual(hyp.GetLength(), args[0])
3916 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3917 # If the 2D mesher sees that all boundary edges are quadratic,
3918 # it generates quadratic faces, else it generates linear faces using
3919 # medium nodes as if they are vertices.
3920 # The 3D mesher generates quadratic volumes only if all boundary faces
3921 # are quadratic, else it fails.
3923 # @ingroup l3_hypos_additi
3924 def QuadraticMesh(self):
3925 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3928 # Public class: Mesh_CompositeSegment
3929 # --------------------------
3931 ## Defines a segment 1D algorithm for discretization
3933 # @ingroup l3_algos_basic
3934 class Mesh_CompositeSegment(Mesh_Segment):
3936 ## Private constructor.
3937 def __init__(self, mesh, geom=0):
3938 self.Create(mesh, geom, "CompositeSegment_1D")
3941 # Public class: Mesh_Segment_Python
3942 # ---------------------------------
3944 ## Defines a segment 1D algorithm for discretization with python function
3946 # @ingroup l3_algos_basic
3947 class Mesh_Segment_Python(Mesh_Segment):
3949 ## Private constructor.
3950 def __init__(self, mesh, geom=0):
3951 import Python1dPlugin
3952 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3954 ## Defines "PythonSplit1D" hypothesis
3955 # @param n for the number of segments that cut an edge
3956 # @param func for the python function that calculates the length of all segments
3957 # @param UseExisting if ==true - searches for the existing hypothesis created with
3958 # the same parameters, else (default) - creates a new one
3959 # @ingroup l3_hypos_1dhyps
3960 def PythonSplit1D(self, n, func, UseExisting=0):
3961 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3962 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3963 hyp.SetNumberOfSegments(n)
3964 hyp.SetPythonLog10RatioFunction(func)
3967 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3968 def ComparePythonSplit1D(self, hyp, args):
3969 #if hyp.GetNumberOfSegments() == args[0]:
3970 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3974 # Public class: Mesh_Triangle
3975 # ---------------------------
3977 ## Defines a triangle 2D algorithm
3979 # @ingroup l3_algos_basic
3980 class Mesh_Triangle(Mesh_Algorithm):
3989 ## Private constructor.
3990 def __init__(self, mesh, algoType, geom=0):
3991 Mesh_Algorithm.__init__(self)
3993 self.algoType = algoType
3994 if algoType == MEFISTO:
3995 self.Create(mesh, geom, "MEFISTO_2D")
3997 elif algoType == BLSURF:
3999 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4000 #self.SetPhysicalMesh() - PAL19680
4001 elif algoType == NETGEN:
4003 print "Warning: NETGENPlugin module unavailable"
4005 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4007 elif algoType == NETGEN_2D:
4009 print "Warning: NETGENPlugin module unavailable"
4011 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4014 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4015 # @param area for the maximum area of each triangle
4016 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4017 # same parameters, else (default) - creates a new one
4019 # Only for algoType == MEFISTO || NETGEN_2D
4020 # @ingroup l3_hypos_2dhyps
4021 def MaxElementArea(self, area, UseExisting=0):
4022 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4023 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4024 CompareMethod=self.CompareMaxElementArea)
4025 elif self.algoType == NETGEN:
4026 hyp = self.Parameters(SIMPLE)
4027 hyp.SetMaxElementArea(area)
4030 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4031 def CompareMaxElementArea(self, hyp, args):
4032 return IsEqual(hyp.GetMaxElementArea(), args[0])
4034 ## Defines "LengthFromEdges" hypothesis to build triangles
4035 # based on the length of the edges taken from the wire
4037 # Only for algoType == MEFISTO || NETGEN_2D
4038 # @ingroup l3_hypos_2dhyps
4039 def LengthFromEdges(self):
4040 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4041 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4043 elif self.algoType == NETGEN:
4044 hyp = self.Parameters(SIMPLE)
4045 hyp.LengthFromEdges()
4048 ## Sets a way to define size of mesh elements to generate.
4049 # @param thePhysicalMesh is: DefaultSize or Custom.
4050 # @ingroup l3_hypos_blsurf
4051 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4052 # Parameter of BLSURF algo
4053 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4055 ## Sets size of mesh elements to generate.
4056 # @ingroup l3_hypos_blsurf
4057 def SetPhySize(self, theVal):
4058 # Parameter of BLSURF algo
4059 self.Parameters().SetPhySize(theVal)
4061 ## Sets lower boundary of mesh element size (PhySize).
4062 # @ingroup l3_hypos_blsurf
4063 def SetPhyMin(self, theVal=-1):
4064 # Parameter of BLSURF algo
4065 self.Parameters().SetPhyMin(theVal)
4067 ## Sets upper boundary of mesh element size (PhySize).
4068 # @ingroup l3_hypos_blsurf
4069 def SetPhyMax(self, theVal=-1):
4070 # Parameter of BLSURF algo
4071 self.Parameters().SetPhyMax(theVal)
4073 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4074 # @param theGeometricMesh is: DefaultGeom or Custom
4075 # @ingroup l3_hypos_blsurf
4076 def SetGeometricMesh(self, theGeometricMesh=0):
4077 # Parameter of BLSURF algo
4078 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4079 self.params.SetGeometricMesh(theGeometricMesh)
4081 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4082 # @ingroup l3_hypos_blsurf
4083 def SetAngleMeshS(self, theVal=_angleMeshS):
4084 # Parameter of BLSURF algo
4085 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4086 self.params.SetAngleMeshS(theVal)
4088 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4089 # @ingroup l3_hypos_blsurf
4090 def SetAngleMeshC(self, theVal=_angleMeshS):
4091 # Parameter of BLSURF algo
4092 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4093 self.params.SetAngleMeshC(theVal)
4095 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4096 # @ingroup l3_hypos_blsurf
4097 def SetGeoMin(self, theVal=-1):
4098 # Parameter of BLSURF algo
4099 self.Parameters().SetGeoMin(theVal)
4101 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4102 # @ingroup l3_hypos_blsurf
4103 def SetGeoMax(self, theVal=-1):
4104 # Parameter of BLSURF algo
4105 self.Parameters().SetGeoMax(theVal)
4107 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4108 # @ingroup l3_hypos_blsurf
4109 def SetGradation(self, theVal=_gradation):
4110 # Parameter of BLSURF algo
4111 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4112 self.params.SetGradation(theVal)
4114 ## Sets topology usage way.
4115 # @param way defines how mesh conformity is assured <ul>
4116 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4117 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4118 # @ingroup l3_hypos_blsurf
4119 def SetTopology(self, way):
4120 # Parameter of BLSURF algo
4121 self.Parameters().SetTopology(way)
4123 ## To respect geometrical edges or not.
4124 # @ingroup l3_hypos_blsurf
4125 def SetDecimesh(self, toIgnoreEdges=False):
4126 # Parameter of BLSURF algo
4127 self.Parameters().SetDecimesh(toIgnoreEdges)
4129 ## Sets verbosity level in the range 0 to 100.
4130 # @ingroup l3_hypos_blsurf
4131 def SetVerbosity(self, level):
4132 # Parameter of BLSURF algo
4133 self.Parameters().SetVerbosity(level)
4135 ## Sets advanced option value.
4136 # @ingroup l3_hypos_blsurf
4137 def SetOptionValue(self, optionName, level):
4138 # Parameter of BLSURF algo
4139 self.Parameters().SetOptionValue(optionName,level)
4141 ## Sets QuadAllowed flag.
4142 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4143 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4144 def SetQuadAllowed(self, toAllow=True):
4145 if self.algoType == NETGEN_2D:
4146 if toAllow: # add QuadranglePreference
4147 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4148 else: # remove QuadranglePreference
4149 for hyp in self.mesh.GetHypothesisList( self.geom ):
4150 if hyp.GetName() == "QuadranglePreference":
4151 self.mesh.RemoveHypothesis( self.geom, hyp )
4156 if self.Parameters():
4157 self.params.SetQuadAllowed(toAllow)
4160 ## Defines hypothesis having several parameters
4162 # @ingroup l3_hypos_netgen
4163 def Parameters(self, which=SOLE):
4166 if self.algoType == NETGEN:
4168 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4169 "libNETGENEngine.so", UseExisting=0)
4171 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4172 "libNETGENEngine.so", UseExisting=0)
4174 elif self.algoType == MEFISTO:
4175 print "Mefisto algo support no multi-parameter hypothesis"
4177 elif self.algoType == NETGEN_2D:
4178 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4179 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4181 elif self.algoType == BLSURF:
4182 self.params = self.Hypothesis("BLSURF_Parameters", [],
4183 "libBLSURFEngine.so", UseExisting=0)
4186 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4191 # Only for algoType == NETGEN
4192 # @ingroup l3_hypos_netgen
4193 def SetMaxSize(self, theSize):
4194 if self.Parameters():
4195 self.params.SetMaxSize(theSize)
4197 ## Sets SecondOrder flag
4199 # Only for algoType == NETGEN
4200 # @ingroup l3_hypos_netgen
4201 def SetSecondOrder(self, theVal):
4202 if self.Parameters():
4203 self.params.SetSecondOrder(theVal)
4205 ## Sets Optimize flag
4207 # Only for algoType == NETGEN
4208 # @ingroup l3_hypos_netgen
4209 def SetOptimize(self, theVal):
4210 if self.Parameters():
4211 self.params.SetOptimize(theVal)
4214 # @param theFineness is:
4215 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4217 # Only for algoType == NETGEN
4218 # @ingroup l3_hypos_netgen
4219 def SetFineness(self, theFineness):
4220 if self.Parameters():
4221 self.params.SetFineness(theFineness)
4225 # Only for algoType == NETGEN
4226 # @ingroup l3_hypos_netgen
4227 def SetGrowthRate(self, theRate):
4228 if self.Parameters():
4229 self.params.SetGrowthRate(theRate)
4231 ## Sets NbSegPerEdge
4233 # Only for algoType == NETGEN
4234 # @ingroup l3_hypos_netgen
4235 def SetNbSegPerEdge(self, theVal):
4236 if self.Parameters():
4237 self.params.SetNbSegPerEdge(theVal)
4239 ## Sets NbSegPerRadius
4241 # Only for algoType == NETGEN
4242 # @ingroup l3_hypos_netgen
4243 def SetNbSegPerRadius(self, theVal):
4244 if self.Parameters():
4245 self.params.SetNbSegPerRadius(theVal)
4247 ## Sets number of segments overriding value set by SetLocalLength()
4249 # Only for algoType == NETGEN
4250 # @ingroup l3_hypos_netgen
4251 def SetNumberOfSegments(self, theVal):
4252 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4254 ## Sets number of segments overriding value set by SetNumberOfSegments()
4256 # Only for algoType == NETGEN
4257 # @ingroup l3_hypos_netgen
4258 def SetLocalLength(self, theVal):
4259 self.Parameters(SIMPLE).SetLocalLength(theVal)
4264 # Public class: Mesh_Quadrangle
4265 # -----------------------------
4267 ## Defines a quadrangle 2D algorithm
4269 # @ingroup l3_algos_basic
4270 class Mesh_Quadrangle(Mesh_Algorithm):
4272 ## Private constructor.
4273 def __init__(self, mesh, geom=0):
4274 Mesh_Algorithm.__init__(self)
4275 self.Create(mesh, geom, "Quadrangle_2D")
4277 ## Defines "QuadranglePreference" hypothesis, forcing construction
4278 # of quadrangles if the number of nodes on the opposite edges is not the same
4279 # while the total number of nodes on edges is even
4281 # @ingroup l3_hypos_additi
4282 def QuadranglePreference(self):
4283 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4284 CompareMethod=self.CompareEqualHyp)
4287 ## Defines "TrianglePreference" hypothesis, forcing construction
4288 # of triangles in the refinement area if the number of nodes
4289 # on the opposite edges is not the same
4291 # @ingroup l3_hypos_additi
4292 def TrianglePreference(self):
4293 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4294 CompareMethod=self.CompareEqualHyp)
4297 # Public class: Mesh_Tetrahedron
4298 # ------------------------------
4300 ## Defines a tetrahedron 3D algorithm
4302 # @ingroup l3_algos_basic
4303 class Mesh_Tetrahedron(Mesh_Algorithm):
4308 ## Private constructor.
4309 def __init__(self, mesh, algoType, geom=0):
4310 Mesh_Algorithm.__init__(self)
4312 if algoType == NETGEN:
4313 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4316 elif algoType == FULL_NETGEN:
4318 print "Warning: NETGENPlugin module has not been imported."
4319 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4322 elif algoType == GHS3D:
4324 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4327 elif algoType == GHS3DPRL:
4328 import GHS3DPRLPlugin
4329 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4332 self.algoType = algoType
4334 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4335 # @param vol for the maximum volume of each tetrahedron
4336 # @param UseExisting if ==true - searches for the existing hypothesis created with
4337 # the same parameters, else (default) - creates a new one
4338 # @ingroup l3_hypos_maxvol
4339 def MaxElementVolume(self, vol, UseExisting=0):
4340 if self.algoType == NETGEN:
4341 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4342 CompareMethod=self.CompareMaxElementVolume)
4343 hyp.SetMaxElementVolume(vol)
4345 elif self.algoType == FULL_NETGEN:
4346 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4349 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4350 def CompareMaxElementVolume(self, hyp, args):
4351 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4353 ## Defines hypothesis having several parameters
4355 # @ingroup l3_hypos_netgen
4356 def Parameters(self, which=SOLE):
4360 if self.algoType == FULL_NETGEN:
4362 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4363 "libNETGENEngine.so", UseExisting=0)
4365 self.params = self.Hypothesis("NETGEN_Parameters", [],
4366 "libNETGENEngine.so", UseExisting=0)
4369 if self.algoType == GHS3D:
4370 self.params = self.Hypothesis("GHS3D_Parameters", [],
4371 "libGHS3DEngine.so", UseExisting=0)
4374 if self.algoType == GHS3DPRL:
4375 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4376 "libGHS3DPRLEngine.so", UseExisting=0)
4379 print "Algo supports no multi-parameter hypothesis"
4383 # Parameter of FULL_NETGEN
4384 # @ingroup l3_hypos_netgen
4385 def SetMaxSize(self, theSize):
4386 self.Parameters().SetMaxSize(theSize)
4388 ## Sets SecondOrder flag
4389 # Parameter of FULL_NETGEN
4390 # @ingroup l3_hypos_netgen
4391 def SetSecondOrder(self, theVal):
4392 self.Parameters().SetSecondOrder(theVal)
4394 ## Sets Optimize flag
4395 # Parameter of FULL_NETGEN
4396 # @ingroup l3_hypos_netgen
4397 def SetOptimize(self, theVal):
4398 self.Parameters().SetOptimize(theVal)
4401 # @param theFineness is:
4402 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4403 # Parameter of FULL_NETGEN
4404 # @ingroup l3_hypos_netgen
4405 def SetFineness(self, theFineness):
4406 self.Parameters().SetFineness(theFineness)
4409 # Parameter of FULL_NETGEN
4410 # @ingroup l3_hypos_netgen
4411 def SetGrowthRate(self, theRate):
4412 self.Parameters().SetGrowthRate(theRate)
4414 ## Sets NbSegPerEdge
4415 # Parameter of FULL_NETGEN
4416 # @ingroup l3_hypos_netgen
4417 def SetNbSegPerEdge(self, theVal):
4418 self.Parameters().SetNbSegPerEdge(theVal)
4420 ## Sets NbSegPerRadius
4421 # Parameter of FULL_NETGEN
4422 # @ingroup l3_hypos_netgen
4423 def SetNbSegPerRadius(self, theVal):
4424 self.Parameters().SetNbSegPerRadius(theVal)
4426 ## Sets number of segments overriding value set by SetLocalLength()
4427 # Only for algoType == NETGEN_FULL
4428 # @ingroup l3_hypos_netgen
4429 def SetNumberOfSegments(self, theVal):
4430 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4432 ## Sets number of segments overriding value set by SetNumberOfSegments()
4433 # Only for algoType == NETGEN_FULL
4434 # @ingroup l3_hypos_netgen
4435 def SetLocalLength(self, theVal):
4436 self.Parameters(SIMPLE).SetLocalLength(theVal)
4438 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4439 # Overrides value set by LengthFromEdges()
4440 # Only for algoType == NETGEN_FULL
4441 # @ingroup l3_hypos_netgen
4442 def MaxElementArea(self, area):
4443 self.Parameters(SIMPLE).SetMaxElementArea(area)
4445 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4446 # Overrides value set by MaxElementArea()
4447 # Only for algoType == NETGEN_FULL
4448 # @ingroup l3_hypos_netgen
4449 def LengthFromEdges(self):
4450 self.Parameters(SIMPLE).LengthFromEdges()
4452 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4453 # Overrides value set by MaxElementVolume()
4454 # Only for algoType == NETGEN_FULL
4455 # @ingroup l3_hypos_netgen
4456 def LengthFromFaces(self):
4457 self.Parameters(SIMPLE).LengthFromFaces()
4459 ## To mesh "holes" in a solid or not. Default is to mesh.
4460 # @ingroup l3_hypos_ghs3dh
4461 def SetToMeshHoles(self, toMesh):
4462 # Parameter of GHS3D
4463 self.Parameters().SetToMeshHoles(toMesh)
4465 ## Set Optimization level:
4466 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
4467 # Default is Medium_Optimization
4468 # @ingroup l3_hypos_ghs3dh
4469 def SetOptimizationLevel(self, level):
4470 # Parameter of GHS3D
4471 self.Parameters().SetOptimizationLevel(level)
4473 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4474 # @ingroup l3_hypos_ghs3dh
4475 def SetMaximumMemory(self, MB):
4476 # Advanced parameter of GHS3D
4477 self.Parameters().SetMaximumMemory(MB)
4479 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4480 # automatic memory adjustment mode.
4481 # @ingroup l3_hypos_ghs3dh
4482 def SetInitialMemory(self, MB):
4483 # Advanced parameter of GHS3D
4484 self.Parameters().SetInitialMemory(MB)
4486 ## Path to working directory.
4487 # @ingroup l3_hypos_ghs3dh
4488 def SetWorkingDirectory(self, path):
4489 # Advanced parameter of GHS3D
4490 self.Parameters().SetWorkingDirectory(path)
4492 ## To keep working files or remove them. Log file remains in case of errors anyway.
4493 # @ingroup l3_hypos_ghs3dh
4494 def SetKeepFiles(self, toKeep):
4495 # Advanced parameter of GHS3D and GHS3DPRL
4496 self.Parameters().SetKeepFiles(toKeep)
4498 ## To set verbose level [0-10]. <ul>
4499 #<li> 0 - no standard output,
4500 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4501 # indicates when the final mesh is being saved. In addition the software
4502 # gives indication regarding the CPU time.
4503 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4504 # histogram of the skin mesh, quality statistics histogram together with
4505 # the characteristics of the final mesh.</ul>
4506 # @ingroup l3_hypos_ghs3dh
4507 def SetVerboseLevel(self, level):
4508 # Advanced parameter of GHS3D
4509 self.Parameters().SetVerboseLevel(level)
4511 ## To create new nodes.
4512 # @ingroup l3_hypos_ghs3dh
4513 def SetToCreateNewNodes(self, toCreate):
4514 # Advanced parameter of GHS3D
4515 self.Parameters().SetToCreateNewNodes(toCreate)
4517 ## To use boundary recovery version which tries to create mesh on a very poor
4518 # quality surface mesh.
4519 # @ingroup l3_hypos_ghs3dh
4520 def SetToUseBoundaryRecoveryVersion(self, toUse):
4521 # Advanced parameter of GHS3D
4522 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4524 ## Sets command line option as text.
4525 # @ingroup l3_hypos_ghs3dh
4526 def SetTextOption(self, option):
4527 # Advanced parameter of GHS3D
4528 self.Parameters().SetTextOption(option)
4530 ## Sets MED files name and path.
4531 def SetMEDName(self, value):
4532 self.Parameters().SetMEDName(value)
4534 ## Sets the number of partition of the initial mesh
4535 def SetNbPart(self, value):
4536 self.Parameters().SetNbPart(value)
4538 ## When big mesh, start tepal in background
4539 def SetBackground(self, value):
4540 self.Parameters().SetBackground(value)
4542 # Public class: Mesh_Hexahedron
4543 # ------------------------------
4545 ## Defines a hexahedron 3D algorithm
4547 # @ingroup l3_algos_basic
4548 class Mesh_Hexahedron(Mesh_Algorithm):
4553 ## Private constructor.
4554 def __init__(self, mesh, algoType=Hexa, geom=0):
4555 Mesh_Algorithm.__init__(self)
4557 self.algoType = algoType
4559 if algoType == Hexa:
4560 self.Create(mesh, geom, "Hexa_3D")
4563 elif algoType == Hexotic:
4564 import HexoticPlugin
4565 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4568 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4569 # @ingroup l3_hypos_hexotic
4570 def MinMaxQuad(self, min=3, max=8, quad=True):
4571 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4573 self.params.SetHexesMinLevel(min)
4574 self.params.SetHexesMaxLevel(max)
4575 self.params.SetHexoticQuadrangles(quad)
4578 # Deprecated, only for compatibility!
4579 # Public class: Mesh_Netgen
4580 # ------------------------------
4582 ## Defines a NETGEN-based 2D or 3D algorithm
4583 # that needs no discrete boundary (i.e. independent)
4585 # This class is deprecated, only for compatibility!
4588 # @ingroup l3_algos_basic
4589 class Mesh_Netgen(Mesh_Algorithm):
4593 ## Private constructor.
4594 def __init__(self, mesh, is3D, geom=0):
4595 Mesh_Algorithm.__init__(self)
4598 print "Warning: NETGENPlugin module has not been imported."
4602 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4606 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4609 ## Defines the hypothesis containing parameters of the algorithm
4610 def Parameters(self):
4612 hyp = self.Hypothesis("NETGEN_Parameters", [],
4613 "libNETGENEngine.so", UseExisting=0)
4615 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4616 "libNETGENEngine.so", UseExisting=0)
4619 # Public class: Mesh_Projection1D
4620 # ------------------------------
4622 ## Defines a projection 1D algorithm
4623 # @ingroup l3_algos_proj
4625 class Mesh_Projection1D(Mesh_Algorithm):
4627 ## Private constructor.
4628 def __init__(self, mesh, geom=0):
4629 Mesh_Algorithm.__init__(self)
4630 self.Create(mesh, geom, "Projection_1D")
4632 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4633 # a mesh pattern is taken, and, optionally, the association of vertices
4634 # between the source edge and a target edge (to which a hypothesis is assigned)
4635 # @param edge from which nodes distribution is taken
4636 # @param mesh from which nodes distribution is taken (optional)
4637 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4638 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4639 # to associate with \a srcV (optional)
4640 # @param UseExisting if ==true - searches for the existing hypothesis created with
4641 # the same parameters, else (default) - creates a new one
4642 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4643 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4645 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4646 hyp.SetSourceEdge( edge )
4647 if not mesh is None and isinstance(mesh, Mesh):
4648 mesh = mesh.GetMesh()
4649 hyp.SetSourceMesh( mesh )
4650 hyp.SetVertexAssociation( srcV, tgtV )
4653 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4654 #def CompareSourceEdge(self, hyp, args):
4655 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4659 # Public class: Mesh_Projection2D
4660 # ------------------------------
4662 ## Defines a projection 2D algorithm
4663 # @ingroup l3_algos_proj
4665 class Mesh_Projection2D(Mesh_Algorithm):
4667 ## Private constructor.
4668 def __init__(self, mesh, geom=0):
4669 Mesh_Algorithm.__init__(self)
4670 self.Create(mesh, geom, "Projection_2D")
4672 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4673 # a mesh pattern is taken, and, optionally, the association of vertices
4674 # between the source face and the target face (to which a hypothesis is assigned)
4675 # @param face from which the mesh pattern is taken
4676 # @param mesh from which the mesh pattern is taken (optional)
4677 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4678 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4679 # to associate with \a srcV1 (optional)
4680 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4681 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4682 # to associate with \a srcV2 (optional)
4683 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4684 # the same parameters, else (default) - forces the creation a new one
4686 # Note: all association vertices must belong to one edge of a face
4687 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4688 srcV2=None, tgtV2=None, UseExisting=0):
4689 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4691 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4692 hyp.SetSourceFace( face )
4693 if not mesh is None and isinstance(mesh, Mesh):
4694 mesh = mesh.GetMesh()
4695 hyp.SetSourceMesh( mesh )
4696 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4699 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4700 #def CompareSourceFace(self, hyp, args):
4701 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4704 # Public class: Mesh_Projection3D
4705 # ------------------------------
4707 ## Defines a projection 3D algorithm
4708 # @ingroup l3_algos_proj
4710 class Mesh_Projection3D(Mesh_Algorithm):
4712 ## Private constructor.
4713 def __init__(self, mesh, geom=0):
4714 Mesh_Algorithm.__init__(self)
4715 self.Create(mesh, geom, "Projection_3D")
4717 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4718 # the mesh pattern is taken, and, optionally, the association of vertices
4719 # between the source and the target solid (to which a hipothesis is assigned)
4720 # @param solid from where the mesh pattern is taken
4721 # @param mesh from where the mesh pattern is taken (optional)
4722 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4723 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4724 # to associate with \a srcV1 (optional)
4725 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4726 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4727 # to associate with \a srcV2 (optional)
4728 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4729 # the same parameters, else (default) - creates a new one
4731 # Note: association vertices must belong to one edge of a solid
4732 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4733 srcV2=0, tgtV2=0, UseExisting=0):
4734 hyp = self.Hypothesis("ProjectionSource3D",
4735 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4737 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4738 hyp.SetSource3DShape( solid )
4739 if not mesh is None and isinstance(mesh, Mesh):
4740 mesh = mesh.GetMesh()
4741 hyp.SetSourceMesh( mesh )
4742 if srcV1 and srcV2 and tgtV1 and tgtV2:
4743 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4744 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4747 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4748 #def CompareSourceShape3D(self, hyp, args):
4749 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4753 # Public class: Mesh_Prism
4754 # ------------------------
4756 ## Defines a 3D extrusion algorithm
4757 # @ingroup l3_algos_3dextr
4759 class Mesh_Prism3D(Mesh_Algorithm):
4761 ## Private constructor.
4762 def __init__(self, mesh, geom=0):
4763 Mesh_Algorithm.__init__(self)
4764 self.Create(mesh, geom, "Prism_3D")
4766 # Public class: Mesh_RadialPrism
4767 # -------------------------------
4769 ## Defines a Radial Prism 3D algorithm
4770 # @ingroup l3_algos_radialp
4772 class Mesh_RadialPrism3D(Mesh_Algorithm):
4774 ## Private constructor.
4775 def __init__(self, mesh, geom=0):
4776 Mesh_Algorithm.__init__(self)
4777 self.Create(mesh, geom, "RadialPrism_3D")
4779 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4780 self.nbLayers = None
4782 ## Return 3D hypothesis holding the 1D one
4783 def Get3DHypothesis(self):
4784 return self.distribHyp
4786 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4787 # hypothesis. Returns the created hypothesis
4788 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4789 #print "OwnHypothesis",hypType
4790 if not self.nbLayers is None:
4791 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4792 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4793 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4794 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4795 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4796 self.distribHyp.SetLayerDistribution( hyp )
4799 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4800 # prisms to build between the inner and outer shells
4801 # @param n number of layers
4802 # @param UseExisting if ==true - searches for the existing hypothesis created with
4803 # the same parameters, else (default) - creates a new one
4804 def NumberOfLayers(self, n, UseExisting=0):
4805 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4806 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4807 CompareMethod=self.CompareNumberOfLayers)
4808 self.nbLayers.SetNumberOfLayers( n )
4809 return self.nbLayers
4811 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4812 def CompareNumberOfLayers(self, hyp, args):
4813 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4815 ## Defines "LocalLength" hypothesis, specifying the segment length
4816 # to build between the inner and the outer shells
4817 # @param l the length of segments
4818 # @param p the precision of rounding
4819 def LocalLength(self, l, p=1e-07):
4820 hyp = self.OwnHypothesis("LocalLength", [l,p])
4825 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4826 # prisms to build between the inner and the outer shells.
4827 # @param n the number of layers
4828 # @param s the scale factor (optional)
4829 def NumberOfSegments(self, n, s=[]):
4831 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4833 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4834 hyp.SetDistrType( 1 )
4835 hyp.SetScaleFactor(s)
4836 hyp.SetNumberOfSegments(n)
4839 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4840 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4841 # @param start the length of the first segment
4842 # @param end the length of the last segment
4843 def Arithmetic1D(self, start, end ):
4844 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4845 hyp.SetLength(start, 1)
4846 hyp.SetLength(end , 0)
4849 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4850 # to build between the inner and the outer shells as geometric length increasing
4851 # @param start for the length of the first segment
4852 # @param end for the length of the last segment
4853 def StartEndLength(self, start, end):
4854 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4855 hyp.SetLength(start, 1)
4856 hyp.SetLength(end , 0)
4859 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4860 # to build between the inner and outer shells
4861 # @param fineness defines the quality of the mesh within the range [0-1]
4862 def AutomaticLength(self, fineness=0):
4863 hyp = self.OwnHypothesis("AutomaticLength")
4864 hyp.SetFineness( fineness )
4867 # Public class: Mesh_RadialQuadrangle1D2D
4868 # -------------------------------
4870 ## Defines a Radial Quadrangle 1D2D algorithm
4871 # @ingroup l2_algos_radialq
4873 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
4875 ## Private constructor.
4876 def __init__(self, mesh, geom=0):
4877 Mesh_Algorithm.__init__(self)
4878 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
4880 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
4881 self.nbLayers = None
4883 ## Return 2D hypothesis holding the 1D one
4884 def Get2DHypothesis(self):
4885 return self.distribHyp
4887 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4888 # hypothesis. Returns the created hypothesis
4889 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4890 #print "OwnHypothesis",hypType
4891 if not self.nbLayers is None:
4892 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4893 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4894 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4895 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4896 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4897 self.distribHyp.SetLayerDistribution( hyp )
4900 ## Defines "NumberOfLayers2D" hypothesis, specifying the number of layers
4901 # @param n number of layers
4902 # @param UseExisting if ==true - searches for the existing hypothesis created with
4903 # the same parameters, else (default) - creates a new one
4904 def NumberOfLayers2D(self, n, UseExisting=0):
4905 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4906 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
4907 CompareMethod=self.CompareNumberOfLayers)
4908 self.nbLayers.SetNumberOfLayers( n )
4909 return self.nbLayers
4911 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4912 def CompareNumberOfLayers(self, hyp, args):
4913 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4915 ## Defines "LocalLength" hypothesis, specifying the segment length
4916 # @param l the length of segments
4917 # @param p the precision of rounding
4918 def LocalLength(self, l, p=1e-07):
4919 hyp = self.OwnHypothesis("LocalLength", [l,p])
4924 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
4925 # @param n the number of layers
4926 # @param s the scale factor (optional)
4927 def NumberOfSegments(self, n, s=[]):
4929 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4931 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4932 hyp.SetDistrType( 1 )
4933 hyp.SetScaleFactor(s)
4934 hyp.SetNumberOfSegments(n)
4937 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4938 # with a length that changes in arithmetic progression
4939 # @param start the length of the first segment
4940 # @param end the length of the last segment
4941 def Arithmetic1D(self, start, end ):
4942 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4943 hyp.SetLength(start, 1)
4944 hyp.SetLength(end , 0)
4947 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4948 # as geometric length increasing
4949 # @param start for the length of the first segment
4950 # @param end for the length of the last segment
4951 def StartEndLength(self, start, end):
4952 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4953 hyp.SetLength(start, 1)
4954 hyp.SetLength(end , 0)
4957 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4958 # @param fineness defines the quality of the mesh within the range [0-1]
4959 def AutomaticLength(self, fineness=0):
4960 hyp = self.OwnHypothesis("AutomaticLength")
4961 hyp.SetFineness( fineness )
4965 # Private class: Mesh_UseExisting
4966 # -------------------------------
4967 class Mesh_UseExisting(Mesh_Algorithm):
4969 def __init__(self, dim, mesh, geom=0):
4971 self.Create(mesh, geom, "UseExisting_1D")
4973 self.Create(mesh, geom, "UseExisting_2D")
4976 import salome_notebook
4977 notebook = salome_notebook.notebook
4979 ##Return values of the notebook variables
4980 def ParseParameters(last, nbParams,nbParam, value):
4984 listSize = len(last)
4985 for n in range(0,nbParams):
4987 if counter < listSize:
4988 strResult = strResult + last[counter]
4990 strResult = strResult + ""
4992 if isinstance(value, str):
4993 if notebook.isVariable(value):
4994 result = notebook.get(value)
4995 strResult=strResult+value
4997 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
4999 strResult=strResult+str(value)
5001 if nbParams - 1 != counter:
5002 strResult=strResult+var_separator #":"
5004 return result, strResult
5006 #Wrapper class for StdMeshers_LocalLength hypothesis
5007 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5009 ## Set Length parameter value
5010 # @param length numerical value or name of variable from notebook
5011 def SetLength(self, length):
5012 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5013 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5014 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5016 ## Set Precision parameter value
5017 # @param precision numerical value or name of variable from notebook
5018 def SetPrecision(self, precision):
5019 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5020 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5021 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5023 #Registering the new proxy for LocalLength
5024 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5027 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5028 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5030 def SetLayerDistribution(self, hypo):
5031 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5032 hypo.ClearParameters();
5033 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5035 #Registering the new proxy for LayerDistribution
5036 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5038 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5039 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5041 ## Set Length parameter value
5042 # @param length numerical value or name of variable from notebook
5043 def SetLength(self, length):
5044 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5045 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5046 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5048 #Registering the new proxy for SegmentLengthAroundVertex
5049 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5052 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5053 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5055 ## Set Length parameter value
5056 # @param length numerical value or name of variable from notebook
5057 # @param isStart true is length is Start Length, otherwise false
5058 def SetLength(self, length, isStart):
5062 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5063 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5064 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5066 #Registering the new proxy for Arithmetic1D
5067 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5069 #Wrapper class for StdMeshers_Deflection1D hypothesis
5070 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5072 ## Set Deflection parameter value
5073 # @param deflection numerical value or name of variable from notebook
5074 def SetDeflection(self, deflection):
5075 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5076 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5077 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5079 #Registering the new proxy for Deflection1D
5080 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5082 #Wrapper class for StdMeshers_StartEndLength hypothesis
5083 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5085 ## Set Length parameter value
5086 # @param length numerical value or name of variable from notebook
5087 # @param isStart true is length is Start Length, otherwise false
5088 def SetLength(self, length, isStart):
5092 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5093 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5094 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5096 #Registering the new proxy for StartEndLength
5097 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5099 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5100 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5102 ## Set Max Element Area parameter value
5103 # @param area numerical value or name of variable from notebook
5104 def SetMaxElementArea(self, area):
5105 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5106 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5107 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5109 #Registering the new proxy for MaxElementArea
5110 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5113 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5114 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5116 ## Set Max Element Volume parameter value
5117 # @param area numerical value or name of variable from notebook
5118 def SetMaxElementVolume(self, volume):
5119 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5120 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5121 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5123 #Registering the new proxy for MaxElementVolume
5124 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5127 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5128 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5130 ## Set Number Of Layers parameter value
5131 # @param nbLayers numerical value or name of variable from notebook
5132 def SetNumberOfLayers(self, nbLayers):
5133 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5134 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5135 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5137 #Registering the new proxy for NumberOfLayers
5138 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5140 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5141 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5143 ## Set Number Of Segments parameter value
5144 # @param nbSeg numerical value or name of variable from notebook
5145 def SetNumberOfSegments(self, nbSeg):
5146 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5147 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5148 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5149 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5151 ## Set Scale Factor parameter value
5152 # @param factor numerical value or name of variable from notebook
5153 def SetScaleFactor(self, factor):
5154 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5155 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5156 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5158 #Registering the new proxy for NumberOfSegments
5159 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5162 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5163 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5165 ## Set Max Size parameter value
5166 # @param maxsize numerical value or name of variable from notebook
5167 def SetMaxSize(self, maxsize):
5168 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5169 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5170 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5171 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5173 ## Set Growth Rate parameter value
5174 # @param value numerical value or name of variable from notebook
5175 def SetGrowthRate(self, value):
5176 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5177 value, parameters = ParseParameters(lastParameters,4,2,value)
5178 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5179 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5181 ## Set Number of Segments per Edge parameter value
5182 # @param value numerical value or name of variable from notebook
5183 def SetNbSegPerEdge(self, value):
5184 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5185 value, parameters = ParseParameters(lastParameters,4,3,value)
5186 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5187 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5189 ## Set Number of Segments per Radius parameter value
5190 # @param value numerical value or name of variable from notebook
5191 def SetNbSegPerRadius(self, value):
5192 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5193 value, parameters = ParseParameters(lastParameters,4,4,value)
5194 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5195 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5197 #Registering the new proxy for NETGENPlugin_Hypothesis
5198 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5201 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5202 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5205 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5206 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5208 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5209 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5211 ## Set Number of Segments parameter value
5212 # @param nbSeg numerical value or name of variable from notebook
5213 def SetNumberOfSegments(self, nbSeg):
5214 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5215 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5216 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5217 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5219 ## Set Local Length parameter value
5220 # @param length numerical value or name of variable from notebook
5221 def SetLocalLength(self, length):
5222 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5223 length, parameters = ParseParameters(lastParameters,2,1,length)
5224 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5225 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5227 ## Set Max Element Area parameter value
5228 # @param area numerical value or name of variable from notebook
5229 def SetMaxElementArea(self, area):
5230 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5231 area, parameters = ParseParameters(lastParameters,2,2,area)
5232 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5233 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5235 def LengthFromEdges(self):
5236 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5238 value, parameters = ParseParameters(lastParameters,2,2,value)
5239 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5240 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5242 #Registering the new proxy for NETGEN_SimpleParameters_2D
5243 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5246 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5247 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5248 ## Set Max Element Volume parameter value
5249 # @param volume numerical value or name of variable from notebook
5250 def SetMaxElementVolume(self, volume):
5251 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5252 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5253 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5254 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5256 def LengthFromFaces(self):
5257 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5259 value, parameters = ParseParameters(lastParameters,3,3,value)
5260 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5261 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5263 #Registering the new proxy for NETGEN_SimpleParameters_3D
5264 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5266 class Pattern(SMESH._objref_SMESH_Pattern):
5268 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5270 if isinstance(theNodeIndexOnKeyPoint1,str):
5272 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5274 theNodeIndexOnKeyPoint1 -= 1
5275 theMesh.SetParameters(Parameters)
5276 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5278 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5281 if isinstance(theNode000Index,str):
5283 if isinstance(theNode001Index,str):
5285 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5287 theNode000Index -= 1
5289 theNode001Index -= 1
5290 theMesh.SetParameters(Parameters)
5291 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5293 #Registering the new proxy for Pattern
5294 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)