1 # Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author : Francis KLOSS, OCC
29 ## @defgroup l1_auxiliary Auxiliary methods and structures
30 ## @defgroup l1_creating Creating meshes
32 ## @defgroup l2_impexp Importing and exporting meshes
33 ## @defgroup l2_construct Constructing meshes
34 ## @defgroup l2_algorithms Defining Algorithms
36 ## @defgroup l3_algos_basic Basic meshing algorithms
37 ## @defgroup l3_algos_proj Projection Algorithms
38 ## @defgroup l3_algos_radialp Radial Prism
39 ## @defgroup l3_algos_segmarv Segments around Vertex
40 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
43 ## @defgroup l2_hypotheses Defining hypotheses
45 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
46 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
47 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
48 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
49 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
50 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
51 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
52 ## @defgroup l3_hypos_additi Additional Hypotheses
55 ## @defgroup l2_submeshes Constructing submeshes
56 ## @defgroup l2_compounds Building Compounds
57 ## @defgroup l2_editing Editing Meshes
60 ## @defgroup l1_meshinfo Mesh Information
61 ## @defgroup l1_controls Quality controls and Filtering
62 ## @defgroup l1_grouping Grouping elements
64 ## @defgroup l2_grps_create Creating groups
65 ## @defgroup l2_grps_edit Editing groups
66 ## @defgroup l2_grps_operon Using operations on groups
67 ## @defgroup l2_grps_delete Deleting Groups
70 ## @defgroup l1_modifying Modifying meshes
72 ## @defgroup l2_modif_add Adding nodes and elements
73 ## @defgroup l2_modif_del Removing nodes and elements
74 ## @defgroup l2_modif_edit Modifying nodes and elements
75 ## @defgroup l2_modif_renumber Renumbering nodes and elements
76 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
77 ## @defgroup l2_modif_movenode Moving nodes
78 ## @defgroup l2_modif_throughp Mesh through point
79 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
80 ## @defgroup l2_modif_unitetri Uniting triangles
81 ## @defgroup l2_modif_changori Changing orientation of elements
82 ## @defgroup l2_modif_cutquadr Cutting quadrangles
83 ## @defgroup l2_modif_smooth Smoothing
84 ## @defgroup l2_modif_extrurev Extrusion and Revolution
85 ## @defgroup l2_modif_patterns Pattern mapping
86 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
93 import SMESH # This is necessary for back compatibility
100 # import NETGENPlugin module if possible
108 ## @addtogroup l1_auxiliary
111 # Types of algorithms
124 NETGEN_1D2D3D = FULL_NETGEN
125 NETGEN_FULL = FULL_NETGEN
130 # MirrorType enumeration
131 POINT = SMESH_MeshEditor.POINT
132 AXIS = SMESH_MeshEditor.AXIS
133 PLANE = SMESH_MeshEditor.PLANE
135 # Smooth_Method enumeration
136 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
137 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
139 # Fineness enumeration (for NETGEN)
147 # Optimization level of GHS3D
148 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
150 # Topology treatment way of BLSURF
151 FromCAD, PreProcess, PreProcessPlus = 0,1,2
153 # Element size flag of BLSURF
154 DefaultSize, DefaultGeom, Custom = 0,0,1
156 PrecisionConfusion = 1e-07
158 # Salome notebook variable separator
159 variable_separator = ":"
161 # Parametrized substitute for PointStruct
162 class PointStructStr:
171 def __init__(self, xStr, yStr, zStr):
175 if isinstance(xStr, str) and notebook.isVariable(xStr):
176 self.x = notebook.get(xStr)
179 if isinstance(yStr, str) and notebook.isVariable(yStr):
180 self.y = notebook.get(yStr)
183 if isinstance(zStr, str) and notebook.isVariable(zStr):
184 self.z = notebook.get(zStr)
188 # Parametrized substitute for AxisStruct
204 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
211 if isinstance(xStr, str) and notebook.isVariable(xStr):
212 self.x = notebook.get(xStr)
215 if isinstance(yStr, str) and notebook.isVariable(yStr):
216 self.y = notebook.get(yStr)
219 if isinstance(zStr, str) and notebook.isVariable(zStr):
220 self.z = notebook.get(zStr)
223 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
224 self.dx = notebook.get(dxStr)
227 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
228 self.dy = notebook.get(dyStr)
231 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
232 self.dz = notebook.get(dzStr)
236 # Parametrized substitute for DirStruct
239 def __init__(self, pointStruct):
240 self.pointStruct = pointStruct
242 # Returns list of variable values from salome notebook
243 def ParsePointStruct(Point):
245 if isinstance(Point, PointStructStr):
246 Parameters = str(Point.xStr) + ":" + str(Point.yStr) + ":" + str(Point.zStr)
247 Point = PointStruct(Point.x, Point.y, Point.z)
248 return Point, Parameters
250 # Returns list of variable values from salome notebook
251 def ParseDirStruct(Dir):
253 if isinstance(Dir, DirStructStr):
254 pntStr = Dir.pointStruct
255 Parameters = str(pntStr.xStr) + ":" + str(pntStr.yStr) + ":" + str(pntStr.zStr)
256 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
257 Dir = DirStruct(Point)
258 return Dir, Parameters
260 # Returns list of variable values from salome notebook
261 def ParseAxisStruct(Axis):
263 if isinstance(Axis, AxisStructStr):
264 Parameters = str(Axis.xStr) + ":" + str(Axis.yStr) + ":" + str(Axis.zStr) + ":"
265 Parameters += str(Axis.dxStr) + ":" + str(Axis.dyStr) + ":" + str(Axis.dzStr)
266 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
267 return Axis, Parameters
269 def IsEqual(val1, val2, tol=PrecisionConfusion):
270 if abs(val1 - val2) < tol:
278 ior = salome.orb.object_to_string(obj)
279 sobj = salome.myStudy.FindObjectIOR(ior)
283 attr = sobj.FindAttribute("AttributeName")[1]
286 ## Sets a name to the object
287 def SetName(obj, name):
288 ior = salome.orb.object_to_string(obj)
289 sobj = salome.myStudy.FindObjectIOR(ior)
291 attr = sobj.FindAttribute("AttributeName")[1]
294 ## Prints error message if a hypothesis was not assigned.
295 def TreatHypoStatus(status, hypName, geomName, isAlgo):
297 hypType = "algorithm"
299 hypType = "hypothesis"
301 if status == HYP_UNKNOWN_FATAL :
302 reason = "for unknown reason"
303 elif status == HYP_INCOMPATIBLE :
304 reason = "this hypothesis mismatches the algorithm"
305 elif status == HYP_NOTCONFORM :
306 reason = "a non-conform mesh would be built"
307 elif status == HYP_ALREADY_EXIST :
308 reason = hypType + " of the same dimension is already assigned to this shape"
309 elif status == HYP_BAD_DIM :
310 reason = hypType + " mismatches the shape"
311 elif status == HYP_CONCURENT :
312 reason = "there are concurrent hypotheses on sub-shapes"
313 elif status == HYP_BAD_SUBSHAPE :
314 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
315 elif status == HYP_BAD_GEOMETRY:
316 reason = "geometry mismatches the expectation of the algorithm"
317 elif status == HYP_HIDDEN_ALGO:
318 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
319 elif status == HYP_HIDING_ALGO:
320 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
321 elif status == HYP_NEED_SHAPE:
322 reason = "Algorithm can't work without shape"
325 hypName = '"' + hypName + '"'
326 geomName= '"' + geomName+ '"'
327 if status < HYP_UNKNOWN_FATAL:
328 print hypName, "was assigned to", geomName,"but", reason
330 print hypName, "was not assigned to",geomName,":", reason
333 ## Converts an angle from degrees to radians
334 def DegreesToRadians(AngleInDegrees):
336 return AngleInDegrees * pi / 180.0
338 # end of l1_auxiliary
341 # All methods of this class are accessible directly from the smesh.py package.
342 class smeshDC(SMESH._objref_SMESH_Gen):
344 ## Sets the current study and Geometry component
345 # @ingroup l1_auxiliary
346 def init_smesh(self,theStudy,geompyD):
348 self.SetGeomEngine(geompyD)
349 self.SetCurrentStudy(theStudy)
351 ## Creates an empty Mesh. This mesh can have an underlying geometry.
352 # @param obj the Geometrical object on which the mesh is built. If not defined,
353 # the mesh will have no underlying geometry.
354 # @param name the name for the new mesh.
355 # @return an instance of Mesh class.
356 # @ingroup l2_construct
357 def Mesh(self, obj=0, name=0):
358 return Mesh(self,self.geompyD,obj,name)
360 ## Returns a long value from enumeration
361 # Should be used for SMESH.FunctorType enumeration
362 # @ingroup l1_controls
363 def EnumToLong(self,theItem):
366 ## Gets PointStruct from vertex
367 # @param theVertex a GEOM object(vertex)
368 # @return SMESH.PointStruct
369 # @ingroup l1_auxiliary
370 def GetPointStruct(self,theVertex):
371 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
372 return PointStruct(x,y,z)
374 ## Gets DirStruct from vector
375 # @param theVector a GEOM object(vector)
376 # @return SMESH.DirStruct
377 # @ingroup l1_auxiliary
378 def GetDirStruct(self,theVector):
379 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
380 if(len(vertices) != 2):
381 print "Error: vector object is incorrect."
383 p1 = self.geompyD.PointCoordinates(vertices[0])
384 p2 = self.geompyD.PointCoordinates(vertices[1])
385 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
386 dirst = DirStruct(pnt)
389 ## Makes DirStruct from a triplet
390 # @param x,y,z vector components
391 # @return SMESH.DirStruct
392 # @ingroup l1_auxiliary
393 def MakeDirStruct(self,x,y,z):
394 pnt = PointStruct(x,y,z)
395 return DirStruct(pnt)
397 ## Get AxisStruct from object
398 # @param theObj a GEOM object (line or plane)
399 # @return SMESH.AxisStruct
400 # @ingroup l1_auxiliary
401 def GetAxisStruct(self,theObj):
402 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
404 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
405 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
406 vertex1 = self.geompyD.PointCoordinates(vertex1)
407 vertex2 = self.geompyD.PointCoordinates(vertex2)
408 vertex3 = self.geompyD.PointCoordinates(vertex3)
409 vertex4 = self.geompyD.PointCoordinates(vertex4)
410 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
411 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
412 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] ]
413 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
415 elif len(edges) == 1:
416 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
417 p1 = self.geompyD.PointCoordinates( vertex1 )
418 p2 = self.geompyD.PointCoordinates( vertex2 )
419 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
423 # From SMESH_Gen interface:
424 # ------------------------
426 ## Sets the current mode
427 # @ingroup l1_auxiliary
428 def SetEmbeddedMode( self,theMode ):
429 #self.SetEmbeddedMode(theMode)
430 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
432 ## Gets the current mode
433 # @ingroup l1_auxiliary
434 def IsEmbeddedMode(self):
435 #return self.IsEmbeddedMode()
436 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
438 ## Sets the current study
439 # @ingroup l1_auxiliary
440 def SetCurrentStudy( self, theStudy ):
441 #self.SetCurrentStudy(theStudy)
442 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
444 ## Gets the current study
445 # @ingroup l1_auxiliary
446 def GetCurrentStudy(self):
447 #return self.GetCurrentStudy()
448 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
450 ## Creates a Mesh object importing data from the given UNV file
451 # @return an instance of Mesh class
453 def CreateMeshesFromUNV( self,theFileName ):
454 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
455 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
458 ## Creates a Mesh object(s) importing data from the given MED file
459 # @return a list of Mesh class instances
461 def CreateMeshesFromMED( self,theFileName ):
462 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
464 for iMesh in range(len(aSmeshMeshes)) :
465 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
466 aMeshes.append(aMesh)
467 return aMeshes, aStatus
469 ## Creates a Mesh object importing data from the given STL file
470 # @return an instance of Mesh class
472 def CreateMeshesFromSTL( self, theFileName ):
473 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
474 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
477 ## From SMESH_Gen interface
478 # @return the list of integer values
479 # @ingroup l1_auxiliary
480 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
481 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
483 ## From SMESH_Gen interface. Creates a pattern
484 # @return an instance of SMESH_Pattern
486 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
487 # @ingroup l2_modif_patterns
488 def GetPattern(self):
489 return SMESH._objref_SMESH_Gen.GetPattern(self)
491 ## Create a compound of Mesh objects
492 # @param theMeshArray array of Mesh objects
493 # @param theUniteIdenticalGroups flag used to unite identical mesh groups
494 # @param theMergeNodesAndElements flag used to merge mesh nodes and elements
495 # @param theMergeTolerance tolerance of merging
496 # @return a compound of Mesh objects
497 # @ingroup l1_auxiliary
498 def Concatenate( self, theMeshArray, theUniteIdenticalGroups, theMergeNodesAndElements, theMergeTolerance ):
499 theMergeTolerance,Parameters = geompyDC.ParseParameters(theMergeTolerance)
500 aMesh = SMESH._objref_SMESH_Gen.Concatenate( self, theMeshArray, theUniteIdenticalGroups, theMergeNodesAndElements, theMergeTolerance )
501 aMesh.SetParameters(Parameters)
504 ## Create a compound of Mesh objects
505 # @param theMeshArray array of Mesh objects
506 # @param theUniteIdenticalGroups flag used to unite identical mesh groups
507 # @param theMergeNodesAndElements flag used to merge mesh nodes and elements
508 # @param theMergeTolerance tolerance of merging
509 # @return a compound of Mesh objects
510 # @ingroup l1_auxiliary
511 def ConcatenateWithGroups( self, theMeshArray, theUniteIdenticalGroups, theMergeNodesAndElements, theMergeTolerance ):
512 theMergeTolerance,Parameters = geompyDC.ParseParameters(theMergeTolerance)
513 aMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups( self, theMeshArray, theUniteIdenticalGroups, theMergeNodesAndElements, theMergeTolerance )
514 aMesh.SetParameters(Parameters)
518 # Filtering. Auxiliary functions:
519 # ------------------------------
521 ## Creates an empty criterion
522 # @return SMESH.Filter.Criterion
523 # @ingroup l1_controls
524 def GetEmptyCriterion(self):
525 Type = self.EnumToLong(FT_Undefined)
526 Compare = self.EnumToLong(FT_Undefined)
530 UnaryOp = self.EnumToLong(FT_Undefined)
531 BinaryOp = self.EnumToLong(FT_Undefined)
534 Precision = -1 ##@1e-07
535 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
536 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
538 ## Creates a criterion by the given parameters
539 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
540 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
541 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
542 # @param Treshold the threshold value (range of ids as string, shape, numeric)
543 # @param UnaryOp FT_LogicalNOT or FT_Undefined
544 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
545 # FT_Undefined (must be for the last criterion of all criteria)
546 # @return SMESH.Filter.Criterion
547 # @ingroup l1_controls
548 def GetCriterion(self,elementType,
550 Compare = FT_EqualTo,
552 UnaryOp=FT_Undefined,
553 BinaryOp=FT_Undefined):
554 aCriterion = self.GetEmptyCriterion()
555 aCriterion.TypeOfElement = elementType
556 aCriterion.Type = self.EnumToLong(CritType)
560 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
561 aCriterion.Compare = self.EnumToLong(Compare)
562 elif Compare == "=" or Compare == "==":
563 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
565 aCriterion.Compare = self.EnumToLong(FT_LessThan)
567 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
569 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
572 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
573 FT_BelongToCylinder, FT_LyingOnGeom]:
574 # Checks the treshold
575 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
576 aCriterion.ThresholdStr = GetName(aTreshold)
577 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
579 print "Error: The treshold should be a shape."
581 elif CritType == FT_RangeOfIds:
582 # Checks the treshold
583 if isinstance(aTreshold, str):
584 aCriterion.ThresholdStr = aTreshold
586 print "Error: The treshold should be a string."
588 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
589 # At this point the treshold is unnecessary
590 if aTreshold == FT_LogicalNOT:
591 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
592 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
593 aCriterion.BinaryOp = aTreshold
597 aTreshold = float(aTreshold)
598 aCriterion.Threshold = aTreshold
600 print "Error: The treshold should be a number."
603 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
604 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
606 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
607 aCriterion.BinaryOp = self.EnumToLong(Treshold)
609 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
610 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
612 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
613 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
617 ## Creates a filter with the given parameters
618 # @param elementType the type of elements in the group
619 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
620 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
621 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
622 # @param UnaryOp FT_LogicalNOT or FT_Undefined
623 # @return SMESH_Filter
624 # @ingroup l1_controls
625 def GetFilter(self,elementType,
626 CritType=FT_Undefined,
629 UnaryOp=FT_Undefined):
630 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
631 aFilterMgr = self.CreateFilterManager()
632 aFilter = aFilterMgr.CreateFilter()
634 aCriteria.append(aCriterion)
635 aFilter.SetCriteria(aCriteria)
638 ## Creates a numerical functor by its type
639 # @param theCriterion FT_...; functor type
640 # @return SMESH_NumericalFunctor
641 # @ingroup l1_controls
642 def GetFunctor(self,theCriterion):
643 aFilterMgr = self.CreateFilterManager()
644 if theCriterion == FT_AspectRatio:
645 return aFilterMgr.CreateAspectRatio()
646 elif theCriterion == FT_AspectRatio3D:
647 return aFilterMgr.CreateAspectRatio3D()
648 elif theCriterion == FT_Warping:
649 return aFilterMgr.CreateWarping()
650 elif theCriterion == FT_MinimumAngle:
651 return aFilterMgr.CreateMinimumAngle()
652 elif theCriterion == FT_Taper:
653 return aFilterMgr.CreateTaper()
654 elif theCriterion == FT_Skew:
655 return aFilterMgr.CreateSkew()
656 elif theCriterion == FT_Area:
657 return aFilterMgr.CreateArea()
658 elif theCriterion == FT_Volume3D:
659 return aFilterMgr.CreateVolume3D()
660 elif theCriterion == FT_MultiConnection:
661 return aFilterMgr.CreateMultiConnection()
662 elif theCriterion == FT_MultiConnection2D:
663 return aFilterMgr.CreateMultiConnection2D()
664 elif theCriterion == FT_Length:
665 return aFilterMgr.CreateLength()
666 elif theCriterion == FT_Length2D:
667 return aFilterMgr.CreateLength2D()
669 print "Error: given parameter is not numerucal functor type."
673 #Registering the new proxy for SMESH_Gen
674 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
680 ## This class allows defining and managing a mesh.
681 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
682 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
683 # new nodes and elements and by changing the existing entities), to get information
684 # about a mesh and to export a mesh into different formats.
693 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
694 # sets the GUI name of this mesh to \a name.
695 # @param smeshpyD an instance of smeshDC class
696 # @param geompyD an instance of geompyDC class
697 # @param obj Shape to be meshed or SMESH_Mesh object
698 # @param name Study name of the mesh
699 # @ingroup l2_construct
700 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
701 self.smeshpyD=smeshpyD
706 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
708 self.mesh = self.smeshpyD.CreateMesh(self.geom)
709 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
712 self.mesh = self.smeshpyD.CreateEmptyMesh()
714 SetName(self.mesh, name)
716 SetName(self.mesh, GetName(obj))
719 self.geom = self.mesh.GetShapeToMesh()
721 self.editor = self.mesh.GetMeshEditor()
723 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
724 # @param theMesh a SMESH_Mesh object
725 # @ingroup l2_construct
726 def SetMesh(self, theMesh):
728 self.geom = self.mesh.GetShapeToMesh()
730 ## Returns the mesh, that is an instance of SMESH_Mesh interface
731 # @return a SMESH_Mesh object
732 # @ingroup l2_construct
736 ## Gets the name of the mesh
737 # @return the name of the mesh as a string
738 # @ingroup l2_construct
740 name = GetName(self.GetMesh())
743 ## Sets a name to the mesh
744 # @param name a new name of the mesh
745 # @ingroup l2_construct
746 def SetName(self, name):
747 SetName(self.GetMesh(), name)
749 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
750 # The subMesh object gives access to the IDs of nodes and elements.
751 # @param theSubObject a geometrical object (shape)
752 # @param theName a name for the submesh
753 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
754 # @ingroup l2_submeshes
755 def GetSubMesh(self, theSubObject, theName):
756 submesh = self.mesh.GetSubMesh(theSubObject, theName)
759 ## Returns the shape associated to the mesh
760 # @return a GEOM_Object
761 # @ingroup l2_construct
765 ## Associates the given shape to the mesh (entails the recreation of the mesh)
766 # @param geom the shape to be meshed (GEOM_Object)
767 # @ingroup l2_construct
768 def SetShape(self, geom):
769 self.mesh = self.smeshpyD.CreateMesh(geom)
771 ## Returns true if the hypotheses are defined well
772 # @param theSubObject a subshape of a mesh shape
773 # @return True or False
774 # @ingroup l2_construct
775 def IsReadyToCompute(self, theSubObject):
776 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
778 ## Returns errors of hypotheses definition.
779 # The list of errors is empty if everything is OK.
780 # @param theSubObject a subshape of a mesh shape
781 # @return a list of errors
782 # @ingroup l2_construct
783 def GetAlgoState(self, theSubObject):
784 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
786 ## Returns a geometrical object on which the given element was built.
787 # The returned geometrical object, if not nil, is either found in the
788 # study or published by this method with the given name
789 # @param theElementID the id of the mesh element
790 # @param theGeomName the user-defined name of the geometrical object
791 # @return GEOM::GEOM_Object instance
792 # @ingroup l2_construct
793 def GetGeometryByMeshElement(self, theElementID, theGeomName):
794 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
796 ## Returns the mesh dimension depending on the dimension of the underlying shape
797 # @return mesh dimension as an integer value [0,3]
798 # @ingroup l1_auxiliary
799 def MeshDimension(self):
800 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
801 if len( shells ) > 0 :
803 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
805 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
811 ## Creates a segment discretization 1D algorithm.
812 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
813 # \n If the optional \a geom parameter is not set, this algorithm is global.
814 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
815 # @param algo the type of the required algorithm. Possible values are:
817 # - smesh.PYTHON for discretization via a python function,
818 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
819 # @param geom If defined is the subshape to be meshed
820 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
821 # @ingroup l3_algos_basic
822 def Segment(self, algo=REGULAR, geom=0):
823 ## if Segment(geom) is called by mistake
824 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
825 algo, geom = geom, algo
826 if not algo: algo = REGULAR
829 return Mesh_Segment(self, geom)
831 return Mesh_Segment_Python(self, geom)
832 elif algo == COMPOSITE:
833 return Mesh_CompositeSegment(self, geom)
835 return Mesh_Segment(self, geom)
837 ## Enables creation of nodes and segments usable by 2D algoritms.
838 # The added nodes and segments must be bound to edges and vertices by
839 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
840 # If the optional \a geom parameter is not set, this algorithm is global.
841 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
842 # @param geom the subshape to be manually meshed
843 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
844 # @ingroup l3_algos_basic
845 def UseExistingSegments(self, geom=0):
846 algo = Mesh_UseExisting(1,self,geom)
847 return algo.GetAlgorithm()
849 ## Enables creation of nodes and faces usable by 3D algoritms.
850 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
851 # and SetMeshElementOnShape()
852 # If the optional \a geom parameter is not set, this algorithm is global.
853 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
854 # @param geom the subshape to be manually meshed
855 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
856 # @ingroup l3_algos_basic
857 def UseExistingFaces(self, geom=0):
858 algo = Mesh_UseExisting(2,self,geom)
859 return algo.GetAlgorithm()
861 ## Creates a triangle 2D algorithm for faces.
862 # If the optional \a geom parameter is not set, this algorithm is global.
863 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
864 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
865 # @param geom If defined, the subshape to be meshed (GEOM_Object)
866 # @return an instance of Mesh_Triangle algorithm
867 # @ingroup l3_algos_basic
868 def Triangle(self, algo=MEFISTO, geom=0):
869 ## if Triangle(geom) is called by mistake
870 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
874 return Mesh_Triangle(self, algo, geom)
876 ## Creates a quadrangle 2D algorithm for faces.
877 # If the optional \a geom parameter is not set, this algorithm is global.
878 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
879 # @param geom If defined, the subshape to be meshed (GEOM_Object)
880 # @return an instance of Mesh_Quadrangle algorithm
881 # @ingroup l3_algos_basic
882 def Quadrangle(self, geom=0):
883 return Mesh_Quadrangle(self, geom)
885 ## Creates a tetrahedron 3D algorithm for solids.
886 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
887 # If the optional \a geom parameter is not set, this algorithm is global.
888 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
889 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
890 # @param geom If defined, the subshape to be meshed (GEOM_Object)
891 # @return an instance of Mesh_Tetrahedron algorithm
892 # @ingroup l3_algos_basic
893 def Tetrahedron(self, algo=NETGEN, geom=0):
894 ## if Tetrahedron(geom) is called by mistake
895 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
896 algo, geom = geom, algo
897 if not algo: algo = NETGEN
899 return Mesh_Tetrahedron(self, algo, geom)
901 ## Creates a hexahedron 3D algorithm for solids.
902 # If the optional \a geom parameter is not set, this algorithm is global.
903 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
904 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
905 # @param geom If defined, the subshape to be meshed (GEOM_Object)
906 # @return an instance of Mesh_Hexahedron algorithm
907 # @ingroup l3_algos_basic
908 def Hexahedron(self, algo=Hexa, geom=0):
909 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
910 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
911 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
912 elif geom == 0: algo, geom = Hexa, algo
913 return Mesh_Hexahedron(self, algo, geom)
915 ## Deprecated, used only for compatibility!
916 # @return an instance of Mesh_Netgen algorithm
917 # @ingroup l3_algos_basic
918 def Netgen(self, is3D, geom=0):
919 return Mesh_Netgen(self, is3D, geom)
921 ## Creates a projection 1D algorithm for edges.
922 # If the optional \a geom parameter is not set, this algorithm is global.
923 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
924 # @param geom If defined, the subshape to be meshed
925 # @return an instance of Mesh_Projection1D algorithm
926 # @ingroup l3_algos_proj
927 def Projection1D(self, geom=0):
928 return Mesh_Projection1D(self, geom)
930 ## Creates a projection 2D algorithm for faces.
931 # If the optional \a geom parameter is not set, this algorithm is global.
932 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
933 # @param geom If defined, the subshape to be meshed
934 # @return an instance of Mesh_Projection2D algorithm
935 # @ingroup l3_algos_proj
936 def Projection2D(self, geom=0):
937 return Mesh_Projection2D(self, geom)
939 ## Creates a projection 3D algorithm for solids.
940 # If the optional \a geom parameter is not set, this algorithm is global.
941 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
942 # @param geom If defined, the subshape to be meshed
943 # @return an instance of Mesh_Projection3D algorithm
944 # @ingroup l3_algos_proj
945 def Projection3D(self, geom=0):
946 return Mesh_Projection3D(self, geom)
948 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
949 # If the optional \a geom parameter is not set, this algorithm is global.
950 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
951 # @param geom If defined, the subshape to be meshed
952 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
953 # @ingroup l3_algos_radialp l3_algos_3dextr
954 def Prism(self, geom=0):
958 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
959 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
960 if nbSolids == 0 or nbSolids == nbShells:
961 return Mesh_Prism3D(self, geom)
962 return Mesh_RadialPrism3D(self, geom)
964 ## Computes the mesh and returns the status of the computation
965 # @return True or False
966 # @ingroup l2_construct
967 def Compute(self, geom=0):
968 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
970 geom = self.mesh.GetShapeToMesh()
975 ok = self.smeshpyD.Compute(self.mesh, geom)
976 except SALOME.SALOME_Exception, ex:
977 print "Mesh computation failed, exception caught:"
978 print " ", ex.details.text
981 print "Mesh computation failed, exception caught:"
982 traceback.print_exc()
984 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
995 reason = '%s %sD algorithm is missing' % (glob, dim)
996 elif err.state == HYP_MISSING:
997 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
998 % (glob, dim, name, dim))
999 elif err.state == HYP_NOTCONFORM:
1000 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1001 elif err.state == HYP_BAD_PARAMETER:
1002 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1003 % ( glob, dim, name ))
1004 elif err.state == HYP_BAD_GEOMETRY:
1005 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1006 'geometry' % ( glob, dim, name ))
1008 reason = "For unknown reason."+\
1009 " Revise Mesh.Compute() implementation in smeshDC.py!"
1011 if allReasons != "":
1014 allReasons += reason
1016 if allReasons != "":
1017 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1021 print '"' + GetName(self.mesh) + '"',"has not been computed."
1024 if salome.sg.hasDesktop():
1025 smeshgui = salome.ImportComponentGUI("SMESH")
1026 smeshgui.Init(salome.myStudyId)
1027 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1028 salome.sg.updateObjBrowser(1)
1032 ## Removes all nodes and elements
1033 # @ingroup l2_construct
1036 if salome.sg.hasDesktop():
1037 smeshgui = salome.ImportComponentGUI("SMESH")
1038 smeshgui.Init(salome.myStudyId)
1039 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1040 salome.sg.updateObjBrowser(1)
1042 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1043 # @param fineness [0,-1] defines mesh fineness
1044 # @return True or False
1045 # @ingroup l3_algos_basic
1046 def AutomaticTetrahedralization(self, fineness=0):
1047 dim = self.MeshDimension()
1049 self.RemoveGlobalHypotheses()
1050 self.Segment().AutomaticLength(fineness)
1052 self.Triangle().LengthFromEdges()
1055 self.Tetrahedron(NETGEN)
1057 return self.Compute()
1059 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1060 # @param fineness [0,-1] defines mesh fineness
1061 # @return True or False
1062 # @ingroup l3_algos_basic
1063 def AutomaticHexahedralization(self, fineness=0):
1064 dim = self.MeshDimension()
1065 # assign the hypotheses
1066 self.RemoveGlobalHypotheses()
1067 self.Segment().AutomaticLength(fineness)
1074 return self.Compute()
1076 ## Assigns a hypothesis
1077 # @param hyp a hypothesis to assign
1078 # @param geom a subhape of mesh geometry
1079 # @return SMESH.Hypothesis_Status
1080 # @ingroup l2_hypotheses
1081 def AddHypothesis(self, hyp, geom=0):
1082 if isinstance( hyp, Mesh_Algorithm ):
1083 hyp = hyp.GetAlgorithm()
1088 geom = self.mesh.GetShapeToMesh()
1090 status = self.mesh.AddHypothesis(geom, hyp)
1091 isAlgo = hyp._narrow( SMESH_Algo )
1092 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1095 ## Unassigns a hypothesis
1096 # @param hyp a hypothesis to unassign
1097 # @param geom a subshape of mesh geometry
1098 # @return SMESH.Hypothesis_Status
1099 # @ingroup l2_hypotheses
1100 def RemoveHypothesis(self, hyp, geom=0):
1101 if isinstance( hyp, Mesh_Algorithm ):
1102 hyp = hyp.GetAlgorithm()
1107 status = self.mesh.RemoveHypothesis(geom, hyp)
1110 ## Gets the list of hypotheses added on a geometry
1111 # @param geom a subshape of mesh geometry
1112 # @return the sequence of SMESH_Hypothesis
1113 # @ingroup l2_hypotheses
1114 def GetHypothesisList(self, geom):
1115 return self.mesh.GetHypothesisList( geom )
1117 ## Removes all global hypotheses
1118 # @ingroup l2_hypotheses
1119 def RemoveGlobalHypotheses(self):
1120 current_hyps = self.mesh.GetHypothesisList( self.geom )
1121 for hyp in current_hyps:
1122 self.mesh.RemoveHypothesis( self.geom, hyp )
1126 ## Creates a mesh group based on the geometric object \a grp
1127 # and gives a \a name, \n if this parameter is not defined
1128 # the name is the same as the geometric group name \n
1129 # Note: Works like GroupOnGeom().
1130 # @param grp a geometric group, a vertex, an edge, a face or a solid
1131 # @param name the name of the mesh group
1132 # @return SMESH_GroupOnGeom
1133 # @ingroup l2_grps_create
1134 def Group(self, grp, name=""):
1135 return self.GroupOnGeom(grp, name)
1137 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1138 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1139 # @param f the file name
1140 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1141 # @ingroup l2_impexp
1142 def ExportToMED(self, f, version, opt=0):
1143 self.mesh.ExportToMED(f, opt, version)
1145 ## Exports the mesh in a file in MED format
1146 # @param f is the file name
1147 # @param auto_groups boolean parameter for creating/not creating
1148 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1149 # the typical use is auto_groups=false.
1150 # @param version MED format version(MED_V2_1 or MED_V2_2)
1151 # @ingroup l2_impexp
1152 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1153 self.mesh.ExportToMED(f, auto_groups, version)
1155 ## Exports the mesh in a file in DAT format
1156 # @param f the file name
1157 # @ingroup l2_impexp
1158 def ExportDAT(self, f):
1159 self.mesh.ExportDAT(f)
1161 ## Exports the mesh in a file in UNV format
1162 # @param f the file name
1163 # @ingroup l2_impexp
1164 def ExportUNV(self, f):
1165 self.mesh.ExportUNV(f)
1167 ## Export the mesh in a file in STL format
1168 # @param f the file name
1169 # @param ascii defines the file encoding
1170 # @ingroup l2_impexp
1171 def ExportSTL(self, f, ascii=1):
1172 self.mesh.ExportSTL(f, ascii)
1175 # Operations with groups:
1176 # ----------------------
1178 ## Creates an empty mesh group
1179 # @param elementType the type of elements in the group
1180 # @param name the name of the mesh group
1181 # @return SMESH_Group
1182 # @ingroup l2_grps_create
1183 def CreateEmptyGroup(self, elementType, name):
1184 return self.mesh.CreateGroup(elementType, name)
1186 ## Creates a mesh group based on the geometrical object \a grp
1187 # and gives a \a name, \n if this parameter is not defined
1188 # the name is the same as the geometrical group name
1189 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1190 # @param name the name of the mesh group
1191 # @param typ the type of elements in the group. If not set, it is
1192 # automatically detected by the type of the geometry
1193 # @return SMESH_GroupOnGeom
1194 # @ingroup l2_grps_create
1195 def GroupOnGeom(self, grp, name="", typ=None):
1197 name = grp.GetName()
1200 tgeo = str(grp.GetShapeType())
1201 if tgeo == "VERTEX":
1203 elif tgeo == "EDGE":
1205 elif tgeo == "FACE":
1207 elif tgeo == "SOLID":
1209 elif tgeo == "SHELL":
1211 elif tgeo == "COMPOUND":
1212 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1213 print "Mesh.Group: empty geometric group", GetName( grp )
1215 tgeo = self.geompyD.GetType(grp)
1216 if tgeo == geompyDC.ShapeType["VERTEX"]:
1218 elif tgeo == geompyDC.ShapeType["EDGE"]:
1220 elif tgeo == geompyDC.ShapeType["FACE"]:
1222 elif tgeo == geompyDC.ShapeType["SOLID"]:
1226 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1229 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1231 ## Creates a mesh group by the given ids of elements
1232 # @param groupName the name of the mesh group
1233 # @param elementType the type of elements in the group
1234 # @param elemIDs the list of ids
1235 # @return SMESH_Group
1236 # @ingroup l2_grps_create
1237 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1238 group = self.mesh.CreateGroup(elementType, groupName)
1242 ## Creates a mesh group by the given conditions
1243 # @param groupName the name of the mesh group
1244 # @param elementType the type of elements in the group
1245 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1246 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1247 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1248 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1249 # @return SMESH_Group
1250 # @ingroup l2_grps_create
1254 CritType=FT_Undefined,
1257 UnaryOp=FT_Undefined):
1258 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1259 group = self.MakeGroupByCriterion(groupName, aCriterion)
1262 ## Creates a mesh group by the given criterion
1263 # @param groupName the name of the mesh group
1264 # @param Criterion the instance of Criterion class
1265 # @return SMESH_Group
1266 # @ingroup l2_grps_create
1267 def MakeGroupByCriterion(self, groupName, Criterion):
1268 aFilterMgr = self.smeshpyD.CreateFilterManager()
1269 aFilter = aFilterMgr.CreateFilter()
1271 aCriteria.append(Criterion)
1272 aFilter.SetCriteria(aCriteria)
1273 group = self.MakeGroupByFilter(groupName, aFilter)
1276 ## Creates a mesh group by the given criteria (list of criteria)
1277 # @param groupName the name of the mesh group
1278 # @param theCriteria the list of criteria
1279 # @return SMESH_Group
1280 # @ingroup l2_grps_create
1281 def MakeGroupByCriteria(self, groupName, theCriteria):
1282 aFilterMgr = self.smeshpyD.CreateFilterManager()
1283 aFilter = aFilterMgr.CreateFilter()
1284 aFilter.SetCriteria(theCriteria)
1285 group = self.MakeGroupByFilter(groupName, aFilter)
1288 ## Creates a mesh group by the given filter
1289 # @param groupName the name of the mesh group
1290 # @param theFilter the instance of Filter class
1291 # @return SMESH_Group
1292 # @ingroup l2_grps_create
1293 def MakeGroupByFilter(self, groupName, theFilter):
1294 anIds = theFilter.GetElementsId(self.mesh)
1295 anElemType = theFilter.GetElementType()
1296 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1299 ## Passes mesh elements through the given filter and return IDs of fitting elements
1300 # @param theFilter SMESH_Filter
1301 # @return a list of ids
1302 # @ingroup l1_controls
1303 def GetIdsFromFilter(self, theFilter):
1304 return theFilter.GetElementsId(self.mesh)
1306 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1307 # Returns a list of special structures (borders).
1308 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1309 # @ingroup l1_controls
1310 def GetFreeBorders(self):
1311 aFilterMgr = self.smeshpyD.CreateFilterManager()
1312 aPredicate = aFilterMgr.CreateFreeEdges()
1313 aPredicate.SetMesh(self.mesh)
1314 aBorders = aPredicate.GetBorders()
1318 # @ingroup l2_grps_delete
1319 def RemoveGroup(self, group):
1320 self.mesh.RemoveGroup(group)
1322 ## Removes a group with its contents
1323 # @ingroup l2_grps_delete
1324 def RemoveGroupWithContents(self, group):
1325 self.mesh.RemoveGroupWithContents(group)
1327 ## Gets the list of groups existing in the mesh
1328 # @return a sequence of SMESH_GroupBase
1329 # @ingroup l2_grps_create
1330 def GetGroups(self):
1331 return self.mesh.GetGroups()
1333 ## Gets the number of groups existing in the mesh
1334 # @return the quantity of groups as an integer value
1335 # @ingroup l2_grps_create
1337 return self.mesh.NbGroups()
1339 ## Gets the list of names of groups existing in the mesh
1340 # @return list of strings
1341 # @ingroup l2_grps_create
1342 def GetGroupNames(self):
1343 groups = self.GetGroups()
1345 for group in groups:
1346 names.append(group.GetName())
1349 ## Produces a union of two groups
1350 # A new group is created. All mesh elements that are
1351 # present in the initial groups are added to the new one
1352 # @return an instance of SMESH_Group
1353 # @ingroup l2_grps_operon
1354 def UnionGroups(self, group1, group2, name):
1355 return self.mesh.UnionGroups(group1, group2, name)
1357 ## Prodices an intersection of two groups
1358 # A new group is created. All mesh elements that are common
1359 # for the two initial groups are added to the new one.
1360 # @return an instance of SMESH_Group
1361 # @ingroup l2_grps_operon
1362 def IntersectGroups(self, group1, group2, name):
1363 return self.mesh.IntersectGroups(group1, group2, name)
1365 ## Produces a cut of two groups
1366 # A new group is created. All mesh elements that are present in
1367 # the main group but are not present in the tool group are added to the new one
1368 # @return an instance of SMESH_Group
1369 # @ingroup l2_grps_operon
1370 def CutGroups(self, mainGroup, toolGroup, name):
1371 return self.mesh.CutGroups(mainGroup, toolGroup, name)
1374 # Get some info about mesh:
1375 # ------------------------
1377 ## Returns the log of nodes and elements added or removed
1378 # since the previous clear of the log.
1379 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1380 # @return list of log_block structures:
1385 # @ingroup l1_auxiliary
1386 def GetLog(self, clearAfterGet):
1387 return self.mesh.GetLog(clearAfterGet)
1389 ## Clears the log of nodes and elements added or removed since the previous
1390 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1391 # @ingroup l1_auxiliary
1393 self.mesh.ClearLog()
1395 ## Toggles auto color mode on the object.
1396 # @param theAutoColor the flag which toggles auto color mode.
1397 # @ingroup l1_auxiliary
1398 def SetAutoColor(self, theAutoColor):
1399 self.mesh.SetAutoColor(theAutoColor)
1401 ## Gets flag of object auto color mode.
1402 # @return True or False
1403 # @ingroup l1_auxiliary
1404 def GetAutoColor(self):
1405 return self.mesh.GetAutoColor()
1407 ## Gets the internal ID
1408 # @return integer value, which is the internal Id of the mesh
1409 # @ingroup l1_auxiliary
1411 return self.mesh.GetId()
1414 # @return integer value, which is the study Id of the mesh
1415 # @ingroup l1_auxiliary
1416 def GetStudyId(self):
1417 return self.mesh.GetStudyId()
1419 ## Checks the group names for duplications.
1420 # Consider the maximum group name length stored in MED file.
1421 # @return True or False
1422 # @ingroup l1_auxiliary
1423 def HasDuplicatedGroupNamesMED(self):
1424 return self.mesh.HasDuplicatedGroupNamesMED()
1426 ## Obtains the mesh editor tool
1427 # @return an instance of SMESH_MeshEditor
1428 # @ingroup l1_modifying
1429 def GetMeshEditor(self):
1430 return self.mesh.GetMeshEditor()
1433 # @return an instance of SALOME_MED::MESH
1434 # @ingroup l1_auxiliary
1435 def GetMEDMesh(self):
1436 return self.mesh.GetMEDMesh()
1439 # Get informations about mesh contents:
1440 # ------------------------------------
1442 ## Returns the number of nodes in the mesh
1443 # @return an integer value
1444 # @ingroup l1_meshinfo
1446 return self.mesh.NbNodes()
1448 ## Returns the number of elements in the mesh
1449 # @return an integer value
1450 # @ingroup l1_meshinfo
1451 def NbElements(self):
1452 return self.mesh.NbElements()
1454 ## Returns the number of edges in the mesh
1455 # @return an integer value
1456 # @ingroup l1_meshinfo
1458 return self.mesh.NbEdges()
1460 ## Returns the number of edges with the given order in the mesh
1461 # @param elementOrder the order of elements:
1462 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1463 # @return an integer value
1464 # @ingroup l1_meshinfo
1465 def NbEdgesOfOrder(self, elementOrder):
1466 return self.mesh.NbEdgesOfOrder(elementOrder)
1468 ## Returns the number of faces in the mesh
1469 # @return an integer value
1470 # @ingroup l1_meshinfo
1472 return self.mesh.NbFaces()
1474 ## Returns the number of faces with the given order in the mesh
1475 # @param elementOrder the order of elements:
1476 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1477 # @return an integer value
1478 # @ingroup l1_meshinfo
1479 def NbFacesOfOrder(self, elementOrder):
1480 return self.mesh.NbFacesOfOrder(elementOrder)
1482 ## Returns the number of triangles in the mesh
1483 # @return an integer value
1484 # @ingroup l1_meshinfo
1485 def NbTriangles(self):
1486 return self.mesh.NbTriangles()
1488 ## Returns the number of triangles with the given order in the mesh
1489 # @param elementOrder is the order of elements:
1490 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1491 # @return an integer value
1492 # @ingroup l1_meshinfo
1493 def NbTrianglesOfOrder(self, elementOrder):
1494 return self.mesh.NbTrianglesOfOrder(elementOrder)
1496 ## Returns the number of quadrangles in the mesh
1497 # @return an integer value
1498 # @ingroup l1_meshinfo
1499 def NbQuadrangles(self):
1500 return self.mesh.NbQuadrangles()
1502 ## Returns the number of quadrangles with the given order in the mesh
1503 # @param elementOrder the order of elements:
1504 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1505 # @return an integer value
1506 # @ingroup l1_meshinfo
1507 def NbQuadranglesOfOrder(self, elementOrder):
1508 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1510 ## Returns the number of polygons in the mesh
1511 # @return an integer value
1512 # @ingroup l1_meshinfo
1513 def NbPolygons(self):
1514 return self.mesh.NbPolygons()
1516 ## Returns the number of volumes in the mesh
1517 # @return an integer value
1518 # @ingroup l1_meshinfo
1519 def NbVolumes(self):
1520 return self.mesh.NbVolumes()
1522 ## Returns the number of volumes with the given order in the mesh
1523 # @param elementOrder the order of elements:
1524 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1525 # @return an integer value
1526 # @ingroup l1_meshinfo
1527 def NbVolumesOfOrder(self, elementOrder):
1528 return self.mesh.NbVolumesOfOrder(elementOrder)
1530 ## Returns the number of tetrahedrons in the mesh
1531 # @return an integer value
1532 # @ingroup l1_meshinfo
1534 return self.mesh.NbTetras()
1536 ## Returns the number of tetrahedrons with the given order in the mesh
1537 # @param elementOrder the order of elements:
1538 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1539 # @return an integer value
1540 # @ingroup l1_meshinfo
1541 def NbTetrasOfOrder(self, elementOrder):
1542 return self.mesh.NbTetrasOfOrder(elementOrder)
1544 ## Returns the number of hexahedrons in the mesh
1545 # @return an integer value
1546 # @ingroup l1_meshinfo
1548 return self.mesh.NbHexas()
1550 ## Returns the number of hexahedrons with the given order in the mesh
1551 # @param elementOrder the order of elements:
1552 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1553 # @return an integer value
1554 # @ingroup l1_meshinfo
1555 def NbHexasOfOrder(self, elementOrder):
1556 return self.mesh.NbHexasOfOrder(elementOrder)
1558 ## Returns the number of pyramids in the mesh
1559 # @return an integer value
1560 # @ingroup l1_meshinfo
1561 def NbPyramids(self):
1562 return self.mesh.NbPyramids()
1564 ## Returns the number of pyramids with the given order in the mesh
1565 # @param elementOrder the order of elements:
1566 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1567 # @return an integer value
1568 # @ingroup l1_meshinfo
1569 def NbPyramidsOfOrder(self, elementOrder):
1570 return self.mesh.NbPyramidsOfOrder(elementOrder)
1572 ## Returns the number of prisms in the mesh
1573 # @return an integer value
1574 # @ingroup l1_meshinfo
1576 return self.mesh.NbPrisms()
1578 ## Returns the number of prisms with the given order in the mesh
1579 # @param elementOrder the order of elements:
1580 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1581 # @return an integer value
1582 # @ingroup l1_meshinfo
1583 def NbPrismsOfOrder(self, elementOrder):
1584 return self.mesh.NbPrismsOfOrder(elementOrder)
1586 ## Returns the number of polyhedrons in the mesh
1587 # @return an integer value
1588 # @ingroup l1_meshinfo
1589 def NbPolyhedrons(self):
1590 return self.mesh.NbPolyhedrons()
1592 ## Returns the number of submeshes in the mesh
1593 # @return an integer value
1594 # @ingroup l1_meshinfo
1595 def NbSubMesh(self):
1596 return self.mesh.NbSubMesh()
1598 ## Returns the list of mesh elements IDs
1599 # @return the list of integer values
1600 # @ingroup l1_meshinfo
1601 def GetElementsId(self):
1602 return self.mesh.GetElementsId()
1604 ## Returns the list of IDs of mesh elements with the given type
1605 # @param elementType the required type of elements
1606 # @return list of integer values
1607 # @ingroup l1_meshinfo
1608 def GetElementsByType(self, elementType):
1609 return self.mesh.GetElementsByType(elementType)
1611 ## Returns the list of mesh nodes IDs
1612 # @return the list of integer values
1613 # @ingroup l1_meshinfo
1614 def GetNodesId(self):
1615 return self.mesh.GetNodesId()
1617 # Get the information about mesh elements:
1618 # ------------------------------------
1620 ## Returns the type of mesh element
1621 # @return the value from SMESH::ElementType enumeration
1622 # @ingroup l1_meshinfo
1623 def GetElementType(self, id, iselem):
1624 return self.mesh.GetElementType(id, iselem)
1626 ## Returns the list of submesh elements IDs
1627 # @param Shape a geom object(subshape) IOR
1628 # Shape must be the subshape of a ShapeToMesh()
1629 # @return the list of integer values
1630 # @ingroup l1_meshinfo
1631 def GetSubMeshElementsId(self, Shape):
1632 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1633 ShapeID = Shape.GetSubShapeIndices()[0]
1636 return self.mesh.GetSubMeshElementsId(ShapeID)
1638 ## Returns the list of submesh nodes IDs
1639 # @param Shape a geom object(subshape) IOR
1640 # Shape must be the subshape of a ShapeToMesh()
1641 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1642 # @return the list of integer values
1643 # @ingroup l1_meshinfo
1644 def GetSubMeshNodesId(self, Shape, all):
1645 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1646 ShapeID = Shape.GetSubShapeIndices()[0]
1649 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1651 ## Returns the list of IDs of submesh elements with the given type
1652 # @param Shape a geom object(subshape) IOR
1653 # Shape must be a subshape of a ShapeToMesh()
1654 # @return the list of integer values
1655 # @ingroup l1_meshinfo
1656 def GetSubMeshElementType(self, Shape):
1657 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1658 ShapeID = Shape.GetSubShapeIndices()[0]
1661 return self.mesh.GetSubMeshElementType(ShapeID)
1663 ## Gets the mesh description
1664 # @return string value
1665 # @ingroup l1_meshinfo
1667 return self.mesh.Dump()
1670 # Get the information about nodes and elements of a mesh by its IDs:
1671 # -----------------------------------------------------------
1673 ## Gets XYZ coordinates of a node
1674 # \n If there is no nodes for the given ID - returns an empty list
1675 # @return a list of double precision values
1676 # @ingroup l1_meshinfo
1677 def GetNodeXYZ(self, id):
1678 return self.mesh.GetNodeXYZ(id)
1680 ## Returns list of IDs of inverse elements for the given node
1681 # \n If there is no node for the given ID - returns an empty list
1682 # @return a list of integer values
1683 # @ingroup l1_meshinfo
1684 def GetNodeInverseElements(self, id):
1685 return self.mesh.GetNodeInverseElements(id)
1687 ## @brief Returns the position of a node on the shape
1688 # @return SMESH::NodePosition
1689 # @ingroup l1_meshinfo
1690 def GetNodePosition(self,NodeID):
1691 return self.mesh.GetNodePosition(NodeID)
1693 ## If the given element is a node, returns the ID of shape
1694 # \n If there is no node for the given ID - returns -1
1695 # @return an integer value
1696 # @ingroup l1_meshinfo
1697 def GetShapeID(self, id):
1698 return self.mesh.GetShapeID(id)
1700 ## Returns the ID of the result shape after
1701 # FindShape() from SMESH_MeshEditor for the given element
1702 # \n If there is no element for the given ID - returns -1
1703 # @return an integer value
1704 # @ingroup l1_meshinfo
1705 def GetShapeIDForElem(self,id):
1706 return self.mesh.GetShapeIDForElem(id)
1708 ## Returns the number of nodes for the given element
1709 # \n If there is no element for the given ID - returns -1
1710 # @return an integer value
1711 # @ingroup l1_meshinfo
1712 def GetElemNbNodes(self, id):
1713 return self.mesh.GetElemNbNodes(id)
1715 ## Returns the node ID the given index for the given element
1716 # \n If there is no element for the given ID - returns -1
1717 # \n If there is no node for the given index - returns -2
1718 # @return an integer value
1719 # @ingroup l1_meshinfo
1720 def GetElemNode(self, id, index):
1721 return self.mesh.GetElemNode(id, index)
1723 ## Returns the IDs of nodes of the given element
1724 # @return a list of integer values
1725 # @ingroup l1_meshinfo
1726 def GetElemNodes(self, id):
1727 return self.mesh.GetElemNodes(id)
1729 ## Returns true if the given node is the medium node in the given quadratic element
1730 # @ingroup l1_meshinfo
1731 def IsMediumNode(self, elementID, nodeID):
1732 return self.mesh.IsMediumNode(elementID, nodeID)
1734 ## Returns true if the given node is the medium node in one of quadratic elements
1735 # @ingroup l1_meshinfo
1736 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1737 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1739 ## Returns the number of edges for the given element
1740 # @ingroup l1_meshinfo
1741 def ElemNbEdges(self, id):
1742 return self.mesh.ElemNbEdges(id)
1744 ## Returns the number of faces for the given element
1745 # @ingroup l1_meshinfo
1746 def ElemNbFaces(self, id):
1747 return self.mesh.ElemNbFaces(id)
1749 ## Returns true if the given element is a polygon
1750 # @ingroup l1_meshinfo
1751 def IsPoly(self, id):
1752 return self.mesh.IsPoly(id)
1754 ## Returns true if the given element is quadratic
1755 # @ingroup l1_meshinfo
1756 def IsQuadratic(self, id):
1757 return self.mesh.IsQuadratic(id)
1759 ## Returns XYZ coordinates of the barycenter of the given element
1760 # \n If there is no element for the given ID - returns an empty list
1761 # @return a list of three double values
1762 # @ingroup l1_meshinfo
1763 def BaryCenter(self, id):
1764 return self.mesh.BaryCenter(id)
1767 # Mesh edition (SMESH_MeshEditor functionality):
1768 # ---------------------------------------------
1770 ## Removes the elements from the mesh by ids
1771 # @param IDsOfElements is a list of ids of elements to remove
1772 # @return True or False
1773 # @ingroup l2_modif_del
1774 def RemoveElements(self, IDsOfElements):
1775 return self.editor.RemoveElements(IDsOfElements)
1777 ## Removes nodes from mesh by ids
1778 # @param IDsOfNodes is a list of ids of nodes to remove
1779 # @return True or False
1780 # @ingroup l2_modif_del
1781 def RemoveNodes(self, IDsOfNodes):
1782 return self.editor.RemoveNodes(IDsOfNodes)
1784 ## Add a node to the mesh by coordinates
1785 # @return Id of the new node
1786 # @ingroup l2_modif_add
1787 def AddNode(self, x, y, z):
1788 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
1789 self.mesh.SetParameters(Parameters)
1790 return self.editor.AddNode( x, y, z)
1792 ## Creates a linear or quadratic edge (this is determined
1793 # by the number of given nodes).
1794 # @param IDsOfNodes the list of node IDs for creation of the element.
1795 # The order of nodes in this list should correspond to the description
1796 # of MED. \n This description is located by the following link:
1797 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1798 # @return the Id of the new edge
1799 # @ingroup l2_modif_add
1800 def AddEdge(self, IDsOfNodes):
1801 return self.editor.AddEdge(IDsOfNodes)
1803 ## Creates a linear or quadratic face (this is determined
1804 # by the number of given nodes).
1805 # @param IDsOfNodes the list of node IDs for creation of the element.
1806 # The order of nodes in this list should correspond to the description
1807 # of MED. \n This description is located by the following link:
1808 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1809 # @return the Id of the new face
1810 # @ingroup l2_modif_add
1811 def AddFace(self, IDsOfNodes):
1812 return self.editor.AddFace(IDsOfNodes)
1814 ## Adds a polygonal face to the mesh by the list of node IDs
1815 # @param IdsOfNodes the list of node IDs for creation of the element.
1816 # @return the Id of the new face
1817 # @ingroup l2_modif_add
1818 def AddPolygonalFace(self, IdsOfNodes):
1819 return self.editor.AddPolygonalFace(IdsOfNodes)
1821 ## Creates both simple and quadratic volume (this is determined
1822 # by the number of given nodes).
1823 # @param IDsOfNodes the list of node IDs for creation of the element.
1824 # The order of nodes in this list should correspond to the description
1825 # of MED. \n This description is located by the following link:
1826 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1827 # @return the Id of the new volumic element
1828 # @ingroup l2_modif_add
1829 def AddVolume(self, IDsOfNodes):
1830 return self.editor.AddVolume(IDsOfNodes)
1832 ## Creates a volume of many faces, giving nodes for each face.
1833 # @param IdsOfNodes the list of node IDs for volume creation face by face.
1834 # @param Quantities the list of integer values, Quantities[i]
1835 # gives the quantity of nodes in face number i.
1836 # @return the Id of the new volumic element
1837 # @ingroup l2_modif_add
1838 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1839 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1841 ## Creates a volume of many faces, giving the IDs of the existing faces.
1842 # @param IdsOfFaces the list of face IDs for volume creation.
1844 # Note: The created volume will refer only to the nodes
1845 # of the given faces, not to the faces themselves.
1846 # @return the Id of the new volumic element
1847 # @ingroup l2_modif_add
1848 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1849 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1852 ## @brief Binds a node to a vertex
1853 # @param NodeID a node ID
1854 # @param Vertex a vertex or vertex ID
1855 # @return True if succeed else raises an exception
1856 # @ingroup l2_modif_add
1857 def SetNodeOnVertex(self, NodeID, Vertex):
1858 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
1859 VertexID = Vertex.GetSubShapeIndices()[0]
1863 self.editor.SetNodeOnVertex(NodeID, VertexID)
1864 except SALOME.SALOME_Exception, inst:
1865 raise ValueError, inst.details.text
1869 ## @brief Stores the node position on an edge
1870 # @param NodeID a node ID
1871 # @param Edge an edge or edge ID
1872 # @param paramOnEdge a parameter on the edge where the node is located
1873 # @return True if succeed else raises an exception
1874 # @ingroup l2_modif_add
1875 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
1876 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
1877 EdgeID = Edge.GetSubShapeIndices()[0]
1881 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
1882 except SALOME.SALOME_Exception, inst:
1883 raise ValueError, inst.details.text
1886 ## @brief Stores node position on a face
1887 # @param NodeID a node ID
1888 # @param Face a face or face ID
1889 # @param u U parameter on the face where the node is located
1890 # @param v V parameter on the face where the node is located
1891 # @return True if succeed else raises an exception
1892 # @ingroup l2_modif_add
1893 def SetNodeOnFace(self, NodeID, Face, u, v):
1894 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
1895 FaceID = Face.GetSubShapeIndices()[0]
1899 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
1900 except SALOME.SALOME_Exception, inst:
1901 raise ValueError, inst.details.text
1904 ## @brief Binds a node to a solid
1905 # @param NodeID a node ID
1906 # @param Solid a solid or solid ID
1907 # @return True if succeed else raises an exception
1908 # @ingroup l2_modif_add
1909 def SetNodeInVolume(self, NodeID, Solid):
1910 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
1911 SolidID = Solid.GetSubShapeIndices()[0]
1915 self.editor.SetNodeInVolume(NodeID, SolidID)
1916 except SALOME.SALOME_Exception, inst:
1917 raise ValueError, inst.details.text
1920 ## @brief Bind an element to a shape
1921 # @param ElementID an element ID
1922 # @param Shape a shape or shape ID
1923 # @return True if succeed else raises an exception
1924 # @ingroup l2_modif_add
1925 def SetMeshElementOnShape(self, ElementID, Shape):
1926 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1927 ShapeID = Shape.GetSubShapeIndices()[0]
1931 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
1932 except SALOME.SALOME_Exception, inst:
1933 raise ValueError, inst.details.text
1937 ## Moves the node with the given id
1938 # @param NodeID the id of the node
1939 # @param x a new X coordinate
1940 # @param y a new Y coordinate
1941 # @param z a new Z coordinate
1942 # @return True if succeed else False
1943 # @ingroup l2_modif_movenode
1944 def MoveNode(self, NodeID, x, y, z):
1945 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
1946 self.mesh.SetParameters(Parameters)
1947 return self.editor.MoveNode(NodeID, x, y, z)
1949 ## Finds the node closest to a point and moves it to a point location
1950 # @param x the X coordinate of a point
1951 # @param y the Y coordinate of a point
1952 # @param z the Z coordinate of a point
1953 # @return the ID of a node
1954 # @ingroup l2_modif_throughp
1955 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
1956 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
1957 self.mesh.SetParameters(Parameters)
1958 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
1960 ## Finds the node closest to a point
1961 # @param x the X coordinate of a point
1962 # @param y the Y coordinate of a point
1963 # @param z the Z coordinate of a point
1964 # @return the ID of a node
1965 # @ingroup l2_modif_throughp
1966 def FindNodeClosestTo(self, x, y, z):
1967 preview = self.mesh.GetMeshEditPreviewer()
1968 return preview.MoveClosestNodeToPoint(x, y, z, -1)
1970 ## Finds the node closest to a point and moves it to a point location
1971 # @param x the X coordinate of a point
1972 # @param y the Y coordinate of a point
1973 # @param z the Z coordinate of a point
1974 # @return the ID of a moved node
1975 # @ingroup l2_modif_throughp
1976 def MeshToPassThroughAPoint(self, x, y, z):
1977 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
1979 ## Replaces two neighbour triangles sharing Node1-Node2 link
1980 # with the triangles built on the same 4 nodes but having other common link.
1981 # @param NodeID1 the ID of the first node
1982 # @param NodeID2 the ID of the second node
1983 # @return false if proper faces were not found
1984 # @ingroup l2_modif_invdiag
1985 def InverseDiag(self, NodeID1, NodeID2):
1986 return self.editor.InverseDiag(NodeID1, NodeID2)
1988 ## Replaces two neighbour triangles sharing Node1-Node2 link
1989 # with a quadrangle built on the same 4 nodes.
1990 # @param NodeID1 the ID of the first node
1991 # @param NodeID2 the ID of the second node
1992 # @return false if proper faces were not found
1993 # @ingroup l2_modif_unitetri
1994 def DeleteDiag(self, NodeID1, NodeID2):
1995 return self.editor.DeleteDiag(NodeID1, NodeID2)
1997 ## Reorients elements by ids
1998 # @param IDsOfElements if undefined reorients all mesh elements
1999 # @return True if succeed else False
2000 # @ingroup l2_modif_changori
2001 def Reorient(self, IDsOfElements=None):
2002 if IDsOfElements == None:
2003 IDsOfElements = self.GetElementsId()
2004 return self.editor.Reorient(IDsOfElements)
2006 ## Reorients all elements of the object
2007 # @param theObject mesh, submesh or group
2008 # @return True if succeed else False
2009 # @ingroup l2_modif_changori
2010 def ReorientObject(self, theObject):
2011 if ( isinstance( theObject, Mesh )):
2012 theObject = theObject.GetMesh()
2013 return self.editor.ReorientObject(theObject)
2015 ## Fuses the neighbouring triangles into quadrangles.
2016 # @param IDsOfElements The triangles to be fused,
2017 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2018 # @param MaxAngle is the maximum angle between element normals at which the fusion
2019 # is still performed; theMaxAngle is mesured in radians.
2020 # Also it could be a name of variable which defines angle in degrees.
2021 # @return TRUE in case of success, FALSE otherwise.
2022 # @ingroup l2_modif_unitetri
2023 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2025 if isinstance(MaxAngle,str):
2027 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2029 MaxAngle = DegreesToRadians(MaxAngle)
2030 if IDsOfElements == []:
2031 IDsOfElements = self.GetElementsId()
2032 self.mesh.SetParameters(Parameters)
2034 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2035 Functor = theCriterion
2037 Functor = self.smeshpyD.GetFunctor(theCriterion)
2038 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2040 ## Fuses the neighbouring triangles of the object into quadrangles
2041 # @param theObject is mesh, submesh or group
2042 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2043 # @param MaxAngle a max angle between element normals at which the fusion
2044 # is still performed; theMaxAngle is mesured in radians.
2045 # @return TRUE in case of success, FALSE otherwise.
2046 # @ingroup l2_modif_unitetri
2047 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2048 if ( isinstance( theObject, Mesh )):
2049 theObject = theObject.GetMesh()
2050 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2052 ## Splits quadrangles into triangles.
2053 # @param IDsOfElements the faces to be splitted.
2054 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2055 # @return TRUE in case of success, FALSE otherwise.
2056 # @ingroup l2_modif_cutquadr
2057 def QuadToTri (self, IDsOfElements, theCriterion):
2058 if IDsOfElements == []:
2059 IDsOfElements = self.GetElementsId()
2060 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2062 ## Splits quadrangles into triangles.
2063 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2064 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2065 # @return TRUE in case of success, FALSE otherwise.
2066 # @ingroup l2_modif_cutquadr
2067 def QuadToTriObject (self, theObject, theCriterion):
2068 if ( isinstance( theObject, Mesh )):
2069 theObject = theObject.GetMesh()
2070 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2072 ## Splits quadrangles into triangles.
2073 # @param IDsOfElements the faces to be splitted
2074 # @param Diag13 is used to choose a diagonal for splitting.
2075 # @return TRUE in case of success, FALSE otherwise.
2076 # @ingroup l2_modif_cutquadr
2077 def SplitQuad (self, IDsOfElements, Diag13):
2078 if IDsOfElements == []:
2079 IDsOfElements = self.GetElementsId()
2080 return self.editor.SplitQuad(IDsOfElements, Diag13)
2082 ## Splits quadrangles into triangles.
2083 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2084 # @param Diag13 is used to choose a diagonal for splitting.
2085 # @return TRUE in case of success, FALSE otherwise.
2086 # @ingroup l2_modif_cutquadr
2087 def SplitQuadObject (self, theObject, Diag13):
2088 if ( isinstance( theObject, Mesh )):
2089 theObject = theObject.GetMesh()
2090 return self.editor.SplitQuadObject(theObject, Diag13)
2092 ## Finds a better splitting of the given quadrangle.
2093 # @param IDOfQuad the ID of the quadrangle to be splitted.
2094 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2095 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2096 # diagonal is better, 0 if error occurs.
2097 # @ingroup l2_modif_cutquadr
2098 def BestSplit (self, IDOfQuad, theCriterion):
2099 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2101 ## Splits quadrangle faces near triangular facets of volumes
2103 # @ingroup l1_auxiliary
2104 def SplitQuadsNearTriangularFacets(self):
2105 faces_array = self.GetElementsByType(SMESH.FACE)
2106 for face_id in faces_array:
2107 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2108 quad_nodes = self.mesh.GetElemNodes(face_id)
2109 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2110 isVolumeFound = False
2111 for node1_elem in node1_elems:
2112 if not isVolumeFound:
2113 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2114 nb_nodes = self.GetElemNbNodes(node1_elem)
2115 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2116 volume_elem = node1_elem
2117 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2118 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2119 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2120 isVolumeFound = True
2121 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2122 self.SplitQuad([face_id], False) # diagonal 2-4
2123 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2124 isVolumeFound = True
2125 self.SplitQuad([face_id], True) # diagonal 1-3
2126 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2127 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2128 isVolumeFound = True
2129 self.SplitQuad([face_id], True) # diagonal 1-3
2131 ## @brief Splits hexahedrons into tetrahedrons.
2133 # This operation uses pattern mapping functionality for splitting.
2134 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2135 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2136 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2137 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2138 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2139 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2140 # @return TRUE in case of success, FALSE otherwise.
2141 # @ingroup l1_auxiliary
2142 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2143 # Pattern: 5.---------.6
2148 # (0,0,1) 4.---------.7 * |
2155 # (0,0,0) 0.---------.3
2156 pattern_tetra = "!!! Nb of points: \n 8 \n\
2166 !!! Indices of points of 6 tetras: \n\
2174 pattern = self.smeshpyD.GetPattern()
2175 isDone = pattern.LoadFromFile(pattern_tetra)
2177 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2180 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2181 isDone = pattern.MakeMesh(self.mesh, False, False)
2182 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2184 # split quafrangle faces near triangular facets of volumes
2185 self.SplitQuadsNearTriangularFacets()
2189 ## @brief Split hexahedrons into prisms.
2191 # Uses the pattern mapping functionality for splitting.
2192 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2193 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2194 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2195 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2196 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2197 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2198 # @return TRUE in case of success, FALSE otherwise.
2199 # @ingroup l1_auxiliary
2200 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2201 # Pattern: 5.---------.6
2206 # (0,0,1) 4.---------.7 |
2213 # (0,0,0) 0.---------.3
2214 pattern_prism = "!!! Nb of points: \n 8 \n\
2224 !!! Indices of points of 2 prisms: \n\
2228 pattern = self.smeshpyD.GetPattern()
2229 isDone = pattern.LoadFromFile(pattern_prism)
2231 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2234 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2235 isDone = pattern.MakeMesh(self.mesh, False, False)
2236 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2238 # Splits quafrangle faces near triangular facets of volumes
2239 self.SplitQuadsNearTriangularFacets()
2243 ## Smoothes elements
2244 # @param IDsOfElements the list if ids of elements to smooth
2245 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2246 # Note that nodes built on edges and boundary nodes are always fixed.
2247 # @param MaxNbOfIterations the maximum number of iterations
2248 # @param MaxAspectRatio varies in range [1.0, inf]
2249 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2250 # @return TRUE in case of success, FALSE otherwise.
2251 # @ingroup l2_modif_smooth
2252 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2253 MaxNbOfIterations, MaxAspectRatio, Method):
2254 if IDsOfElements == []:
2255 IDsOfElements = self.GetElementsId()
2256 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2257 self.mesh.SetParameters(Parameters)
2258 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2259 MaxNbOfIterations, MaxAspectRatio, Method)
2261 ## Smoothes elements which belong to the given object
2262 # @param theObject the object to smooth
2263 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2264 # Note that nodes built on edges and boundary nodes are always fixed.
2265 # @param MaxNbOfIterations the maximum number of iterations
2266 # @param MaxAspectRatio varies in range [1.0, inf]
2267 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2268 # @return TRUE in case of success, FALSE otherwise.
2269 # @ingroup l2_modif_smooth
2270 def SmoothObject(self, theObject, IDsOfFixedNodes,
2271 MaxNbOfIterations, MaxAspectRatio, Method):
2272 if ( isinstance( theObject, Mesh )):
2273 theObject = theObject.GetMesh()
2274 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2275 MaxNbOfIterations, MaxAspectRatio, Method)
2277 ## Parametrically smoothes the given elements
2278 # @param IDsOfElements the list if ids of elements to smooth
2279 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2280 # Note that nodes built on edges and boundary nodes are always fixed.
2281 # @param MaxNbOfIterations the maximum number of iterations
2282 # @param MaxAspectRatio varies in range [1.0, inf]
2283 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2284 # @return TRUE in case of success, FALSE otherwise.
2285 # @ingroup l2_modif_smooth
2286 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2287 MaxNbOfIterations, MaxAspectRatio, Method):
2288 if IDsOfElements == []:
2289 IDsOfElements = self.GetElementsId()
2290 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2291 self.mesh.SetParameters(Parameters)
2292 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2293 MaxNbOfIterations, MaxAspectRatio, Method)
2295 ## Parametrically smoothes the elements which belong to the given object
2296 # @param theObject the object to smooth
2297 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2298 # Note that nodes built on edges and boundary nodes are always fixed.
2299 # @param MaxNbOfIterations the maximum number of iterations
2300 # @param MaxAspectRatio varies in range [1.0, inf]
2301 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2302 # @return TRUE in case of success, FALSE otherwise.
2303 # @ingroup l2_modif_smooth
2304 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2305 MaxNbOfIterations, MaxAspectRatio, Method):
2306 if ( isinstance( theObject, Mesh )):
2307 theObject = theObject.GetMesh()
2308 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2309 MaxNbOfIterations, MaxAspectRatio, Method)
2311 ## Converts the mesh to quadratic, deletes old elements, replacing
2312 # them with quadratic with the same id.
2313 # @ingroup l2_modif_tofromqu
2314 def ConvertToQuadratic(self, theForce3d):
2315 self.editor.ConvertToQuadratic(theForce3d)
2317 ## Converts the mesh from quadratic to ordinary,
2318 # deletes old quadratic elements, \n replacing
2319 # them with ordinary mesh elements with the same id.
2320 # @return TRUE in case of success, FALSE otherwise.
2321 # @ingroup l2_modif_tofromqu
2322 def ConvertFromQuadratic(self):
2323 return self.editor.ConvertFromQuadratic()
2325 ## Renumber mesh nodes
2326 # @ingroup l2_modif_renumber
2327 def RenumberNodes(self):
2328 self.editor.RenumberNodes()
2330 ## Renumber mesh elements
2331 # @ingroup l2_modif_renumber
2332 def RenumberElements(self):
2333 self.editor.RenumberElements()
2335 ## Generates new elements by rotation of the elements around the axis
2336 # @param IDsOfElements the list of ids of elements to sweep
2337 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2338 # @param AngleInRadians the angle of Rotation
2339 # @param NbOfSteps the number of steps
2340 # @param Tolerance tolerance
2341 # @param MakeGroups forces the generation of new groups from existing ones
2342 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2343 # of all steps, else - size of each step
2344 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2345 # @ingroup l2_modif_extrurev
2346 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2347 MakeGroups=False, TotalAngle=False):
2348 if IDsOfElements == []:
2349 IDsOfElements = self.GetElementsId()
2350 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2351 Axis = self.smeshpyD.GetAxisStruct(Axis)
2352 if TotalAngle and NbOfSteps:
2353 AngleInRadians /= NbOfSteps
2355 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2356 AngleInRadians, NbOfSteps, Tolerance)
2357 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2360 ## Generates new elements by rotation of the elements of object around the axis
2361 # @param theObject object which elements should be sweeped
2362 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2363 # @param AngleInRadians the angle of Rotation
2364 # @param NbOfSteps number of steps
2365 # @param Tolerance tolerance
2366 # @param MakeGroups forces the generation of new groups from existing ones
2367 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2368 # of all steps, else - size of each step
2369 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2370 # @ingroup l2_modif_extrurev
2371 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2372 MakeGroups=False, TotalAngle=False):
2373 if ( isinstance( theObject, Mesh )):
2374 theObject = theObject.GetMesh()
2375 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2376 Axis = self.smeshpyD.GetAxisStruct(Axis)
2377 if TotalAngle and NbOfSteps:
2378 AngleInRadians /= NbOfSteps
2380 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2381 NbOfSteps, Tolerance)
2382 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2385 ## Generates new elements by extrusion of the elements with given ids
2386 # @param IDsOfElements the list of elements ids for extrusion
2387 # @param StepVector vector, defining the direction and value of extrusion
2388 # @param NbOfSteps the number of steps
2389 # @param MakeGroups forces the generation of new groups from existing ones
2390 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2391 # @ingroup l2_modif_extrurev
2392 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2393 if IDsOfElements == []:
2394 IDsOfElements = self.GetElementsId()
2395 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2396 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2397 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2398 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2399 Parameters = StepVectorParameters + ":" + Parameters
2400 self.mesh.SetParameters(Parameters)
2402 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2403 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2406 ## Generates new elements by extrusion of the elements with given ids
2407 # @param IDsOfElements is ids of elements
2408 # @param StepVector vector, defining the direction and value of extrusion
2409 # @param NbOfSteps the number of steps
2410 # @param ExtrFlags sets flags for extrusion
2411 # @param SewTolerance uses for comparing locations of nodes if flag
2412 # EXTRUSION_FLAG_SEW is set
2413 # @param MakeGroups forces the generation of new groups from existing ones
2414 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2415 # @ingroup l2_modif_extrurev
2416 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2417 ExtrFlags, SewTolerance, MakeGroups=False):
2418 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2419 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2421 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2422 ExtrFlags, SewTolerance)
2423 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2424 ExtrFlags, SewTolerance)
2427 ## Generates new elements by extrusion of the elements which belong to the object
2428 # @param theObject the object which elements should be processed
2429 # @param StepVector vector, defining the direction and value of extrusion
2430 # @param NbOfSteps the number of steps
2431 # @param MakeGroups forces the generation of new groups from existing ones
2432 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2433 # @ingroup l2_modif_extrurev
2434 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2435 if ( isinstance( theObject, Mesh )):
2436 theObject = theObject.GetMesh()
2437 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2438 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2440 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2441 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2444 ## Generates new elements by extrusion of the elements which belong to the object
2445 # @param theObject object which elements should be processed
2446 # @param StepVector vector, defining the direction and value of extrusion
2447 # @param NbOfSteps the number of steps
2448 # @param MakeGroups to generate new groups from existing ones
2449 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2450 # @ingroup l2_modif_extrurev
2451 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2452 if ( isinstance( theObject, Mesh )):
2453 theObject = theObject.GetMesh()
2454 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2455 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2457 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2458 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2461 ## Generates new elements by extrusion of the elements which belong to the object
2462 # @param theObject object which elements should be processed
2463 # @param StepVector vector, defining the direction and value of extrusion
2464 # @param NbOfSteps the number of steps
2465 # @param MakeGroups forces the generation of new groups from existing ones
2466 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2467 # @ingroup l2_modif_extrurev
2468 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2469 if ( isinstance( theObject, Mesh )):
2470 theObject = theObject.GetMesh()
2471 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2472 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2474 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2475 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2478 ## Generates new elements by extrusion of the given elements
2479 # The path of extrusion must be a meshed edge.
2480 # @param IDsOfElements ids of elements
2481 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2482 # @param PathShape shape(edge) defines the sub-mesh for the path
2483 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2484 # @param HasAngles allows the shape to be rotated around the path
2485 # to get the resulting mesh in a helical fashion
2486 # @param Angles list of angles
2487 # @param HasRefPoint allows using the reference point
2488 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2489 # The User can specify any point as the Reference Point.
2490 # @param MakeGroups forces the generation of new groups from existing ones
2491 # @param LinearVariation forces the computation of rotation angles as linear
2492 # variation of the given Angles along path steps
2493 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2494 # only SMESH::Extrusion_Error otherwise
2495 # @ingroup l2_modif_extrurev
2496 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2497 HasAngles, Angles, HasRefPoint, RefPoint,
2498 MakeGroups=False, LinearVariation=False):
2499 if IDsOfElements == []:
2500 IDsOfElements = self.GetElementsId()
2501 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2502 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2504 if ( isinstance( PathMesh, Mesh )):
2505 PathMesh = PathMesh.GetMesh()
2506 if HasAngles and Angles and LinearVariation:
2507 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2510 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2511 PathShape, NodeStart, HasAngles,
2512 Angles, HasRefPoint, RefPoint)
2513 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2514 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2516 ## Generates new elements by extrusion of the elements which belong to the object
2517 # The path of extrusion must be a meshed edge.
2518 # @param theObject the object which elements should be processed
2519 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2520 # @param PathShape shape(edge) defines the sub-mesh for the path
2521 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2522 # @param HasAngles allows the shape to be rotated around the path
2523 # to get the resulting mesh in a helical fashion
2524 # @param Angles list of angles
2525 # @param HasRefPoint allows using the reference point
2526 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2527 # The User can specify any point as the Reference Point.
2528 # @param MakeGroups forces the generation of new groups from existing ones
2529 # @param LinearVariation forces the computation of rotation angles as linear
2530 # variation of the given Angles along path steps
2531 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2532 # only SMESH::Extrusion_Error otherwise
2533 # @ingroup l2_modif_extrurev
2534 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2535 HasAngles, Angles, HasRefPoint, RefPoint,
2536 MakeGroups=False, LinearVariation=False):
2537 if ( isinstance( theObject, Mesh )):
2538 theObject = theObject.GetMesh()
2539 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2540 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2541 if ( isinstance( PathMesh, Mesh )):
2542 PathMesh = PathMesh.GetMesh()
2543 if HasAngles and Angles and LinearVariation:
2544 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2547 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2548 PathShape, NodeStart, HasAngles,
2549 Angles, HasRefPoint, RefPoint)
2550 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2551 NodeStart, HasAngles, Angles, HasRefPoint,
2554 ## Creates a symmetrical copy of mesh elements
2555 # @param IDsOfElements list of elements ids
2556 # @param Mirror is AxisStruct or geom object(point, line, plane)
2557 # @param theMirrorType is POINT, AXIS or PLANE
2558 # If the Mirror is a geom object this parameter is unnecessary
2559 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2560 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2561 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2562 # @ingroup l2_modif_trsf
2563 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2564 if IDsOfElements == []:
2565 IDsOfElements = self.GetElementsId()
2566 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2567 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2568 Mirror,Parameters = ParseAxisStruct(Mirror)
2569 self.mesh.SetParameters(Parameters)
2570 if Copy and MakeGroups:
2571 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2572 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2575 ## Creates a new mesh by a symmetrical copy of mesh elements
2576 # @param IDsOfElements the list of elements ids
2577 # @param Mirror is AxisStruct or geom object (point, line, plane)
2578 # @param theMirrorType is POINT, AXIS or PLANE
2579 # If the Mirror is a geom object this parameter is unnecessary
2580 # @param MakeGroups to generate new groups from existing ones
2581 # @param NewMeshName a name of the new mesh to create
2582 # @return instance of Mesh class
2583 # @ingroup l2_modif_trsf
2584 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2585 if IDsOfElements == []:
2586 IDsOfElements = self.GetElementsId()
2587 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2588 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2589 Mirror,Parameters = ParseAxisStruct(Mirror)
2590 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2591 MakeGroups, NewMeshName)
2592 mesh.SetParameters(Parameters)
2593 return Mesh(self.smeshpyD,self.geompyD,mesh)
2595 ## Creates a symmetrical copy of the object
2596 # @param theObject mesh, submesh or group
2597 # @param Mirror AxisStruct or geom object (point, line, plane)
2598 # @param theMirrorType is POINT, AXIS or PLANE
2599 # If the Mirror is a geom object this parameter is unnecessary
2600 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2601 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2602 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2603 # @ingroup l2_modif_trsf
2604 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2605 if ( isinstance( theObject, Mesh )):
2606 theObject = theObject.GetMesh()
2607 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2608 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2609 if Copy and MakeGroups:
2610 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2611 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2614 ## Creates a new mesh by a symmetrical copy of the object
2615 # @param theObject mesh, submesh or group
2616 # @param Mirror AxisStruct or geom object (point, line, plane)
2617 # @param theMirrorType POINT, AXIS or PLANE
2618 # If the Mirror is a geom object this parameter is unnecessary
2619 # @param MakeGroups forces the generation of new groups from existing ones
2620 # @param NewMeshName the name of the new mesh to create
2621 # @return instance of Mesh class
2622 # @ingroup l2_modif_trsf
2623 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2624 if ( isinstance( theObject, Mesh )):
2625 theObject = theObject.GetMesh()
2626 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2627 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2628 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2629 MakeGroups, NewMeshName)
2630 return Mesh( self.smeshpyD,self.geompyD,mesh )
2632 ## Translates the elements
2633 # @param IDsOfElements list of elements ids
2634 # @param Vector the direction of translation (DirStruct or vector)
2635 # @param Copy allows copying the translated elements
2636 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2637 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2638 # @ingroup l2_modif_trsf
2639 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2640 if IDsOfElements == []:
2641 IDsOfElements = self.GetElementsId()
2642 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2643 Vector = self.smeshpyD.GetDirStruct(Vector)
2644 Vector,Parameters = ParseDirStruct(Vector)
2645 self.mesh.SetParameters(Parameters)
2646 if Copy and MakeGroups:
2647 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
2648 self.editor.Translate(IDsOfElements, Vector, Copy)
2651 ## Creates a new mesh of translated elements
2652 # @param IDsOfElements list of elements ids
2653 # @param Vector the direction of translation (DirStruct or vector)
2654 # @param MakeGroups forces the generation of new groups from existing ones
2655 # @param NewMeshName the name of the newly created mesh
2656 # @return instance of Mesh class
2657 # @ingroup l2_modif_trsf
2658 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
2659 if IDsOfElements == []:
2660 IDsOfElements = self.GetElementsId()
2661 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2662 Vector = self.smeshpyD.GetDirStruct(Vector)
2663 Vector,Parameters = ParseDirStruct(Vector)
2664 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
2665 mesh.SetParameters(Parameters)
2666 return Mesh ( self.smeshpyD, self.geompyD, mesh )
2668 ## Translates the object
2669 # @param theObject the object to translate (mesh, submesh, or group)
2670 # @param Vector direction of translation (DirStruct or geom vector)
2671 # @param Copy allows copying the translated elements
2672 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2673 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2674 # @ingroup l2_modif_trsf
2675 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
2676 if ( isinstance( theObject, Mesh )):
2677 theObject = theObject.GetMesh()
2678 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2679 Vector = self.smeshpyD.GetDirStruct(Vector)
2680 if Copy and MakeGroups:
2681 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
2682 self.editor.TranslateObject(theObject, Vector, Copy)
2685 ## Creates a new mesh from the translated object
2686 # @param theObject the object to translate (mesh, submesh, or group)
2687 # @param Vector the direction of translation (DirStruct or geom vector)
2688 # @param MakeGroups forces the generation of new groups from existing ones
2689 # @param NewMeshName the name of the newly created mesh
2690 # @return instance of Mesh class
2691 # @ingroup l2_modif_trsf
2692 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
2693 if (isinstance(theObject, Mesh)):
2694 theObject = theObject.GetMesh()
2695 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
2696 Vector = self.smeshpyD.GetDirStruct(Vector)
2697 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
2698 return Mesh( self.smeshpyD, self.geompyD, mesh )
2700 ## Rotates the elements
2701 # @param IDsOfElements list of elements ids
2702 # @param Axis the axis of rotation (AxisStruct or geom line)
2703 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
2704 # @param Copy allows copying the rotated elements
2705 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2706 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2707 # @ingroup l2_modif_trsf
2708 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
2710 if isinstance(AngleInRadians,str):
2712 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
2714 AngleInRadians = DegreesToRadians(AngleInRadians)
2715 if IDsOfElements == []:
2716 IDsOfElements = self.GetElementsId()
2717 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2718 Axis = self.smeshpyD.GetAxisStruct(Axis)
2719 Axis,AxisParameters = ParseAxisStruct(Axis)
2720 Parameters = AxisParameters + ":" + Parameters
2721 self.mesh.SetParameters(Parameters)
2722 if Copy and MakeGroups:
2723 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
2724 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2727 ## Creates a new mesh of rotated elements
2728 # @param IDsOfElements list of element ids
2729 # @param Axis the axis of rotation (AxisStruct or geom line)
2730 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
2731 # @param MakeGroups forces the generation of new groups from existing ones
2732 # @param NewMeshName the name of the newly created mesh
2733 # @return instance of Mesh class
2734 # @ingroup l2_modif_trsf
2735 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
2737 if isinstance(AngleInRadians,str):
2739 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
2741 AngleInRadians = DegreesToRadians(AngleInRadians)
2742 if IDsOfElements == []:
2743 IDsOfElements = self.GetElementsId()
2744 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2745 Axis = self.smeshpyD.GetAxisStruct(Axis)
2746 Axis,AxisParameters = ParseAxisStruct(Axis)
2747 Parameters = AxisParameters + ":" + Parameters
2748 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
2749 MakeGroups, NewMeshName)
2750 mesh.SetParameters(Parameters)
2751 return Mesh( self.smeshpyD, self.geompyD, mesh )
2753 ## Rotates the object
2754 # @param theObject the object to rotate( mesh, submesh, or group)
2755 # @param Axis the axis of rotation (AxisStruct or geom line)
2756 # @param AngleInRadians the angle of rotation (in radians)
2757 # @param Copy allows copying the rotated elements
2758 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2759 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2760 # @ingroup l2_modif_trsf
2761 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
2762 if (isinstance(theObject, Mesh)):
2763 theObject = theObject.GetMesh()
2764 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2765 Axis = self.smeshpyD.GetAxisStruct(Axis)
2766 if Copy and MakeGroups:
2767 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
2768 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2771 ## Creates a new mesh from the rotated object
2772 # @param theObject the object to rotate (mesh, submesh, or group)
2773 # @param Axis the axis of rotation (AxisStruct or geom line)
2774 # @param AngleInRadians the angle of rotation (in radians)
2775 # @param MakeGroups forces the generation of new groups from existing ones
2776 # @param NewMeshName the name of the newly created mesh
2777 # @return instance of Mesh class
2778 # @ingroup l2_modif_trsf
2779 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
2780 if (isinstance( theObject, Mesh )):
2781 theObject = theObject.GetMesh()
2782 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2783 Axis = self.smeshpyD.GetAxisStruct(Axis)
2784 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
2785 MakeGroups, NewMeshName)
2786 return Mesh( self.smeshpyD, self.geompyD, mesh )
2788 ## Finds groups of ajacent nodes within Tolerance.
2789 # @param Tolerance the value of tolerance
2790 # @return the list of groups of nodes
2791 # @ingroup l2_modif_trsf
2792 def FindCoincidentNodes (self, Tolerance):
2793 return self.editor.FindCoincidentNodes(Tolerance)
2795 ## Finds groups of ajacent nodes within Tolerance.
2796 # @param Tolerance the value of tolerance
2797 # @param SubMeshOrGroup SubMesh or Group
2798 # @return the list of groups of nodes
2799 # @ingroup l2_modif_trsf
2800 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
2801 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
2804 # @param GroupsOfNodes the list of groups of nodes
2805 # @ingroup l2_modif_trsf
2806 def MergeNodes (self, GroupsOfNodes):
2807 self.editor.MergeNodes(GroupsOfNodes)
2809 ## Finds the elements built on the same nodes.
2810 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
2811 # @return a list of groups of equal elements
2812 # @ingroup l2_modif_trsf
2813 def FindEqualElements (self, MeshOrSubMeshOrGroup):
2814 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
2816 ## Merges elements in each given group.
2817 # @param GroupsOfElementsID groups of elements for merging
2818 # @ingroup l2_modif_trsf
2819 def MergeElements(self, GroupsOfElementsID):
2820 self.editor.MergeElements(GroupsOfElementsID)
2822 ## Leaves one element and removes all other elements built on the same nodes.
2823 # @ingroup l2_modif_trsf
2824 def MergeEqualElements(self):
2825 self.editor.MergeEqualElements()
2827 ## Sews free borders
2828 # @return SMESH::Sew_Error
2829 # @ingroup l2_modif_trsf
2830 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2831 FirstNodeID2, SecondNodeID2, LastNodeID2,
2832 CreatePolygons, CreatePolyedrs):
2833 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2834 FirstNodeID2, SecondNodeID2, LastNodeID2,
2835 CreatePolygons, CreatePolyedrs)
2837 ## Sews conform free borders
2838 # @return SMESH::Sew_Error
2839 # @ingroup l2_modif_trsf
2840 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2841 FirstNodeID2, SecondNodeID2):
2842 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2843 FirstNodeID2, SecondNodeID2)
2845 ## Sews border to side
2846 # @return SMESH::Sew_Error
2847 # @ingroup l2_modif_trsf
2848 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2849 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
2850 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2851 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
2853 ## Sews two sides of a mesh. The nodes belonging to Side1 are
2854 # merged with the nodes of elements of Side2.
2855 # The number of elements in theSide1 and in theSide2 must be
2856 # equal and they should have similar nodal connectivity.
2857 # The nodes to merge should belong to side borders and
2858 # the first node should be linked to the second.
2859 # @return SMESH::Sew_Error
2860 # @ingroup l2_modif_trsf
2861 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
2862 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2863 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
2864 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
2865 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2866 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
2868 ## Sets new nodes for the given element.
2869 # @param ide the element id
2870 # @param newIDs nodes ids
2871 # @return If the number of nodes does not correspond to the type of element - returns false
2872 # @ingroup l2_modif_edit
2873 def ChangeElemNodes(self, ide, newIDs):
2874 return self.editor.ChangeElemNodes(ide, newIDs)
2876 ## If during the last operation of MeshEditor some nodes were
2877 # created, this method returns the list of their IDs, \n
2878 # if new nodes were not created - returns empty list
2879 # @return the list of integer values (can be empty)
2880 # @ingroup l1_auxiliary
2881 def GetLastCreatedNodes(self):
2882 return self.editor.GetLastCreatedNodes()
2884 ## If during the last operation of MeshEditor some elements were
2885 # created this method returns the list of their IDs, \n
2886 # if new elements were not created - returns empty list
2887 # @return the list of integer values (can be empty)
2888 # @ingroup l1_auxiliary
2889 def GetLastCreatedElems(self):
2890 return self.editor.GetLastCreatedElems()
2892 ## The mother class to define algorithm, it is not recommended to use it directly.
2895 # @ingroup l2_algorithms
2896 class Mesh_Algorithm:
2897 # @class Mesh_Algorithm
2898 # @brief Class Mesh_Algorithm
2900 #def __init__(self,smesh):
2908 ## Finds a hypothesis in the study by its type name and parameters.
2909 # Finds only the hypotheses created in smeshpyD engine.
2910 # @return SMESH.SMESH_Hypothesis
2911 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
2912 study = smeshpyD.GetCurrentStudy()
2913 #to do: find component by smeshpyD object, not by its data type
2914 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2915 if scomp is not None:
2916 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
2917 # Check if the root label of the hypotheses exists
2918 if res and hypRoot is not None:
2919 iter = study.NewChildIterator(hypRoot)
2920 # Check all published hypotheses
2922 hypo_so_i = iter.Value()
2923 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
2924 if attr is not None:
2925 anIOR = attr.Value()
2926 hypo_o_i = salome.orb.string_to_object(anIOR)
2927 if hypo_o_i is not None:
2928 # Check if this is a hypothesis
2929 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
2930 if hypo_i is not None:
2931 # Check if the hypothesis belongs to current engine
2932 if smeshpyD.GetObjectId(hypo_i) > 0:
2933 # Check if this is the required hypothesis
2934 if hypo_i.GetName() == hypname:
2936 if CompareMethod(hypo_i, args):
2950 ## Finds the algorithm in the study by its type name.
2951 # Finds only the algorithms, which have been created in smeshpyD engine.
2952 # @return SMESH.SMESH_Algo
2953 def FindAlgorithm (self, algoname, smeshpyD):
2954 study = smeshpyD.GetCurrentStudy()
2955 #to do: find component by smeshpyD object, not by its data type
2956 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2957 if scomp is not None:
2958 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
2959 # Check if the root label of the algorithms exists
2960 if res and hypRoot is not None:
2961 iter = study.NewChildIterator(hypRoot)
2962 # Check all published algorithms
2964 algo_so_i = iter.Value()
2965 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
2966 if attr is not None:
2967 anIOR = attr.Value()
2968 algo_o_i = salome.orb.string_to_object(anIOR)
2969 if algo_o_i is not None:
2970 # Check if this is an algorithm
2971 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
2972 if algo_i is not None:
2973 # Checks if the algorithm belongs to the current engine
2974 if smeshpyD.GetObjectId(algo_i) > 0:
2975 # Check if this is the required algorithm
2976 if algo_i.GetName() == algoname:
2989 ## If the algorithm is global, returns 0; \n
2990 # else returns the submesh associated to this algorithm.
2991 def GetSubMesh(self):
2994 ## Returns the wrapped mesher.
2995 def GetAlgorithm(self):
2998 ## Gets the list of hypothesis that can be used with this algorithm
2999 def GetCompatibleHypothesis(self):
3002 mylist = self.algo.GetCompatibleHypothesis()
3005 ## Gets the name of the algorithm
3009 ## Sets the name to the algorithm
3010 def SetName(self, name):
3011 SetName(self.algo, name)
3013 ## Gets the id of the algorithm
3015 return self.algo.GetId()
3018 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3020 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3021 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3023 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3025 self.Assign(algo, mesh, geom)
3029 def Assign(self, algo, mesh, geom):
3031 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3038 name = GetName(geom)
3040 name = mesh.geompyD.SubShapeName(geom, piece)
3041 mesh.geompyD.addToStudyInFather(piece, geom, name)
3042 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3045 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3046 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3048 def CompareHyp (self, hyp, args):
3049 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3052 def CompareEqualHyp (self, hyp, args):
3056 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3057 UseExisting=0, CompareMethod=""):
3060 if CompareMethod == "": CompareMethod = self.CompareHyp
3061 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3064 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3070 a = a + s + str(args[i])
3074 SetName(hypo, hyp + a)
3076 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3077 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3081 # Public class: Mesh_Segment
3082 # --------------------------
3084 ## Class to define a segment 1D algorithm for discretization
3087 # @ingroup l3_algos_basic
3088 class Mesh_Segment(Mesh_Algorithm):
3090 ## Private constructor.
3091 def __init__(self, mesh, geom=0):
3092 Mesh_Algorithm.__init__(self)
3093 self.Create(mesh, geom, "Regular_1D")
3095 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3096 # @param l for the length of segments that cut an edge
3097 # @param UseExisting if ==true - searches for an existing hypothesis created with
3098 # the same parameters, else (default) - creates a new one
3099 # @param p precision, used for calculation of the number of segments.
3100 # The precision should be a positive, meaningful value within the range [0,1].
3101 # In general, the number of segments is calculated with the formula:
3102 # nb = ceil((edge_length / l) - p)
3103 # Function ceil rounds its argument to the higher integer.
3104 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3105 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3106 # p=1 means rounding of (edge_length / l) to the lower integer.
3107 # Default value is 1e-07.
3108 # @return an instance of StdMeshers_LocalLength hypothesis
3109 # @ingroup l3_hypos_1dhyps
3110 def LocalLength(self, l, UseExisting=0, p=1e-07):
3111 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3112 CompareMethod=self.CompareLocalLength)
3118 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3119 def CompareLocalLength(self, hyp, args):
3120 if IsEqual(hyp.GetLength(), args[0]):
3121 return IsEqual(hyp.GetPrecision(), args[1])
3124 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3125 # @param n for the number of segments that cut an edge
3126 # @param s for the scale factor (optional)
3127 # @param UseExisting if ==true - searches for an existing hypothesis created with
3128 # the same parameters, else (default) - create a new one
3129 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3130 # @ingroup l3_hypos_1dhyps
3131 def NumberOfSegments(self, n, s=[], UseExisting=0):
3133 hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
3134 CompareMethod=self.CompareNumberOfSegments)
3136 hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
3137 CompareMethod=self.CompareNumberOfSegments)
3138 hyp.SetDistrType( 1 )
3139 hyp.SetScaleFactor(s)
3140 hyp.SetNumberOfSegments(n)
3144 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3145 def CompareNumberOfSegments(self, hyp, args):
3146 if hyp.GetNumberOfSegments() == args[0]:
3150 if hyp.GetDistrType() == 1:
3151 if IsEqual(hyp.GetScaleFactor(), args[1]):
3155 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3156 # @param start defines the length of the first segment
3157 # @param end defines the length of the last segment
3158 # @param UseExisting if ==true - searches for an existing hypothesis created with
3159 # the same parameters, else (default) - creates a new one
3160 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3161 # @ingroup l3_hypos_1dhyps
3162 def Arithmetic1D(self, start, end, UseExisting=0):
3163 hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
3164 CompareMethod=self.CompareArithmetic1D)
3165 hyp.SetLength(start, 1)
3166 hyp.SetLength(end , 0)
3170 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3171 def CompareArithmetic1D(self, hyp, args):
3172 if IsEqual(hyp.GetLength(1), args[0]):
3173 if IsEqual(hyp.GetLength(0), args[1]):
3177 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3178 # @param start defines the length of the first segment
3179 # @param end defines the length of the last segment
3180 # @param UseExisting if ==true - searches for an existing hypothesis created with
3181 # the same parameters, else (default) - creates a new one
3182 # @return an instance of StdMeshers_StartEndLength hypothesis
3183 # @ingroup l3_hypos_1dhyps
3184 def StartEndLength(self, start, end, UseExisting=0):
3185 hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
3186 CompareMethod=self.CompareStartEndLength)
3187 hyp.SetLength(start, 1)
3188 hyp.SetLength(end , 0)
3191 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3192 def CompareStartEndLength(self, hyp, args):
3193 if IsEqual(hyp.GetLength(1), args[0]):
3194 if IsEqual(hyp.GetLength(0), args[1]):
3198 ## Defines "Deflection1D" hypothesis
3199 # @param d for the deflection
3200 # @param UseExisting if ==true - searches for an existing hypothesis created with
3201 # the same parameters, else (default) - create a new one
3202 # @ingroup l3_hypos_1dhyps
3203 def Deflection1D(self, d, UseExisting=0):
3204 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3205 CompareMethod=self.CompareDeflection1D)
3206 hyp.SetDeflection(d)
3209 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3210 def CompareDeflection1D(self, hyp, args):
3211 return IsEqual(hyp.GetDeflection(), args[0])
3213 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3214 # the opposite side in case of quadrangular faces
3215 # @ingroup l3_hypos_additi
3216 def Propagation(self):
3217 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3219 ## Defines "AutomaticLength" hypothesis
3220 # @param fineness for the fineness [0-1]
3221 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3222 # same parameters, else (default) - create a new one
3223 # @ingroup l3_hypos_1dhyps
3224 def AutomaticLength(self, fineness=0, UseExisting=0):
3225 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3226 CompareMethod=self.CompareAutomaticLength)
3227 hyp.SetFineness( fineness )
3230 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3231 def CompareAutomaticLength(self, hyp, args):
3232 return IsEqual(hyp.GetFineness(), args[0])
3234 ## Defines "SegmentLengthAroundVertex" hypothesis
3235 # @param length for the segment length
3236 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3237 # Any other integer value means that the hypothesis will be set on the
3238 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3239 # @param UseExisting if ==true - searches for an existing hypothesis created with
3240 # the same parameters, else (default) - creates a new one
3241 # @ingroup l3_algos_segmarv
3242 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3244 store_geom = self.geom
3245 if type(vertex) is types.IntType:
3246 if vertex == 0 or vertex == 1:
3247 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3255 if self.geom is None:
3256 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3257 name = GetName(self.geom)
3259 piece = self.mesh.geom
3260 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3261 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3262 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3264 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3266 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3267 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3269 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3270 CompareMethod=self.CompareLengthNearVertex)
3271 self.geom = store_geom
3272 hyp.SetLength( length )
3275 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3276 # @ingroup l3_algos_segmarv
3277 def CompareLengthNearVertex(self, hyp, args):
3278 return IsEqual(hyp.GetLength(), args[0])
3280 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3281 # If the 2D mesher sees that all boundary edges are quadratic,
3282 # it generates quadratic faces, else it generates linear faces using
3283 # medium nodes as if they are vertices.
3284 # The 3D mesher generates quadratic volumes only if all boundary faces
3285 # are quadratic, else it fails.
3287 # @ingroup l3_hypos_additi
3288 def QuadraticMesh(self):
3289 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3292 # Public class: Mesh_CompositeSegment
3293 # --------------------------
3295 ## Defines a segment 1D algorithm for discretization
3297 # @ingroup l3_algos_basic
3298 class Mesh_CompositeSegment(Mesh_Segment):
3300 ## Private constructor.
3301 def __init__(self, mesh, geom=0):
3302 self.Create(mesh, geom, "CompositeSegment_1D")
3305 # Public class: Mesh_Segment_Python
3306 # ---------------------------------
3308 ## Defines a segment 1D algorithm for discretization with python function
3310 # @ingroup l3_algos_basic
3311 class Mesh_Segment_Python(Mesh_Segment):
3313 ## Private constructor.
3314 def __init__(self, mesh, geom=0):
3315 import Python1dPlugin
3316 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3318 ## Defines "PythonSplit1D" hypothesis
3319 # @param n for the number of segments that cut an edge
3320 # @param func for the python function that calculates the length of all segments
3321 # @param UseExisting if ==true - searches for the existing hypothesis created with
3322 # the same parameters, else (default) - creates a new one
3323 # @ingroup l3_hypos_1dhyps
3324 def PythonSplit1D(self, n, func, UseExisting=0):
3325 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3326 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3327 hyp.SetNumberOfSegments(n)
3328 hyp.SetPythonLog10RatioFunction(func)
3331 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3332 def ComparePythonSplit1D(self, hyp, args):
3333 #if hyp.GetNumberOfSegments() == args[0]:
3334 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3338 # Public class: Mesh_Triangle
3339 # ---------------------------
3341 ## Defines a triangle 2D algorithm
3343 # @ingroup l3_algos_basic
3344 class Mesh_Triangle(Mesh_Algorithm):
3353 ## Private constructor.
3354 def __init__(self, mesh, algoType, geom=0):
3355 Mesh_Algorithm.__init__(self)
3357 self.algoType = algoType
3358 if algoType == MEFISTO:
3359 self.Create(mesh, geom, "MEFISTO_2D")
3361 elif algoType == BLSURF:
3363 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3364 #self.SetPhysicalMesh() - PAL19680
3365 elif algoType == NETGEN:
3367 print "Warning: NETGENPlugin module unavailable"
3369 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3371 elif algoType == NETGEN_2D:
3373 print "Warning: NETGENPlugin module unavailable"
3375 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3378 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3379 # @param area for the maximum area of each triangle
3380 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3381 # same parameters, else (default) - creates a new one
3383 # Only for algoType == MEFISTO || NETGEN_2D
3384 # @ingroup l3_hypos_2dhyps
3385 def MaxElementArea(self, area, UseExisting=0):
3386 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3387 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3388 CompareMethod=self.CompareMaxElementArea)
3389 elif self.algoType == NETGEN:
3390 hyp = self.Parameters(SIMPLE)
3391 hyp.SetMaxElementArea(area)
3394 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3395 def CompareMaxElementArea(self, hyp, args):
3396 return IsEqual(hyp.GetMaxElementArea(), args[0])
3398 ## Defines "LengthFromEdges" hypothesis to build triangles
3399 # based on the length of the edges taken from the wire
3401 # Only for algoType == MEFISTO || NETGEN_2D
3402 # @ingroup l3_hypos_2dhyps
3403 def LengthFromEdges(self):
3404 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3405 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3407 elif self.algoType == NETGEN:
3408 hyp = self.Parameters(SIMPLE)
3409 hyp.LengthFromEdges()
3412 ## Sets a way to define size of mesh elements to generate.
3413 # @param thePhysicalMesh is: DefaultSize or Custom.
3414 # @ingroup l3_hypos_blsurf
3415 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3416 # Parameter of BLSURF algo
3417 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3419 ## Sets size of mesh elements to generate.
3420 # @ingroup l3_hypos_blsurf
3421 def SetPhySize(self, theVal):
3422 # Parameter of BLSURF algo
3423 self.Parameters().SetPhySize(theVal)
3425 ## Sets lower boundary of mesh element size (PhySize).
3426 # @ingroup l3_hypos_blsurf
3427 def SetPhyMin(self, theVal=-1):
3428 # Parameter of BLSURF algo
3429 self.Parameters().SetPhyMin(theVal)
3431 ## Sets upper boundary of mesh element size (PhySize).
3432 # @ingroup l3_hypos_blsurf
3433 def SetPhyMax(self, theVal=-1):
3434 # Parameter of BLSURF algo
3435 self.Parameters().SetPhyMax(theVal)
3437 ## Sets a way to define maximum angular deflection of mesh from CAD model.
3438 # @param theGeometricMesh is: DefaultGeom or Custom
3439 # @ingroup l3_hypos_blsurf
3440 def SetGeometricMesh(self, theGeometricMesh=0):
3441 # Parameter of BLSURF algo
3442 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3443 self.params.SetGeometricMesh(theGeometricMesh)
3445 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3446 # @ingroup l3_hypos_blsurf
3447 def SetAngleMeshS(self, theVal=_angleMeshS):
3448 # Parameter of BLSURF algo
3449 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3450 self.params.SetAngleMeshS(theVal)
3452 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3453 # @ingroup l3_hypos_blsurf
3454 def SetAngleMeshC(self, theVal=_angleMeshS):
3455 # Parameter of BLSURF algo
3456 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3457 self.params.SetAngleMeshC(theVal)
3459 ## Sets lower boundary of mesh element size computed to respect angular deflection.
3460 # @ingroup l3_hypos_blsurf
3461 def SetGeoMin(self, theVal=-1):
3462 # Parameter of BLSURF algo
3463 self.Parameters().SetGeoMin(theVal)
3465 ## Sets upper boundary of mesh element size computed to respect angular deflection.
3466 # @ingroup l3_hypos_blsurf
3467 def SetGeoMax(self, theVal=-1):
3468 # Parameter of BLSURF algo
3469 self.Parameters().SetGeoMax(theVal)
3471 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3472 # @ingroup l3_hypos_blsurf
3473 def SetGradation(self, theVal=_gradation):
3474 # Parameter of BLSURF algo
3475 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3476 self.params.SetGradation(theVal)
3478 ## Sets topology usage way.
3479 # @param way defines how mesh conformity is assured <ul>
3480 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
3481 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
3482 # @ingroup l3_hypos_blsurf
3483 def SetTopology(self, way):
3484 # Parameter of BLSURF algo
3485 self.Parameters().SetTopology(way)
3487 ## To respect geometrical edges or not.
3488 # @ingroup l3_hypos_blsurf
3489 def SetDecimesh(self, toIgnoreEdges=False):
3490 # Parameter of BLSURF algo
3491 self.Parameters().SetDecimesh(toIgnoreEdges)
3493 ## Sets verbosity level in the range 0 to 100.
3494 # @ingroup l3_hypos_blsurf
3495 def SetVerbosity(self, level):
3496 # Parameter of BLSURF algo
3497 self.Parameters().SetVerbosity(level)
3499 ## Sets advanced option value.
3500 # @ingroup l3_hypos_blsurf
3501 def SetOptionValue(self, optionName, level):
3502 # Parameter of BLSURF algo
3503 self.Parameters().SetOptionValue(optionName,level)
3505 ## Sets QuadAllowed flag.
3506 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
3507 # @ingroup l3_hypos_netgen l3_hypos_blsurf
3508 def SetQuadAllowed(self, toAllow=True):
3509 if self.algoType == NETGEN_2D:
3510 if toAllow: # add QuadranglePreference
3511 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3512 else: # remove QuadranglePreference
3513 for hyp in self.mesh.GetHypothesisList( self.geom ):
3514 if hyp.GetName() == "QuadranglePreference":
3515 self.mesh.RemoveHypothesis( self.geom, hyp )
3520 if self.Parameters():
3521 self.params.SetQuadAllowed(toAllow)
3524 ## Defines hypothesis having several parameters
3526 # @ingroup l3_hypos_netgen
3527 def Parameters(self, which=SOLE):
3530 if self.algoType == NETGEN:
3532 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
3533 "libNETGENEngine.so", UseExisting=0)
3535 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
3536 "libNETGENEngine.so", UseExisting=0)
3538 elif self.algoType == MEFISTO:
3539 print "Mefisto algo support no multi-parameter hypothesis"
3541 elif self.algoType == NETGEN_2D:
3542 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
3543 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3545 elif self.algoType == BLSURF:
3546 self.params = self.Hypothesis("BLSURF_Parameters", [],
3547 "libBLSURFEngine.so", UseExisting=0)
3550 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
3555 # Only for algoType == NETGEN
3556 # @ingroup l3_hypos_netgen
3557 def SetMaxSize(self, theSize):
3558 if self.Parameters():
3559 self.params.SetMaxSize(theSize)
3561 ## Sets SecondOrder flag
3563 # Only for algoType == NETGEN
3564 # @ingroup l3_hypos_netgen
3565 def SetSecondOrder(self, theVal):
3566 if self.Parameters():
3567 self.params.SetSecondOrder(theVal)
3569 ## Sets Optimize flag
3571 # Only for algoType == NETGEN
3572 # @ingroup l3_hypos_netgen
3573 def SetOptimize(self, theVal):
3574 if self.Parameters():
3575 self.params.SetOptimize(theVal)
3578 # @param theFineness is:
3579 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3581 # Only for algoType == NETGEN
3582 # @ingroup l3_hypos_netgen
3583 def SetFineness(self, theFineness):
3584 if self.Parameters():
3585 self.params.SetFineness(theFineness)
3589 # Only for algoType == NETGEN
3590 # @ingroup l3_hypos_netgen
3591 def SetGrowthRate(self, theRate):
3592 if self.Parameters():
3593 self.params.SetGrowthRate(theRate)
3595 ## Sets NbSegPerEdge
3597 # Only for algoType == NETGEN
3598 # @ingroup l3_hypos_netgen
3599 def SetNbSegPerEdge(self, theVal):
3600 if self.Parameters():
3601 self.params.SetNbSegPerEdge(theVal)
3603 ## Sets NbSegPerRadius
3605 # Only for algoType == NETGEN
3606 # @ingroup l3_hypos_netgen
3607 def SetNbSegPerRadius(self, theVal):
3608 if self.Parameters():
3609 self.params.SetNbSegPerRadius(theVal)
3611 ## Sets number of segments overriding value set by SetLocalLength()
3613 # Only for algoType == NETGEN
3614 # @ingroup l3_hypos_netgen
3615 def SetNumberOfSegments(self, theVal):
3616 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3618 ## Sets number of segments overriding value set by SetNumberOfSegments()
3620 # Only for algoType == NETGEN
3621 # @ingroup l3_hypos_netgen
3622 def SetLocalLength(self, theVal):
3623 self.Parameters(SIMPLE).SetLocalLength(theVal)
3628 # Public class: Mesh_Quadrangle
3629 # -----------------------------
3631 ## Defines a quadrangle 2D algorithm
3633 # @ingroup l3_algos_basic
3634 class Mesh_Quadrangle(Mesh_Algorithm):
3636 ## Private constructor.
3637 def __init__(self, mesh, geom=0):
3638 Mesh_Algorithm.__init__(self)
3639 self.Create(mesh, geom, "Quadrangle_2D")
3641 ## Defines "QuadranglePreference" hypothesis, forcing construction
3642 # of quadrangles if the number of nodes on the opposite edges is not the same
3643 # while the total number of nodes on edges is even
3645 # @ingroup l3_hypos_additi
3646 def QuadranglePreference(self):
3647 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
3648 CompareMethod=self.CompareEqualHyp)
3651 ## Defines "TrianglePreference" hypothesis, forcing construction
3652 # of triangles in the refinement area if the number of nodes
3653 # on the opposite edges is not the same
3655 # @ingroup l3_hypos_additi
3656 def TrianglePreference(self):
3657 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
3658 CompareMethod=self.CompareEqualHyp)
3661 # Public class: Mesh_Tetrahedron
3662 # ------------------------------
3664 ## Defines a tetrahedron 3D algorithm
3666 # @ingroup l3_algos_basic
3667 class Mesh_Tetrahedron(Mesh_Algorithm):
3672 ## Private constructor.
3673 def __init__(self, mesh, algoType, geom=0):
3674 Mesh_Algorithm.__init__(self)
3676 if algoType == NETGEN:
3677 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
3680 elif algoType == FULL_NETGEN:
3682 print "Warning: NETGENPlugin module has not been imported."
3683 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3686 elif algoType == GHS3D:
3688 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
3691 self.algoType = algoType
3693 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
3694 # @param vol for the maximum volume of each tetrahedron
3695 # @param UseExisting if ==true - searches for the existing hypothesis created with
3696 # the same parameters, else (default) - creates a new one
3697 # @ingroup l3_hypos_maxvol
3698 def MaxElementVolume(self, vol, UseExisting=0):
3699 if self.algoType == NETGEN:
3700 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
3701 CompareMethod=self.CompareMaxElementVolume)
3702 hyp.SetMaxElementVolume(vol)
3704 elif self.algoType == FULL_NETGEN:
3705 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
3708 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
3709 def CompareMaxElementVolume(self, hyp, args):
3710 return IsEqual(hyp.GetMaxElementVolume(), args[0])
3712 ## Defines hypothesis having several parameters
3714 # @ingroup l3_hypos_netgen
3715 def Parameters(self, which=SOLE):
3718 if self.algoType == FULL_NETGEN:
3720 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
3721 "libNETGENEngine.so", UseExisting=0)
3723 self.params = self.Hypothesis("NETGEN_Parameters", [],
3724 "libNETGENEngine.so", UseExisting=0)
3726 if self.algoType == GHS3D:
3727 self.params = self.Hypothesis("GHS3D_Parameters", [],
3728 "libGHS3DEngine.so", UseExisting=0)
3731 print "Algo supports no multi-parameter hypothesis"
3735 # Parameter of FULL_NETGEN
3736 # @ingroup l3_hypos_netgen
3737 def SetMaxSize(self, theSize):
3738 self.Parameters().SetMaxSize(theSize)
3740 ## Sets SecondOrder flag
3741 # Parameter of FULL_NETGEN
3742 # @ingroup l3_hypos_netgen
3743 def SetSecondOrder(self, theVal):
3744 self.Parameters().SetSecondOrder(theVal)
3746 ## Sets Optimize flag
3747 # Parameter of FULL_NETGEN
3748 # @ingroup l3_hypos_netgen
3749 def SetOptimize(self, theVal):
3750 self.Parameters().SetOptimize(theVal)
3753 # @param theFineness is:
3754 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3755 # Parameter of FULL_NETGEN
3756 # @ingroup l3_hypos_netgen
3757 def SetFineness(self, theFineness):
3758 self.Parameters().SetFineness(theFineness)
3761 # Parameter of FULL_NETGEN
3762 # @ingroup l3_hypos_netgen
3763 def SetGrowthRate(self, theRate):
3764 self.Parameters().SetGrowthRate(theRate)
3766 ## Sets NbSegPerEdge
3767 # Parameter of FULL_NETGEN
3768 # @ingroup l3_hypos_netgen
3769 def SetNbSegPerEdge(self, theVal):
3770 self.Parameters().SetNbSegPerEdge(theVal)
3772 ## Sets NbSegPerRadius
3773 # Parameter of FULL_NETGEN
3774 # @ingroup l3_hypos_netgen
3775 def SetNbSegPerRadius(self, theVal):
3776 self.Parameters().SetNbSegPerRadius(theVal)
3778 ## Sets number of segments overriding value set by SetLocalLength()
3779 # Only for algoType == NETGEN_FULL
3780 # @ingroup l3_hypos_netgen
3781 def SetNumberOfSegments(self, theVal):
3782 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3784 ## Sets number of segments overriding value set by SetNumberOfSegments()
3785 # Only for algoType == NETGEN_FULL
3786 # @ingroup l3_hypos_netgen
3787 def SetLocalLength(self, theVal):
3788 self.Parameters(SIMPLE).SetLocalLength(theVal)
3790 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
3791 # Overrides value set by LengthFromEdges()
3792 # Only for algoType == NETGEN_FULL
3793 # @ingroup l3_hypos_netgen
3794 def MaxElementArea(self, area):
3795 self.Parameters(SIMPLE).SetMaxElementArea(area)
3797 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
3798 # Overrides value set by MaxElementArea()
3799 # Only for algoType == NETGEN_FULL
3800 # @ingroup l3_hypos_netgen
3801 def LengthFromEdges(self):
3802 self.Parameters(SIMPLE).LengthFromEdges()
3804 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
3805 # Overrides value set by MaxElementVolume()
3806 # Only for algoType == NETGEN_FULL
3807 # @ingroup l3_hypos_netgen
3808 def LengthFromFaces(self):
3809 self.Parameters(SIMPLE).LengthFromFaces()
3811 ## To mesh "holes" in a solid or not. Default is to mesh.
3812 # @ingroup l3_hypos_ghs3dh
3813 def SetToMeshHoles(self, toMesh):
3814 # Parameter of GHS3D
3815 self.Parameters().SetToMeshHoles(toMesh)
3817 ## Set Optimization level:
3818 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
3819 # Default is Medium_Optimization
3820 # @ingroup l3_hypos_ghs3dh
3821 def SetOptimizationLevel(self, level):
3822 # Parameter of GHS3D
3823 self.Parameters().SetOptimizationLevel(level)
3825 ## Maximal size of memory to be used by the algorithm (in Megabytes).
3826 # @ingroup l3_hypos_ghs3dh
3827 def SetMaximumMemory(self, MB):
3828 # Advanced parameter of GHS3D
3829 self.Parameters().SetMaximumMemory(MB)
3831 ## Initial size of memory to be used by the algorithm (in Megabytes) in
3832 # automatic memory adjustment mode.
3833 # @ingroup l3_hypos_ghs3dh
3834 def SetInitialMemory(self, MB):
3835 # Advanced parameter of GHS3D
3836 self.Parameters().SetInitialMemory(MB)
3838 ## Path to working directory.
3839 # @ingroup l3_hypos_ghs3dh
3840 def SetWorkingDirectory(self, path):
3841 # Advanced parameter of GHS3D
3842 self.Parameters().SetWorkingDirectory(path)
3844 ## To keep working files or remove them. Log file remains in case of errors anyway.
3845 # @ingroup l3_hypos_ghs3dh
3846 def SetKeepFiles(self, toKeep):
3847 # Advanced parameter of GHS3D
3848 self.Parameters().SetKeepFiles(toKeep)
3850 ## To set verbose level [0-10]. <ul>
3851 #<li> 0 - no standard output,
3852 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
3853 # indicates when the final mesh is being saved. In addition the software
3854 # gives indication regarding the CPU time.
3855 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
3856 # histogram of the skin mesh, quality statistics histogram together with
3857 # the characteristics of the final mesh.</ul>
3858 # @ingroup l3_hypos_ghs3dh
3859 def SetVerboseLevel(self, level):
3860 # Advanced parameter of GHS3D
3861 self.Parameters().SetVerboseLevel(level)
3863 ## To create new nodes.
3864 # @ingroup l3_hypos_ghs3dh
3865 def SetToCreateNewNodes(self, toCreate):
3866 # Advanced parameter of GHS3D
3867 self.Parameters().SetToCreateNewNodes(toCreate)
3869 ## To use boundary recovery version which tries to create mesh on a very poor
3870 # quality surface mesh.
3871 # @ingroup l3_hypos_ghs3dh
3872 def SetToUseBoundaryRecoveryVersion(self, toUse):
3873 # Advanced parameter of GHS3D
3874 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
3876 ## Sets command line option as text.
3877 # @ingroup l3_hypos_ghs3dh
3878 def SetTextOption(self, option):
3879 # Advanced parameter of GHS3D
3880 self.Parameters().SetTextOption(option)
3882 # Public class: Mesh_Hexahedron
3883 # ------------------------------
3885 ## Defines a hexahedron 3D algorithm
3887 # @ingroup l3_algos_basic
3888 class Mesh_Hexahedron(Mesh_Algorithm):
3893 ## Private constructor.
3894 def __init__(self, mesh, algoType=Hexa, geom=0):
3895 Mesh_Algorithm.__init__(self)
3897 self.algoType = algoType
3899 if algoType == Hexa:
3900 self.Create(mesh, geom, "Hexa_3D")
3903 elif algoType == Hexotic:
3904 import HexoticPlugin
3905 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
3908 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
3909 # @ingroup l3_hypos_hexotic
3910 def MinMaxQuad(self, min=3, max=8, quad=True):
3911 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
3913 self.params.SetHexesMinLevel(min)
3914 self.params.SetHexesMaxLevel(max)
3915 self.params.SetHexoticQuadrangles(quad)
3918 # Deprecated, only for compatibility!
3919 # Public class: Mesh_Netgen
3920 # ------------------------------
3922 ## Defines a NETGEN-based 2D or 3D algorithm
3923 # that needs no discrete boundary (i.e. independent)
3925 # This class is deprecated, only for compatibility!
3928 # @ingroup l3_algos_basic
3929 class Mesh_Netgen(Mesh_Algorithm):
3933 ## Private constructor.
3934 def __init__(self, mesh, is3D, geom=0):
3935 Mesh_Algorithm.__init__(self)
3938 print "Warning: NETGENPlugin module has not been imported."
3942 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3946 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3949 ## Defines the hypothesis containing parameters of the algorithm
3950 def Parameters(self):
3952 hyp = self.Hypothesis("NETGEN_Parameters", [],
3953 "libNETGENEngine.so", UseExisting=0)
3955 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
3956 "libNETGENEngine.so", UseExisting=0)
3959 # Public class: Mesh_Projection1D
3960 # ------------------------------
3962 ## Defines a projection 1D algorithm
3963 # @ingroup l3_algos_proj
3965 class Mesh_Projection1D(Mesh_Algorithm):
3967 ## Private constructor.
3968 def __init__(self, mesh, geom=0):
3969 Mesh_Algorithm.__init__(self)
3970 self.Create(mesh, geom, "Projection_1D")
3972 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
3973 # a mesh pattern is taken, and, optionally, the association of vertices
3974 # between the source edge and a target edge (to which a hypothesis is assigned)
3975 # @param edge from which nodes distribution is taken
3976 # @param mesh from which nodes distribution is taken (optional)
3977 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
3978 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
3979 # to associate with \a srcV (optional)
3980 # @param UseExisting if ==true - searches for the existing hypothesis created with
3981 # the same parameters, else (default) - creates a new one
3982 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
3983 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
3985 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
3986 hyp.SetSourceEdge( edge )
3987 if not mesh is None and isinstance(mesh, Mesh):
3988 mesh = mesh.GetMesh()
3989 hyp.SetSourceMesh( mesh )
3990 hyp.SetVertexAssociation( srcV, tgtV )
3993 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
3994 #def CompareSourceEdge(self, hyp, args):
3995 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
3999 # Public class: Mesh_Projection2D
4000 # ------------------------------
4002 ## Defines a projection 2D algorithm
4003 # @ingroup l3_algos_proj
4005 class Mesh_Projection2D(Mesh_Algorithm):
4007 ## Private constructor.
4008 def __init__(self, mesh, geom=0):
4009 Mesh_Algorithm.__init__(self)
4010 self.Create(mesh, geom, "Projection_2D")
4012 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4013 # a mesh pattern is taken, and, optionally, the association of vertices
4014 # between the source face and the target face (to which a hypothesis is assigned)
4015 # @param face from which the mesh pattern is taken
4016 # @param mesh from which the mesh pattern is taken (optional)
4017 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4018 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4019 # to associate with \a srcV1 (optional)
4020 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4021 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4022 # to associate with \a srcV2 (optional)
4023 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4024 # the same parameters, else (default) - forces the creation a new one
4026 # Note: all association vertices must belong to one edge of a face
4027 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4028 srcV2=None, tgtV2=None, UseExisting=0):
4029 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4031 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4032 hyp.SetSourceFace( face )
4033 if not mesh is None and isinstance(mesh, Mesh):
4034 mesh = mesh.GetMesh()
4035 hyp.SetSourceMesh( mesh )
4036 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4039 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4040 #def CompareSourceFace(self, hyp, args):
4041 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4044 # Public class: Mesh_Projection3D
4045 # ------------------------------
4047 ## Defines a projection 3D algorithm
4048 # @ingroup l3_algos_proj
4050 class Mesh_Projection3D(Mesh_Algorithm):
4052 ## Private constructor.
4053 def __init__(self, mesh, geom=0):
4054 Mesh_Algorithm.__init__(self)
4055 self.Create(mesh, geom, "Projection_3D")
4057 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4058 # the mesh pattern is taken, and, optionally, the association of vertices
4059 # between the source and the target solid (to which a hipothesis is assigned)
4060 # @param solid from where the mesh pattern is taken
4061 # @param mesh from where the mesh pattern is taken (optional)
4062 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4063 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4064 # to associate with \a srcV1 (optional)
4065 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4066 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4067 # to associate with \a srcV2 (optional)
4068 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4069 # the same parameters, else (default) - creates a new one
4071 # Note: association vertices must belong to one edge of a solid
4072 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4073 srcV2=0, tgtV2=0, UseExisting=0):
4074 hyp = self.Hypothesis("ProjectionSource3D",
4075 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4077 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4078 hyp.SetSource3DShape( solid )
4079 if not mesh is None and isinstance(mesh, Mesh):
4080 mesh = mesh.GetMesh()
4081 hyp.SetSourceMesh( mesh )
4082 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4085 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4086 #def CompareSourceShape3D(self, hyp, args):
4087 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4091 # Public class: Mesh_Prism
4092 # ------------------------
4094 ## Defines a 3D extrusion algorithm
4095 # @ingroup l3_algos_3dextr
4097 class Mesh_Prism3D(Mesh_Algorithm):
4099 ## Private constructor.
4100 def __init__(self, mesh, geom=0):
4101 Mesh_Algorithm.__init__(self)
4102 self.Create(mesh, geom, "Prism_3D")
4104 # Public class: Mesh_RadialPrism
4105 # -------------------------------
4107 ## Defines a Radial Prism 3D algorithm
4108 # @ingroup l3_algos_radialp
4110 class Mesh_RadialPrism3D(Mesh_Algorithm):
4112 ## Private constructor.
4113 def __init__(self, mesh, geom=0):
4114 Mesh_Algorithm.__init__(self)
4115 self.Create(mesh, geom, "RadialPrism_3D")
4117 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4118 self.nbLayers = None
4120 ## Return 3D hypothesis holding the 1D one
4121 def Get3DHypothesis(self):
4122 return self.distribHyp
4124 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4125 # hypothesis. Returns the created hypothesis
4126 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4127 #print "OwnHypothesis",hypType
4128 if not self.nbLayers is None:
4129 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4130 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4131 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4132 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4133 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4134 self.distribHyp.SetLayerDistribution( hyp )
4137 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4138 # prisms to build between the inner and outer shells
4139 # @param n number of layers
4140 # @param UseExisting if ==true - searches for the existing hypothesis created with
4141 # the same parameters, else (default) - creates a new one
4142 def NumberOfLayers(self, n, UseExisting=0):
4143 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4144 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4145 CompareMethod=self.CompareNumberOfLayers)
4146 self.nbLayers.SetNumberOfLayers( n )
4147 return self.nbLayers
4149 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4150 def CompareNumberOfLayers(self, hyp, args):
4151 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4153 ## Defines "LocalLength" hypothesis, specifying the segment length
4154 # to build between the inner and the outer shells
4155 # @param l the length of segments
4156 # @param p the precision of rounding
4157 def LocalLength(self, l, p=1e-07):
4158 hyp = self.OwnHypothesis("LocalLength", [l,p])
4163 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4164 # prisms to build between the inner and the outer shells.
4165 # @param n the number of layers
4166 # @param s the scale factor (optional)
4167 def NumberOfSegments(self, n, s=[]):
4169 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4171 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4172 hyp.SetDistrType( 1 )
4173 hyp.SetScaleFactor(s)
4174 hyp.SetNumberOfSegments(n)
4177 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4178 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4179 # @param start the length of the first segment
4180 # @param end the length of the last segment
4181 def Arithmetic1D(self, start, end ):
4182 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4183 hyp.SetLength(start, 1)
4184 hyp.SetLength(end , 0)
4187 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4188 # to build between the inner and the outer shells as geometric length increasing
4189 # @param start for the length of the first segment
4190 # @param end for the length of the last segment
4191 def StartEndLength(self, start, end):
4192 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4193 hyp.SetLength(start, 1)
4194 hyp.SetLength(end , 0)
4197 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4198 # to build between the inner and outer shells
4199 # @param fineness defines the quality of the mesh within the range [0-1]
4200 def AutomaticLength(self, fineness=0):
4201 hyp = self.OwnHypothesis("AutomaticLength")
4202 hyp.SetFineness( fineness )
4205 # Private class: Mesh_UseExisting
4206 # -------------------------------
4207 class Mesh_UseExisting(Mesh_Algorithm):
4209 def __init__(self, dim, mesh, geom=0):
4211 self.Create(mesh, geom, "UseExisting_1D")
4213 self.Create(mesh, geom, "UseExisting_2D")
4216 import salome_notebook
4217 notebook = salome_notebook.notebook
4219 ##Return values of the notebook variables
4220 def ParseParameters(last, nbParams,nbParam, value):
4224 listSize = len(last)
4225 for n in range(0,nbParams):
4227 if counter < listSize:
4228 strResult = strResult + last[counter]
4230 strResult = strResult + ""
4232 if isinstance(value, str):
4233 if notebook.isVariable(value):
4234 result = notebook.get(value)
4235 strResult=strResult+value
4237 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
4239 strResult=strResult+str(value)
4241 if nbParams - 1 != counter:
4242 strResult=strResult+variable_separator #":"
4244 return result, strResult
4246 #Wrapper class for StdMeshers_LocalLength hypothesis
4247 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
4249 ## Set Length parameter value
4250 # @param length numerical value or name of variable from notebook
4251 def SetLength(self, length):
4252 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
4253 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4254 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
4256 ## Set Precision parameter value
4257 # @param precision numerical value or name of variable from notebook
4258 def SetPrecision(self, precision):
4259 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
4260 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
4261 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
4263 #Registering the new proxy for LocalLength
4264 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
4267 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
4268 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
4270 ## Set Length parameter value
4271 # @param length numerical value or name of variable from notebook
4272 def SetLength(self, length):
4273 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
4274 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
4275 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
4277 #Registering the new proxy for SegmentLengthAroundVertex
4278 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
4281 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
4282 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
4284 ## Set Length parameter value
4285 # @param length numerical value or name of variable from notebook
4286 # @param isStart true is length is Start Length, otherwise false
4287 def SetLength(self, length, isStart):
4291 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
4292 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
4293 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
4295 #Registering the new proxy for Arithmetic1D
4296 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
4298 #Wrapper class for StdMeshers_Deflection1D hypothesis
4299 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
4301 ## Set Deflection parameter value
4302 # @param deflection numerical value or name of variable from notebook
4303 def SetDeflection(self, deflection):
4304 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
4305 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
4306 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
4308 #Registering the new proxy for Deflection1D
4309 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
4311 #Wrapper class for StdMeshers_StartEndLength hypothesis
4312 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
4314 ## Set Length parameter value
4315 # @param length numerical value or name of variable from notebook
4316 # @param isStart true is length is Start Length, otherwise false
4317 def SetLength(self, length, isStart):
4321 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
4322 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
4323 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
4325 #Registering the new proxy for StartEndLength
4326 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
4328 #Wrapper class for StdMeshers_MaxElementArea hypothesis
4329 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
4331 ## Set Max Element Area parameter value
4332 # @param area numerical value or name of variable from notebook
4333 def SetMaxElementArea(self, area):
4334 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
4335 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
4336 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
4338 #Registering the new proxy for MaxElementArea
4339 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
4341 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
4342 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
4344 ## Set Number Of Layers parameter value
4345 # @param nbLayers numerical value or name of variable from notebook
4346 def SetNumberOfLayers(self, nbLayers):
4347 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
4348 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
4349 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
4351 #Registering the new proxy for NumberOfLayers
4352 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
4354 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
4355 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
4357 ## Set Number Of Segments parameter value
4358 # @param nbSeg numerical value or name of variable from notebook
4359 def SetNumberOfSegments(self, nbSeg):
4360 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
4361 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
4362 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4363 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
4365 ## Set Scale Factor parameter value
4366 # @param factor numerical value or name of variable from notebook
4367 def SetScaleFactor(self, factor):
4368 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
4369 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
4370 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
4372 #Registering the new proxy for NumberOfSegments
4373 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)