1 # Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Author : Francis KLOSS, OCC
28 ## @defgroup l1_auxiliary Auxiliary methods and structures
29 ## @defgroup l1_creating Creating meshes
31 ## @defgroup l2_impexp Importing and exporting meshes
32 ## @defgroup l2_construct Constructing meshes
33 ## @defgroup l2_algorithms Defining Algorithms
35 ## @defgroup l3_algos_basic Basic meshing algorithms
36 ## @defgroup l3_algos_proj Projection Algorithms
37 ## @defgroup l3_algos_radialp Radial Prism
38 ## @defgroup l3_algos_segmarv Segments around Vertex
39 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
42 ## @defgroup l2_hypotheses Defining hypotheses
44 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
45 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
46 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
47 ## @defgroup l3_hypos_quad Quadrangle Parameters hypothesis
48 ## @defgroup l3_hypos_additi Additional Hypotheses
51 ## @defgroup l2_submeshes Constructing submeshes
52 ## @defgroup l2_compounds Building Compounds
53 ## @defgroup l2_editing Editing Meshes
56 ## @defgroup l1_meshinfo Mesh Information
57 ## @defgroup l1_controls Quality controls and Filtering
58 ## @defgroup l1_grouping Grouping elements
60 ## @defgroup l2_grps_create Creating groups
61 ## @defgroup l2_grps_edit Editing groups
62 ## @defgroup l2_grps_operon Using operations on groups
63 ## @defgroup l2_grps_delete Deleting Groups
66 ## @defgroup l1_modifying Modifying meshes
68 ## @defgroup l2_modif_add Adding nodes and elements
69 ## @defgroup l2_modif_del Removing nodes and elements
70 ## @defgroup l2_modif_edit Modifying nodes and elements
71 ## @defgroup l2_modif_renumber Renumbering nodes and elements
72 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
73 ## @defgroup l2_modif_movenode Moving nodes
74 ## @defgroup l2_modif_throughp Mesh through point
75 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
76 ## @defgroup l2_modif_unitetri Uniting triangles
77 ## @defgroup l2_modif_changori Changing orientation of elements
78 ## @defgroup l2_modif_cutquadr Cutting quadrangles
79 ## @defgroup l2_modif_smooth Smoothing
80 ## @defgroup l2_modif_extrurev Extrusion and Revolution
81 ## @defgroup l2_modif_patterns Pattern mapping
82 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
85 ## @defgroup l1_measurements Measurements
90 import SMESH # This is necessary for back compatibility
96 ## @addtogroup l1_auxiliary
99 # MirrorType enumeration
100 POINT = SMESH_MeshEditor.POINT
101 AXIS = SMESH_MeshEditor.AXIS
102 PLANE = SMESH_MeshEditor.PLANE
104 # Smooth_Method enumeration
105 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
106 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
108 PrecisionConfusion = 1e-07
110 # TopAbs_State enumeration
111 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
113 # Methods of splitting a hexahedron into tetrahedra
114 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
116 ## Converts an angle from degrees to radians
117 def DegreesToRadians(AngleInDegrees):
119 return AngleInDegrees * pi / 180.0
121 import salome_notebook
122 notebook = salome_notebook.notebook
123 # Salome notebook variable separator
126 ## Return list of variable values from salome notebook.
127 # The last argument, if is callable, is used to modify values got from notebook
128 def ParseParameters(*args):
133 if args and callable( args[-1] ):
134 args, varModifFun = args[:-1], args[-1]
135 for parameter in args:
137 Parameters += str(parameter) + var_separator
139 if isinstance(parameter,str):
140 # check if there is an inexistent variable name
141 if not notebook.isVariable(parameter):
142 raise ValueError, "Variable with name '" + parameter + "' doesn't exist!!!"
143 parameter = notebook.get(parameter)
146 parameter = varModifFun(parameter)
149 Result.append(parameter)
152 Parameters = Parameters[:-1]
153 Result.append( Parameters )
154 Result.append( hasVariables )
157 # Parse parameters converting variables to radians
158 def ParseAngles(*args):
159 return ParseParameters( *( args + (DegreesToRadians, )))
161 # Substitute PointStruct.__init__() to create SMESH.PointStruct using notebook variables.
162 # Parameters are stored in PointStruct.parameters attribute
163 def __initPointStruct(point,*args):
164 point.x, point.y, point.z, point.parameters,hasVars = ParseParameters(*args)
166 SMESH.PointStruct.__init__ = __initPointStruct
168 # Substitute AxisStruct.__init__() to create SMESH.AxisStruct using notebook variables.
169 # Parameters are stored in AxisStruct.parameters attribute
170 def __initAxisStruct(ax,*args):
171 ax.x, ax.y, ax.z, ax.vx, ax.vy, ax.vz, ax.parameters,hasVars = ParseParameters(*args)
173 SMESH.AxisStruct.__init__ = __initAxisStruct
176 def IsEqual(val1, val2, tol=PrecisionConfusion):
177 if abs(val1 - val2) < tol:
187 if isinstance(obj, SALOMEDS._objref_SObject):
190 ior = salome.orb.object_to_string(obj)
193 studies = salome.myStudyManager.GetOpenStudies()
194 for sname in studies:
195 s = salome.myStudyManager.GetStudyByName(sname)
197 sobj = s.FindObjectIOR(ior)
198 if not sobj: continue
199 return sobj.GetName()
200 if hasattr(obj, "GetName"):
201 # unknown CORBA object, having GetName() method
204 # unknown CORBA object, no GetName() method
207 if hasattr(obj, "GetName"):
208 # unknown non-CORBA object, having GetName() method
211 raise RuntimeError, "Null or invalid object"
213 ## Prints error message if a hypothesis was not assigned.
214 def TreatHypoStatus(status, hypName, geomName, isAlgo):
216 hypType = "algorithm"
218 hypType = "hypothesis"
220 if status == HYP_UNKNOWN_FATAL :
221 reason = "for unknown reason"
222 elif status == HYP_INCOMPATIBLE :
223 reason = "this hypothesis mismatches the algorithm"
224 elif status == HYP_NOTCONFORM :
225 reason = "a non-conform mesh would be built"
226 elif status == HYP_ALREADY_EXIST :
227 if isAlgo: return # it does not influence anything
228 reason = hypType + " of the same dimension is already assigned to this shape"
229 elif status == HYP_BAD_DIM :
230 reason = hypType + " mismatches the shape"
231 elif status == HYP_CONCURENT :
232 reason = "there are concurrent hypotheses on sub-shapes"
233 elif status == HYP_BAD_SUBSHAPE :
234 reason = "the shape is neither the main one, nor its sub-shape, nor a valid group"
235 elif status == HYP_BAD_GEOMETRY:
236 reason = "geometry mismatches the expectation of the algorithm"
237 elif status == HYP_HIDDEN_ALGO:
238 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
239 elif status == HYP_HIDING_ALGO:
240 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
241 elif status == HYP_NEED_SHAPE:
242 reason = "Algorithm can't work without shape"
245 hypName = '"' + hypName + '"'
246 geomName= '"' + geomName+ '"'
247 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
248 print hypName, "was assigned to", geomName,"but", reason
249 elif not geomName == '""':
250 print hypName, "was not assigned to",geomName,":", reason
252 print hypName, "was not assigned:", reason
255 ## Private method. Add geom (sub-shape of the main shape) into the study if not yet there
256 def AssureGeomPublished(mesh, geom, name=''):
257 if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
259 if not geom.IsSame( mesh.geom ) and \
260 not geom.GetStudyEntry() and \
261 mesh.smeshpyD.GetCurrentStudy():
263 studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
264 if studyID != mesh.geompyD.myStudyId:
265 mesh.geompyD.init_geom( mesh.smeshpyD.GetCurrentStudy())
267 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
268 # for all groups SubShapeName() returns "Compound_-1"
269 name = mesh.geompyD.SubShapeName(geom, mesh.geom)
271 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
273 mesh.geompyD.addToStudyInFather( mesh.geom, geom, name )
276 ## Return the first vertex of a geomertical edge by ignoring orienation
277 def FirstVertexOnCurve(edge):
278 from geompy import SubShapeAll, ShapeType, KindOfShape, PointCoordinates
279 vv = SubShapeAll( edge, ShapeType["VERTEX"])
281 raise TypeError, "Given object has no vertices"
282 if len( vv ) == 1: return vv[0]
283 info = KindOfShape(edge)
284 xyz = info[1:4] # coords of the first vertex
285 xyz1 = PointCoordinates( vv[0] )
286 xyz2 = PointCoordinates( vv[1] )
289 dist1 += abs( xyz[i] - xyz1[i] )
290 dist2 += abs( xyz[i] - xyz2[i] )
296 # end of l1_auxiliary
299 # All methods of this class are accessible directly from the smesh.py package.
300 class smeshDC(SMESH._objref_SMESH_Gen):
302 ## Dump component to the Python script
303 # This method overrides IDL function to allow default values for the parameters.
304 def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True):
305 return SMESH._objref_SMESH_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile)
307 ## Set mode of DumpPython(), \a historical or \a snapshot.
308 # In the \a historical mode, the Python Dump script includes all commands
309 # performed by SMESH engine. In the \a snapshot mode, commands
310 # relating to objects removed from the Study are excluded from the script
311 # as well as commands not influencing the current state of meshes
312 def SetDumpPythonHistorical(self, isHistorical):
313 if isHistorical: val = "true"
315 SMESH._objref_SMESH_Gen.SetOption(self, "historical_python_dump", val)
317 ## Sets the current study and Geometry component
318 # @ingroup l1_auxiliary
319 def init_smesh(self,theStudy,geompyD):
320 self.SetCurrentStudy(theStudy,geompyD)
322 ## Creates an empty Mesh. This mesh can have an underlying geometry.
323 # @param obj the Geometrical object on which the mesh is built. If not defined,
324 # the mesh will have no underlying geometry.
325 # @param name the name for the new mesh.
326 # @return an instance of Mesh class.
327 # @ingroup l2_construct
328 def Mesh(self, obj=0, name=0):
329 if isinstance(obj,str):
331 return Mesh(self,self.geompyD,obj,name)
333 ## Returns a long value from enumeration
334 # Should be used for SMESH.FunctorType enumeration
335 # @ingroup l1_controls
336 def EnumToLong(self,theItem):
339 ## Returns a string representation of the color.
340 # To be used with filters.
341 # @param c color value (SALOMEDS.Color)
342 # @ingroup l1_controls
343 def ColorToString(self,c):
345 if isinstance(c, SALOMEDS.Color):
346 val = "%s;%s;%s" % (c.R, c.G, c.B)
347 elif isinstance(c, str):
350 raise ValueError, "Color value should be of string or SALOMEDS.Color type"
353 ## Gets PointStruct from vertex
354 # @param theVertex a GEOM object(vertex)
355 # @return SMESH.PointStruct
356 # @ingroup l1_auxiliary
357 def GetPointStruct(self,theVertex):
358 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
359 return PointStruct(x,y,z)
361 ## Gets DirStruct from vector
362 # @param theVector a GEOM object(vector)
363 # @return SMESH.DirStruct
364 # @ingroup l1_auxiliary
365 def GetDirStruct(self,theVector):
366 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
367 if(len(vertices) != 2):
368 print "Error: vector object is incorrect."
370 p1 = self.geompyD.PointCoordinates(vertices[0])
371 p2 = self.geompyD.PointCoordinates(vertices[1])
372 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
373 dirst = DirStruct(pnt)
376 ## Makes DirStruct from a triplet
377 # @param x,y,z vector components
378 # @return SMESH.DirStruct
379 # @ingroup l1_auxiliary
380 def MakeDirStruct(self,x,y,z):
381 pnt = PointStruct(x,y,z)
382 return DirStruct(pnt)
384 ## Get AxisStruct from object
385 # @param theObj a GEOM object (line or plane)
386 # @return SMESH.AxisStruct
387 # @ingroup l1_auxiliary
388 def GetAxisStruct(self,theObj):
389 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
391 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
392 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
393 vertex1 = self.geompyD.PointCoordinates(vertex1)
394 vertex2 = self.geompyD.PointCoordinates(vertex2)
395 vertex3 = self.geompyD.PointCoordinates(vertex3)
396 vertex4 = self.geompyD.PointCoordinates(vertex4)
397 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
398 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
399 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] ]
400 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
402 elif len(edges) == 1:
403 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
404 p1 = self.geompyD.PointCoordinates( vertex1 )
405 p2 = self.geompyD.PointCoordinates( vertex2 )
406 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
410 # From SMESH_Gen interface:
411 # ------------------------
413 ## Sets the given name to the object
414 # @param obj the object to rename
415 # @param name a new object name
416 # @ingroup l1_auxiliary
417 def SetName(self, obj, name):
418 if isinstance( obj, Mesh ):
420 elif isinstance( obj, Mesh_Algorithm ):
421 obj = obj.GetAlgorithm()
422 ior = salome.orb.object_to_string(obj)
423 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
425 ## Sets the current mode
426 # @ingroup l1_auxiliary
427 def SetEmbeddedMode( self,theMode ):
428 #self.SetEmbeddedMode(theMode)
429 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
431 ## Gets the current mode
432 # @ingroup l1_auxiliary
433 def IsEmbeddedMode(self):
434 #return self.IsEmbeddedMode()
435 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
437 ## Sets the current study
438 # @ingroup l1_auxiliary
439 def SetCurrentStudy( self, theStudy, geompyD = None ):
440 #self.SetCurrentStudy(theStudy)
443 geompyD = geompy.geom
446 self.SetGeomEngine(geompyD)
447 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
450 notebook = salome_notebook.NoteBook( theStudy )
452 notebook = salome_notebook.NoteBook( salome_notebook.PseudoStudyForNoteBook() )
454 ## Gets the current study
455 # @ingroup l1_auxiliary
456 def GetCurrentStudy(self):
457 #return self.GetCurrentStudy()
458 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
460 ## Creates a Mesh object importing data from the given UNV file
461 # @return an instance of Mesh class
463 def CreateMeshesFromUNV( self,theFileName ):
464 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
465 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
468 ## Creates a Mesh object(s) importing data from the given MED file
469 # @return a list of Mesh class instances
471 def CreateMeshesFromMED( self,theFileName ):
472 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
474 for iMesh in range(len(aSmeshMeshes)) :
475 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
476 aMeshes.append(aMesh)
477 return aMeshes, aStatus
479 ## Creates a Mesh object(s) importing data from the given SAUV file
480 # @return a list of Mesh class instances
482 def CreateMeshesFromSAUV( self,theFileName ):
483 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromSAUV(self,theFileName)
485 for iMesh in range(len(aSmeshMeshes)) :
486 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
487 aMeshes.append(aMesh)
488 return aMeshes, aStatus
490 ## Creates a Mesh object importing data from the given STL file
491 # @return an instance of Mesh class
493 def CreateMeshesFromSTL( self, theFileName ):
494 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
495 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
498 ## Creates Mesh objects importing data from the given CGNS file
499 # @return an instance of Mesh class
501 def CreateMeshesFromCGNS( self, theFileName ):
502 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromCGNS(self,theFileName)
504 for iMesh in range(len(aSmeshMeshes)) :
505 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
506 aMeshes.append(aMesh)
507 return aMeshes, aStatus
509 ## Concatenate the given meshes into one mesh.
510 # @return an instance of Mesh class
511 # @param meshes the meshes to combine into one mesh
512 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
513 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
514 # @param mergeTolerance tolerance for merging nodes
515 # @param allGroups forces creation of groups of all elements
516 def Concatenate( self, meshes, uniteIdenticalGroups,
517 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
518 if not meshes: return None
519 for i,m in enumerate(meshes):
520 if isinstance(m, Mesh):
521 meshes[i] = m.GetMesh()
522 mergeTolerance,Parameters,hasVars = ParseParameters(mergeTolerance)
523 meshes[0].SetParameters(Parameters)
525 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
526 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
528 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
529 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
530 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
533 ## Create a mesh by copying a part of another mesh.
534 # @param meshPart a part of mesh to copy, either a Mesh, a sub-mesh or a group;
535 # to copy nodes or elements not contained in any mesh object,
536 # pass result of Mesh.GetIDSource( list_of_ids, type ) as meshPart
537 # @param meshName a name of the new mesh
538 # @param toCopyGroups to create in the new mesh groups the copied elements belongs to
539 # @param toKeepIDs to preserve IDs of the copied elements or not
540 # @return an instance of Mesh class
541 def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False):
542 if (isinstance( meshPart, Mesh )):
543 meshPart = meshPart.GetMesh()
544 mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs )
545 return Mesh(self, self.geompyD, mesh)
547 ## From SMESH_Gen interface
548 # @return the list of integer values
549 # @ingroup l1_auxiliary
550 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
551 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
553 ## From SMESH_Gen interface. Creates a pattern
554 # @return an instance of SMESH_Pattern
556 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
557 # @ingroup l2_modif_patterns
558 def GetPattern(self):
559 return SMESH._objref_SMESH_Gen.GetPattern(self)
561 ## Sets number of segments per diagonal of boundary box of geometry by which
562 # default segment length of appropriate 1D hypotheses is defined.
563 # Default value is 10
564 # @ingroup l1_auxiliary
565 def SetBoundaryBoxSegmentation(self, nbSegments):
566 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
568 # Filtering. Auxiliary functions:
569 # ------------------------------
571 ## Creates an empty criterion
572 # @return SMESH.Filter.Criterion
573 # @ingroup l1_controls
574 def GetEmptyCriterion(self):
575 Type = self.EnumToLong(FT_Undefined)
576 Compare = self.EnumToLong(FT_Undefined)
580 UnaryOp = self.EnumToLong(FT_Undefined)
581 BinaryOp = self.EnumToLong(FT_Undefined)
584 Precision = -1 ##@1e-07
585 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
586 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
588 ## Creates a criterion by the given parameters
589 # \n Criterion structures allow to define complex filters by combining them with logical operations (AND / OR) (see example below)
590 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
591 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
592 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
593 # @param Threshold the threshold value (range of ids as string, shape, numeric)
594 # @param UnaryOp FT_LogicalNOT or FT_Undefined
595 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
596 # FT_Undefined (must be for the last criterion of all criteria)
597 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
598 # FT_LyingOnGeom, FT_CoplanarFaces criteria
599 # @return SMESH.Filter.Criterion
601 # <a href="../tui_filters_page.html#combining_filters">Example of Criteria usage</a>
602 # @ingroup l1_controls
603 def GetCriterion(self,elementType,
605 Compare = FT_EqualTo,
607 UnaryOp=FT_Undefined,
608 BinaryOp=FT_Undefined,
610 if not CritType in SMESH.FunctorType._items:
611 raise TypeError, "CritType should be of SMESH.FunctorType"
612 aCriterion = self.GetEmptyCriterion()
613 aCriterion.TypeOfElement = elementType
614 aCriterion.Type = self.EnumToLong(CritType)
615 aCriterion.Tolerance = Tolerance
617 aThreshold = Threshold
619 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
620 aCriterion.Compare = self.EnumToLong(Compare)
621 elif Compare == "=" or Compare == "==":
622 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
624 aCriterion.Compare = self.EnumToLong(FT_LessThan)
626 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
627 elif Compare != FT_Undefined:
628 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
631 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
632 FT_BelongToCylinder, FT_LyingOnGeom]:
633 # Checks the Threshold
634 if isinstance(aThreshold, geompyDC.GEOM._objref_GEOM_Object):
635 aCriterion.ThresholdStr = GetName(aThreshold)
636 aCriterion.ThresholdID = salome.ObjectToID(aThreshold)
638 print "Error: The Threshold should be a shape."
640 if isinstance(UnaryOp,float):
641 aCriterion.Tolerance = UnaryOp
642 UnaryOp = FT_Undefined
644 elif CritType == FT_RangeOfIds:
645 # Checks the Threshold
646 if isinstance(aThreshold, str):
647 aCriterion.ThresholdStr = aThreshold
649 print "Error: The Threshold should be a string."
651 elif CritType == FT_CoplanarFaces:
652 # Checks the Threshold
653 if isinstance(aThreshold, int):
654 aCriterion.ThresholdID = "%s"%aThreshold
655 elif isinstance(aThreshold, str):
658 raise ValueError, "Invalid ID of mesh face: '%s'"%aThreshold
659 aCriterion.ThresholdID = aThreshold
662 "The Threshold should be an ID of mesh face and not '%s'"%aThreshold
663 elif CritType == FT_ElemGeomType:
664 # Checks the Threshold
666 aCriterion.Threshold = self.EnumToLong(aThreshold)
667 assert( aThreshold in SMESH.GeometryType._items )
669 if isinstance(aThreshold, int):
670 aCriterion.Threshold = aThreshold
672 print "Error: The Threshold should be an integer or SMESH.GeometryType."
676 elif CritType == FT_GroupColor:
677 # Checks the Threshold
679 aCriterion.ThresholdStr = self.ColorToString(aThreshold)
681 print "Error: The threshold value should be of SALOMEDS.Color type"
684 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_FreeNodes, FT_FreeFaces,
685 FT_LinearOrQuadratic, FT_BadOrientedVolume,
686 FT_BareBorderFace, FT_BareBorderVolume,
687 FT_OverConstrainedFace, FT_OverConstrainedVolume,
688 FT_EqualNodes,FT_EqualEdges,FT_EqualFaces,FT_EqualVolumes ]:
689 # At this point the Threshold is unnecessary
690 if aThreshold == FT_LogicalNOT:
691 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
692 elif aThreshold in [FT_LogicalAND, FT_LogicalOR]:
693 aCriterion.BinaryOp = aThreshold
697 aThreshold = float(aThreshold)
698 aCriterion.Threshold = aThreshold
700 print "Error: The Threshold should be a number."
703 if Threshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
704 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
706 if Threshold in [FT_LogicalAND, FT_LogicalOR]:
707 aCriterion.BinaryOp = self.EnumToLong(Threshold)
709 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
710 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
712 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
713 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
717 ## Creates a filter with the given parameters
718 # @param elementType the type of elements in the group
719 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
720 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
721 # @param Threshold the threshold value (range of id ids as string, shape, numeric)
722 # @param UnaryOp FT_LogicalNOT or FT_Undefined
723 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
724 # FT_LyingOnGeom, FT_CoplanarFaces and FT_EqualNodes criteria
725 # @return SMESH_Filter
727 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
728 # @ingroup l1_controls
729 def GetFilter(self,elementType,
730 CritType=FT_Undefined,
733 UnaryOp=FT_Undefined,
735 aCriterion = self.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance)
736 aFilterMgr = self.CreateFilterManager()
737 aFilter = aFilterMgr.CreateFilter()
739 aCriteria.append(aCriterion)
740 aFilter.SetCriteria(aCriteria)
741 aFilterMgr.UnRegister()
744 ## Creates a filter from criteria
745 # @param criteria a list of criteria
746 # @return SMESH_Filter
748 # <a href="../tui_filters_page.html#tui_filters">Example of Filters usage</a>
749 # @ingroup l1_controls
750 def GetFilterFromCriteria(self,criteria):
751 aFilterMgr = self.CreateFilterManager()
752 aFilter = aFilterMgr.CreateFilter()
753 aFilter.SetCriteria(criteria)
754 aFilterMgr.UnRegister()
757 ## Creates a numerical functor by its type
758 # @param theCriterion FT_...; functor type
759 # @return SMESH_NumericalFunctor
760 # @ingroup l1_controls
761 def GetFunctor(self,theCriterion):
762 aFilterMgr = self.CreateFilterManager()
763 if theCriterion == FT_AspectRatio:
764 return aFilterMgr.CreateAspectRatio()
765 elif theCriterion == FT_AspectRatio3D:
766 return aFilterMgr.CreateAspectRatio3D()
767 elif theCriterion == FT_Warping:
768 return aFilterMgr.CreateWarping()
769 elif theCriterion == FT_MinimumAngle:
770 return aFilterMgr.CreateMinimumAngle()
771 elif theCriterion == FT_Taper:
772 return aFilterMgr.CreateTaper()
773 elif theCriterion == FT_Skew:
774 return aFilterMgr.CreateSkew()
775 elif theCriterion == FT_Area:
776 return aFilterMgr.CreateArea()
777 elif theCriterion == FT_Volume3D:
778 return aFilterMgr.CreateVolume3D()
779 elif theCriterion == FT_MaxElementLength2D:
780 return aFilterMgr.CreateMaxElementLength2D()
781 elif theCriterion == FT_MaxElementLength3D:
782 return aFilterMgr.CreateMaxElementLength3D()
783 elif theCriterion == FT_MultiConnection:
784 return aFilterMgr.CreateMultiConnection()
785 elif theCriterion == FT_MultiConnection2D:
786 return aFilterMgr.CreateMultiConnection2D()
787 elif theCriterion == FT_Length:
788 return aFilterMgr.CreateLength()
789 elif theCriterion == FT_Length2D:
790 return aFilterMgr.CreateLength2D()
792 print "Error: given parameter is not numerical functor type."
794 ## Creates hypothesis
795 # @param theHType mesh hypothesis type (string)
796 # @param theLibName mesh plug-in library name
797 # @return created hypothesis instance
798 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
799 hyp = SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
801 if isinstance( hyp, SMESH._objref_SMESH_Algo ):
804 # wrap hypothesis methods
805 #print "HYPOTHESIS", theHType
806 for meth_name in dir( hyp.__class__ ):
807 if not meth_name.startswith("Get") and \
808 not meth_name in dir ( SMESH._objref_SMESH_Hypothesis ):
809 method = getattr ( hyp.__class__, meth_name )
811 setattr( hyp, meth_name, hypMethodWrapper( hyp, method ))
815 ## Gets the mesh statistic
816 # @return dictionary "element type" - "count of elements"
817 # @ingroup l1_meshinfo
818 def GetMeshInfo(self, obj):
819 if isinstance( obj, Mesh ):
822 if hasattr(obj, "GetMeshInfo"):
823 values = obj.GetMeshInfo()
824 for i in range(SMESH.Entity_Last._v):
825 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
829 ## Get minimum distance between two objects
831 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
832 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
834 # @param src1 first source object
835 # @param src2 second source object
836 # @param id1 node/element id from the first source
837 # @param id2 node/element id from the second (or first) source
838 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
839 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
840 # @return minimum distance value
841 # @sa GetMinDistance()
842 # @ingroup l1_measurements
843 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
844 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
848 result = result.value
851 ## Get measure structure specifying minimum distance data between two objects
853 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
854 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
856 # @param src1 first source object
857 # @param src2 second source object
858 # @param id1 node/element id from the first source
859 # @param id2 node/element id from the second (or first) source
860 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
861 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
862 # @return Measure structure or None if input data is invalid
864 # @ingroup l1_measurements
865 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
866 if isinstance(src1, Mesh): src1 = src1.mesh
867 if isinstance(src2, Mesh): src2 = src2.mesh
868 if src2 is None and id2 != 0: src2 = src1
869 if not hasattr(src1, "_narrow"): return None
870 src1 = src1._narrow(SMESH.SMESH_IDSource)
871 if not src1: return None
874 e = m.GetMeshEditor()
876 src1 = e.MakeIDSource([id1], SMESH.FACE)
878 src1 = e.MakeIDSource([id1], SMESH.NODE)
880 if hasattr(src2, "_narrow"):
881 src2 = src2._narrow(SMESH.SMESH_IDSource)
882 if src2 and id2 != 0:
884 e = m.GetMeshEditor()
886 src2 = e.MakeIDSource([id2], SMESH.FACE)
888 src2 = e.MakeIDSource([id2], SMESH.NODE)
891 aMeasurements = self.CreateMeasurements()
892 result = aMeasurements.MinDistance(src1, src2)
893 aMeasurements.UnRegister()
896 ## Get bounding box of the specified object(s)
897 # @param objects single source object or list of source objects
898 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
899 # @sa GetBoundingBox()
900 # @ingroup l1_measurements
901 def BoundingBox(self, objects):
902 result = self.GetBoundingBox(objects)
906 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
909 ## Get measure structure specifying bounding box data of the specified object(s)
910 # @param objects single source object or list of source objects
911 # @return Measure structure
913 # @ingroup l1_measurements
914 def GetBoundingBox(self, objects):
915 if isinstance(objects, tuple):
916 objects = list(objects)
917 if not isinstance(objects, list):
921 if isinstance(o, Mesh):
922 srclist.append(o.mesh)
923 elif hasattr(o, "_narrow"):
924 src = o._narrow(SMESH.SMESH_IDSource)
925 if src: srclist.append(src)
928 aMeasurements = self.CreateMeasurements()
929 result = aMeasurements.BoundingBox(srclist)
930 aMeasurements.UnRegister()
934 #Registering the new proxy for SMESH_Gen
935 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
941 ## This class allows defining and managing a mesh.
942 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
943 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
944 # new nodes and elements and by changing the existing entities), to get information
945 # about a mesh and to export a mesh into different formats.
954 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
955 # sets the GUI name of this mesh to \a name.
956 # @param smeshpyD an instance of smeshDC class
957 # @param geompyD an instance of geompyDC class
958 # @param obj Shape to be meshed or SMESH_Mesh object
959 # @param name Study name of the mesh
960 # @ingroup l2_construct
961 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
962 self.smeshpyD=smeshpyD
968 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
970 # publish geom of mesh (issue 0021122)
971 if not self.geom.GetStudyEntry() and smeshpyD.GetCurrentStudy():
973 studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
974 if studyID != geompyD.myStudyId:
975 geompyD.init_geom( smeshpyD.GetCurrentStudy())
977 geo_name = "%s_%s_for_meshing"%(self.geom.GetShapeType(), id(self.geom)%100)
978 geompyD.addToStudy( self.geom, geo_name )
979 self.mesh = self.smeshpyD.CreateMesh(self.geom)
981 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
984 self.mesh = self.smeshpyD.CreateEmptyMesh()
986 self.smeshpyD.SetName(self.mesh, name)
987 elif obj != 0 and objHasName:
988 self.smeshpyD.SetName(self.mesh, GetName(obj))
991 self.geom = self.mesh.GetShapeToMesh()
993 self.editor = self.mesh.GetMeshEditor()
995 # set self to algoCreator's
996 for attrName in dir(self):
997 attr = getattr( self, attrName )
998 if isinstance( attr, algoCreator ):
999 setattr( self, attrName, attr.copy( self ))
1001 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1002 # @param theMesh a SMESH_Mesh object
1003 # @ingroup l2_construct
1004 def SetMesh(self, theMesh):
1006 self.geom = self.mesh.GetShapeToMesh()
1008 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1009 # @return a SMESH_Mesh object
1010 # @ingroup l2_construct
1014 ## Gets the name of the mesh
1015 # @return the name of the mesh as a string
1016 # @ingroup l2_construct
1018 name = GetName(self.GetMesh())
1021 ## Sets a name to the mesh
1022 # @param name a new name of the mesh
1023 # @ingroup l2_construct
1024 def SetName(self, name):
1025 self.smeshpyD.SetName(self.GetMesh(), name)
1027 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1028 # The subMesh object gives access to the IDs of nodes and elements.
1029 # @param geom a geometrical object (shape)
1030 # @param name a name for the submesh
1031 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1032 # @ingroup l2_submeshes
1033 def GetSubMesh(self, geom, name):
1034 AssureGeomPublished( self, geom, name )
1035 submesh = self.mesh.GetSubMesh( geom, name )
1038 ## Returns the shape associated to the mesh
1039 # @return a GEOM_Object
1040 # @ingroup l2_construct
1044 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1045 # @param geom the shape to be meshed (GEOM_Object)
1046 # @ingroup l2_construct
1047 def SetShape(self, geom):
1048 self.mesh = self.smeshpyD.CreateMesh(geom)
1050 ## Loads mesh from the study after opening the study
1054 ## Returns true if the hypotheses are defined well
1055 # @param theSubObject a sub-shape of a mesh shape
1056 # @return True or False
1057 # @ingroup l2_construct
1058 def IsReadyToCompute(self, theSubObject):
1059 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1061 ## Returns errors of hypotheses definition.
1062 # The list of errors is empty if everything is OK.
1063 # @param theSubObject a sub-shape of a mesh shape
1064 # @return a list of errors
1065 # @ingroup l2_construct
1066 def GetAlgoState(self, theSubObject):
1067 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1069 ## Returns a geometrical object on which the given element was built.
1070 # The returned geometrical object, if not nil, is either found in the
1071 # study or published by this method with the given name
1072 # @param theElementID the id of the mesh element
1073 # @param theGeomName the user-defined name of the geometrical object
1074 # @return GEOM::GEOM_Object instance
1075 # @ingroup l2_construct
1076 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1077 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1079 ## Returns the mesh dimension depending on the dimension of the underlying shape
1080 # @return mesh dimension as an integer value [0,3]
1081 # @ingroup l1_auxiliary
1082 def MeshDimension(self):
1083 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1084 if len( shells ) > 0 :
1086 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1088 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1094 ## Evaluates size of prospective mesh on a shape
1095 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1096 # To know predicted number of e.g. edges, inquire it this way
1097 # Evaluate()[ EnumToLong( Entity_Edge )]
1098 def Evaluate(self, geom=0):
1099 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1101 geom = self.mesh.GetShapeToMesh()
1104 return self.smeshpyD.Evaluate(self.mesh, geom)
1107 ## Computes the mesh and returns the status of the computation
1108 # @param geom geomtrical shape on which mesh data should be computed
1109 # @param discardModifs if True and the mesh has been edited since
1110 # a last total re-compute and that may prevent successful partial re-compute,
1111 # then the mesh is cleaned before Compute()
1112 # @return True or False
1113 # @ingroup l2_construct
1114 def Compute(self, geom=0, discardModifs=False):
1115 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1117 geom = self.mesh.GetShapeToMesh()
1122 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1124 ok = self.smeshpyD.Compute(self.mesh, geom)
1125 except SALOME.SALOME_Exception, ex:
1126 print "Mesh computation failed, exception caught:"
1127 print " ", ex.details.text
1130 print "Mesh computation failed, exception caught:"
1131 traceback.print_exc()
1135 # Treat compute errors
1136 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1137 for err in computeErrors:
1139 if self.mesh.HasShapeToMesh():
1141 mainIOR = salome.orb.object_to_string(geom)
1142 for sname in salome.myStudyManager.GetOpenStudies():
1143 s = salome.myStudyManager.GetStudyByName(sname)
1145 mainSO = s.FindObjectIOR(mainIOR)
1146 if not mainSO: continue
1147 if err.subShapeID == 1:
1148 shapeText = ' on "%s"' % mainSO.GetName()
1149 subIt = s.NewChildIterator(mainSO)
1151 subSO = subIt.Value()
1153 obj = subSO.GetObject()
1154 if not obj: continue
1155 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1157 ids = go.GetSubShapeIndices()
1158 if len(ids) == 1 and ids[0] == err.subShapeID:
1159 shapeText = ' on "%s"' % subSO.GetName()
1162 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1164 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1166 shapeText = " on subshape #%s" % (err.subShapeID)
1168 shapeText = " on subshape #%s" % (err.subShapeID)
1170 stdErrors = ["OK", #COMPERR_OK
1171 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1172 "std::exception", #COMPERR_STD_EXCEPTION
1173 "OCC exception", #COMPERR_OCC_EXCEPTION
1174 "SALOME exception", #COMPERR_SLM_EXCEPTION
1175 "Unknown exception", #COMPERR_EXCEPTION
1176 "Memory allocation problem", #COMPERR_MEMORY_PB
1177 "Algorithm failed", #COMPERR_ALGO_FAILED
1178 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1180 if err.code < len(stdErrors): errText = stdErrors[err.code]
1182 errText = "code %s" % -err.code
1183 if errText: errText += ". "
1184 errText += err.comment
1185 if allReasons != "":allReasons += "\n"
1186 allReasons += '- "%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1190 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1192 if err.isGlobalAlgo:
1200 reason = '%s %sD algorithm is missing' % (glob, dim)
1201 elif err.state == HYP_MISSING:
1202 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1203 % (glob, dim, name, dim))
1204 elif err.state == HYP_NOTCONFORM:
1205 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1206 elif err.state == HYP_BAD_PARAMETER:
1207 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1208 % ( glob, dim, name ))
1209 elif err.state == HYP_BAD_GEOMETRY:
1210 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1211 'geometry' % ( glob, dim, name ))
1213 reason = "For unknown reason."+\
1214 " Revise Mesh.Compute() implementation in smeshDC.py!"
1216 if allReasons != "":allReasons += "\n"
1217 allReasons += "- " + reason
1219 if not ok or allReasons != "":
1220 msg = '"' + GetName(self.mesh) + '"'
1221 if ok: msg += " has been computed with warnings"
1222 else: msg += " has not been computed"
1223 if allReasons != "": msg += ":"
1228 if salome.sg.hasDesktop() and self.mesh.GetStudyId() >= 0:
1229 smeshgui = salome.ImportComponentGUI("SMESH")
1230 smeshgui.Init(self.mesh.GetStudyId())
1231 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1232 salome.sg.updateObjBrowser(1)
1236 ## Return submesh objects list in meshing order
1237 # @return list of list of submesh objects
1238 # @ingroup l2_construct
1239 def GetMeshOrder(self):
1240 return self.mesh.GetMeshOrder()
1242 ## Return submesh objects list in meshing order
1243 # @return list of list of submesh objects
1244 # @ingroup l2_construct
1245 def SetMeshOrder(self, submeshes):
1246 return self.mesh.SetMeshOrder(submeshes)
1248 ## Removes all nodes and elements
1249 # @ingroup l2_construct
1252 if salome.sg.hasDesktop():
1253 smeshgui = salome.ImportComponentGUI("SMESH")
1254 smeshgui.Init(self.mesh.GetStudyId())
1255 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1256 salome.sg.updateObjBrowser(1)
1258 ## Removes all nodes and elements of indicated shape
1259 # @ingroup l2_construct
1260 def ClearSubMesh(self, geomId):
1261 self.mesh.ClearSubMesh(geomId)
1262 if salome.sg.hasDesktop():
1263 smeshgui = salome.ImportComponentGUI("SMESH")
1264 smeshgui.Init(self.mesh.GetStudyId())
1265 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1266 salome.sg.updateObjBrowser(1)
1268 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1269 # @param fineness [0.0,1.0] defines mesh fineness
1270 # @return True or False
1271 # @ingroup l3_algos_basic
1272 def AutomaticTetrahedralization(self, fineness=0):
1273 dim = self.MeshDimension()
1275 self.RemoveGlobalHypotheses()
1276 self.Segment().AutomaticLength(fineness)
1278 self.Triangle().LengthFromEdges()
1281 from NETGENPluginDC import NETGEN
1282 self.Tetrahedron(NETGEN)
1284 return self.Compute()
1286 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1287 # @param fineness [0.0, 1.0] defines mesh fineness
1288 # @return True or False
1289 # @ingroup l3_algos_basic
1290 def AutomaticHexahedralization(self, fineness=0):
1291 dim = self.MeshDimension()
1292 # assign the hypotheses
1293 self.RemoveGlobalHypotheses()
1294 self.Segment().AutomaticLength(fineness)
1301 return self.Compute()
1303 ## Assigns a hypothesis
1304 # @param hyp a hypothesis to assign
1305 # @param geom a subhape of mesh geometry
1306 # @return SMESH.Hypothesis_Status
1307 # @ingroup l2_hypotheses
1308 def AddHypothesis(self, hyp, geom=0):
1309 if isinstance( hyp, Mesh_Algorithm ):
1310 hyp = hyp.GetAlgorithm()
1315 geom = self.mesh.GetShapeToMesh()
1317 AssureGeomPublished( self, geom, "shape for %s" % hyp.GetName())
1318 status = self.mesh.AddHypothesis(geom, hyp)
1319 isAlgo = hyp._narrow( SMESH_Algo )
1320 hyp_name = GetName( hyp )
1323 geom_name = GetName( geom )
1324 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1327 ## Return True if an algorithm of hypothesis is assigned to a given shape
1328 # @param hyp a hypothesis to check
1329 # @param geom a subhape of mesh geometry
1330 # @return True of False
1331 # @ingroup l2_hypotheses
1332 def IsUsedHypothesis(self, hyp, geom):
1333 if not hyp or not geom:
1335 if isinstance( hyp, Mesh_Algorithm ):
1336 hyp = hyp.GetAlgorithm()
1338 hyps = self.GetHypothesisList(geom)
1340 if h.GetId() == hyp.GetId():
1344 ## Unassigns a hypothesis
1345 # @param hyp a hypothesis to unassign
1346 # @param geom a sub-shape of mesh geometry
1347 # @return SMESH.Hypothesis_Status
1348 # @ingroup l2_hypotheses
1349 def RemoveHypothesis(self, hyp, geom=0):
1350 if isinstance( hyp, Mesh_Algorithm ):
1351 hyp = hyp.GetAlgorithm()
1356 status = self.mesh.RemoveHypothesis(geom, hyp)
1359 ## Gets the list of hypotheses added on a geometry
1360 # @param geom a sub-shape of mesh geometry
1361 # @return the sequence of SMESH_Hypothesis
1362 # @ingroup l2_hypotheses
1363 def GetHypothesisList(self, geom):
1364 return self.mesh.GetHypothesisList( geom )
1366 ## Removes all global hypotheses
1367 # @ingroup l2_hypotheses
1368 def RemoveGlobalHypotheses(self):
1369 current_hyps = self.mesh.GetHypothesisList( self.geom )
1370 for hyp in current_hyps:
1371 self.mesh.RemoveHypothesis( self.geom, hyp )
1375 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1376 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1377 ## allowing to overwrite the file if it exists or add the exported data to its contents
1378 # @param f the file name
1379 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1380 # @param opt boolean parameter for creating/not creating
1381 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1382 # @param overwrite boolean parameter for overwriting/not overwriting the file
1383 # @ingroup l2_impexp
1384 def ExportToMED(self, f, version, opt=0, overwrite=1):
1385 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1387 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1388 ## allowing to overwrite the file if it exists or add the exported data to its contents
1389 # @param f is the file name
1390 # @param auto_groups boolean parameter for creating/not creating
1391 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1392 # the typical use is auto_groups=false.
1393 # @param version MED format version(MED_V2_1 or MED_V2_2)
1394 # @param overwrite boolean parameter for overwriting/not overwriting the file
1395 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1396 # @ingroup l2_impexp
1397 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1, meshPart=None):
1399 if isinstance( meshPart, list ):
1400 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1401 self.mesh.ExportPartToMED( meshPart, f, auto_groups, version, overwrite )
1403 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1405 ## Exports the mesh in a file in SAUV format
1406 # @param f is the file name
1407 # @param auto_groups boolean parameter for creating/not creating
1408 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1409 # the typical use is auto_groups=false.
1410 # @ingroup l2_impexp
1411 def ExportSAUV(self, f, auto_groups=0):
1412 self.mesh.ExportSAUV(f, auto_groups)
1414 ## Exports the mesh in a file in DAT format
1415 # @param f the file name
1416 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1417 # @ingroup l2_impexp
1418 def ExportDAT(self, f, meshPart=None):
1420 if isinstance( meshPart, list ):
1421 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1422 self.mesh.ExportPartToDAT( meshPart, f )
1424 self.mesh.ExportDAT(f)
1426 ## Exports the mesh in a file in UNV format
1427 # @param f the file name
1428 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1429 # @ingroup l2_impexp
1430 def ExportUNV(self, f, meshPart=None):
1432 if isinstance( meshPart, list ):
1433 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1434 self.mesh.ExportPartToUNV( meshPart, f )
1436 self.mesh.ExportUNV(f)
1438 ## Export the mesh in a file in STL format
1439 # @param f the file name
1440 # @param ascii defines the file encoding
1441 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1442 # @ingroup l2_impexp
1443 def ExportSTL(self, f, ascii=1, meshPart=None):
1445 if isinstance( meshPart, list ):
1446 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1447 self.mesh.ExportPartToSTL( meshPart, f, ascii )
1449 self.mesh.ExportSTL(f, ascii)
1451 ## Exports the mesh in a file in CGNS format
1452 # @param f is the file name
1453 # @param overwrite boolean parameter for overwriting/not overwriting the file
1454 # @param meshPart a part of mesh (group, sub-mesh) to export instead of the mesh
1455 # @ingroup l2_impexp
1456 def ExportCGNS(self, f, overwrite=1, meshPart=None):
1457 if isinstance( meshPart, list ):
1458 meshPart = self.GetIDSource( meshPart, SMESH.ALL )
1459 if isinstance( meshPart, Mesh ):
1460 meshPart = meshPart.mesh
1462 meshPart = self.mesh
1463 self.mesh.ExportCGNS(meshPart, f, overwrite)
1465 # Operations with groups:
1466 # ----------------------
1468 ## Creates an empty mesh group
1469 # @param elementType the type of elements in the group
1470 # @param name the name of the mesh group
1471 # @return SMESH_Group
1472 # @ingroup l2_grps_create
1473 def CreateEmptyGroup(self, elementType, name):
1474 return self.mesh.CreateGroup(elementType, name)
1476 ## Creates a mesh group based on the geometric object \a grp
1477 # and gives a \a name, \n if this parameter is not defined
1478 # the name is the same as the geometric group name \n
1479 # Note: Works like GroupOnGeom().
1480 # @param grp a geometric group, a vertex, an edge, a face or a solid
1481 # @param name the name of the mesh group
1482 # @return SMESH_GroupOnGeom
1483 # @ingroup l2_grps_create
1484 def Group(self, grp, name=""):
1485 return self.GroupOnGeom(grp, name)
1487 ## Creates a mesh group based on the geometrical object \a grp
1488 # and gives a \a name, \n if this parameter is not defined
1489 # the name is the same as the geometrical group name
1490 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1491 # @param name the name of the mesh group
1492 # @param typ the type of elements in the group. If not set, it is
1493 # automatically detected by the type of the geometry
1494 # @return SMESH_GroupOnGeom
1495 # @ingroup l2_grps_create
1496 def GroupOnGeom(self, grp, name="", typ=None):
1497 AssureGeomPublished( self, grp, name )
1499 name = grp.GetName()
1501 typ = self._groupTypeFromShape( grp )
1502 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1504 ## Pivate method to get a type of group on geometry
1505 def _groupTypeFromShape( self, shape ):
1506 tgeo = str(shape.GetShapeType())
1507 if tgeo == "VERTEX":
1509 elif tgeo == "EDGE":
1511 elif tgeo == "FACE" or tgeo == "SHELL":
1513 elif tgeo == "SOLID" or tgeo == "COMPSOLID":
1515 elif tgeo == "COMPOUND":
1516 sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"])
1518 raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
1519 return self._groupTypeFromShape( sub[0] )
1522 "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
1525 ## Creates a mesh group with given \a name based on the \a filter which
1526 ## is a special type of group dynamically updating it's contents during
1527 ## mesh modification
1528 # @param typ the type of elements in the group
1529 # @param name the name of the mesh group
1530 # @param filter the filter defining group contents
1531 # @return SMESH_GroupOnFilter
1532 # @ingroup l2_grps_create
1533 def GroupOnFilter(self, typ, name, filter):
1534 return self.mesh.CreateGroupFromFilter(typ, name, filter)
1536 ## Creates a mesh group by the given ids of elements
1537 # @param groupName the name of the mesh group
1538 # @param elementType the type of elements in the group
1539 # @param elemIDs the list of ids
1540 # @return SMESH_Group
1541 # @ingroup l2_grps_create
1542 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1543 group = self.mesh.CreateGroup(elementType, groupName)
1547 ## Creates a mesh group by the given conditions
1548 # @param groupName the name of the mesh group
1549 # @param elementType the type of elements in the group
1550 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1551 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1552 # @param Threshold the threshold value (range of id ids as string, shape, numeric)
1553 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1554 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1555 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1556 # @return SMESH_Group
1557 # @ingroup l2_grps_create
1561 CritType=FT_Undefined,
1564 UnaryOp=FT_Undefined,
1566 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Threshold, UnaryOp, FT_Undefined,Tolerance)
1567 group = self.MakeGroupByCriterion(groupName, aCriterion)
1570 ## Creates a mesh group by the given criterion
1571 # @param groupName the name of the mesh group
1572 # @param Criterion the instance of Criterion class
1573 # @return SMESH_Group
1574 # @ingroup l2_grps_create
1575 def MakeGroupByCriterion(self, groupName, Criterion):
1576 aFilterMgr = self.smeshpyD.CreateFilterManager()
1577 aFilter = aFilterMgr.CreateFilter()
1579 aCriteria.append(Criterion)
1580 aFilter.SetCriteria(aCriteria)
1581 group = self.MakeGroupByFilter(groupName, aFilter)
1582 aFilterMgr.UnRegister()
1585 ## Creates a mesh group by the given criteria (list of criteria)
1586 # @param groupName the name of the mesh group
1587 # @param theCriteria the list of criteria
1588 # @return SMESH_Group
1589 # @ingroup l2_grps_create
1590 def MakeGroupByCriteria(self, groupName, theCriteria):
1591 aFilterMgr = self.smeshpyD.CreateFilterManager()
1592 aFilter = aFilterMgr.CreateFilter()
1593 aFilter.SetCriteria(theCriteria)
1594 group = self.MakeGroupByFilter(groupName, aFilter)
1595 aFilterMgr.UnRegister()
1598 ## Creates a mesh group by the given filter
1599 # @param groupName the name of the mesh group
1600 # @param theFilter the instance of Filter class
1601 # @return SMESH_Group
1602 # @ingroup l2_grps_create
1603 def MakeGroupByFilter(self, groupName, theFilter):
1604 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1605 theFilter.SetMesh( self.mesh )
1606 group.AddFrom( theFilter )
1609 ## Passes mesh elements through the given filter and return IDs of fitting elements
1610 # @param theFilter SMESH_Filter
1611 # @return a list of ids
1612 # @ingroup l1_controls
1613 def GetIdsFromFilter(self, theFilter):
1614 theFilter.SetMesh( self.mesh )
1615 return theFilter.GetIDs()
1617 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1618 # Returns a list of special structures (borders).
1619 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1620 # @ingroup l1_controls
1621 def GetFreeBorders(self):
1622 aFilterMgr = self.smeshpyD.CreateFilterManager()
1623 aPredicate = aFilterMgr.CreateFreeEdges()
1624 aPredicate.SetMesh(self.mesh)
1625 aBorders = aPredicate.GetBorders()
1626 aFilterMgr.UnRegister()
1630 # @ingroup l2_grps_delete
1631 def RemoveGroup(self, group):
1632 self.mesh.RemoveGroup(group)
1634 ## Removes a group with its contents
1635 # @ingroup l2_grps_delete
1636 def RemoveGroupWithContents(self, group):
1637 self.mesh.RemoveGroupWithContents(group)
1639 ## Gets the list of groups existing in the mesh
1640 # @return a sequence of SMESH_GroupBase
1641 # @ingroup l2_grps_create
1642 def GetGroups(self):
1643 return self.mesh.GetGroups()
1645 ## Gets the number of groups existing in the mesh
1646 # @return the quantity of groups as an integer value
1647 # @ingroup l2_grps_create
1649 return self.mesh.NbGroups()
1651 ## Gets the list of names of groups existing in the mesh
1652 # @return list of strings
1653 # @ingroup l2_grps_create
1654 def GetGroupNames(self):
1655 groups = self.GetGroups()
1657 for group in groups:
1658 names.append(group.GetName())
1661 ## Produces a union of two groups
1662 # A new group is created. All mesh elements that are
1663 # present in the initial groups are added to the new one
1664 # @return an instance of SMESH_Group
1665 # @ingroup l2_grps_operon
1666 def UnionGroups(self, group1, group2, name):
1667 return self.mesh.UnionGroups(group1, group2, name)
1669 ## Produces a union list of groups
1670 # New group is created. All mesh elements that are present in
1671 # initial groups are added to the new one
1672 # @return an instance of SMESH_Group
1673 # @ingroup l2_grps_operon
1674 def UnionListOfGroups(self, groups, name):
1675 return self.mesh.UnionListOfGroups(groups, name)
1677 ## Prodices an intersection of two groups
1678 # A new group is created. All mesh elements that are common
1679 # for the two initial groups are added to the new one.
1680 # @return an instance of SMESH_Group
1681 # @ingroup l2_grps_operon
1682 def IntersectGroups(self, group1, group2, name):
1683 return self.mesh.IntersectGroups(group1, group2, name)
1685 ## Produces an intersection of groups
1686 # New group is created. All mesh elements that are present in all
1687 # initial groups simultaneously are added to the new one
1688 # @return an instance of SMESH_Group
1689 # @ingroup l2_grps_operon
1690 def IntersectListOfGroups(self, groups, name):
1691 return self.mesh.IntersectListOfGroups(groups, name)
1693 ## Produces a cut of two groups
1694 # A new group is created. All mesh elements that are present in
1695 # the main group but are not present in the tool group are added to the new one
1696 # @return an instance of SMESH_Group
1697 # @ingroup l2_grps_operon
1698 def CutGroups(self, main_group, tool_group, name):
1699 return self.mesh.CutGroups(main_group, tool_group, name)
1701 ## Produces a cut of groups
1702 # A new group is created. All mesh elements that are present in main groups
1703 # but do not present in tool groups are added to the new one
1704 # @return an instance of SMESH_Group
1705 # @ingroup l2_grps_operon
1706 def CutListOfGroups(self, main_groups, tool_groups, name):
1707 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1709 ## Produces a group of elements of specified type using list of existing groups
1710 # A new group is created. System
1711 # 1) extracts all nodes on which groups elements are built
1712 # 2) combines all elements of specified dimension laying on these nodes
1713 # @return an instance of SMESH_Group
1714 # @ingroup l2_grps_operon
1715 def CreateDimGroup(self, groups, elem_type, name):
1716 return self.mesh.CreateDimGroup(groups, elem_type, name)
1719 ## Convert group on geom into standalone group
1720 # @ingroup l2_grps_delete
1721 def ConvertToStandalone(self, group):
1722 return self.mesh.ConvertToStandalone(group)
1724 # Get some info about mesh:
1725 # ------------------------
1727 ## Returns the log of nodes and elements added or removed
1728 # since the previous clear of the log.
1729 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1730 # @return list of log_block structures:
1735 # @ingroup l1_auxiliary
1736 def GetLog(self, clearAfterGet):
1737 return self.mesh.GetLog(clearAfterGet)
1739 ## Clears the log of nodes and elements added or removed since the previous
1740 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1741 # @ingroup l1_auxiliary
1743 self.mesh.ClearLog()
1745 ## Toggles auto color mode on the object.
1746 # @param theAutoColor the flag which toggles auto color mode.
1747 # @ingroup l1_auxiliary
1748 def SetAutoColor(self, theAutoColor):
1749 self.mesh.SetAutoColor(theAutoColor)
1751 ## Gets flag of object auto color mode.
1752 # @return True or False
1753 # @ingroup l1_auxiliary
1754 def GetAutoColor(self):
1755 return self.mesh.GetAutoColor()
1757 ## Gets the internal ID
1758 # @return integer value, which is the internal Id of the mesh
1759 # @ingroup l1_auxiliary
1761 return self.mesh.GetId()
1764 # @return integer value, which is the study Id of the mesh
1765 # @ingroup l1_auxiliary
1766 def GetStudyId(self):
1767 return self.mesh.GetStudyId()
1769 ## Checks the group names for duplications.
1770 # Consider the maximum group name length stored in MED file.
1771 # @return True or False
1772 # @ingroup l1_auxiliary
1773 def HasDuplicatedGroupNamesMED(self):
1774 return self.mesh.HasDuplicatedGroupNamesMED()
1776 ## Obtains the mesh editor tool
1777 # @return an instance of SMESH_MeshEditor
1778 # @ingroup l1_modifying
1779 def GetMeshEditor(self):
1780 return self.mesh.GetMeshEditor()
1782 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
1783 # can be passed as argument to a method accepting mesh, group or sub-mesh
1784 # @return an instance of SMESH_IDSource
1785 # @ingroup l1_auxiliary
1786 def GetIDSource(self, ids, elemType):
1787 return self.GetMeshEditor().MakeIDSource(ids, elemType)
1790 # @return an instance of SALOME_MED::MESH
1791 # @ingroup l1_auxiliary
1792 def GetMEDMesh(self):
1793 return self.mesh.GetMEDMesh()
1796 # Get informations about mesh contents:
1797 # ------------------------------------
1799 ## Gets the mesh stattistic
1800 # @return dictionary type element - count of elements
1801 # @ingroup l1_meshinfo
1802 def GetMeshInfo(self, obj = None):
1803 if not obj: obj = self.mesh
1804 return self.smeshpyD.GetMeshInfo(obj)
1806 ## Returns the number of nodes in the mesh
1807 # @return an integer value
1808 # @ingroup l1_meshinfo
1810 return self.mesh.NbNodes()
1812 ## Returns the number of elements in the mesh
1813 # @return an integer value
1814 # @ingroup l1_meshinfo
1815 def NbElements(self):
1816 return self.mesh.NbElements()
1818 ## Returns the number of 0d elements in the mesh
1819 # @return an integer value
1820 # @ingroup l1_meshinfo
1821 def Nb0DElements(self):
1822 return self.mesh.Nb0DElements()
1824 ## Returns the number of edges in the mesh
1825 # @return an integer value
1826 # @ingroup l1_meshinfo
1828 return self.mesh.NbEdges()
1830 ## Returns the number of edges with the given order in the mesh
1831 # @param elementOrder the order of elements:
1832 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1833 # @return an integer value
1834 # @ingroup l1_meshinfo
1835 def NbEdgesOfOrder(self, elementOrder):
1836 return self.mesh.NbEdgesOfOrder(elementOrder)
1838 ## Returns the number of faces in the mesh
1839 # @return an integer value
1840 # @ingroup l1_meshinfo
1842 return self.mesh.NbFaces()
1844 ## Returns the number of faces with the given order in the mesh
1845 # @param elementOrder the order of elements:
1846 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1847 # @return an integer value
1848 # @ingroup l1_meshinfo
1849 def NbFacesOfOrder(self, elementOrder):
1850 return self.mesh.NbFacesOfOrder(elementOrder)
1852 ## Returns the number of triangles in the mesh
1853 # @return an integer value
1854 # @ingroup l1_meshinfo
1855 def NbTriangles(self):
1856 return self.mesh.NbTriangles()
1858 ## Returns the number of triangles with the given order in the mesh
1859 # @param elementOrder is the order of elements:
1860 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1861 # @return an integer value
1862 # @ingroup l1_meshinfo
1863 def NbTrianglesOfOrder(self, elementOrder):
1864 return self.mesh.NbTrianglesOfOrder(elementOrder)
1866 ## Returns the number of quadrangles in the mesh
1867 # @return an integer value
1868 # @ingroup l1_meshinfo
1869 def NbQuadrangles(self):
1870 return self.mesh.NbQuadrangles()
1872 ## Returns the number of quadrangles with the given order in the mesh
1873 # @param elementOrder the order of elements:
1874 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1875 # @return an integer value
1876 # @ingroup l1_meshinfo
1877 def NbQuadranglesOfOrder(self, elementOrder):
1878 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1880 ## Returns the number of biquadratic quadrangles in the mesh
1881 # @return an integer value
1882 # @ingroup l1_meshinfo
1883 def NbBiQuadQuadrangles(self):
1884 return self.mesh.NbBiQuadQuadrangles()
1886 ## Returns the number of polygons in the mesh
1887 # @return an integer value
1888 # @ingroup l1_meshinfo
1889 def NbPolygons(self):
1890 return self.mesh.NbPolygons()
1892 ## Returns the number of volumes in the mesh
1893 # @return an integer value
1894 # @ingroup l1_meshinfo
1895 def NbVolumes(self):
1896 return self.mesh.NbVolumes()
1898 ## Returns the number of volumes with the given order in the mesh
1899 # @param elementOrder the order of elements:
1900 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1901 # @return an integer value
1902 # @ingroup l1_meshinfo
1903 def NbVolumesOfOrder(self, elementOrder):
1904 return self.mesh.NbVolumesOfOrder(elementOrder)
1906 ## Returns the number of tetrahedrons in the mesh
1907 # @return an integer value
1908 # @ingroup l1_meshinfo
1910 return self.mesh.NbTetras()
1912 ## Returns the number of tetrahedrons with the given order in the mesh
1913 # @param elementOrder the order of elements:
1914 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1915 # @return an integer value
1916 # @ingroup l1_meshinfo
1917 def NbTetrasOfOrder(self, elementOrder):
1918 return self.mesh.NbTetrasOfOrder(elementOrder)
1920 ## Returns the number of hexahedrons in the mesh
1921 # @return an integer value
1922 # @ingroup l1_meshinfo
1924 return self.mesh.NbHexas()
1926 ## Returns the number of hexahedrons with the given order in the mesh
1927 # @param elementOrder the order of elements:
1928 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1929 # @return an integer value
1930 # @ingroup l1_meshinfo
1931 def NbHexasOfOrder(self, elementOrder):
1932 return self.mesh.NbHexasOfOrder(elementOrder)
1934 ## Returns the number of triquadratic hexahedrons in the mesh
1935 # @return an integer value
1936 # @ingroup l1_meshinfo
1937 def NbTriQuadraticHexas(self):
1938 return self.mesh.NbTriQuadraticHexas()
1940 ## Returns the number of pyramids in the mesh
1941 # @return an integer value
1942 # @ingroup l1_meshinfo
1943 def NbPyramids(self):
1944 return self.mesh.NbPyramids()
1946 ## Returns the number of pyramids with the given order in the mesh
1947 # @param elementOrder the order of elements:
1948 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1949 # @return an integer value
1950 # @ingroup l1_meshinfo
1951 def NbPyramidsOfOrder(self, elementOrder):
1952 return self.mesh.NbPyramidsOfOrder(elementOrder)
1954 ## Returns the number of prisms in the mesh
1955 # @return an integer value
1956 # @ingroup l1_meshinfo
1958 return self.mesh.NbPrisms()
1960 ## Returns the number of prisms with the given order in the mesh
1961 # @param elementOrder the order of elements:
1962 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1963 # @return an integer value
1964 # @ingroup l1_meshinfo
1965 def NbPrismsOfOrder(self, elementOrder):
1966 return self.mesh.NbPrismsOfOrder(elementOrder)
1968 ## Returns the number of hexagonal prisms in the mesh
1969 # @return an integer value
1970 # @ingroup l1_meshinfo
1971 def NbHexagonalPrisms(self):
1972 return self.mesh.NbHexagonalPrisms()
1974 ## Returns the number of polyhedrons in the mesh
1975 # @return an integer value
1976 # @ingroup l1_meshinfo
1977 def NbPolyhedrons(self):
1978 return self.mesh.NbPolyhedrons()
1980 ## Returns the number of submeshes in the mesh
1981 # @return an integer value
1982 # @ingroup l1_meshinfo
1983 def NbSubMesh(self):
1984 return self.mesh.NbSubMesh()
1986 ## Returns the list of mesh elements IDs
1987 # @return the list of integer values
1988 # @ingroup l1_meshinfo
1989 def GetElementsId(self):
1990 return self.mesh.GetElementsId()
1992 ## Returns the list of IDs of mesh elements with the given type
1993 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
1994 # @return list of integer values
1995 # @ingroup l1_meshinfo
1996 def GetElementsByType(self, elementType):
1997 return self.mesh.GetElementsByType(elementType)
1999 ## Returns the list of mesh nodes IDs
2000 # @return the list of integer values
2001 # @ingroup l1_meshinfo
2002 def GetNodesId(self):
2003 return self.mesh.GetNodesId()
2005 # Get the information about mesh elements:
2006 # ------------------------------------
2008 ## Returns the type of mesh element
2009 # @return the value from SMESH::ElementType enumeration
2010 # @ingroup l1_meshinfo
2011 def GetElementType(self, id, iselem):
2012 return self.mesh.GetElementType(id, iselem)
2014 ## Returns the geometric type of mesh element
2015 # @return the value from SMESH::EntityType enumeration
2016 # @ingroup l1_meshinfo
2017 def GetElementGeomType(self, id):
2018 return self.mesh.GetElementGeomType(id)
2020 ## Returns the list of submesh elements IDs
2021 # @param Shape a geom object(sub-shape) IOR
2022 # Shape must be the sub-shape of a ShapeToMesh()
2023 # @return the list of integer values
2024 # @ingroup l1_meshinfo
2025 def GetSubMeshElementsId(self, Shape):
2026 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2027 ShapeID = Shape.GetSubShapeIndices()[0]
2030 return self.mesh.GetSubMeshElementsId(ShapeID)
2032 ## Returns the list of submesh nodes IDs
2033 # @param Shape a geom object(sub-shape) IOR
2034 # Shape must be the sub-shape of a ShapeToMesh()
2035 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2036 # @return the list of integer values
2037 # @ingroup l1_meshinfo
2038 def GetSubMeshNodesId(self, Shape, all):
2039 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2040 ShapeID = Shape.GetSubShapeIndices()[0]
2043 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2045 ## Returns type of elements on given shape
2046 # @param Shape a geom object(sub-shape) IOR
2047 # Shape must be a sub-shape of a ShapeToMesh()
2048 # @return element type
2049 # @ingroup l1_meshinfo
2050 def GetSubMeshElementType(self, Shape):
2051 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2052 ShapeID = Shape.GetSubShapeIndices()[0]
2055 return self.mesh.GetSubMeshElementType(ShapeID)
2057 ## Gets the mesh description
2058 # @return string value
2059 # @ingroup l1_meshinfo
2061 return self.mesh.Dump()
2064 # Get the information about nodes and elements of a mesh by its IDs:
2065 # -----------------------------------------------------------
2067 ## Gets XYZ coordinates of a node
2068 # \n If there is no nodes for the given ID - returns an empty list
2069 # @return a list of double precision values
2070 # @ingroup l1_meshinfo
2071 def GetNodeXYZ(self, id):
2072 return self.mesh.GetNodeXYZ(id)
2074 ## Returns list of IDs of inverse elements for the given node
2075 # \n If there is no node for the given ID - returns an empty list
2076 # @return a list of integer values
2077 # @ingroup l1_meshinfo
2078 def GetNodeInverseElements(self, id):
2079 return self.mesh.GetNodeInverseElements(id)
2081 ## @brief Returns the position of a node on the shape
2082 # @return SMESH::NodePosition
2083 # @ingroup l1_meshinfo
2084 def GetNodePosition(self,NodeID):
2085 return self.mesh.GetNodePosition(NodeID)
2087 ## If the given element is a node, returns the ID of shape
2088 # \n If there is no node for the given ID - returns -1
2089 # @return an integer value
2090 # @ingroup l1_meshinfo
2091 def GetShapeID(self, id):
2092 return self.mesh.GetShapeID(id)
2094 ## Returns the ID of the result shape after
2095 # FindShape() from SMESH_MeshEditor for the given element
2096 # \n If there is no element for the given ID - returns -1
2097 # @return an integer value
2098 # @ingroup l1_meshinfo
2099 def GetShapeIDForElem(self,id):
2100 return self.mesh.GetShapeIDForElem(id)
2102 ## Returns the number of nodes for the given element
2103 # \n If there is no element for the given ID - returns -1
2104 # @return an integer value
2105 # @ingroup l1_meshinfo
2106 def GetElemNbNodes(self, id):
2107 return self.mesh.GetElemNbNodes(id)
2109 ## Returns the node ID the given index for the given element
2110 # \n If there is no element for the given ID - returns -1
2111 # \n If there is no node for the given index - returns -2
2112 # @return an integer value
2113 # @ingroup l1_meshinfo
2114 def GetElemNode(self, id, index):
2115 return self.mesh.GetElemNode(id, index)
2117 ## Returns the IDs of nodes of the given element
2118 # @return a list of integer values
2119 # @ingroup l1_meshinfo
2120 def GetElemNodes(self, id):
2121 return self.mesh.GetElemNodes(id)
2123 ## Returns true if the given node is the medium node in the given quadratic element
2124 # @ingroup l1_meshinfo
2125 def IsMediumNode(self, elementID, nodeID):
2126 return self.mesh.IsMediumNode(elementID, nodeID)
2128 ## Returns true if the given node is the medium node in one of quadratic elements
2129 # @ingroup l1_meshinfo
2130 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2131 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2133 ## Returns the number of edges for the given element
2134 # @ingroup l1_meshinfo
2135 def ElemNbEdges(self, id):
2136 return self.mesh.ElemNbEdges(id)
2138 ## Returns the number of faces for the given element
2139 # @ingroup l1_meshinfo
2140 def ElemNbFaces(self, id):
2141 return self.mesh.ElemNbFaces(id)
2143 ## Returns nodes of given face (counted from zero) for given volumic element.
2144 # @ingroup l1_meshinfo
2145 def GetElemFaceNodes(self,elemId, faceIndex):
2146 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2148 ## Returns an element based on all given nodes.
2149 # @ingroup l1_meshinfo
2150 def FindElementByNodes(self,nodes):
2151 return self.mesh.FindElementByNodes(nodes)
2153 ## Returns true if the given element is a polygon
2154 # @ingroup l1_meshinfo
2155 def IsPoly(self, id):
2156 return self.mesh.IsPoly(id)
2158 ## Returns true if the given element is quadratic
2159 # @ingroup l1_meshinfo
2160 def IsQuadratic(self, id):
2161 return self.mesh.IsQuadratic(id)
2163 ## Returns XYZ coordinates of the barycenter of the given element
2164 # \n If there is no element for the given ID - returns an empty list
2165 # @return a list of three double values
2166 # @ingroup l1_meshinfo
2167 def BaryCenter(self, id):
2168 return self.mesh.BaryCenter(id)
2171 # Get mesh measurements information:
2172 # ------------------------------------
2174 ## Get minimum distance between two nodes, elements or distance to the origin
2175 # @param id1 first node/element id
2176 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2177 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2178 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2179 # @return minimum distance value
2180 # @sa GetMinDistance()
2181 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2182 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2183 return aMeasure.value
2185 ## Get measure structure specifying minimum distance data between two objects
2186 # @param id1 first node/element id
2187 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2188 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2189 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2190 # @return Measure structure
2192 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2194 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2196 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2199 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2201 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2206 aMeasurements = self.smeshpyD.CreateMeasurements()
2207 aMeasure = aMeasurements.MinDistance(id1, id2)
2208 aMeasurements.UnRegister()
2211 ## Get bounding box of the specified object(s)
2212 # @param objects single source object or list of source objects or list of nodes/elements IDs
2213 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2214 # @c False specifies that @a objects are nodes
2215 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2216 # @sa GetBoundingBox()
2217 def BoundingBox(self, objects=None, isElem=False):
2218 result = self.GetBoundingBox(objects, isElem)
2222 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2225 ## Get measure structure specifying bounding box data of the specified object(s)
2226 # @param IDs single source object or list of source objects or list of nodes/elements IDs
2227 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2228 # @c False specifies that @a objects are nodes
2229 # @return Measure structure
2231 def GetBoundingBox(self, IDs=None, isElem=False):
2234 elif isinstance(IDs, tuple):
2236 if not isinstance(IDs, list):
2238 if len(IDs) > 0 and isinstance(IDs[0], int):
2242 if isinstance(o, Mesh):
2243 srclist.append(o.mesh)
2244 elif hasattr(o, "_narrow"):
2245 src = o._narrow(SMESH.SMESH_IDSource)
2246 if src: srclist.append(src)
2248 elif isinstance(o, list):
2250 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2252 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2255 aMeasurements = self.smeshpyD.CreateMeasurements()
2256 aMeasure = aMeasurements.BoundingBox(srclist)
2257 aMeasurements.UnRegister()
2260 # Mesh edition (SMESH_MeshEditor functionality):
2261 # ---------------------------------------------
2263 ## Removes the elements from the mesh by ids
2264 # @param IDsOfElements is a list of ids of elements to remove
2265 # @return True or False
2266 # @ingroup l2_modif_del
2267 def RemoveElements(self, IDsOfElements):
2268 return self.editor.RemoveElements(IDsOfElements)
2270 ## Removes nodes from mesh by ids
2271 # @param IDsOfNodes is a list of ids of nodes to remove
2272 # @return True or False
2273 # @ingroup l2_modif_del
2274 def RemoveNodes(self, IDsOfNodes):
2275 return self.editor.RemoveNodes(IDsOfNodes)
2277 ## Removes all orphan (free) nodes from mesh
2278 # @return number of the removed nodes
2279 # @ingroup l2_modif_del
2280 def RemoveOrphanNodes(self):
2281 return self.editor.RemoveOrphanNodes()
2283 ## Add a node to the mesh by coordinates
2284 # @return Id of the new node
2285 # @ingroup l2_modif_add
2286 def AddNode(self, x, y, z):
2287 x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
2288 if hasVars: self.mesh.SetParameters(Parameters)
2289 return self.editor.AddNode( x, y, z)
2291 ## Creates a 0D element on a node with given number.
2292 # @param IDOfNode the ID of node for creation of the element.
2293 # @return the Id of the new 0D element
2294 # @ingroup l2_modif_add
2295 def Add0DElement(self, IDOfNode):
2296 return self.editor.Add0DElement(IDOfNode)
2298 ## Creates a linear or quadratic edge (this is determined
2299 # by the number of given nodes).
2300 # @param IDsOfNodes the list of node IDs for creation of the element.
2301 # The order of nodes in this list should correspond to the description
2302 # of MED. \n This description is located by the following link:
2303 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2304 # @return the Id of the new edge
2305 # @ingroup l2_modif_add
2306 def AddEdge(self, IDsOfNodes):
2307 return self.editor.AddEdge(IDsOfNodes)
2309 ## Creates a linear or quadratic face (this is determined
2310 # by the number of given nodes).
2311 # @param IDsOfNodes the list of node IDs for creation of the element.
2312 # The order of nodes in this list should correspond to the description
2313 # of MED. \n This description is located by the following link:
2314 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2315 # @return the Id of the new face
2316 # @ingroup l2_modif_add
2317 def AddFace(self, IDsOfNodes):
2318 return self.editor.AddFace(IDsOfNodes)
2320 ## Adds a polygonal face to the mesh by the list of node IDs
2321 # @param IdsOfNodes the list of node IDs for creation of the element.
2322 # @return the Id of the new face
2323 # @ingroup l2_modif_add
2324 def AddPolygonalFace(self, IdsOfNodes):
2325 return self.editor.AddPolygonalFace(IdsOfNodes)
2327 ## Creates both simple and quadratic volume (this is determined
2328 # by the number of given nodes).
2329 # @param IDsOfNodes the list of node IDs for creation of the element.
2330 # The order of nodes in this list should correspond to the description
2331 # of MED. \n This description is located by the following link:
2332 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2333 # @return the Id of the new volumic element
2334 # @ingroup l2_modif_add
2335 def AddVolume(self, IDsOfNodes):
2336 return self.editor.AddVolume(IDsOfNodes)
2338 ## Creates a volume of many faces, giving nodes for each face.
2339 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2340 # @param Quantities the list of integer values, Quantities[i]
2341 # gives the quantity of nodes in face number i.
2342 # @return the Id of the new volumic element
2343 # @ingroup l2_modif_add
2344 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2345 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2347 ## Creates a volume of many faces, giving the IDs of the existing faces.
2348 # @param IdsOfFaces the list of face IDs for volume creation.
2350 # Note: The created volume will refer only to the nodes
2351 # of the given faces, not to the faces themselves.
2352 # @return the Id of the new volumic element
2353 # @ingroup l2_modif_add
2354 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2355 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2358 ## @brief Binds a node to a vertex
2359 # @param NodeID a node ID
2360 # @param Vertex a vertex or vertex ID
2361 # @return True if succeed else raises an exception
2362 # @ingroup l2_modif_add
2363 def SetNodeOnVertex(self, NodeID, Vertex):
2364 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2365 VertexID = Vertex.GetSubShapeIndices()[0]
2369 self.editor.SetNodeOnVertex(NodeID, VertexID)
2370 except SALOME.SALOME_Exception, inst:
2371 raise ValueError, inst.details.text
2375 ## @brief Stores the node position on an edge
2376 # @param NodeID a node ID
2377 # @param Edge an edge or edge ID
2378 # @param paramOnEdge a parameter on the edge where the node is located
2379 # @return True if succeed else raises an exception
2380 # @ingroup l2_modif_add
2381 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2382 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2383 EdgeID = Edge.GetSubShapeIndices()[0]
2387 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2388 except SALOME.SALOME_Exception, inst:
2389 raise ValueError, inst.details.text
2392 ## @brief Stores node position on a face
2393 # @param NodeID a node ID
2394 # @param Face a face or face ID
2395 # @param u U parameter on the face where the node is located
2396 # @param v V parameter on the face where the node is located
2397 # @return True if succeed else raises an exception
2398 # @ingroup l2_modif_add
2399 def SetNodeOnFace(self, NodeID, Face, u, v):
2400 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2401 FaceID = Face.GetSubShapeIndices()[0]
2405 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2406 except SALOME.SALOME_Exception, inst:
2407 raise ValueError, inst.details.text
2410 ## @brief Binds a node to a solid
2411 # @param NodeID a node ID
2412 # @param Solid a solid or solid ID
2413 # @return True if succeed else raises an exception
2414 # @ingroup l2_modif_add
2415 def SetNodeInVolume(self, NodeID, Solid):
2416 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2417 SolidID = Solid.GetSubShapeIndices()[0]
2421 self.editor.SetNodeInVolume(NodeID, SolidID)
2422 except SALOME.SALOME_Exception, inst:
2423 raise ValueError, inst.details.text
2426 ## @brief Bind an element to a shape
2427 # @param ElementID an element ID
2428 # @param Shape a shape or shape ID
2429 # @return True if succeed else raises an exception
2430 # @ingroup l2_modif_add
2431 def SetMeshElementOnShape(self, ElementID, Shape):
2432 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2433 ShapeID = Shape.GetSubShapeIndices()[0]
2437 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2438 except SALOME.SALOME_Exception, inst:
2439 raise ValueError, inst.details.text
2443 ## Moves the node with the given id
2444 # @param NodeID the id of the node
2445 # @param x a new X coordinate
2446 # @param y a new Y coordinate
2447 # @param z a new Z coordinate
2448 # @return True if succeed else False
2449 # @ingroup l2_modif_movenode
2450 def MoveNode(self, NodeID, x, y, z):
2451 x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
2452 if hasVars: self.mesh.SetParameters(Parameters)
2453 return self.editor.MoveNode(NodeID, x, y, z)
2455 ## Finds the node closest to a point and moves it to a point location
2456 # @param x the X coordinate of a point
2457 # @param y the Y coordinate of a point
2458 # @param z the Z coordinate of a point
2459 # @param NodeID if specified (>0), the node with this ID is moved,
2460 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2461 # @return the ID of a node
2462 # @ingroup l2_modif_throughp
2463 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2464 x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
2465 if hasVars: self.mesh.SetParameters(Parameters)
2466 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2468 ## Finds the node closest to a point
2469 # @param x the X coordinate of a point
2470 # @param y the Y coordinate of a point
2471 # @param z the Z coordinate of a point
2472 # @return the ID of a node
2473 # @ingroup l2_modif_throughp
2474 def FindNodeClosestTo(self, x, y, z):
2475 #preview = self.mesh.GetMeshEditPreviewer()
2476 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2477 return self.editor.FindNodeClosestTo(x, y, z)
2479 ## Finds the elements where a point lays IN or ON
2480 # @param x the X coordinate of a point
2481 # @param y the Y coordinate of a point
2482 # @param z the Z coordinate of a point
2483 # @param elementType type of elements to find (SMESH.ALL type
2484 # means elements of any type excluding nodes and 0D elements)
2485 # @param meshPart a part of mesh (group, sub-mesh) to search within
2486 # @return list of IDs of found elements
2487 # @ingroup l2_modif_throughp
2488 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL, meshPart=None):
2490 return self.editor.FindAmongElementsByPoint( meshPart, x, y, z, elementType );
2492 return self.editor.FindElementsByPoint(x, y, z, elementType)
2494 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2495 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2497 def GetPointState(self, x, y, z):
2498 return self.editor.GetPointState(x, y, z)
2500 ## Finds the node closest to a point and moves it to a point location
2501 # @param x the X coordinate of a point
2502 # @param y the Y coordinate of a point
2503 # @param z the Z coordinate of a point
2504 # @return the ID of a moved node
2505 # @ingroup l2_modif_throughp
2506 def MeshToPassThroughAPoint(self, x, y, z):
2507 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2509 ## Replaces two neighbour triangles sharing Node1-Node2 link
2510 # with the triangles built on the same 4 nodes but having other common link.
2511 # @param NodeID1 the ID of the first node
2512 # @param NodeID2 the ID of the second node
2513 # @return false if proper faces were not found
2514 # @ingroup l2_modif_invdiag
2515 def InverseDiag(self, NodeID1, NodeID2):
2516 return self.editor.InverseDiag(NodeID1, NodeID2)
2518 ## Replaces two neighbour triangles sharing Node1-Node2 link
2519 # with a quadrangle built on the same 4 nodes.
2520 # @param NodeID1 the ID of the first node
2521 # @param NodeID2 the ID of the second node
2522 # @return false if proper faces were not found
2523 # @ingroup l2_modif_unitetri
2524 def DeleteDiag(self, NodeID1, NodeID2):
2525 return self.editor.DeleteDiag(NodeID1, NodeID2)
2527 ## Reorients elements by ids
2528 # @param IDsOfElements if undefined reorients all mesh elements
2529 # @return True if succeed else False
2530 # @ingroup l2_modif_changori
2531 def Reorient(self, IDsOfElements=None):
2532 if IDsOfElements == None:
2533 IDsOfElements = self.GetElementsId()
2534 return self.editor.Reorient(IDsOfElements)
2536 ## Reorients all elements of the object
2537 # @param theObject mesh, submesh or group
2538 # @return True if succeed else False
2539 # @ingroup l2_modif_changori
2540 def ReorientObject(self, theObject):
2541 if ( isinstance( theObject, Mesh )):
2542 theObject = theObject.GetMesh()
2543 return self.editor.ReorientObject(theObject)
2545 ## Reorient faces contained in \a the2DObject.
2546 # @param the2DObject is a mesh, sub-mesh, group or list of IDs of 2D elements
2547 # @param theDirection is a desired direction of normal of \a theFace.
2548 # It can be either a GEOM vector or a list of coordinates [x,y,z].
2549 # @param theFaceOrPoint defines a face of \a the2DObject whose normal will be
2550 # compared with theDirection. It can be either ID of face or a point
2551 # by which the face will be found. The point can be given as either
2552 # a GEOM vertex or a list of point coordinates.
2553 # @return number of reoriented faces
2554 # @ingroup l2_modif_changori
2555 def Reorient2D(self, the2DObject, theDirection, theFaceOrPoint ):
2557 if isinstance( the2DObject, Mesh ):
2558 the2DObject = the2DObject.GetMesh()
2559 if isinstance( the2DObject, list ):
2560 the2DObject = self.GetIDSource( the2DObject, SMESH.FACE )
2561 # check theDirection
2562 if isinstance( theDirection, geompyDC.GEOM._objref_GEOM_Object):
2563 theDirection = self.smeshpyD.GetDirStruct( theDirection )
2564 if isinstance( theDirection, list ):
2565 theDirection = self.smeshpyD.MakeDirStruct( *theDirection )
2566 # prepare theFace and thePoint
2567 theFace = theFaceOrPoint
2568 thePoint = PointStruct(0,0,0)
2569 if isinstance( theFaceOrPoint, geompyDC.GEOM._objref_GEOM_Object):
2570 thePoint = self.smeshpyD.GetPointStruct( theFaceOrPoint )
2572 if isinstance( theFaceOrPoint, list ):
2573 thePoint = PointStruct( *theFaceOrPoint )
2575 if isinstance( theFaceOrPoint, PointStruct ):
2576 thePoint = theFaceOrPoint
2578 return self.editor.Reorient2D( the2DObject, theDirection, theFace, thePoint )
2580 ## Fuses the neighbouring triangles into quadrangles.
2581 # @param IDsOfElements The triangles to be fused,
2582 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2583 # @param MaxAngle is the maximum angle between element normals at which the fusion
2584 # is still performed; theMaxAngle is mesured in radians.
2585 # Also it could be a name of variable which defines angle in degrees.
2586 # @return TRUE in case of success, FALSE otherwise.
2587 # @ingroup l2_modif_unitetri
2588 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2590 if isinstance(MaxAngle,str):
2592 MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle)
2593 self.mesh.SetParameters(Parameters)
2594 if not IDsOfElements:
2595 IDsOfElements = self.GetElementsId()
2597 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2598 Functor = theCriterion
2600 Functor = self.smeshpyD.GetFunctor(theCriterion)
2601 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2603 ## Fuses the neighbouring triangles of the object into quadrangles
2604 # @param theObject is mesh, submesh or group
2605 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2606 # @param MaxAngle a max angle between element normals at which the fusion
2607 # is still performed; theMaxAngle is mesured in radians.
2608 # @return TRUE in case of success, FALSE otherwise.
2609 # @ingroup l2_modif_unitetri
2610 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2611 MaxAngle,Parameters,hasVars = ParseAngles(MaxAngle)
2612 self.mesh.SetParameters(Parameters)
2613 if ( isinstance( theObject, Mesh )):
2614 theObject = theObject.GetMesh()
2615 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2617 ## Splits quadrangles into triangles.
2618 # @param IDsOfElements the faces to be splitted.
2619 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2620 # @return TRUE in case of success, FALSE otherwise.
2621 # @ingroup l2_modif_cutquadr
2622 def QuadToTri (self, IDsOfElements, theCriterion):
2623 if IDsOfElements == []:
2624 IDsOfElements = self.GetElementsId()
2625 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2627 ## Splits quadrangles into triangles.
2628 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2629 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2630 # @return TRUE in case of success, FALSE otherwise.
2631 # @ingroup l2_modif_cutquadr
2632 def QuadToTriObject (self, theObject, theCriterion):
2633 if ( isinstance( theObject, Mesh )):
2634 theObject = theObject.GetMesh()
2635 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2637 ## Splits quadrangles into triangles.
2638 # @param IDsOfElements the faces to be splitted
2639 # @param Diag13 is used to choose a diagonal for splitting.
2640 # @return TRUE in case of success, FALSE otherwise.
2641 # @ingroup l2_modif_cutquadr
2642 def SplitQuad (self, IDsOfElements, Diag13):
2643 if IDsOfElements == []:
2644 IDsOfElements = self.GetElementsId()
2645 return self.editor.SplitQuad(IDsOfElements, Diag13)
2647 ## Splits quadrangles into triangles.
2648 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2649 # @param Diag13 is used to choose a diagonal for splitting.
2650 # @return TRUE in case of success, FALSE otherwise.
2651 # @ingroup l2_modif_cutquadr
2652 def SplitQuadObject (self, theObject, Diag13):
2653 if ( isinstance( theObject, Mesh )):
2654 theObject = theObject.GetMesh()
2655 return self.editor.SplitQuadObject(theObject, Diag13)
2657 ## Finds a better splitting of the given quadrangle.
2658 # @param IDOfQuad the ID of the quadrangle to be splitted.
2659 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2660 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2661 # diagonal is better, 0 if error occurs.
2662 # @ingroup l2_modif_cutquadr
2663 def BestSplit (self, IDOfQuad, theCriterion):
2664 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2666 ## Splits volumic elements into tetrahedrons
2667 # @param elemIDs either list of elements or mesh or group or submesh
2668 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2669 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2670 # @ingroup l2_modif_cutquadr
2671 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2672 if isinstance( elemIDs, Mesh ):
2673 elemIDs = elemIDs.GetMesh()
2674 if ( isinstance( elemIDs, list )):
2675 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2676 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2678 ## Splits quadrangle faces near triangular facets of volumes
2680 # @ingroup l1_auxiliary
2681 def SplitQuadsNearTriangularFacets(self):
2682 faces_array = self.GetElementsByType(SMESH.FACE)
2683 for face_id in faces_array:
2684 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2685 quad_nodes = self.mesh.GetElemNodes(face_id)
2686 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2687 isVolumeFound = False
2688 for node1_elem in node1_elems:
2689 if not isVolumeFound:
2690 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2691 nb_nodes = self.GetElemNbNodes(node1_elem)
2692 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2693 volume_elem = node1_elem
2694 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2695 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2696 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2697 isVolumeFound = True
2698 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2699 self.SplitQuad([face_id], False) # diagonal 2-4
2700 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2701 isVolumeFound = True
2702 self.SplitQuad([face_id], True) # diagonal 1-3
2703 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2704 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2705 isVolumeFound = True
2706 self.SplitQuad([face_id], True) # diagonal 1-3
2708 ## @brief Splits hexahedrons into tetrahedrons.
2710 # This operation uses pattern mapping functionality for splitting.
2711 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2712 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2713 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2714 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2715 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2716 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2717 # @return TRUE in case of success, FALSE otherwise.
2718 # @ingroup l1_auxiliary
2719 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2720 # Pattern: 5.---------.6
2725 # (0,0,1) 4.---------.7 * |
2732 # (0,0,0) 0.---------.3
2733 pattern_tetra = "!!! Nb of points: \n 8 \n\
2743 !!! Indices of points of 6 tetras: \n\
2751 pattern = self.smeshpyD.GetPattern()
2752 isDone = pattern.LoadFromFile(pattern_tetra)
2754 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2757 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2758 isDone = pattern.MakeMesh(self.mesh, False, False)
2759 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2761 # split quafrangle faces near triangular facets of volumes
2762 self.SplitQuadsNearTriangularFacets()
2766 ## @brief Split hexahedrons into prisms.
2768 # Uses the pattern mapping functionality for splitting.
2769 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2770 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2771 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2772 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2773 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2774 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2775 # @return TRUE in case of success, FALSE otherwise.
2776 # @ingroup l1_auxiliary
2777 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2778 # Pattern: 5.---------.6
2783 # (0,0,1) 4.---------.7 |
2790 # (0,0,0) 0.---------.3
2791 pattern_prism = "!!! Nb of points: \n 8 \n\
2801 !!! Indices of points of 2 prisms: \n\
2805 pattern = self.smeshpyD.GetPattern()
2806 isDone = pattern.LoadFromFile(pattern_prism)
2808 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2811 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2812 isDone = pattern.MakeMesh(self.mesh, False, False)
2813 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2815 # Splits quafrangle faces near triangular facets of volumes
2816 self.SplitQuadsNearTriangularFacets()
2820 ## Smoothes elements
2821 # @param IDsOfElements the list if ids of elements to smooth
2822 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2823 # Note that nodes built on edges and boundary nodes are always fixed.
2824 # @param MaxNbOfIterations the maximum number of iterations
2825 # @param MaxAspectRatio varies in range [1.0, inf]
2826 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2827 # @return TRUE in case of success, FALSE otherwise.
2828 # @ingroup l2_modif_smooth
2829 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2830 MaxNbOfIterations, MaxAspectRatio, Method):
2831 if IDsOfElements == []:
2832 IDsOfElements = self.GetElementsId()
2833 MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2834 self.mesh.SetParameters(Parameters)
2835 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2836 MaxNbOfIterations, MaxAspectRatio, Method)
2838 ## Smoothes elements which belong to the given object
2839 # @param theObject the object to smooth
2840 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2841 # Note that nodes built on edges and boundary nodes are always fixed.
2842 # @param MaxNbOfIterations the maximum number of iterations
2843 # @param MaxAspectRatio varies in range [1.0, inf]
2844 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2845 # @return TRUE in case of success, FALSE otherwise.
2846 # @ingroup l2_modif_smooth
2847 def SmoothObject(self, theObject, IDsOfFixedNodes,
2848 MaxNbOfIterations, MaxAspectRatio, Method):
2849 if ( isinstance( theObject, Mesh )):
2850 theObject = theObject.GetMesh()
2851 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2852 MaxNbOfIterations, MaxAspectRatio, Method)
2854 ## Parametrically smoothes the given elements
2855 # @param IDsOfElements the list if ids of elements to smooth
2856 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2857 # Note that nodes built on edges and boundary nodes are always fixed.
2858 # @param MaxNbOfIterations the maximum number of iterations
2859 # @param MaxAspectRatio varies in range [1.0, inf]
2860 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2861 # @return TRUE in case of success, FALSE otherwise.
2862 # @ingroup l2_modif_smooth
2863 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2864 MaxNbOfIterations, MaxAspectRatio, Method):
2865 if IDsOfElements == []:
2866 IDsOfElements = self.GetElementsId()
2867 MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2868 self.mesh.SetParameters(Parameters)
2869 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2870 MaxNbOfIterations, MaxAspectRatio, Method)
2872 ## Parametrically smoothes the elements which belong to the given object
2873 # @param theObject the object to smooth
2874 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2875 # Note that nodes built on edges and boundary nodes are always fixed.
2876 # @param MaxNbOfIterations the maximum number of iterations
2877 # @param MaxAspectRatio varies in range [1.0, inf]
2878 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2879 # @return TRUE in case of success, FALSE otherwise.
2880 # @ingroup l2_modif_smooth
2881 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2882 MaxNbOfIterations, MaxAspectRatio, Method):
2883 if ( isinstance( theObject, Mesh )):
2884 theObject = theObject.GetMesh()
2885 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2886 MaxNbOfIterations, MaxAspectRatio, Method)
2888 ## Converts the mesh to quadratic, deletes old elements, replacing
2889 # them with quadratic with the same id.
2890 # @param theForce3d new node creation method:
2891 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
2892 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
2893 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
2894 # @ingroup l2_modif_tofromqu
2895 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
2897 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
2899 self.editor.ConvertToQuadratic(theForce3d)
2901 ## Converts the mesh from quadratic to ordinary,
2902 # deletes old quadratic elements, \n replacing
2903 # them with ordinary mesh elements with the same id.
2904 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
2905 # @ingroup l2_modif_tofromqu
2906 def ConvertFromQuadratic(self, theSubMesh=None):
2908 self.editor.ConvertFromQuadraticObject(theSubMesh)
2910 return self.editor.ConvertFromQuadratic()
2912 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2913 # @return TRUE if operation has been completed successfully, FALSE otherwise
2914 # @ingroup l2_modif_edit
2915 def Make2DMeshFrom3D(self):
2916 return self.editor. Make2DMeshFrom3D()
2918 ## Creates missing boundary elements
2919 # @param elements - elements whose boundary is to be checked:
2920 # mesh, group, sub-mesh or list of elements
2921 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
2922 # @param dimension - defines type of boundary elements to create:
2923 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
2924 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
2925 # @param groupName - a name of group to store created boundary elements in,
2926 # "" means not to create the group
2927 # @param meshName - a name of new mesh to store created boundary elements in,
2928 # "" means not to create the new mesh
2929 # @param toCopyElements - if true, the checked elements will be copied into
2930 # the new mesh else only boundary elements will be copied into the new mesh
2931 # @param toCopyExistingBondary - if true, not only new but also pre-existing
2932 # boundary elements will be copied into the new mesh
2933 # @return tuple (mesh, group) where bondary elements were added to
2934 # @ingroup l2_modif_edit
2935 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
2936 toCopyElements=False, toCopyExistingBondary=False):
2937 if isinstance( elements, Mesh ):
2938 elements = elements.GetMesh()
2939 if ( isinstance( elements, list )):
2940 elemType = SMESH.ALL
2941 if elements: elemType = self.GetElementType( elements[0], iselem=True)
2942 elements = self.editor.MakeIDSource(elements, elemType)
2943 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
2944 toCopyElements,toCopyExistingBondary)
2945 if mesh: mesh = self.smeshpyD.Mesh(mesh)
2949 # @brief Creates missing boundary elements around either the whole mesh or
2950 # groups of 2D elements
2951 # @param dimension - defines type of boundary elements to create
2952 # @param groupName - a name of group to store all boundary elements in,
2953 # "" means not to create the group
2954 # @param meshName - a name of a new mesh, which is a copy of the initial
2955 # mesh + created boundary elements; "" means not to create the new mesh
2956 # @param toCopyAll - if true, the whole initial mesh will be copied into
2957 # the new mesh else only boundary elements will be copied into the new mesh
2958 # @param groups - groups of 2D elements to make boundary around
2959 # @retval tuple( long, mesh, groups )
2960 # long - number of added boundary elements
2961 # mesh - the mesh where elements were added to
2962 # group - the group of boundary elements or None
2964 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
2965 toCopyAll=False, groups=[]):
2966 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
2968 if mesh: mesh = self.smeshpyD.Mesh(mesh)
2969 return nb, mesh, group
2971 ## Renumber mesh nodes
2972 # @ingroup l2_modif_renumber
2973 def RenumberNodes(self):
2974 self.editor.RenumberNodes()
2976 ## Renumber mesh elements
2977 # @ingroup l2_modif_renumber
2978 def RenumberElements(self):
2979 self.editor.RenumberElements()
2981 ## Generates new elements by rotation of the elements around the axis
2982 # @param IDsOfElements the list of ids of elements to sweep
2983 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2984 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2985 # @param NbOfSteps the number of steps
2986 # @param Tolerance tolerance
2987 # @param MakeGroups forces the generation of new groups from existing ones
2988 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2989 # of all steps, else - size of each step
2990 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2991 # @ingroup l2_modif_extrurev
2992 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2993 MakeGroups=False, TotalAngle=False):
2994 if IDsOfElements == []:
2995 IDsOfElements = self.GetElementsId()
2996 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2997 Axis = self.smeshpyD.GetAxisStruct(Axis)
2998 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
2999 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3000 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3001 self.mesh.SetParameters(Parameters)
3002 if TotalAngle and NbOfSteps:
3003 AngleInRadians /= NbOfSteps
3005 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3006 AngleInRadians, NbOfSteps, Tolerance)
3007 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3010 ## Generates new elements by rotation of the elements of object around the axis
3011 # @param theObject object which elements should be sweeped.
3012 # It can be a mesh, a sub mesh or a group.
3013 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3014 # @param AngleInRadians the angle of Rotation
3015 # @param NbOfSteps number of steps
3016 # @param Tolerance tolerance
3017 # @param MakeGroups forces the generation of new groups from existing ones
3018 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3019 # of all steps, else - size of each step
3020 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3021 # @ingroup l2_modif_extrurev
3022 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3023 MakeGroups=False, TotalAngle=False):
3024 if ( isinstance( theObject, Mesh )):
3025 theObject = theObject.GetMesh()
3026 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3027 Axis = self.smeshpyD.GetAxisStruct(Axis)
3028 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3029 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3030 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3031 self.mesh.SetParameters(Parameters)
3032 if TotalAngle and NbOfSteps:
3033 AngleInRadians /= NbOfSteps
3035 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3036 NbOfSteps, Tolerance)
3037 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3040 ## Generates new elements by rotation of the elements of object around the axis
3041 # @param theObject object which elements should be sweeped.
3042 # It can be a mesh, a sub mesh or a group.
3043 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3044 # @param AngleInRadians the angle of Rotation
3045 # @param NbOfSteps number of steps
3046 # @param Tolerance tolerance
3047 # @param MakeGroups forces the generation of new groups from existing ones
3048 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3049 # of all steps, else - size of each step
3050 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3051 # @ingroup l2_modif_extrurev
3052 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3053 MakeGroups=False, TotalAngle=False):
3054 if ( isinstance( theObject, Mesh )):
3055 theObject = theObject.GetMesh()
3056 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3057 Axis = self.smeshpyD.GetAxisStruct(Axis)
3058 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3059 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3060 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3061 self.mesh.SetParameters(Parameters)
3062 if TotalAngle and NbOfSteps:
3063 AngleInRadians /= NbOfSteps
3065 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3066 NbOfSteps, Tolerance)
3067 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3070 ## Generates new elements by rotation of the elements of object around the axis
3071 # @param theObject object which elements should be sweeped.
3072 # It can be a mesh, a sub mesh or a group.
3073 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3074 # @param AngleInRadians the angle of Rotation
3075 # @param NbOfSteps number of steps
3076 # @param Tolerance tolerance
3077 # @param MakeGroups forces the generation of new groups from existing ones
3078 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3079 # of all steps, else - size of each step
3080 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3081 # @ingroup l2_modif_extrurev
3082 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3083 MakeGroups=False, TotalAngle=False):
3084 if ( isinstance( theObject, Mesh )):
3085 theObject = theObject.GetMesh()
3086 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3087 Axis = self.smeshpyD.GetAxisStruct(Axis)
3088 AngleInRadians,AngleParameters,hasVars = ParseAngles(AngleInRadians)
3089 NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
3090 Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
3091 self.mesh.SetParameters(Parameters)
3092 if TotalAngle and NbOfSteps:
3093 AngleInRadians /= NbOfSteps
3095 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3096 NbOfSteps, Tolerance)
3097 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3100 ## Generates new elements by extrusion of the elements with given ids
3101 # @param IDsOfElements the list of elements ids for extrusion
3102 # @param StepVector vector or DirStruct, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3103 # @param NbOfSteps the number of steps
3104 # @param MakeGroups forces the generation of new groups from existing ones
3105 # @param IsNodes is True if elements with given ids are nodes
3106 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3107 # @ingroup l2_modif_extrurev
3108 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False, IsNodes = False):
3109 if IDsOfElements == []:
3110 IDsOfElements = self.GetElementsId()
3111 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3112 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3113 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3114 Parameters = StepVector.PS.parameters + var_separator + Parameters
3115 self.mesh.SetParameters(Parameters)
3118 return self.editor.ExtrusionSweepMakeGroups0D(IDsOfElements, StepVector, NbOfSteps)
3120 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3122 self.editor.ExtrusionSweep0D(IDsOfElements, StepVector, NbOfSteps)
3124 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3127 ## Generates new elements by extrusion of the elements with given ids
3128 # @param IDsOfElements is ids of elements
3129 # @param StepVector vector, defining the direction and value of extrusion
3130 # @param NbOfSteps the number of steps
3131 # @param ExtrFlags sets flags for extrusion
3132 # @param SewTolerance uses for comparing locations of nodes if flag
3133 # EXTRUSION_FLAG_SEW is set
3134 # @param MakeGroups forces the generation of new groups from existing ones
3135 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3136 # @ingroup l2_modif_extrurev
3137 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3138 ExtrFlags, SewTolerance, MakeGroups=False):
3139 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3140 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3142 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3143 ExtrFlags, SewTolerance)
3144 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3145 ExtrFlags, SewTolerance)
3148 ## Generates new elements by extrusion of the elements which belong to the object
3149 # @param theObject the object which elements should be processed.
3150 # It can be a mesh, a sub mesh or a group.
3151 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3152 # @param NbOfSteps the number of steps
3153 # @param MakeGroups forces the generation of new groups from existing ones
3154 # @param IsNodes is True if elements which belong to the object are nodes
3155 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3156 # @ingroup l2_modif_extrurev
3157 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False, IsNodes=False):
3158 if ( isinstance( theObject, Mesh )):
3159 theObject = theObject.GetMesh()
3160 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3161 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3162 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3163 Parameters = StepVector.PS.parameters + var_separator + Parameters
3164 self.mesh.SetParameters(Parameters)
3167 return self.editor.ExtrusionSweepObject0DMakeGroups(theObject, StepVector, NbOfSteps)
3169 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3171 self.editor.ExtrusionSweepObject0D(theObject, StepVector, NbOfSteps)
3173 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3176 ## Generates new elements by extrusion of the elements which belong to the object
3177 # @param theObject object which elements should be processed.
3178 # It can be a mesh, a sub mesh or a group.
3179 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3180 # @param NbOfSteps the number of steps
3181 # @param MakeGroups to generate new groups from existing ones
3182 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3183 # @ingroup l2_modif_extrurev
3184 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3185 if ( isinstance( theObject, Mesh )):
3186 theObject = theObject.GetMesh()
3187 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3188 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3189 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3190 Parameters = StepVector.PS.parameters + var_separator + Parameters
3191 self.mesh.SetParameters(Parameters)
3193 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3194 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3197 ## Generates new elements by extrusion of the elements which belong to the object
3198 # @param theObject object which elements should be processed.
3199 # It can be a mesh, a sub mesh or a group.
3200 # @param StepVector vector, defining the direction and value of extrusion for one step (the total extrusion length will be NbOfSteps * ||StepVector||)
3201 # @param NbOfSteps the number of steps
3202 # @param MakeGroups forces the generation of new groups from existing ones
3203 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3204 # @ingroup l2_modif_extrurev
3205 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3206 if ( isinstance( theObject, Mesh )):
3207 theObject = theObject.GetMesh()
3208 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3209 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3210 NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
3211 Parameters = StepVector.PS.parameters + var_separator + Parameters
3212 self.mesh.SetParameters(Parameters)
3214 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3215 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3220 ## Generates new elements by extrusion of the given elements
3221 # The path of extrusion must be a meshed edge.
3222 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3223 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3224 # @param NodeStart the start node from Path. Defines the direction of extrusion
3225 # @param HasAngles allows the shape to be rotated around the path
3226 # to get the resulting mesh in a helical fashion
3227 # @param Angles list of angles in radians
3228 # @param LinearVariation forces the computation of rotation angles as linear
3229 # variation of the given Angles along path steps
3230 # @param HasRefPoint allows using the reference point
3231 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3232 # The User can specify any point as the Reference Point.
3233 # @param MakeGroups forces the generation of new groups from existing ones
3234 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3235 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3236 # only SMESH::Extrusion_Error otherwise
3237 # @ingroup l2_modif_extrurev
3238 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3239 HasAngles, Angles, LinearVariation,
3240 HasRefPoint, RefPoint, MakeGroups, ElemType):
3241 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3242 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3244 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3245 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3246 self.mesh.SetParameters(Parameters)
3248 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3250 if isinstance(Base, list):
3252 if Base == []: IDsOfElements = self.GetElementsId()
3253 else: IDsOfElements = Base
3254 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3255 HasAngles, Angles, LinearVariation,
3256 HasRefPoint, RefPoint, MakeGroups, ElemType)
3258 if isinstance(Base, Mesh): Base = Base.GetMesh()
3259 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3260 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3261 HasAngles, Angles, LinearVariation,
3262 HasRefPoint, RefPoint, MakeGroups, ElemType)
3264 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3267 ## Generates new elements by extrusion of the given elements
3268 # The path of extrusion must be a meshed edge.
3269 # @param IDsOfElements ids of elements
3270 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3271 # @param PathShape shape(edge) defines the sub-mesh for the path
3272 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3273 # @param HasAngles allows the shape to be rotated around the path
3274 # to get the resulting mesh in a helical fashion
3275 # @param Angles list of angles in radians
3276 # @param HasRefPoint allows using the reference point
3277 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3278 # The User can specify any point as the Reference Point.
3279 # @param MakeGroups forces the generation of new groups from existing ones
3280 # @param LinearVariation forces the computation of rotation angles as linear
3281 # variation of the given Angles along path steps
3282 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3283 # only SMESH::Extrusion_Error otherwise
3284 # @ingroup l2_modif_extrurev
3285 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3286 HasAngles, Angles, HasRefPoint, RefPoint,
3287 MakeGroups=False, LinearVariation=False):
3288 if IDsOfElements == []:
3289 IDsOfElements = self.GetElementsId()
3290 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3291 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3293 if ( isinstance( PathMesh, Mesh )):
3294 PathMesh = PathMesh.GetMesh()
3295 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3296 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3297 self.mesh.SetParameters(Parameters)
3298 if HasAngles and Angles and LinearVariation:
3299 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3302 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3303 PathShape, NodeStart, HasAngles,
3304 Angles, HasRefPoint, RefPoint)
3305 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3306 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3308 ## Generates new elements by extrusion of the elements which belong to the object
3309 # The path of extrusion must be a meshed edge.
3310 # @param theObject the object which elements should be processed.
3311 # It can be a mesh, a sub mesh or a group.
3312 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3313 # @param PathShape shape(edge) defines the sub-mesh for the path
3314 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3315 # @param HasAngles allows the shape to be rotated around the path
3316 # to get the resulting mesh in a helical fashion
3317 # @param Angles list of angles
3318 # @param HasRefPoint allows using the reference point
3319 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3320 # The User can specify any point as the Reference Point.
3321 # @param MakeGroups forces the generation of new groups from existing ones
3322 # @param LinearVariation forces the computation of rotation angles as linear
3323 # variation of the given Angles along path steps
3324 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3325 # only SMESH::Extrusion_Error otherwise
3326 # @ingroup l2_modif_extrurev
3327 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3328 HasAngles, Angles, HasRefPoint, RefPoint,
3329 MakeGroups=False, LinearVariation=False):
3330 if ( isinstance( theObject, Mesh )):
3331 theObject = theObject.GetMesh()
3332 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3333 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3334 if ( isinstance( PathMesh, Mesh )):
3335 PathMesh = PathMesh.GetMesh()
3336 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3337 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3338 self.mesh.SetParameters(Parameters)
3339 if HasAngles and Angles and LinearVariation:
3340 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3343 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3344 PathShape, NodeStart, HasAngles,
3345 Angles, HasRefPoint, RefPoint)
3346 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3347 NodeStart, HasAngles, Angles, HasRefPoint,
3350 ## Generates new elements by extrusion of the elements which belong to the object
3351 # The path of extrusion must be a meshed edge.
3352 # @param theObject the object which elements should be processed.
3353 # It can be a mesh, a sub mesh or a group.
3354 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3355 # @param PathShape shape(edge) defines the sub-mesh for the path
3356 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3357 # @param HasAngles allows the shape to be rotated around the path
3358 # to get the resulting mesh in a helical fashion
3359 # @param Angles list of angles
3360 # @param HasRefPoint allows using the reference point
3361 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3362 # The User can specify any point as the Reference Point.
3363 # @param MakeGroups forces the generation of new groups from existing ones
3364 # @param LinearVariation forces the computation of rotation angles as linear
3365 # variation of the given Angles along path steps
3366 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3367 # only SMESH::Extrusion_Error otherwise
3368 # @ingroup l2_modif_extrurev
3369 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3370 HasAngles, Angles, HasRefPoint, RefPoint,
3371 MakeGroups=False, LinearVariation=False):
3372 if ( isinstance( theObject, Mesh )):
3373 theObject = theObject.GetMesh()
3374 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3375 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3376 if ( isinstance( PathMesh, Mesh )):
3377 PathMesh = PathMesh.GetMesh()
3378 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3379 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3380 self.mesh.SetParameters(Parameters)
3381 if HasAngles and Angles and LinearVariation:
3382 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3385 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3386 PathShape, NodeStart, HasAngles,
3387 Angles, HasRefPoint, RefPoint)
3388 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3389 NodeStart, HasAngles, Angles, HasRefPoint,
3392 ## Generates new elements by extrusion of the elements which belong to the object
3393 # The path of extrusion must be a meshed edge.
3394 # @param theObject the object which elements should be processed.
3395 # It can be a mesh, a sub mesh or a group.
3396 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3397 # @param PathShape shape(edge) defines the sub-mesh for the path
3398 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3399 # @param HasAngles allows the shape to be rotated around the path
3400 # to get the resulting mesh in a helical fashion
3401 # @param Angles list of angles
3402 # @param HasRefPoint allows using the reference point
3403 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3404 # The User can specify any point as the Reference Point.
3405 # @param MakeGroups forces the generation of new groups from existing ones
3406 # @param LinearVariation forces the computation of rotation angles as linear
3407 # variation of the given Angles along path steps
3408 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3409 # only SMESH::Extrusion_Error otherwise
3410 # @ingroup l2_modif_extrurev
3411 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3412 HasAngles, Angles, HasRefPoint, RefPoint,
3413 MakeGroups=False, LinearVariation=False):
3414 if ( isinstance( theObject, Mesh )):
3415 theObject = theObject.GetMesh()
3416 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3417 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3418 if ( isinstance( PathMesh, Mesh )):
3419 PathMesh = PathMesh.GetMesh()
3420 Angles,AnglesParameters,hasVars = ParseAngles(Angles)
3421 Parameters = AnglesParameters + var_separator + RefPoint.parameters
3422 self.mesh.SetParameters(Parameters)
3423 if HasAngles and Angles and LinearVariation:
3424 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3427 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3428 PathShape, NodeStart, HasAngles,
3429 Angles, HasRefPoint, RefPoint)
3430 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3431 NodeStart, HasAngles, Angles, HasRefPoint,
3434 ## Creates a symmetrical copy of mesh elements
3435 # @param IDsOfElements list of elements ids
3436 # @param Mirror is AxisStruct or geom object(point, line, plane)
3437 # @param theMirrorType is POINT, AXIS or PLANE
3438 # If the Mirror is a geom object this parameter is unnecessary
3439 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3440 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3441 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3442 # @ingroup l2_modif_trsf
3443 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3444 if IDsOfElements == []:
3445 IDsOfElements = self.GetElementsId()
3446 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3447 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3448 self.mesh.SetParameters(Mirror.parameters)
3449 if Copy and MakeGroups:
3450 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3451 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3454 ## Creates a new mesh by a symmetrical copy of mesh elements
3455 # @param IDsOfElements the list of elements ids
3456 # @param Mirror is AxisStruct or geom object (point, line, plane)
3457 # @param theMirrorType is POINT, AXIS or PLANE
3458 # If the Mirror is a geom object this parameter is unnecessary
3459 # @param MakeGroups to generate new groups from existing ones
3460 # @param NewMeshName a name of the new mesh to create
3461 # @return instance of Mesh class
3462 # @ingroup l2_modif_trsf
3463 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3464 if IDsOfElements == []:
3465 IDsOfElements = self.GetElementsId()
3466 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3467 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3468 self.mesh.SetParameters(Mirror.parameters)
3469 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3470 MakeGroups, NewMeshName)
3471 return Mesh(self.smeshpyD,self.geompyD,mesh)
3473 ## Creates a symmetrical copy of the object
3474 # @param theObject mesh, submesh or group
3475 # @param Mirror AxisStruct or geom object (point, line, plane)
3476 # @param theMirrorType is POINT, AXIS or PLANE
3477 # If the Mirror is a geom object this parameter is unnecessary
3478 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3479 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3480 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3481 # @ingroup l2_modif_trsf
3482 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3483 if ( isinstance( theObject, Mesh )):
3484 theObject = theObject.GetMesh()
3485 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3486 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3487 self.mesh.SetParameters(Mirror.parameters)
3488 if Copy and MakeGroups:
3489 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3490 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3493 ## Creates a new mesh by a symmetrical copy of the object
3494 # @param theObject mesh, submesh or group
3495 # @param Mirror AxisStruct or geom object (point, line, plane)
3496 # @param theMirrorType POINT, AXIS or PLANE
3497 # If the Mirror is a geom object this parameter is unnecessary
3498 # @param MakeGroups forces the generation of new groups from existing ones
3499 # @param NewMeshName the name of the new mesh to create
3500 # @return instance of Mesh class
3501 # @ingroup l2_modif_trsf
3502 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3503 if ( isinstance( theObject, Mesh )):
3504 theObject = theObject.GetMesh()
3505 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3506 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3507 self.mesh.SetParameters(Mirror.parameters)
3508 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3509 MakeGroups, NewMeshName)
3510 return Mesh( self.smeshpyD,self.geompyD,mesh )
3512 ## Translates the elements
3513 # @param IDsOfElements list of elements ids
3514 # @param Vector the direction of translation (DirStruct or vector)
3515 # @param Copy allows copying the translated elements
3516 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3517 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3518 # @ingroup l2_modif_trsf
3519 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3520 if IDsOfElements == []:
3521 IDsOfElements = self.GetElementsId()
3522 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3523 Vector = self.smeshpyD.GetDirStruct(Vector)
3524 self.mesh.SetParameters(Vector.PS.parameters)
3525 if Copy and MakeGroups:
3526 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3527 self.editor.Translate(IDsOfElements, Vector, Copy)
3530 ## Creates a new mesh of translated elements
3531 # @param IDsOfElements list of elements ids
3532 # @param Vector the direction of translation (DirStruct or vector)
3533 # @param MakeGroups forces the generation of new groups from existing ones
3534 # @param NewMeshName the name of the newly created mesh
3535 # @return instance of Mesh class
3536 # @ingroup l2_modif_trsf
3537 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3538 if IDsOfElements == []:
3539 IDsOfElements = self.GetElementsId()
3540 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3541 Vector = self.smeshpyD.GetDirStruct(Vector)
3542 self.mesh.SetParameters(Vector.PS.parameters)
3543 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3544 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3546 ## Translates the object
3547 # @param theObject the object to translate (mesh, submesh, or group)
3548 # @param Vector direction of translation (DirStruct or geom vector)
3549 # @param Copy allows copying the translated elements
3550 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3551 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3552 # @ingroup l2_modif_trsf
3553 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3554 if ( isinstance( theObject, Mesh )):
3555 theObject = theObject.GetMesh()
3556 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3557 Vector = self.smeshpyD.GetDirStruct(Vector)
3558 self.mesh.SetParameters(Vector.PS.parameters)
3559 if Copy and MakeGroups:
3560 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3561 self.editor.TranslateObject(theObject, Vector, Copy)
3564 ## Creates a new mesh from the translated object
3565 # @param theObject the object to translate (mesh, submesh, or group)
3566 # @param Vector the direction of translation (DirStruct or geom vector)
3567 # @param MakeGroups forces the generation of new groups from existing ones
3568 # @param NewMeshName the name of the newly created mesh
3569 # @return instance of Mesh class
3570 # @ingroup l2_modif_trsf
3571 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3572 if (isinstance(theObject, Mesh)):
3573 theObject = theObject.GetMesh()
3574 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3575 Vector = self.smeshpyD.GetDirStruct(Vector)
3576 self.mesh.SetParameters(Vector.PS.parameters)
3577 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3578 return Mesh( self.smeshpyD, self.geompyD, mesh )
3582 ## Scales the object
3583 # @param theObject - the object to translate (mesh, submesh, or group)
3584 # @param thePoint - base point for scale
3585 # @param theScaleFact - list of 1-3 scale factors for axises
3586 # @param Copy - allows copying the translated elements
3587 # @param MakeGroups - forces the generation of new groups from existing
3589 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3590 # empty list otherwise
3591 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3592 if ( isinstance( theObject, Mesh )):
3593 theObject = theObject.GetMesh()
3594 if ( isinstance( theObject, list )):
3595 theObject = self.GetIDSource(theObject, SMESH.ALL)
3597 self.mesh.SetParameters(thePoint.parameters)
3599 if Copy and MakeGroups:
3600 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3601 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3604 ## Creates a new mesh from the translated object
3605 # @param theObject - the object to translate (mesh, submesh, or group)
3606 # @param thePoint - base point for scale
3607 # @param theScaleFact - list of 1-3 scale factors for axises
3608 # @param MakeGroups - forces the generation of new groups from existing ones
3609 # @param NewMeshName - the name of the newly created mesh
3610 # @return instance of Mesh class
3611 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3612 if (isinstance(theObject, Mesh)):
3613 theObject = theObject.GetMesh()
3614 if ( isinstance( theObject, list )):
3615 theObject = self.GetIDSource(theObject,SMESH.ALL)
3617 self.mesh.SetParameters(thePoint.parameters)
3618 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3619 MakeGroups, NewMeshName)
3620 return Mesh( self.smeshpyD, self.geompyD, mesh )
3624 ## Rotates the elements
3625 # @param IDsOfElements list of elements ids
3626 # @param Axis the axis of rotation (AxisStruct or geom line)
3627 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3628 # @param Copy allows copying the rotated elements
3629 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3630 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3631 # @ingroup l2_modif_trsf
3632 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3633 if IDsOfElements == []:
3634 IDsOfElements = self.GetElementsId()
3635 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3636 Axis = self.smeshpyD.GetAxisStruct(Axis)
3637 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3638 Parameters = Axis.parameters + var_separator + Parameters
3639 self.mesh.SetParameters(Parameters)
3640 if Copy and MakeGroups:
3641 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3642 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3645 ## Creates a new mesh of rotated elements
3646 # @param IDsOfElements list of element ids
3647 # @param Axis the axis of rotation (AxisStruct or geom line)
3648 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3649 # @param MakeGroups forces the generation of new groups from existing ones
3650 # @param NewMeshName the name of the newly created mesh
3651 # @return instance of Mesh class
3652 # @ingroup l2_modif_trsf
3653 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3654 if IDsOfElements == []:
3655 IDsOfElements = self.GetElementsId()
3656 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3657 Axis = self.smeshpyD.GetAxisStruct(Axis)
3658 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3659 Parameters = Axis.parameters + var_separator + Parameters
3660 self.mesh.SetParameters(Parameters)
3661 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3662 MakeGroups, NewMeshName)
3663 return Mesh( self.smeshpyD, self.geompyD, mesh )
3665 ## Rotates the object
3666 # @param theObject the object to rotate( mesh, submesh, or group)
3667 # @param Axis the axis of rotation (AxisStruct or geom line)
3668 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3669 # @param Copy allows copying the rotated elements
3670 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3671 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3672 # @ingroup l2_modif_trsf
3673 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3674 if (isinstance(theObject, Mesh)):
3675 theObject = theObject.GetMesh()
3676 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3677 Axis = self.smeshpyD.GetAxisStruct(Axis)
3678 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3679 Parameters = Axis.parameters + ":" + Parameters
3680 self.mesh.SetParameters(Parameters)
3681 if Copy and MakeGroups:
3682 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3683 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3686 ## Creates a new mesh from the rotated object
3687 # @param theObject the object to rotate (mesh, submesh, or group)
3688 # @param Axis the axis of rotation (AxisStruct or geom line)
3689 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3690 # @param MakeGroups forces the generation of new groups from existing ones
3691 # @param NewMeshName the name of the newly created mesh
3692 # @return instance of Mesh class
3693 # @ingroup l2_modif_trsf
3694 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3695 if (isinstance( theObject, Mesh )):
3696 theObject = theObject.GetMesh()
3697 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3698 Axis = self.smeshpyD.GetAxisStruct(Axis)
3699 AngleInRadians,Parameters,hasVars = ParseAngles(AngleInRadians)
3700 Parameters = Axis.parameters + ":" + Parameters
3701 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3702 MakeGroups, NewMeshName)
3703 self.mesh.SetParameters(Parameters)
3704 return Mesh( self.smeshpyD, self.geompyD, mesh )
3706 ## Finds groups of ajacent nodes within Tolerance.
3707 # @param Tolerance the value of tolerance
3708 # @return the list of groups of nodes
3709 # @ingroup l2_modif_trsf
3710 def FindCoincidentNodes (self, Tolerance):
3711 return self.editor.FindCoincidentNodes(Tolerance)
3713 ## Finds groups of ajacent nodes within Tolerance.
3714 # @param Tolerance the value of tolerance
3715 # @param SubMeshOrGroup SubMesh or Group
3716 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3717 # @return the list of groups of nodes
3718 # @ingroup l2_modif_trsf
3719 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3720 if (isinstance( SubMeshOrGroup, Mesh )):
3721 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3722 if not isinstance( exceptNodes, list):
3723 exceptNodes = [ exceptNodes ]
3724 if exceptNodes and isinstance( exceptNodes[0], int):
3725 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
3726 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3729 # @param GroupsOfNodes the list of groups of nodes
3730 # @ingroup l2_modif_trsf
3731 def MergeNodes (self, GroupsOfNodes):
3732 self.editor.MergeNodes(GroupsOfNodes)
3734 ## Finds the elements built on the same nodes.
3735 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3736 # @return a list of groups of equal elements
3737 # @ingroup l2_modif_trsf
3738 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3739 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3740 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3741 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3743 ## Merges elements in each given group.
3744 # @param GroupsOfElementsID groups of elements for merging
3745 # @ingroup l2_modif_trsf
3746 def MergeElements(self, GroupsOfElementsID):
3747 self.editor.MergeElements(GroupsOfElementsID)
3749 ## Leaves one element and removes all other elements built on the same nodes.
3750 # @ingroup l2_modif_trsf
3751 def MergeEqualElements(self):
3752 self.editor.MergeEqualElements()
3754 ## Sews free borders
3755 # @return SMESH::Sew_Error
3756 # @ingroup l2_modif_trsf
3757 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3758 FirstNodeID2, SecondNodeID2, LastNodeID2,
3759 CreatePolygons, CreatePolyedrs):
3760 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3761 FirstNodeID2, SecondNodeID2, LastNodeID2,
3762 CreatePolygons, CreatePolyedrs)
3764 ## Sews conform free borders
3765 # @return SMESH::Sew_Error
3766 # @ingroup l2_modif_trsf
3767 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3768 FirstNodeID2, SecondNodeID2):
3769 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3770 FirstNodeID2, SecondNodeID2)
3772 ## Sews border to side
3773 # @return SMESH::Sew_Error
3774 # @ingroup l2_modif_trsf
3775 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3776 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3777 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3778 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3780 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3781 # merged with the nodes of elements of Side2.
3782 # The number of elements in theSide1 and in theSide2 must be
3783 # equal and they should have similar nodal connectivity.
3784 # The nodes to merge should belong to side borders and
3785 # the first node should be linked to the second.
3786 # @return SMESH::Sew_Error
3787 # @ingroup l2_modif_trsf
3788 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3789 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3790 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3791 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3792 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3793 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3795 ## Sets new nodes for the given element.
3796 # @param ide the element id
3797 # @param newIDs nodes ids
3798 # @return If the number of nodes does not correspond to the type of element - returns false
3799 # @ingroup l2_modif_edit
3800 def ChangeElemNodes(self, ide, newIDs):
3801 return self.editor.ChangeElemNodes(ide, newIDs)
3803 ## If during the last operation of MeshEditor some nodes were
3804 # created, this method returns the list of their IDs, \n
3805 # if new nodes were not created - returns empty list
3806 # @return the list of integer values (can be empty)
3807 # @ingroup l1_auxiliary
3808 def GetLastCreatedNodes(self):
3809 return self.editor.GetLastCreatedNodes()
3811 ## If during the last operation of MeshEditor some elements were
3812 # created this method returns the list of their IDs, \n
3813 # if new elements were not created - returns empty list
3814 # @return the list of integer values (can be empty)
3815 # @ingroup l1_auxiliary
3816 def GetLastCreatedElems(self):
3817 return self.editor.GetLastCreatedElems()
3819 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3820 # @param theNodes identifiers of nodes to be doubled
3821 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3822 # nodes. If list of element identifiers is empty then nodes are doubled but
3823 # they not assigned to elements
3824 # @return TRUE if operation has been completed successfully, FALSE otherwise
3825 # @ingroup l2_modif_edit
3826 def DoubleNodes(self, theNodes, theModifiedElems):
3827 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3829 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3830 # This method provided for convenience works as DoubleNodes() described above.
3831 # @param theNodeId identifiers of node to be doubled
3832 # @param theModifiedElems identifiers of elements to be updated
3833 # @return TRUE if operation has been completed successfully, FALSE otherwise
3834 # @ingroup l2_modif_edit
3835 def DoubleNode(self, theNodeId, theModifiedElems):
3836 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3838 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3839 # This method provided for convenience works as DoubleNodes() described above.
3840 # @param theNodes group of nodes to be doubled
3841 # @param theModifiedElems group of elements to be updated.
3842 # @param theMakeGroup forces the generation of a group containing new nodes.
3843 # @return TRUE or a created group if operation has been completed successfully,
3844 # FALSE or None otherwise
3845 # @ingroup l2_modif_edit
3846 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
3848 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
3849 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3851 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3852 # This method provided for convenience works as DoubleNodes() described above.
3853 # @param theNodes list of groups of nodes to be doubled
3854 # @param theModifiedElems list of groups of elements to be updated.
3855 # @param theMakeGroup forces the generation of a group containing new nodes.
3856 # @return TRUE if operation has been completed successfully, FALSE otherwise
3857 # @ingroup l2_modif_edit
3858 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
3860 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
3861 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3863 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3864 # @param theElems - the list of elements (edges or faces) to be replicated
3865 # The nodes for duplication could be found from these elements
3866 # @param theNodesNot - list of nodes to NOT replicate
3867 # @param theAffectedElems - the list of elements (cells and edges) to which the
3868 # replicated nodes should be associated to.
3869 # @return TRUE if operation has been completed successfully, FALSE otherwise
3870 # @ingroup l2_modif_edit
3871 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3872 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3874 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3875 # @param theElems - the list of elements (edges or faces) to be replicated
3876 # The nodes for duplication could be found from these elements
3877 # @param theNodesNot - list of nodes to NOT replicate
3878 # @param theShape - shape to detect affected elements (element which geometric center
3879 # located on or inside shape).
3880 # The replicated nodes should be associated to affected elements.
3881 # @return TRUE if operation has been completed successfully, FALSE otherwise
3882 # @ingroup l2_modif_edit
3883 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3884 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3886 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3887 # This method provided for convenience works as DoubleNodes() described above.
3888 # @param theElems - group of of elements (edges or faces) to be replicated
3889 # @param theNodesNot - group of nodes not to replicated
3890 # @param theAffectedElems - group of elements to which the replicated nodes
3891 # should be associated to.
3892 # @param theMakeGroup forces the generation of a group containing new elements.
3893 # @param theMakeNodeGroup forces the generation of a group containing new nodes.
3894 # @return TRUE or created groups (one or two) if operation has been completed successfully,
3895 # FALSE or None otherwise
3896 # @ingroup l2_modif_edit
3897 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems,
3898 theMakeGroup=False, theMakeNodeGroup=False):
3899 if theMakeGroup or theMakeNodeGroup:
3900 twoGroups = self.editor.DoubleNodeElemGroup2New(theElems, theNodesNot,
3902 theMakeGroup, theMakeNodeGroup)
3903 if theMakeGroup and theMakeNodeGroup:
3906 return twoGroups[ int(theMakeNodeGroup) ]
3907 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3909 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3910 # This method provided for convenience works as DoubleNodes() described above.
3911 # @param theElems - group of of elements (edges or faces) to be replicated
3912 # @param theNodesNot - group of nodes not to replicated
3913 # @param theShape - shape to detect affected elements (element which geometric center
3914 # located on or inside shape).
3915 # The replicated nodes should be associated to affected elements.
3916 # @ingroup l2_modif_edit
3917 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3918 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3920 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3921 # This method provided for convenience works as DoubleNodes() described above.
3922 # @param theElems - list of groups of elements (edges or faces) to be replicated
3923 # @param theNodesNot - list of groups of nodes not to replicated
3924 # @param theAffectedElems - group of elements to which the replicated nodes
3925 # should be associated to.
3926 # @param theMakeGroup forces the generation of a group containing new elements.
3927 # @param theMakeNodeGroup forces the generation of a group containing new nodes.
3928 # @return TRUE or created groups (one or two) if operation has been completed successfully,
3929 # FALSE or None otherwise
3930 # @ingroup l2_modif_edit
3931 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems,
3932 theMakeGroup=False, theMakeNodeGroup=False):
3933 if theMakeGroup or theMakeNodeGroup:
3934 twoGroups = self.editor.DoubleNodeElemGroups2New(theElems, theNodesNot,
3936 theMakeGroup, theMakeNodeGroup)
3937 if theMakeGroup and theMakeNodeGroup:
3940 return twoGroups[ int(theMakeNodeGroup) ]
3941 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3943 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3944 # This method provided for convenience works as DoubleNodes() described above.
3945 # @param theElems - list of groups of elements (edges or faces) to be replicated
3946 # @param theNodesNot - list of groups of nodes not to replicated
3947 # @param theShape - shape to detect affected elements (element which geometric center
3948 # located on or inside shape).
3949 # The replicated nodes should be associated to affected elements.
3950 # @return TRUE if operation has been completed successfully, FALSE otherwise
3951 # @ingroup l2_modif_edit
3952 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3953 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3955 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
3956 # The list of groups must describe a partition of the mesh volumes.
3957 # The nodes of the internal faces at the boundaries of the groups are doubled.
3958 # In option, the internal faces are replaced by flat elements.
3959 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
3960 # @param theDomains - list of groups of volumes
3961 # @param createJointElems - if TRUE, create the elements
3962 # @return TRUE if operation has been completed successfully, FALSE otherwise
3963 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
3964 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
3966 ## Double nodes on some external faces and create flat elements.
3967 # Flat elements are mainly used by some types of mechanic calculations.
3969 # Each group of the list must be constituted of faces.
3970 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
3971 # @param theGroupsOfFaces - list of groups of faces
3972 # @return TRUE if operation has been completed successfully, FALSE otherwise
3973 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
3974 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
3976 def _valueFromFunctor(self, funcType, elemId):
3977 fn = self.smeshpyD.GetFunctor(funcType)
3978 fn.SetMesh(self.mesh)
3979 if fn.GetElementType() == self.GetElementType(elemId, True):
3980 val = fn.GetValue(elemId)
3985 ## Get length of 1D element.
3986 # @param elemId mesh element ID
3987 # @return element's length value
3988 # @ingroup l1_measurements
3989 def GetLength(self, elemId):
3990 return self._valueFromFunctor(SMESH.FT_Length, elemId)
3992 ## Get area of 2D element.
3993 # @param elemId mesh element ID
3994 # @return element's area value
3995 # @ingroup l1_measurements
3996 def GetArea(self, elemId):
3997 return self._valueFromFunctor(SMESH.FT_Area, elemId)
3999 ## Get volume of 3D element.
4000 # @param elemId mesh element ID
4001 # @return element's volume value
4002 # @ingroup l1_measurements
4003 def GetVolume(self, elemId):
4004 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4006 ## Get maximum element length.
4007 # @param elemId mesh element ID
4008 # @return element's maximum length value
4009 # @ingroup l1_measurements
4010 def GetMaxElementLength(self, elemId):
4011 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4012 ftype = SMESH.FT_MaxElementLength3D
4014 ftype = SMESH.FT_MaxElementLength2D
4015 return self._valueFromFunctor(ftype, elemId)
4017 ## Get aspect ratio of 2D or 3D element.
4018 # @param elemId mesh element ID
4019 # @return element's aspect ratio value
4020 # @ingroup l1_measurements
4021 def GetAspectRatio(self, elemId):
4022 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4023 ftype = SMESH.FT_AspectRatio3D
4025 ftype = SMESH.FT_AspectRatio
4026 return self._valueFromFunctor(ftype, elemId)
4028 ## Get warping angle of 2D element.
4029 # @param elemId mesh element ID
4030 # @return element's warping angle value
4031 # @ingroup l1_measurements
4032 def GetWarping(self, elemId):
4033 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4035 ## Get minimum angle of 2D element.
4036 # @param elemId mesh element ID
4037 # @return element's minimum angle value
4038 # @ingroup l1_measurements
4039 def GetMinimumAngle(self, elemId):
4040 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4042 ## Get taper of 2D element.
4043 # @param elemId mesh element ID
4044 # @return element's taper value
4045 # @ingroup l1_measurements
4046 def GetTaper(self, elemId):
4047 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4049 ## Get skew of 2D element.
4050 # @param elemId mesh element ID
4051 # @return element's skew value
4052 # @ingroup l1_measurements
4053 def GetSkew(self, elemId):
4054 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4056 ## The mother class to define algorithm, it is not recommended to use it directly.
4058 # For each meshing algorithm, a python class inheriting from class Mesh_Algorithm
4059 # should be defined. This descendant class sould have two attributes defining the way
4060 # it is created by class Mesh (see e.g. class StdMeshersDC_Segment in StdMeshersDC.py).
4061 # - meshMethod attribute defines name of method of class Mesh by calling which the
4062 # python class of algorithm is created. E.g. if in class MyPlugin_Algorithm
4063 # meshMethod = "MyAlgorithm", then an instance of MyPlugin_Algorithm is created
4064 # by the following code: my_algo = mesh.MyAlgorithm()
4065 # - algoType defines name of algorithm type and is used mostly to discriminate
4066 # algorithms that are created by the same method of class Mesh. E.g. if
4067 # MyPlugin_Algorithm.algoType = "MyPLUGIN" then it's creation code can be:
4068 # my_algo = mesh.MyAlgorithm(algo="MyPLUGIN")
4069 # @ingroup l2_algorithms
4070 class Mesh_Algorithm:
4071 # @class Mesh_Algorithm
4072 # @brief Class Mesh_Algorithm
4074 #def __init__(self,smesh):
4082 ## Finds a hypothesis in the study by its type name and parameters.
4083 # Finds only the hypotheses created in smeshpyD engine.
4084 # @return SMESH.SMESH_Hypothesis
4085 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4086 study = smeshpyD.GetCurrentStudy()
4087 #to do: find component by smeshpyD object, not by its data type
4088 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4089 if scomp is not None:
4090 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4091 # Check if the root label of the hypotheses exists
4092 if res and hypRoot is not None:
4093 iter = study.NewChildIterator(hypRoot)
4094 # Check all published hypotheses
4096 hypo_so_i = iter.Value()
4097 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4098 if attr is not None:
4099 anIOR = attr.Value()
4100 hypo_o_i = salome.orb.string_to_object(anIOR)
4101 if hypo_o_i is not None:
4102 # Check if this is a hypothesis
4103 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4104 if hypo_i is not None:
4105 # Check if the hypothesis belongs to current engine
4106 if smeshpyD.GetObjectId(hypo_i) > 0:
4107 # Check if this is the required hypothesis
4108 if hypo_i.GetName() == hypname:
4110 if CompareMethod(hypo_i, args):
4124 ## Finds the algorithm in the study by its type name.
4125 # Finds only the algorithms, which have been created in smeshpyD engine.
4126 # @return SMESH.SMESH_Algo
4127 def FindAlgorithm (self, algoname, smeshpyD):
4128 study = smeshpyD.GetCurrentStudy()
4129 if not study: return None
4130 #to do: find component by smeshpyD object, not by its data type
4131 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4132 if scomp is not None:
4133 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4134 # Check if the root label of the algorithms exists
4135 if res and hypRoot is not None:
4136 iter = study.NewChildIterator(hypRoot)
4137 # Check all published algorithms
4139 algo_so_i = iter.Value()
4140 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4141 if attr is not None:
4142 anIOR = attr.Value()
4143 algo_o_i = salome.orb.string_to_object(anIOR)
4144 if algo_o_i is not None:
4145 # Check if this is an algorithm
4146 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4147 if algo_i is not None:
4148 # Checks if the algorithm belongs to the current engine
4149 if smeshpyD.GetObjectId(algo_i) > 0:
4150 # Check if this is the required algorithm
4151 if algo_i.GetName() == algoname:
4164 ## If the algorithm is global, returns 0; \n
4165 # else returns the submesh associated to this algorithm.
4166 def GetSubMesh(self):
4169 ## Returns the wrapped mesher.
4170 def GetAlgorithm(self):
4173 ## Gets the list of hypothesis that can be used with this algorithm
4174 def GetCompatibleHypothesis(self):
4177 mylist = self.algo.GetCompatibleHypothesis()
4180 ## Gets the name of the algorithm
4184 ## Sets the name to the algorithm
4185 def SetName(self, name):
4186 self.mesh.smeshpyD.SetName(self.algo, name)
4188 ## Gets the id of the algorithm
4190 return self.algo.GetId()
4193 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4195 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4196 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4198 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4200 self.Assign(algo, mesh, geom)
4204 def Assign(self, algo, mesh, geom):
4206 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4210 self.geom = mesh.geom
4213 AssureGeomPublished( mesh, geom )
4215 name = GetName(geom)
4219 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4221 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4222 TreatHypoStatus( status, algo.GetName(), name, True )
4225 def CompareHyp (self, hyp, args):
4226 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4229 def CompareEqualHyp (self, hyp, args):
4233 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4234 UseExisting=0, CompareMethod=""):
4237 if CompareMethod == "": CompareMethod = self.CompareHyp
4238 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4241 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4246 if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
4247 argStr = arg.GetStudyEntry()
4248 if not argStr: argStr = "GEOM_Obj_%s", arg.GetEntry()
4249 if len( argStr ) > 10:
4250 argStr = argStr[:7]+"..."
4251 if argStr[0] == '[': argStr += ']'
4257 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4261 geomName = GetName(self.geom)
4262 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4263 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4266 ## Returns entry of the shape to mesh in the study
4267 def MainShapeEntry(self):
4268 if not self.mesh or not self.mesh.GetMesh(): return ""
4269 if not self.mesh.GetMesh().HasShapeToMesh(): return ""
4270 shape = self.mesh.GetShape()
4271 return shape.GetStudyEntry()
4273 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4274 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4275 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4276 # @param thickness total thickness of layers of prisms
4277 # @param numberOfLayers number of layers of prisms
4278 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4279 # @param ignoreFaces list of geometrical faces (or their ids) not to generate layers on
4280 # @ingroup l3_hypos_additi
4281 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4282 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4283 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4284 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4285 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4286 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4287 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4288 hyp = self.Hypothesis("ViscousLayers",
4289 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4290 hyp.SetTotalThickness(thickness)
4291 hyp.SetNumberLayers(numberOfLayers)
4292 hyp.SetStretchFactor(stretchFactor)
4293 hyp.SetIgnoreFaces(ignoreFaces)
4296 ## Transform a list of ether edges or tuples (edge 1st_vertex_of_edge)
4297 # into a list acceptable to SetReversedEdges() of some 1D hypotheses
4298 # @ingroup l3_hypos_1dhyps
4299 def ReversedEdgeIndices(self, reverseList):
4301 geompy = self.mesh.geompyD
4302 for i in reverseList:
4303 if isinstance( i, int ):
4304 s = geompy.SubShapes(self.mesh.geom, [i])[0]
4305 if s.GetShapeType() != geompyDC.GEOM.EDGE:
4306 raise TypeError, "Not EDGE index given"
4308 elif isinstance( i, geompyDC.GEOM._objref_GEOM_Object ):
4309 if i.GetShapeType() != geompyDC.GEOM.EDGE:
4310 raise TypeError, "Not an EDGE given"
4311 resList.append( geompy.GetSubShapeID(self.mesh.geom, i ))
4315 if not isinstance( e, geompyDC.GEOM._objref_GEOM_Object ) or \
4316 not isinstance( v, geompyDC.GEOM._objref_GEOM_Object ):
4317 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4318 if v.GetShapeType() == geompyDC.GEOM.EDGE and \
4319 e.GetShapeType() == geompyDC.GEOM.VERTEX:
4321 if e.GetShapeType() != geompyDC.GEOM.EDGE or \
4322 v.GetShapeType() != geompyDC.GEOM.VERTEX:
4323 raise TypeError, "A list item must be a tuple (edge 1st_vertex_of_edge)"
4324 vFirst = FirstVertexOnCurve( e )
4325 tol = geompy.Tolerance( vFirst )[-1]
4326 if geompy.MinDistance( v, vFirst ) > 1.5*tol:
4327 resList.append( geompy.GetSubShapeID(self.mesh.geom, e ))
4329 raise TypeError, "Item must be either an edge or tuple (edge 1st_vertex_of_edge)"
4333 class Pattern(SMESH._objref_SMESH_Pattern):
4335 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
4336 decrFun = lambda i: i-1
4337 theNodeIndexOnKeyPoint1,Parameters,hasVars = ParseParameters(theNodeIndexOnKeyPoint1, decrFun)
4338 theMesh.SetParameters(Parameters)
4339 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
4341 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
4342 decrFun = lambda i: i-1
4343 theNode000Index,theNode001Index,Parameters,hasVars = ParseParameters(theNode000Index,theNode001Index, decrFun)
4344 theMesh.SetParameters(Parameters)
4345 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
4347 #Registering the new proxy for Pattern
4348 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)
4354 ## Private class used to bind methods creating algorithms to the class Mesh
4359 self.defaultAlgoType = ""
4360 self.algoTypeToClass = {}
4362 # Stores a python class of algorithm
4363 def add(self, algoClass):
4364 if type( algoClass ).__name__ == 'classobj' and \
4365 hasattr( algoClass, "algoType"):
4366 self.algoTypeToClass[ algoClass.algoType ] = algoClass
4367 if not self.defaultAlgoType and \
4368 hasattr( algoClass, "isDefault") and algoClass.isDefault:
4369 self.defaultAlgoType = algoClass.algoType
4370 #print "Add",algoClass.algoType, "dflt",self.defaultAlgoType
4372 # creates a copy of self and assign mesh to the copy
4373 def copy(self, mesh):
4374 other = algoCreator()
4375 other.defaultAlgoType = self.defaultAlgoType
4376 other.algoTypeToClass = self.algoTypeToClass
4380 # creates an instance of algorithm
4381 def __call__(self,algo="",geom=0,*args):
4382 algoType = self.defaultAlgoType
4383 for arg in args + (algo,geom):
4384 if isinstance( arg, geompyDC.GEOM._objref_GEOM_Object ):
4386 if isinstance( arg, str ) and arg:
4388 if not algoType and self.algoTypeToClass:
4389 algoType = self.algoTypeToClass.keys()[0]
4390 if self.algoTypeToClass.has_key( algoType ):
4391 #print "Create algo",algoType
4392 return self.algoTypeToClass[ algoType ]( self.mesh, geom )
4393 raise RuntimeError, "No class found for algo type %s" % algoType
4396 # Private class used to substitute and store variable parameters of hypotheses.
4397 class hypMethodWrapper:
4398 def __init__(self, hyp, method):
4400 self.method = method
4401 #print "REBIND:", method.__name__
4404 # call a method of hypothesis with calling SetVarParameter() before
4405 def __call__(self,*args):
4407 return self.method( self.hyp, *args ) # hypothesis method with no args
4409 #print "MethWrapper.__call__",self.method.__name__, args
4411 parsed = ParseParameters(*args) # replace variables with their values
4412 self.hyp.SetVarParameter( parsed[-2], self.method.__name__ )
4413 result = self.method( self.hyp, *parsed[:-2] ) # call hypothesis method
4414 except omniORB.CORBA.BAD_PARAM: # raised by hypothesis method call
4415 # maybe there is a replaced string arg which is not variable
4416 result = self.method( self.hyp, *args )
4417 except ValueError, detail: # raised by ParseParameters()
4419 result = self.method( self.hyp, *args )
4420 except omniORB.CORBA.BAD_PARAM:
4421 raise ValueError, detail # wrong variable name